fix(dossier): delay submit to autosave end
This commit is contained in:
parent
5f6fb3013d
commit
de9d3501b5
2 changed files with 6 additions and 2 deletions
|
@ -75,9 +75,11 @@ export class AutosaveController extends ApplicationController {
|
||||||
if (!target.disabled) {
|
if (!target.disabled) {
|
||||||
if (target.type == 'file') {
|
if (target.type == 'file') {
|
||||||
if (target.dataset.autoAttachUrl && target.files?.length) {
|
if (target.dataset.autoAttachUrl && target.files?.length) {
|
||||||
|
this.globalDispatch('autosave:input');
|
||||||
this.enqueueAutouploadRequest(target, target.files[0]);
|
this.enqueueAutouploadRequest(target, target.files[0]);
|
||||||
}
|
}
|
||||||
} else if (target.type == 'hidden') {
|
} else if (target.type == 'hidden') {
|
||||||
|
this.globalDispatch('autosave:input');
|
||||||
// In React comboboxes we dispatch a "change" event on hidden inputs to trigger autosave.
|
// In React comboboxes we dispatch a "change" event on hidden inputs to trigger autosave.
|
||||||
// We want to debounce them.
|
// We want to debounce them.
|
||||||
this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY);
|
this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY);
|
||||||
|
@ -85,6 +87,7 @@ export class AutosaveController extends ApplicationController {
|
||||||
isSelectElement(target) ||
|
isSelectElement(target) ||
|
||||||
isCheckboxOrRadioInputElement(target)
|
isCheckboxOrRadioInputElement(target)
|
||||||
) {
|
) {
|
||||||
|
this.globalDispatch('autosave:input');
|
||||||
// Wait next tick so champs having JS can interact
|
// Wait next tick so champs having JS can interact
|
||||||
// with form elements before extracting form data.
|
// with form elements before extracting form data.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -103,6 +106,7 @@ export class AutosaveController extends ApplicationController {
|
||||||
target.getAttribute('role') != 'combobox' &&
|
target.getAttribute('role') != 'combobox' &&
|
||||||
isTextInputElement(target)
|
isTextInputElement(target)
|
||||||
) {
|
) {
|
||||||
|
this.globalDispatch('autosave:input');
|
||||||
this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY);
|
this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY);
|
||||||
|
|
||||||
this.showConditionnalSpinner(target);
|
this.showConditionnalSpinner(target);
|
||||||
|
|
|
@ -8,7 +8,7 @@ export class AutosaveSubmitController extends ApplicationController {
|
||||||
#buttonText?: string;
|
#buttonText?: string;
|
||||||
|
|
||||||
connect(): void {
|
connect(): void {
|
||||||
this.onGlobal('autosave:enqueue', () => this.didEnqueue());
|
this.onGlobal('autosave:input', () => this.didInput());
|
||||||
this.onGlobal('autosave:end', () => this.didSucceed());
|
this.onGlobal('autosave:end', () => this.didSucceed());
|
||||||
this.onGlobal('autosave:error', () => this.didFail());
|
this.onGlobal('autosave:error', () => this.didFail());
|
||||||
this.on('click', (event) => this.onClick(event));
|
this.on('click', (event) => this.onClick(event));
|
||||||
|
@ -23,7 +23,7 @@ export class AutosaveSubmitController extends ApplicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private didEnqueue() {
|
private didInput() {
|
||||||
this.#isSaving = true;
|
this.#isSaving = true;
|
||||||
this.#shouldSubmit = false;
|
this.#shouldSubmit = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue