context menu disables actions not applicable to search note

This commit is contained in:
azivner
2018-03-13 19:31:07 -04:00
parent 0fd5102a26
commit 9c32f66329
2 changed files with 18 additions and 5 deletions

View File

@@ -95,9 +95,17 @@ const contextMenu = (function() {
],
beforeOpen: (event, ui) => {
const node = $.ui.fancytree.getNode(ui.target);
const nt = noteTree.getNoteTree(node.data.noteTreeId);
const note = noteTree.getNote(node.data.noteId);
const parentNote = noteTree.getNote(nt.parentNoteId);
// Modify menu entries depending on node status
$tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0);
$tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0);
$tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0 && (!parentNote || parentNote.type !== 'search'));
$tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search');
$tree.contextmenu("enableEntry", "insertNoteHere", !parentNote || parentNote.type !== 'search');
$tree.contextmenu("enableEntry", "insertChildNote", note.type !== 'search');
$tree.contextmenu("enableEntry", "importSubTree", note.type !== 'search');
$tree.contextmenu("enableEntry", "exportSubTree", note.type !== 'search');
// Activate node on right-click
node.setActive();