launchbar WIP

This commit is contained in:
zadam
2022-08-05 16:44:26 +02:00
parent 7565458332
commit 42cade17cb
24 changed files with 208 additions and 53 deletions

View File

@@ -1,6 +1,8 @@
import FlexContainer from "./flex_container.js";
import froca from "../../services/froca.js";
import ButtonWidget from "../buttons/button_widget.js";
import CalendarWidget from "../buttons/calendar.js";
import appContext from "../../services/app_context.js";
export default class ShortcutContainer extends FlexContainer {
constructor() {
@@ -18,13 +20,28 @@ export default class ShortcutContainer extends FlexContainer {
const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts');
console.log(await visibleShortcutsRoot.getChildNotes());
for (const shortcut of await visibleShortcutsRoot.getChildNotes()) {
this.child(new ButtonWidget()
.icon(shortcut.getLabelValue("iconClass"))
.title(shortcut.title)
.command(shortcut.getLabelValue("command")));
if (shortcut.getLabelValue("command")) {
this.child(new ButtonWidget()
.title(shortcut.title)
.icon(shortcut.getIcon())
.command(shortcut.getLabelValue("command")));
} else if (shortcut.hasRelation('targetNote')) {
this.child(new ButtonWidget()
.title(shortcut.title)
.icon(shortcut.getIcon())
.onClick(() => appContext.tabManager.openTabWithNoteWithHoisting(shortcut.getRelationValue('targetNote'), true)));
} else {
const builtinWidget = shortcut.getLabelValue("builtinWidget");
if (builtinWidget) {
if (builtinWidget === 'calendar') {
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
} else {
console.log(`Unrecognized builtin widget ${builtinWidget} for shortcut ${shortcut.noteId} "${shortcut.title}"`);
}
}
}
}
this.$widget.empty();
@@ -34,8 +51,9 @@ export default class ShortcutContainer extends FlexContainer {
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.getNotes().find(note => note.noteId.startsWith("lb_"))
|| loadResults.getBranches().find(branch => branch.branchId.startsWith("lb_"))) {
if (loadResults.getNoteIds().find(noteId => noteId.startsWith("lb_"))
|| loadResults.getBranches().find(branch => branch.branchId.startsWith("lb_"))
|| loadResults.getAttributes().find(attr => attr.noteId.startsWith("lb_"))) {
this.load();
}
}