From: kitsumed Date: Fri, 8 Sep 2023 23:35:30 +0000 (-0400) Subject: Update NoteViewerEditor.vue X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=244d8a76708eefebb37451b40d07d1a90f0630ac;p=flatnotes.git Update NoteViewerEditor.vue Add a confirm dialog when the user press the Close button, wait for the user agreement before clearing the saved text on local side. --- diff --git a/flatnotes/src/components/NoteViewerEditor.vue b/flatnotes/src/components/NoteViewerEditor.vue index b6354b9..215ff60 100644 --- a/flatnotes/src/components/NoteViewerEditor.vue +++ b/flatnotes/src/components/NoteViewerEditor.vue @@ -517,13 +517,24 @@ export default { }, cancelNote: function () { - localStorage.removeItem(this.currentNote.title); - if (this.currentNote.lastModified == null) { - // Cancelling a new note - EventBus.$emit("navigate", constants.basePaths.home); - } else { - this.setEditMode(false); - } + this.$bvModal.msgBoxConfirm(`Are you sure you want to close the note '${this.currentNote.title}' without saving?`, + { + centered: true, + title: "Confirm Closure", + okTitle: "Yes, Close", + okVariant: "warning", + }) + .then(function (response) { + if (response == true) { + localStorage.removeItem(this.currentNote.title); + if (this.currentNote.lastModified == null) { + // Cancelling a new note + EventBus.$emit("navigate", constants.basePaths.home); + } else { + this.setEditMode(false); + } + } + }); }, deleteNote: function () {