From: Adam Dullage Date: Thu, 30 Jun 2022 13:21:55 +0000 (+0100) Subject: Implemented title input validation. Resolves #2. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a78f3307a6644f60657241fe3474d716c711cb54;p=flatnotes.git Implemented title input validation. Resolves #2. --- diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 5397bc8..76c0673 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -234,6 +234,18 @@ export default { saveNote: function() { let parent = this; let newContent = this.getEditorContent(); + + // Title Validation + 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 + } // New Note if (this.currentNote.lastModified == null) { @@ -289,7 +301,7 @@ export default { }, saveNoteToast: function() { - this.$bvToast.toast("Note Saved ✓", { + this.$bvToast.toast("Note saved ✓", { variant: "success", noCloseButton: true, }); @@ -314,7 +326,7 @@ export default { ) { api.delete(`/api/notes/${this.currentNote.filename}`).then(function() { parent.navigate("/"); - parent.$bvToast.toast("Note Deleted ✓", { + parent.$bvToast.toast("Note deleted ✓", { variant: "success", noCloseButton: true, });