diff --git a/src/public/javascripts/entities/note_short.js b/src/public/javascripts/entities/note_short.js index 304926a99..913cf13b5 100644 --- a/src/public/javascripts/entities/note_short.js +++ b/src/public/javascripts/entities/note_short.js @@ -445,6 +445,11 @@ class NoteShort { return dto; } + + async getCssClass() { + const labels = await this.getLabels('cssClass'); + return labels.map(l => l.value).join(' '); + } } export default NoteShort; \ No newline at end of file diff --git a/src/public/javascripts/services/tree_builder.js b/src/public/javascripts/services/tree_builder.js index 896bbccea..2e4046c87 100644 --- a/src/public/javascripts/services/tree_builder.js +++ b/src/public/javascripts/services/tree_builder.js @@ -134,11 +134,6 @@ async function prepareSearchBranch(note) { return await prepareRealBranch(newNote); } -async function getCssClass(note) { - const labels = await note.getLabels('cssClass'); - return labels.map(l => l.value).join(' '); -} - async function getExtraClasses(note) { utils.assertArguments(note); @@ -152,7 +147,7 @@ async function getExtraClasses(note) { extraClasses.push("multiple-parents"); } - const cssClass = await getCssClass(note); + const cssClass = await note.getCssClass(); if (cssClass) { extraClasses.push(cssClass); diff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.js index 7145a6daa..d19e20d9b 100644 --- a/src/public/javascripts/widgets/note_detail.js +++ b/src/public/javascripts/widgets/note_detail.js @@ -132,7 +132,8 @@ export default class NoteDetailWidget extends TabAwareWidget { const note = this.note; if (note) { - this.$widget.addClass(note.cssClass); + note.getCssClass().then(cssClass => this.$widget.addClass(cssClass)); + this.$widget.addClass(utils.getNoteTypeClass(note.type)); this.$widget.addClass(utils.getMimeTypeClass(note.mime)); diff --git a/src/public/javascripts/widgets/tab_row.js b/src/public/javascripts/widgets/tab_row.js index 6e3c95cf0..079176e35 100644 --- a/src/public/javascripts/widgets/tab_row.js +++ b/src/public/javascripts/widgets/tab_row.js @@ -596,7 +596,7 @@ export default class TabRowWidget extends BasicWidget { } } - $tab.addClass(note.cssClass); + note.getCssClass().then(cssClass => $tab.addClass(cssClass)); $tab.addClass(utils.getNoteTypeClass(note.type)); $tab.addClass(utils.getMimeTypeClass(note.mime)); }