diff --git a/src/public/javascripts/note_editor.js b/src/public/javascripts/note_editor.js index f55962f58..39b9a52e3 100644 --- a/src/public/javascripts/note_editor.js +++ b/src/public/javascripts/note_editor.js @@ -5,6 +5,7 @@ const noteEditor = (function() { const $noteDetail = $('#note-detail'); const $noteDetailCode = $('#note-detail-code'); + const $noteDetailSearch = $('#note-detail-search'); const $noteDetailRender = $('#note-detail-render'); const $noteDetailAttachment = $('#note-detail-attachment'); @@ -19,6 +20,7 @@ const noteEditor = (function() { const $attachmentFileSize = $("#attachment-filesize"); const $attachmentDownload = $("#attachment-download"); const $attachmentOpen = $("#attachment-open"); + const $searchString = $("#search-string"); let editor = null; let codeEditor = null; @@ -90,6 +92,11 @@ const noteEditor = (function() { else if (note.detail.type === 'code') { note.detail.content = codeEditor.getValue(); } + else if (note.detail.type === 'search') { + note.detail.content = JSON.stringify({ + searchString: $searchString.val() + }); + } else if (note.detail.type === 'render' || note.detail.type === 'file') { // nothing } @@ -179,6 +186,21 @@ const noteEditor = (function() { codeEditor.refresh(); } + else if (currentNote.detail.type === 'search') { + $noteDetailSearch.show(); + + try { + const json = JSON.parse(content); + + $searchString.val(json.searchString); + } + catch (e) { + console.log(e); + $searchString.val(''); + } + + $searchString.on('input', noteChanged); + } } async function loadNoteToEditor(noteId) { @@ -212,6 +234,7 @@ const noteEditor = (function() { noteType.setNoteMime(currentNote.detail.mime); $noteDetail.hide(); + $noteDetailSearch.hide(); $noteDetailCode.hide(); $noteDetailRender.html('').hide(); $noteDetailAttachment.hide(); @@ -283,7 +306,7 @@ const noteEditor = (function() { else if (note.detail.type === 'code') { codeEditor.focus(); } - else if (note.detail.type === 'render' || note.detail.type === 'file') { + else if (note.detail.type === 'render' || note.detail.type === 'file' || note.detail.type === 'search') { // do nothing } else { diff --git a/src/public/javascripts/note_tree.js b/src/public/javascripts/note_tree.js index 3fc3a14e9..acf00551e 100644 --- a/src/public/javascripts/note_tree.js +++ b/src/public/javascripts/note_tree.js @@ -154,15 +154,7 @@ const noteTree = (function() { extraClasses.push("multiple-parents"); } - if (note.type === 'code') { - extraClasses.push("code"); - } - else if (note.type === 'render') { - extraClasses.push('render'); - } - else if (note.type === 'file') { - extraClasses.push('attachment'); - } + extraClasses.push(note.type); return extraClasses.join(" "); } diff --git a/src/public/javascripts/note_type.js b/src/public/javascripts/note_type.js index 8a0e9aa12..d29afbf02 100644 --- a/src/public/javascripts/note_type.js +++ b/src/public/javascripts/note_type.js @@ -63,6 +63,9 @@ const noteType = (function() { return found ? found.title : mime; } } + else if (type === 'search') { + return 'Saved search'; + } else if (type === 'render') { return 'Render HTML note'; } @@ -100,6 +103,13 @@ const noteType = (function() { save(); }; + this.selectSavedSearch = function() { + self.type('search'); + self.mime(''); + + save(); + }; + this.selectRender = function() { self.type('render'); self.mime(''); diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 01380f06d..81abe378c 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -72,7 +72,7 @@ span.fancytree-node.fancytree-folder.code > span.fancytree-icon { background-image: url("../images/icons/code-folder.png"); } -span.fancytree-node.attachment > span.fancytree-icon { +span.fancytree-node.file > span.fancytree-icon { background-position: 0 0; background-image: url("../images/icons/paperclip.png"); } diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index fdb3dd122..1db06755a 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -214,7 +214,7 @@ async function runAllChecks() { FROM notes WHERE - type != 'text' AND type != 'code' AND type != 'render' AND type != 'file'`, + type != 'text' AND type != 'code' AND type != 'render' AND type != 'file' AND type != 'search'`, "Note has invalid type", errorList); await runSyncRowChecks("notes", "noteId", errorList); diff --git a/src/views/index.ejs b/src/views/index.ejs index b4a2ecda0..be19acc14 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -106,6 +106,8 @@