mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-28 06:11:48 +00:00
Added a "unsaved changed" warning dialog for part, entity edits and system settings
This fixes issue #1368
This commit is contained in:
parent
ad0c60f766
commit
79c36494ea
21 changed files with 556 additions and 11 deletions
|
|
@ -91,6 +91,9 @@ export default class extends Controller {
|
|||
config.translations = [window.CKEDITOR_TRANSLATIONS, translations];
|
||||
}
|
||||
|
||||
//Apply the default value of the source element as data attribute, so that dirty-form-controller can detect changes
|
||||
this.element.dataset.defaultValue = this.element.defaultValue;
|
||||
|
||||
const watchdog = new EditorWatchdog();
|
||||
watchdog.setCreator((elementOrData, editorConfig) => {
|
||||
return EDITOR_TYPE.create(elementOrData, editorConfig)
|
||||
|
|
@ -111,10 +114,21 @@ export default class extends Controller {
|
|||
editor.updateSourceElement();
|
||||
|
||||
// Dispatch the input event for further treatment
|
||||
const event = new Event("input");
|
||||
this.element.dispatchEvent(event);
|
||||
this.element.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
|
||||
//Set an reset listener to update the editor if the source element is reset (e.g. by a reset button)
|
||||
if (this.element.form && this.element.name) {
|
||||
this.element.form.addEventListener("reset", () => {
|
||||
if (editor.isReadOnly) {
|
||||
return;
|
||||
}
|
||||
if (this.element.dataset.defaultValue !== undefined) {
|
||||
editor.setData(this.element.dataset.defaultValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//This return is important! Otherwise we get mysterious errors in the console
|
||||
//See: https://github.com/ckeditor/ckeditor5/issues/5897#issuecomment-628471302
|
||||
return editor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue