Implemented title input validation. Resolves #2.
authorAdam Dullage <redacted>
Thu, 30 Jun 2022 13:21:55 +0000 (14:21 +0100)
committerAdam Dullage <redacted>
Thu, 30 Jun 2022 13:21:55 +0000 (14:21 +0100)
flatnotes/src/components/App.js

index 5397bc87ec341f2a748b6d6add19dd6a2709ca03..76c06739d5a31906cec43547ae8a849722b4cf29 100644 (file)
@@ -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,
           });
git clone https://git.99rst.org/PROJECT