From 5fc9f5f3f9acca9ca1f4c8afa830b4b9a80d0d1b Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 6 Dec 2022 23:48:44 +0100 Subject: [PATCH] improvements --- .../0204__migrate_bookmarks_to_clones.js | 2 +- db/migrations/0206__rename_noteIds.sql | 12 ++++ src/becca/entities/branch.js | 2 +- src/becca/entities/note.js | 4 ++ .../app/components/root_command_executor.js | 2 +- src/public/app/entities/note_short.js | 2 +- src/public/app/menus/launcher_context_menu.js | 12 ++-- src/public/app/services/branches.js | 10 ++-- src/public/app/widgets/bookmark_buttons.js | 4 +- src/public/app/widgets/bookmark_switch.js | 4 +- .../widgets/buttons/history/history_back.js | 2 +- .../buttons/history/history_forward.js | 2 +- .../app/widgets/buttons/note_actions.js | 2 +- .../widgets/containers/launcher_container.js | 4 +- src/public/app/widgets/note_detail.js | 2 +- src/public/app/widgets/note_title.js | 2 +- src/public/app/widgets/note_tree.js | 12 ++-- .../ribbon_widgets/owned_attribute_list.js | 2 +- src/services/handlers.js | 9 --- src/services/notes.js | 4 +- src/services/special_notes.js | 55 ++++++++++--------- src/services/tree.js | 4 +- 22 files changed, 81 insertions(+), 73 deletions(-) diff --git a/db/migrations/0204__migrate_bookmarks_to_clones.js b/db/migrations/0204__migrate_bookmarks_to_clones.js index db8f74ced..8f78066cb 100644 --- a/db/migrations/0204__migrate_bookmarks_to_clones.js +++ b/db/migrations/0204__migrate_bookmarks_to_clones.js @@ -8,7 +8,7 @@ module.exports = () => { beccaLoader.load(); for (const attr of becca.findAttributes('label','bookmarked')) { - cloningService.toggleNoteInParent(true, attr.noteId, 'lb_bookmarks'); + cloningService.toggleNoteInParent(true, attr.noteId, 'lbBookmarks'); attr.markAsDeleted("0204__migrate_bookmarks_to_clones"); } diff --git a/db/migrations/0206__rename_noteIds.sql b/db/migrations/0206__rename_noteIds.sql index 1fb34dc02..8ef48d4ed 100644 --- a/db/migrations/0206__rename_noteIds.sql +++ b/db/migrations/0206__rename_noteIds.sql @@ -6,6 +6,10 @@ UPDATE branches SET branchId = 'globalNoteMap' WHERE branchId = 'globalnotemap'; UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction'; UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole'; +UPDATE branches SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE branches SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; +UPDATE branches SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; + UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap'; UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction'; UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole'; @@ -13,3 +17,11 @@ UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; + +UPDATE attributes SET value = 'globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; +UPDATE attributes SET value = 'bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; +UPDATE attributes SET value = 'sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; + +UPDATE entity_changes SET entityId = 'globalNoteMap' WHERE entityId = 'globalnotemap'; +UPDATE entity_changes SET entityId = 'bulkAction' WHERE entityId = 'bulkaction'; +UPDATE entity_changes SET entityId = 'sqlConsole' WHERE entityId = 'sqlconsole'; diff --git a/src/becca/entities/branch.js b/src/becca/entities/branch.js index 610f95e70..691a46e39 100644 --- a/src/becca/entities/branch.js +++ b/src/becca/entities/branch.js @@ -129,7 +129,7 @@ class Branch extends AbstractEntity { * @returns {boolean} */ get isWeak() { - return ['share', 'lb_bookmarks'].includes(this.parentNoteId); + return ['share', 'lbBookmarks'].includes(this.parentNoteId); } /** diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js index 94a212f2b..75e4c30f7 100644 --- a/src/becca/entities/note.js +++ b/src/becca/entities/note.js @@ -1328,6 +1328,10 @@ class Note extends AbstractEntity { } } + isLaunchBarConfig() { + return this.type === 'launcher' || ['lbRoot', 'lbAvailableShortcuts', 'lbVisibleShortcuts']; + } + get isDeleted() { return !(this.noteId in this.becca.notes) || this.isBeingDeleted; } diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.js index 6eca67a08..3fb219c3c 100644 --- a/src/public/app/components/root_command_executor.js +++ b/src/public/app/components/root_command_executor.js @@ -73,7 +73,7 @@ export default class RootCommandExecutor extends Component { } async showLaunchBarSubtreeCommand() { - await appContext.tabManager.openContextWithNote('lb_root', true, null, 'lb_root'); + await appContext.tabManager.openContextWithNote('lbRoot', true, null, 'lbRoot'); } async showShareSubtreeCommand() { diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index 656e2b8b6..e6db36e2a 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -828,7 +828,7 @@ class NoteShort { } isLaunchBarConfig() { - return this.type === 'launcher' || this.noteId.startsWith("lb_"); + return this.type === 'launcher' || ['lbRoot', 'lbAvailableShortcuts', 'lbVisibleShortcuts']; } } diff --git a/src/public/app/menus/launcher_context_menu.js b/src/public/app/menus/launcher_context_menu.js index 4635f8f23..14d4f023f 100644 --- a/src/public/app/menus/launcher_context_menu.js +++ b/src/public/app/menus/launcher_context_menu.js @@ -27,13 +27,13 @@ export default class LauncherContextMenu { const note = await froca.getNote(this.node.data.noteId); const parentNoteId = this.node.getParent().data.noteId; - const isVisibleRoot = note.noteId === 'lb_visiblelaunchers'; - const isAvailableRoot = note.noteId === 'lb_availablelaunchers'; - const isVisibleItem = parentNoteId === 'lb_visiblelaunchers'; - const isAvailableItem = parentNoteId === 'lb_availablelaunchers'; + const isVisibleRoot = note.noteId === 'lbVisibleLaunchers'; + const isAvailableRoot = note.noteId === 'lbAvailableLaunchers'; + const isVisibleItem = parentNoteId === 'lbVisibleLaunchers'; + const isAvailableItem = parentNoteId === 'lbAvailableLaunchers'; const isItem = isVisibleItem || isAvailableItem; - const canBeDeleted = !note.noteId.startsWith("lb_"); - const canBeReset = note.noteId.startsWith("lb_"); + const canBeDeleted = !note.isLaunchBarConfig(); + const canBeReset = note.isLaunchBarConfig(); return [ (isVisibleRoot || isAvailableRoot) ? { title: 'Add a note launcher', command: 'addNoteLauncher', uiIcon: "bx bx-plus" } : null, diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js index 0df8e454c..86a9bce5f 100644 --- a/src/public/app/services/branches.js +++ b/src/public/app/services/branches.js @@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove); - if (['root', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(beforeBranchId)) { + if (['root', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(beforeBranchId)) { toastService.showError('Cannot move notes here.'); return; } @@ -34,9 +34,9 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { const forbiddenNoteIds = [ 'root', hoistedNoteService.getHoistedNoteId(), - 'lb_root', - 'lb_availablelaunchers', - 'lb_visiblelaunchers' + 'lbRoot', + 'lbAvailableLaunchers', + 'lbVisibleLaunchers' ]; if (forbiddenNoteIds.includes(afterNote.noteId)) { @@ -57,7 +57,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { } async function moveToParentNote(branchIdsToMove, newParentBranchId) { - if (newParentBranchId === 'lb_root') { + if (newParentBranchId === 'lbRoot') { toastService.showError('Cannot move notes here.'); return; } diff --git a/src/public/app/widgets/bookmark_buttons.js b/src/public/app/widgets/bookmark_buttons.js index 2beaaf9ad..5d561d134 100644 --- a/src/public/app/widgets/bookmark_buttons.js +++ b/src/public/app/widgets/bookmark_buttons.js @@ -15,7 +15,7 @@ export default class BookmarkButtons extends FlexContainer { this.children = []; this.noteIds = []; - const bookmarkParentNote = await froca.getNote('lb_bookmarks'); + const bookmarkParentNote = await froca.getNote('lbBookmarks'); for (const note of await bookmarkParentNote.getChildNotes()) { this.noteIds.push(note.noteId); @@ -37,7 +37,7 @@ export default class BookmarkButtons extends FlexContainer { } entitiesReloadedEvent({loadResults}) { - if (loadResults.getBranches().find(branch => branch.parentNoteId === 'lb_bookmarks')) { + if (loadResults.getBranches().find(branch => branch.parentNoteId === 'lbBookmarks')) { this.refresh(); } diff --git a/src/public/app/widgets/bookmark_switch.js b/src/public/app/widgets/bookmark_switch.js index 14407acf2..8755b0504 100644 --- a/src/public/app/widgets/bookmark_switch.js +++ b/src/public/app/widgets/bookmark_switch.js @@ -20,7 +20,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget { } async toggle(state) { - const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lb_bookmarks/` + !!state); + const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/` + !!state); if (!resp.success) { toastService.showError(resp.message); @@ -28,7 +28,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget { } refreshWithNote(note) { - const isBookmarked = !!note.getParentBranches().find(b => b.parentNoteId === 'lb_bookmarks'); + const isBookmarked = !!note.getParentBranches().find(b => b.parentNoteId === 'lbBookmarks'); this.$switchOn.toggle(!isBookmarked); this.$switchOff.toggle(isBookmarked); diff --git a/src/public/app/widgets/buttons/history/history_back.js b/src/public/app/widgets/buttons/history/history_back.js index 77ceff03b..b549599e0 100644 --- a/src/public/app/widgets/buttons/history/history_back.js +++ b/src/public/app/widgets/buttons/history/history_back.js @@ -8,7 +8,7 @@ export default class BackInHistoryButtonWidget extends AbstractHistoryNavigation .title("Go to previous note.") .command("backInNoteHistory") .titlePlacement("right") - .buttonNoteIdProvider(() => 'lb_backinhistory') + .buttonNoteIdProvider(() => 'lbBackInHistory') .onContextMenu(e => this.showContextMenu(e)); } } diff --git a/src/public/app/widgets/buttons/history/history_forward.js b/src/public/app/widgets/buttons/history/history_forward.js index 7b824e6fd..5c8a3ad62 100644 --- a/src/public/app/widgets/buttons/history/history_forward.js +++ b/src/public/app/widgets/buttons/history/history_forward.js @@ -8,7 +8,7 @@ export default class ForwardInHistoryButtonWidget extends AbstractHistoryNavigat .title("Go to next note.") .command("forwardInNoteHistory") .titlePlacement("right") - .buttonNoteIdProvider(() => 'lb_forwardinhistory') + .buttonNoteIdProvider(() => 'lbForwardInHistory') .onContextMenu(e => this.showContextMenu(e)); } } diff --git a/src/public/app/widgets/buttons/note_actions.js b/src/public/app/widgets/buttons/note_actions.js index c5f783597..6b1c15b51 100644 --- a/src/public/app/widgets/buttons/note_actions.js +++ b/src/public/app/widgets/buttons/note_actions.js @@ -38,7 +38,7 @@ const TPL = ` export default class NoteActionsWidget extends NoteContextAwareWidget { isEnabled() { - return !this.note?.isLaunchBarConfig(); + return this.note?.type !== 'launcher'; } doRender() { diff --git a/src/public/app/widgets/containers/launcher_container.js b/src/public/app/widgets/containers/launcher_container.js index d71c3958f..9e27e08fb 100644 --- a/src/public/app/widgets/containers/launcher_container.js +++ b/src/public/app/widgets/containers/launcher_container.js @@ -17,7 +17,7 @@ export default class LauncherContainer extends FlexContainer { async load() { this.children = []; - const visibleLaunchersRoot = await froca.getNote('lb_visiblelaunchers', true); + const visibleLaunchersRoot = await froca.getNote('lbVisibleLaunchers', true); if (!visibleLaunchersRoot) { console.log("Visible launchers root note doesn't exist."); @@ -61,7 +61,7 @@ export default class LauncherContainer extends FlexContainer { } entitiesReloadedEvent({loadResults}) { - if (loadResults.getBranches().find(branch => branch.parentNoteId.startsWith("lb_"))) { + if (loadResults.getBranches().find(branch => froca.getNoteFromCache(branch.parentNoteId)?.isLaunchBarConfig())) { // changes in note placement requires reload of all launchers, all other changes are handled by individual // launchers this.load(); diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 1a802ff87..590bbb21b 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -58,7 +58,7 @@ const typeWidgetClasses = { 'canvas': CanvasTypeWidget, 'protectedSession': ProtectedSessionTypeWidget, 'book': BookTypeWidget, - 'note-map': NoteMapTypeWidget, + 'noteMap': NoteMapTypeWidget, 'webView': WebViewTypeWidget, 'doc': DocTypeWidget, 'contentWidget': ContentWidgetTypeWidget diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index ce33def91..97b20c759 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget { this.$noteTitle.val(note.title); this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) - || ["lb_root", "lb_availablelaunchers", "lb_visiblelaunchers"].includes(note.noteId)); + || ["lbRoot", "lbAvailableLaunchers", "lbVisibleLaunchers"].includes(note.noteId)); this.setProtectedStatus(note); } diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 5f92793b5..b27d58e90 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -398,7 +398,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { autoExpandMS: 600, preventLazyParents: false, dragStart: (node, data) => { - if (['root', 'hidden', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(node.data.noteId)) { + if (['root', 'hidden', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(node.data.noteId)) { return false; } @@ -426,7 +426,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { dragEnter: (node, data) => { if (node.data.noteType === 'search') { return false; - } else if (node.data.noteId === 'lb_root') { + } else if (node.data.noteId === 'lbRoot') { return false; } else if (node.data.noteType === 'launcher') { return ['before', 'after']; @@ -604,7 +604,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { this.$tree.on('contextmenu', '.fancytree-node', e => { const node = $.ui.fancytree.getNode(e); - if (hoistedNoteService.getHoistedNoteId() === 'lb_root') { + if (hoistedNoteService.getHoistedNoteId() === 'lbRoot') { import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => { const shortcutContextMenu = new LauncherContextMenu(this, node); shortcutContextMenu.show(e); @@ -744,7 +744,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { .map(noteId => froca.notes[noteId]) .filter(note => !!note) .filter(note => - !['share', 'lb_bookmarks'].includes(note.noteId) + !['share', 'lbBookmarks'].includes(note.noteId) && note.type !== 'search'); if (realClones.length > 1) { @@ -1554,11 +1554,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) { - branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visiblelaunchers'); + branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbVisibleLaunchers'); } moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) { - branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availablelaunchers'); + branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbAvailableLaunchers'); } addNoteLauncherCommand({node}) { diff --git a/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js b/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js index db989e0ba..836d39a98 100644 --- a/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js +++ b/src/public/app/widgets/ribbon_widgets/owned_attribute_list.js @@ -47,7 +47,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget { getTitle() { return { - show: true,//!this.note.isLaunchBarConfig(), + show: !this.note.isLaunchBarConfig(), title: "Owned attributes", icon: "bx bx-list-check" }; diff --git a/src/services/handlers.js b/src/services/handlers.js index f33607097..618a13e6b 100644 --- a/src/services/handlers.js +++ b/src/services/handlers.js @@ -162,8 +162,6 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({ entityName, entity }) => }); }); -const debouncedCreateMissingSpecialNotes = debounce(() => specialNotesService.createMissingSpecialNotes(), 300); - eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) => { processInverseRelations(entityName, entity, (definition, note, targetNote) => { // if one inverse attribute is deleted then the other should be deleted as well @@ -179,13 +177,6 @@ eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) => if (entityName === 'branches') { runAttachedRelations(entity.getNote(), 'runOnBranchDeletion', entity); } - - if (entityName === 'notes') { - if (entity.noteId.startsWith("lb_")) { - // if user deletes shortcuts, restore them immediately - debouncedCreateMissingSpecialNotes(); - } - } }); module.exports = { diff --git a/src/services/notes.js b/src/services/notes.js index 176556d33..d5111b82c 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -114,11 +114,11 @@ function getAndValidateParent(params) { throw new Error(`Launchers should not have child notes.`); } - if (!params.ignoreForbiddenParents && ['lb_root'].includes(parentNote.noteId)) { + if (!params.ignoreForbiddenParents && ['lbRoot'].includes(parentNote.noteId)) { throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`); } - if (['lb_availablelaunchers', 'lb_visiblelaunchers'].includes(parentNote.noteId) && params.type !== 'launcher') { + if (['lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(parentNote.noteId) && params.type !== 'launcher') { throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for type 'launcher'.`); } diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 5b5efc559..edcf6a044 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -4,6 +4,7 @@ const becca = require("../becca/becca"); const noteService = require("./notes"); const cls = require("./cls"); const dateUtils = require("./date_utils"); +const log = require("./log.js"); const LBTPL_ROOT = "lbtpl_root"; const LBTPL_BASE = "lbtpl_base"; @@ -253,12 +254,12 @@ function getBulkActionNote() { } function getLaunchBarRoot() { - let note = becca.getNote('lb_root'); + let note = becca.getNote('lbRoot'); if (!note) { note = noteService.createNewNote({ - branchId: 'lb_root', - noteId: 'lb_root', + branchId: 'lbRoot', + noteId: 'lbRoot', title: 'Launch bar', type: 'doc', content: '', @@ -273,12 +274,12 @@ function getLaunchBarRoot() { } function getLaunchBarAvailableLaunchersRoot() { - let note = becca.getNote('lb_availablelaunchers'); + let note = becca.getNote('lbAvailableLaunchers'); if (!note) { note = noteService.createNewNote({ - branchId: 'lb_availablelaunchers', - noteId: 'lb_availablelaunchers', + branchId: 'lbAvailableLaunchers', + noteId: 'lbAvailableLaunchers', title: 'Available launchers', type: 'doc', content: '', @@ -290,7 +291,7 @@ function getLaunchBarAvailableLaunchersRoot() { note.addLabel("docName", "launchbar_intro"); } - const branch = becca.getBranch('lb_availablelaunchers'); + const branch = becca.getBranch('lbAvailableLaunchers'); if (!branch.isExpanded) { branch.isExpanded = true; branch.save(); @@ -300,12 +301,12 @@ function getLaunchBarAvailableLaunchersRoot() { } function getLaunchBarVisibleLaunchersRoot() { - let note = becca.getNote('lb_visiblelaunchers'); + let note = becca.getNote('lbVisibleLaunchers'); if (!note) { note = noteService.createNewNote({ - branchId: 'lb_visiblelaunchers', - noteId: 'lb_visiblelaunchers', + branchId: 'lbVisibleLaunchers', + noteId: 'lbVisibleLaunchers', title: 'Visible launchers', type: 'doc', content: '', @@ -317,7 +318,7 @@ function getLaunchBarVisibleLaunchersRoot() { note.addLabel("docName", "launchbar_intro"); } - const branch = becca.getBranch('lb_visiblelaunchers'); + const branch = becca.getBranch('lbVisibleLaunchers'); if (!branch.isExpanded) { branch.isExpanded = true; branch.save(); @@ -328,21 +329,21 @@ function getLaunchBarVisibleLaunchersRoot() { const launchers = [ // visible launchers: - { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true }, - { id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true }, - { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, - { id: 'lb_notemap', targetNoteId: 'globalNotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true }, - { id: 'lb_calendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true }, - { id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "50", growthFactor: "0" }, - { id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true }, - { id: 'lb_spacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "0", growthFactor: "1" }, - { id: 'lb_protectedsession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', isVisible: true }, - { id: 'lb_syncstatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true }, + { id: 'lbNewNote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true }, + { id: 'lbSearch', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true }, + { id: 'lbJumpTo', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, + { id: 'lbNoteMap', targetNoteId: 'globalNotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true }, + { id: 'lbCalendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true }, + { id: 'lbSpacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "50", growthFactor: "0" }, + { id: 'lbBookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true }, + { id: 'lbSpacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "0", growthFactor: "1" }, + { id: 'lbProtectedSession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', isVisible: true }, + { id: 'lbSyncStatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true }, // available launchers: - { id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Recent changes', icon: 'bx bx-history', isVisible: false }, - { id: 'lb_backinhistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false }, - { id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false }, + { id: 'lbRecentChanges', command: 'showRecentChanges', title: 'Recent changes', icon: 'bx bx-history', isVisible: false }, + { id: 'lbBackInHistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false }, + { id: 'lbForwardInHistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false }, ]; function createLaunchers() { @@ -628,11 +629,11 @@ function createMissingSpecialNotes() { } function resetLauncher(noteId) { - if (noteId.startsWith('lb_')) { - const note = becca.getNote(noteId); + const note = becca.getNote(noteId); + if (note.isLauncherConfig()) { if (note) { - if (noteId === 'lb_root') { + if (noteId === 'lbRoot') { // deleting hoisted notes are not allowed, so we just reset the children for (const childNote of note.getChildNotes()) { childNote.deleteNote(); diff --git a/src/services/tree.js b/src/services/tree.js index 60c14f417..a6e1ec4d3 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -30,7 +30,7 @@ function getNotes(noteIds) { } function validateParentChild(parentNoteId, childNoteId, branchId = null) { - if (['root', 'hidden', 'share', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(childNoteId)) { + if (['root', 'hidden', 'share', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(childNoteId)) { return { success: false, message: `Cannot change this note's location.`}; } @@ -58,7 +58,7 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { }; } - if (parentNoteId !== 'lb_bookmarks' && becca.getNote(parentNoteId).type === 'launcher') { + if (parentNoteId !== 'lbBookmarks' && becca.getNote(parentNoteId).type === 'launcher') { return { success: false, message: 'Launcher note cannot have any children.'