shortcut improvements

This commit is contained in:
zadam
2022-11-29 16:16:57 +01:00
parent eecfce3cc9
commit e759b4846a
9 changed files with 88 additions and 46 deletions

View File

@@ -6,11 +6,17 @@ export default class ButtonFromNoteWidget extends ButtonWidget {
constructor() {
super();
this.settings.buttonNoteId = null;
this.settings.buttonNoteIdProvider = null;
this.settings.defaultIconProvider = null;
}
buttonNoteId(noteId) {
this.settings.buttonNoteId = noteId;
buttonNoteIdProvider(provider) {
this.settings.buttonNoteIdProvider = provider;
return this;
}
defaultIconProvider(provider) {
this.settings.defaultIconProvider = provider;
return this;
}
@@ -21,18 +27,32 @@ export default class ButtonFromNoteWidget extends ButtonWidget {
}
updateIcon() {
froca.getNote(this.settings.buttonNoteId).then(note => {
this.settings.icon = note.getLabelValue("iconClass");
const buttonNoteId = this.settings.buttonNoteIdProvider();
if (!buttonNoteId && this.settings.defaultIconProvider()) {
this.settings.icon = this.settings.defaultIconProvider();
this.refreshIcon();
});
} else {
froca.getNote(buttonNoteId).then(note => {
this.settings.icon = note.getIcon();
this.refreshIcon();
});
}
}
entitiesReloadedEvent({loadResults}) {
const buttonNote = froca.getNoteFromCache(this.buttonNoteIdProvider());
if (!buttonNote) {
return;
}
if (loadResults.getAttributes(this.componentId).find(attr =>
attr.type === 'label'
&& attr.name === 'iconClass'
&& attributeService.isAffecting(attr, this.note))) {
&& attributeService.isAffecting(attr, buttonNote))) {
this.updateIcon();
}

View File

@@ -8,7 +8,7 @@ export default class BackInHistoryButtonWidget extends AbstractHistoryNavigation
.title("Go to previous note.")
.command("backInNoteHistory")
.titlePlacement("right")
.buttonNoteId('lb_backinhistory')
.buttonNoteIdProvider(() => 'lb_backinhistory')
.onContextMenu(e => this.showContextMenu(e));
}
}

View File

@@ -8,7 +8,7 @@ export default class ForwardInHistoryButtonWidget extends AbstractHistoryNavigat
.title("Go to next note.")
.command("forwardInNoteHistory")
.titlePlacement("right")
.buttonNoteId('lb_forwardinhistory')
.buttonNoteIdProvider(() => 'lb_forwardinhistory')
.onContextMenu(e => this.showContextMenu(e));
}
}