feat(dossier): autosave en construction

This commit is contained in:
Paul Chavard 2022-09-08 11:26:18 +02:00
parent d35ceb7214
commit d6f5be622c
14 changed files with 66 additions and 82 deletions

View file

@ -42,7 +42,10 @@ export class AutosaveController extends ApplicationController {
this.#latestPromise = Promise.resolve();
this.onGlobal('autosave:retry', () => this.didRequestRetry());
this.on('change', (event) => this.onChange(event));
this.on('input', (event) => this.onInput(event));
if (this.saveOnInput) {
this.on('input', (event) => this.onInput(event));
}
}
disconnect() {
@ -80,7 +83,8 @@ export class AutosaveController extends ApplicationController {
this.debounce(this.enqueueAutosaveRequest, AUTOSAVE_DEBOUNCE_DELAY);
} else if (
isSelectElement(target) ||
isCheckboxOrRadioInputElement(target)
isCheckboxOrRadioInputElement(target) ||
(!this.saveOnInput && isTextInputElement(target))
) {
this.enqueueAutosaveRequest();
}
@ -99,6 +103,10 @@ export class AutosaveController extends ApplicationController {
}
}
private get saveOnInput() {
return !!this.form?.dataset.saveOnInput;
}
private didRequestRetry() {
if (this.#needsRetry) {
this.enqueueAutosaveRequest();