From 5a5e2089b96f76e45617a16deab56800feeadba9 Mon Sep 17 00:00:00 2001 From: Sofien Haj Chedhli Date: Fri, 20 Sep 2024 13:40:06 +0100 Subject: [PATCH] feat: Disable save button when editing note properties - EXO-74267 - Meeds-io/MIPs#129 (#1125) --- .../components/NoteFullRichEditor.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/NoteFullRichEditor.vue b/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/NoteFullRichEditor.vue index 94d93de24..7a5b434f8 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/NoteFullRichEditor.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/NoteFullRichEditor.vue @@ -37,7 +37,7 @@ :web-page-url="webPageUrl" :editor-icon="editorIcon" :save-button-icon="saveButtonIcon" - :save-button-disabled="saveButtonDisabled" + :save-button-disabled="saveNoteButtonDisabled" :editor-ready="!!editor" @editor-closed="editorClosed" @post-note="postNote" @@ -89,7 +89,8 @@ export default { editor: null, initialized: false, instanceReady: false, - noteTitleMaxLength: 500 + noteTitleMaxLength: 500, + updatingProperties: null }; }, props: { @@ -225,6 +226,9 @@ export default { hasFeaturedImage() { return !!this.noteObject?.properties?.featuredImage?.id; }, + saveNoteButtonDisabled() { + return this.updatingProperties || this.saveButtonDisabled; + } }, created() { this.cloneNoteObject(); @@ -238,10 +242,14 @@ export default { }, methods: { metadataUpdated(properties) { + this.updatingProperties = true; this.noteObject.properties = properties; this.updateData(); if (this.noteObject?.title?.length) { this.autoSave(); + this.waitForNoteMetadataUpdate(); + } else { + this.updatingProperties = null; } }, editorClosed(){ @@ -515,6 +523,11 @@ export default { message: this.$t('notes.title.max.length.warning.message', {0: this.noteTitleMaxLength}) }; this.displayAlert(messageObject); + }, + waitForNoteMetadataUpdate() { + setTimeout(() => { + this.updatingProperties = null; + }, 1000); } } };