diff --git a/src/public/app/entities/attribute.js b/src/public/app/entities/attribute.js index 3d5a63616..91b8044da 100644 --- a/src/public/app/entities/attribute.js +++ b/src/public/app/entities/attribute.js @@ -27,6 +27,10 @@ class Attribute { return this.treeCache.notes[this.noteId]; } + get targetNoteId() { // alias + return this.type === 'relation' ? this.value : undefined; + } + get jsonValue() { try { return JSON.parse(this.value); diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index a553acd98..6bbb54bc3 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -484,6 +484,15 @@ class NoteShort { .map(attributeId => this.treeCache.attributes[attributeId]); } + /** + * Return note complement which is most importantly note's content + * + * @return {Promise} + */ + async getNoteComplement() { + return await this.treeCache.getNoteComplement(this.noteId); + } + get toString() { return `Note(noteId=${this.noteId}, title=${this.title})`; } diff --git a/src/public/app/services/bundle.js b/src/public/app/services/bundle.js index 8ee824629..2935b9102 100644 --- a/src/public/app/services/bundle.js +++ b/src/public/app/services/bundle.js @@ -1,7 +1,6 @@ import ScriptContext from "./script_context.js"; import server from "./server.js"; import toastService from "./toast.js"; -import treeCache from "./tree_cache.js"; async function getAndExecuteBundle(noteId, originEntity = null) { const bundle = await server.get('script/bundle/' + noteId); @@ -77,4 +76,4 @@ export default { getAndExecuteBundle, executeStartupBundles, getWidgetBundlesByParent -} \ No newline at end of file +} diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index 0aaebac3e..8461a1f58 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -276,6 +276,9 @@ class TreeCache { return child.parentToBranch[parentNoteId]; } + /** + * @return {Promise} + */ async getNoteComplement(noteId) { if (!this.noteComplementPromises[noteId]) { this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row)); diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index d979368fd..225294991 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -285,7 +285,7 @@ export default class NoteDetailWidget extends TabAwareWidget { const relation = attrs.find(attr => attr.type === 'relation' - && ['template', 'runOnNoteView', 'renderNote'].includes(attr.name) + && ['template', 'renderNote'].includes(attr.name) && attr.isAffecting(this.note)); if (label || relation) { diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index 576dd5b81..edcf8874d 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -100,4 +100,4 @@ export default class NoteTitleWidget extends TabAwareWidget { beforeUnloadEvent() { this.spacedUpdate.updateNowIfNecessary(); } -} \ No newline at end of file +} diff --git a/src/services/attributes.js b/src/services/attributes.js index 975d80084..13db04fbc 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -29,7 +29,6 @@ const BUILTIN_ATTRIBUTES = [ { type: 'label', name: 'bookZoomLevel', isDangerous: false }, // relation names - { type: 'relation', name: 'runOnNoteView', isDangerous: true }, { type: 'relation', name: 'runOnNoteCreation', isDangerous: true }, { type: 'relation', name: 'runOnNoteTitleChange', isDangerous: true }, { type: 'relation', name: 'runOnNoteChange', isDangerous: true },