show "reset to default icon" button only when there is an explicit icon

This commit is contained in:
zadam 2021-02-18 20:06:14 +01:00
parent 1f7997eeed
commit 4cbf9c2e86

View File

@ -142,17 +142,17 @@ export default class NoteIconWidget extends TabAwareWidget {
async renderDropdown(categoryId, search) {
this.$iconList.empty();
this.$iconList.append(
$(`<div style="text-align: center">`)
.append(
$('<button class="btn btn-sm">Reset to default icon</button>')
.on('click', () =>
this.note.getOwnedLabels()
.filter(label => ['workspaceIconClass', 'iconClass'].includes(label.name))
if (this.getIconLabels().length > 0) {
this.$iconList.append(
$(`<div style="text-align: center">`)
.append(
$('<button class="btn btn-sm">Reset to default icon</button>')
.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;