From: Adam Dullage Date: Sun, 3 Jul 2022 09:09:53 +0000 (+0100) Subject: Replaced browser message when confirming deletions. Resolves #11. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=eeb009319066fa671d0dd1983b3b0e84631675e0;p=flatnotes.git Replaced browser message when confirming deletions. Resolves #11. --- diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 76c0673..7fd5441 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -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) {