rails ya soportaba deshabilitar durante el envío
This commit is contained in:
parent
9cf59d7137
commit
c9531af77b
2 changed files with 8 additions and 32 deletions
|
@ -1,15 +0,0 @@
|
||||||
import { Controller } from 'stimulus'
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deshabilita el elemento que recibe el evento, para evitar que la
|
|
||||||
* acción se realice varias veces.
|
|
||||||
*
|
|
||||||
* <form data-controller="submit-once">
|
|
||||||
* <input type="submit" data-action="submit-once#disable" />
|
|
||||||
* </form>
|
|
||||||
*/
|
|
||||||
export default class extends Controller {
|
|
||||||
disable (event) {
|
|
||||||
event.target.disabled = true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,9 @@
|
||||||
- if policy(site).build?
|
- if policy(site).build?
|
||||||
- if site.enqueued?
|
|
||||||
= render 'layouts/btn_with_tooltip',
|
|
||||||
tooltip: t('help.sites.enqueued'),
|
|
||||||
text: t('sites.enqueued'),
|
|
||||||
type: 'secondary',
|
|
||||||
link: nil,
|
|
||||||
disabled: true
|
|
||||||
- else
|
|
||||||
= form_tag site_enqueue_path(site),
|
= form_tag site_enqueue_path(site),
|
||||||
method: :post,
|
method: :post,
|
||||||
data: { controller: 'submit-once' },
|
|
||||||
class: 'form-inline inline' do
|
class: 'form-inline inline' do
|
||||||
= button_tag type: 'submit',
|
= submit_tag site.enqueued? ? t('sites.enqueued') : t('sites.enqueue'),
|
||||||
class: 'btn no-border-radius',
|
class: 'btn no-border-radius',
|
||||||
title: t('help.sites.enqueue'),
|
title: site.enqueued? ? t('help.sites.enqueued') : t('help.sites.enqueue'),
|
||||||
data: { action: 'submit-once#disable' } do
|
data: { disable_with: t('sites.enqueued') },
|
||||||
= t('sites.enqueue')
|
disabled: site.enqueued?
|
||||||
|
|
Loading…
Reference in a new issue