From 4cbf9c2e8622ed7ea340fb5d082dacb18f653216 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 18 Feb 2021 20:06:14 +0100 Subject: [PATCH] show "reset to default icon" button only when there is an explicit icon --- src/public/app/widgets/note_icon.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/public/app/widgets/note_icon.js b/src/public/app/widgets/note_icon.js index 17c313ff7..cd76724a0 100644 --- a/src/public/app/widgets/note_icon.js +++ b/src/public/app/widgets/note_icon.js @@ -142,17 +142,17 @@ export default class NoteIconWidget extends TabAwareWidget { async renderDropdown(categoryId, search) { this.$iconList.empty(); - this.$iconList.append( - $(`
`) - .append( - $('') - .on('click', () => - this.note.getOwnedLabels() - .filter(label => ['workspaceIconClass', 'iconClass'].includes(label.name)) + if (this.getIconLabels().length > 0) { + this.$iconList.append( + $(`
`) + .append( + $('') + .on('click', () => this.getIconLabels() .forEach(label => attributeService.removeAttributeById(this.noteId, label.attributeId)) - ) - ) - ); + ) + ) + ); + } const {icons} = (await import('./icon_list.js')).default; @@ -173,6 +173,11 @@ export default class NoteIconWidget extends TabAwareWidget { } } + getIconLabels() { + return this.note.getOwnedLabels() + .filter(label => ['workspaceIconClass', 'iconClass'].includes(label.name)); + } + getIconClass(icon) { if (icon.type_of_icon === 'LOGO') { return "bx bxl-" + icon.name;