Replaced browser message when confirming deletions. Resolves #11.
authorAdam Dullage <redacted>
Sun, 3 Jul 2022 09:09:53 +0000 (10:09 +0100)
committerAdam Dullage <redacted>
Sun, 3 Jul 2022 09:09:53 +0000 (10:09 +0100)
flatnotes/src/components/App.js

index 76c06739d5a31906cec43547ae8a849722b4cf29..7fd54416d4b762c38c65ff0a3e4294fc905fb4ca 100644 (file)
@@ -234,17 +234,17 @@ export default {
     saveNote: function() {
       let parent = this;
       let newContent = this.getEditorContent();
-    
+
       // Title Validation
-      if (typeof this.titleInput == 'string') {
-        this.titleInput = this.titleInput.trim()
+      if (typeof this.titleInput == "string") {
+        this.titleInput = this.titleInput.trim();
       }
       if (!this.titleInput) {
         this.$bvToast.toast("Cannot save note without a title ✘", {
           variant: "danger",
           noCloseButton: true,
         });
-        return
+        return;
       }
 
       // New Note
@@ -319,19 +319,29 @@ export default {
 
     deleteNote: function() {
       let parent = this;
-      if (
-        confirm(
-          `Are you sure you want to delete the note '${this.currentNote.title}'?`
+      this.$bvModal
+        .msgBoxConfirm(
+          `Are you sure you want to delete the note '${this.currentNote.title}'?`,
+          {
+            centered: true,
+            title: "Confirm Deletion",
+            okTitle: "Delete",
+            okVariant: "danger",
+          }
         )
-      ) {
-        api.delete(`/api/notes/${this.currentNote.filename}`).then(function() {
-          parent.navigate("/");
-          parent.$bvToast.toast("Note deleted ✓", {
-            variant: "success",
-            noCloseButton: true,
-          });
+        .then(function(response) {
+          if (response == true) {
+            api
+              .delete(`/api/notes/${parent.currentNote.filename}`)
+              .then(function() {
+                parent.navigate("/");
+                parent.$bvToast.toast("Note deleted ✓", {
+                  variant: "success",
+                  noCloseButton: true,
+                });
+              });
+          }
         });
-      }
     },
 
     keyboardShortcuts: function(e) {
git clone https://git.99rst.org/PROJECT