From 99e965d4da09d108e0cb1c2d48f78135d2202248 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 25 Jun 2024 14:24:12 -0300 Subject: [PATCH] =?UTF-8?q?fixup!=20fixup!=20fix:=20no=20enviar=20el=20for?= =?UTF-8?q?mulario=20si=20tiene=20alg=C3=BAn=20atributo=20de=20htmx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/controllers/form_validation_controller.js | 8 +++++++- app/javascript/packs/application.js | 2 +- package.json | 2 +- yarn.lock | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/javascript/controllers/form_validation_controller.js b/app/javascript/controllers/form_validation_controller.js index 8756e272..dd1a98ed 100644 --- a/app/javascript/controllers/form_validation_controller.js +++ b/app/javascript/controllers/form_validation_controller.js @@ -28,12 +28,16 @@ export default class extends Controller { } submit(event = undefined) { + if (this.submitting) return; + + this.submitting = true; + event?.preventDefault(); if (this.element.reportValidity()) { this.element.classList.remove("was-validated"); - if (this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit(); + if (!this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit(); window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.submittingIdValue } })); } else { @@ -43,5 +47,7 @@ export default class extends Controller { window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.invalidIdValue } })); } + + this.submitting = false; } } diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index dc87b1c3..a0f18024 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -41,5 +41,5 @@ Rails.start() Turbolinks.start() ActiveStorage.start() -window.htmx = require("@suttyweb/htmx.org/dist/htmx.js"); +window.htmx = require("@suttyweb/htmx.org/dist/htmx.cjs.js"); window.htmx.config.selfRequestsOnly = true; diff --git a/package.json b/package.json index 73cfd589..c5642236 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@rails/ujs": "^6.1.3-1", "@rails/webpacker": "5.4.4", "@suttyweb/editor": "^0.1.29", - "@suttyweb/htmx.org": "^1.9.13", + "@suttyweb/htmx.org": "2.0.0", "babel-loader": "^8.2.2", "bs-custom-file-input": "^1.3.4", "chart.js": "^3.5.1", diff --git a/yarn.lock b/yarn.lock index d181bebe..45ceae0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1984,10 +1984,10 @@ linkifyjs "^4.1.1" prosemirror-svelte-nodeview "^1.0.2" -"@suttyweb/htmx.org@^1.9.13": - version "1.9.13" - resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-1.9.13.tgz#bc67a5e2947d7cc125649b829610da8ee61f21af" - integrity sha512-/2x3AGXT2CFOmp8Nf59XY2brah5wSo4YvcctYA2zD4BByNft4XE0rUk4VM7TjPxR1LOzg6VK1crZmdiy3JyzxQ== +"@suttyweb/htmx.org@2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-2.0.0.tgz#44435d834d143ae9b60daa454f68f8e72e6ebd7f" + integrity sha512-EJk9s8judGLIZ6c9N779z91WHPIfAkwkVY5QF7WH2ZT2Kt03k/hAoy7P4NjYreFIQcIo8d+TU/CIhViCmB4c0Q== "@types/caseless@*": version "0.12.2"