From 8fb0de900bca082512ff29a650b34ba31f9db588 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 14 Aug 2018 12:54:58 +0200 Subject: [PATCH] createNote API now accepts attributes instead of just labels --- src/public/javascripts/services/script_api.js | 3 ++- src/services/notes.js | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/public/javascripts/services/script_api.js b/src/public/javascripts/services/script_api.js index dba80a42c..b17b4be59 100644 --- a/src/public/javascripts/services/script_api.js +++ b/src/public/javascripts/services/script_api.js @@ -63,7 +63,8 @@ function ScriptApi(startNote, currentNote, originEntity = null) { parseDate: utils.parseDate, showMessage: infoService.showMessage, showError: infoService.showError, - reloadTree: treeService.reload, + reloadTree: treeService.reload, // deprecated + refreshTree: treeService.reload, createNoteLink: linkService.createNoteLink } } diff --git a/src/services/notes.js b/src/services/notes.js index 31e1af24a..b87241dc1 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -93,11 +93,13 @@ async function createNote(parentNoteId, title, content = "", extraOptions = {}) const {note, branch} = await createNewNote(parentNoteId, noteData); - // FIXME: need to make this more generic for all kinds of attributes - if (extraOptions.labels) { - for (const labelName in extraOptions.labels) { - await attributeService.createLabel(note.noteId, labelName, extraOptions.labels[labelName]); - } + for (const attr of extraOptions.attributes || []) { + await attributeService.createAttribute({ + noteId: note.noteId, + type: attr.type, + name: attr.name, + value: attr.value + }); } await triggerNoteTitleChanged(note);