From b2ff97ccf243fa257864af39ec4b124347c57b07 Mon Sep 17 00:00:00 2001 From: azivner Date: Fri, 26 Jan 2018 21:31:52 -0500 Subject: [PATCH] new note inherits type and mime from parent note, closes #20 --- public/javascripts/note_editor.js | 2 +- services/notes.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/public/javascripts/note_editor.js b/public/javascripts/note_editor.js index bd0d55ffa..150fe0691 100644 --- a/public/javascripts/note_editor.js +++ b/public/javascripts/note_editor.js @@ -71,7 +71,7 @@ const noteEditor = (function() { // if content is only tags/whitespace (typically

 

), then just make it empty // this is important when setting new note to code - if ($(note.detail.note_text).text().trim() === '') { + if (jQuery(note.detail.note_text).text().trim() === '') { note.detail.note_text = '' } } diff --git a/services/notes.js b/services/notes.js index f36bb0632..c90ee7c44 100644 --- a/services/notes.js +++ b/services/notes.js @@ -41,6 +41,18 @@ async function createNewNote(parentNoteId, note, sourceId) { throw new Error('Unknown target: ' + note.target); } + if (parentNoteId !== 'root') { + const parent = await sql.getFirst("SELECT * FROM notes WHERE note_id = ?", [parentNoteId]); + + if (!note.type) { + note.type = parent.type; + } + + if (!note.mime) { + note.mime = parent.mime; + } + } + const now = utils.nowDate(); await sql.insert("notes", {