5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 17:11:41 +00:00

rails ya soportaba deshabilitar durante el envío

This commit is contained in:
f 2021-04-21 15:26:27 -03:00
parent 9cf59d7137
commit c9531af77b
2 changed files with 8 additions and 32 deletions

View file

@ -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
}
}

View file

@ -1,18 +1,9 @@
- 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),
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: { action: 'submit-once#disable' } do
= t('sites.enqueue')
= form_tag site_enqueue_path(site),
method: :post,
class: 'form-inline inline' do
= submit_tag site.enqueued? ? t('sites.enqueued') : t('sites.enqueue'),
class: 'btn no-border-radius',
title: site.enqueued? ? t('help.sites.enqueued') : t('help.sites.enqueue'),
data: { disable_with: t('sites.enqueued') },
disabled: site.enqueued?