moving edit branch prefix, search in subtree and toggle note hoisting to global entrypoints instead of being tree specific

This commit is contained in:
zadam 2019-11-23 23:06:25 +01:00
parent 0cde7ede24
commit 01ff34b5d4
3 changed files with 45 additions and 30 deletions

View file

@ -17,11 +17,21 @@ export async function showDialog(node) {
glob.activeDialog = $dialog;
$dialog.modal();
branchId = node.data.branchId;
const branch = treeCache.getBranch(branchId);
if (branch.noteId === 'root') {
return;
}
const parentNote = await treeCache.getNote(branch.parentNoteId);
if (parentNote.type === 'search') {
return;
}
$dialog.modal();
$treePrefixInput.val(branch.prefix);
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);

View file

@ -7,6 +7,8 @@ import treeService from "./tree.js";
import dateNoteService from "./date_notes.js";
import noteDetailService from "./note_detail.js";
import keyboardActionService from "./keyboard_actions.js";
import hoistedNoteService from "./hoisted_note.js";
import treeCache from "./tree_cache.js";
const NOTE_REVISIONS = "../dialogs/note_revisions.js";
const OPTIONS = "../dialogs/options.js";
@ -113,7 +115,7 @@ function registerEntrypoints() {
$("#toggle-zen-mode-button").on('click', toggleZenMode);
keyboardActionService.setActionHandler("ToggleZenMode", toggleZenMode);
keyboardActionService.setActionHandler("InsertDateTime", () => {
keyboardActionService.setActionHandler("InsertDateTimeToText", () => {
const date = new Date();
const dateString = utils.formatDateTime(date);
@ -230,6 +232,36 @@ function registerEntrypoints() {
isProtected: node.data.isProtected
});
});
keyboardActionService.setActionHandler("EditBranchPrefix", async () => {
const node = treeService.getActiveNode();
const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");
editBranchPrefixDialog.showDialog(node);
});
keyboardActionService.setActionHandler("ToggleNoteHoisting", async () => {
const node = treeService.getActiveNode();
hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {
if (node.data.noteId === hoistedNoteId) {
hoistedNoteService.unhoist();
}
else {
const note = await treeCache.getNote(node.data.noteId);
if (note.type !== 'search') {
hoistedNoteService.setHoistedNoteId(node.data.noteId);
}
}
});
});
keyboardActionService.setActionHandler("SearchInSubtree", () => {
const node = treeService.getActiveNode();
searchNotesService.searchInSubtree(node.data.noteId);
});
}
export default {

View file

@ -114,11 +114,6 @@ const templates = {
return false;
},
// TODO: this shouldn't be tree specific shortcut
"EditBranchPrefix": async node => {
const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");
editBranchPrefixDialog.showDialog(node);
},
"CollapseSubtree": node => {
treeService.collapseTree(node);
},
@ -158,28 +153,6 @@ const templates = {
if (!await hoistedNoteService.isRootNode(node)) {
node.getParent().setActive().then(treeService.clearSelectedNodes);
}
},
// TODO: this should probably be app-global shortcut
"ToggleNoteHoisting": node => {
hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {
if (node.data.noteId === hoistedNoteId) {
hoistedNoteService.unhoist();
}
else {
const note = await treeCache.getNote(node.data.noteId);
if (note.type !== 'search') {
hoistedNoteService.setHoistedNoteId(node.data.noteId);
}
}
});
return false;
},
"SearchInSubtree": node => {
searchNoteService.searchInSubtree(node.data.noteId);
return false;
}
};