diff --git a/app/javascript/controllers/submit_once_controller.js b/app/javascript/controllers/submit_once_controller.js new file mode 100644 index 00000000..b47a33e2 --- /dev/null +++ b/app/javascript/controllers/submit_once_controller.js @@ -0,0 +1,15 @@ +import { Controller } from 'stimulus' + +/* + * Deshabilita el elemento que recibe el evento, para evitar que la + * acción se realice varias veces. + * + *
+ */ +export default class extends Controller { + disable (event) { + event.target.disabled = true + } +} diff --git a/app/views/sites/_build.haml b/app/views/sites/_build.haml index 4115e970..d9d6be83 100644 --- a/app/views/sites/_build.haml +++ b/app/views/sites/_build.haml @@ -4,12 +4,15 @@ tooltip: t('help.sites.enqueued'), text: t('sites.enqueued'), type: 'secondary', - link: nil + link: nil, + disabled: true - else = form_tag site_enqueue_path(site), - method: :post, class: 'form-inline inline' do + method: :post, + data: { controller: 'submit-once' }, + class: 'form-inline inline' do = button_tag type: 'submit', class: 'btn no-border-radius', title: t('help.sites.enqueue'), - data: { toggle: 'tooltip' } do + data: { action: 'submit-once#disable' } do = t('sites.enqueue')