add debounce for date_publication autosubmit

This commit is contained in:
Christophe Robillard 2022-11-04 12:22:39 +01:00
parent a5fa21ca1b
commit 7ef114c910
2 changed files with 7 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import { ApplicationController } from './application_controller';
import { toggle } from '@utils';
const AUTOSUBMIT_DEBOUNCE_DELAY = 5000;
export class AutosubmitController extends ApplicationController {
static targets = ['form', 'spinner'];
@ -10,6 +11,11 @@ export class AutosubmitController extends ApplicationController {
submit() {
this.formTarget.requestSubmit();
}
debouncedSubmit() {
this.debounce(this.submit, AUTOSUBMIT_DEBOUNCE_DELAY);
}
connect() {
this.onGlobal('turbo:submit-start', () => {
toggle(this.spinnerTarget);

View file

@ -50,7 +50,7 @@
.fr-input-group.hidden{ 'data-expand-target': 'content' }
= f.label 'from_publication_date', 'Depuis', class: 'fr-label'
.fr-input-wrap.fr-fi-calendar-line
= f.date_field 'from_publication_date', value: @filter.from_publication_date, class: 'fr-input', 'data-action': 'blur->autosubmit#submit'
= f.date_field 'from_publication_date', value: @filter.from_publication_date, class: 'fr-input', 'data-action': 'blur->autosubmit#submit change->autosubmit#debouncedSubmit'
%li.fr-py-2w.fr-pl-2w{ 'data-controller': "expand" }
.fr-mb-1w