Update NoteViewerEditor.vue
authorkitsumed <redacted>
Fri, 8 Sep 2023 23:35:30 +0000 (19:35 -0400)
committerkitsumed <redacted>
Fri, 8 Sep 2023 23:35:30 +0000 (19:35 -0400)
Add a confirm dialog when the user press the Close button, wait for the user agreement before clearing the saved text on local side.

flatnotes/src/components/NoteViewerEditor.vue

index b6354b9ecb184a7bdac84291703bf1cd5683ddcb..215ff60037d0afe09b9570a42e7cc9ce741765ab 100644 (file)
@@ -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 () {
git clone https://git.99rst.org/PROJECT