From b96e43434563d8c745fcece5c1c711669a592005 Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 22 Nov 2017 20:46:42 -0500 Subject: [PATCH] fixing encrypt / decrypt subtree --- public/javascripts/context_menu.js | 9 +++------ public/javascripts/protected_session.js | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js index 4f3fdd950..66bb37d86 100644 --- a/public/javascripts/context_menu.js +++ b/public/javascripts/context_menu.js @@ -45,9 +45,6 @@ const contextMenu = (function() { treeEl.contextmenu("enableEntry", "pasteAfter", noteTree.getClipboardNoteTreeId() !== null); treeEl.contextmenu("enableEntry", "pasteInto", noteTree.getClipboardNoteTreeId() !== null); - treeEl.contextmenu("enableEntry", "protectSubTree", protected_session.isProtectedSessionAvailable()); - treeEl.contextmenu("enableEntry", "unprotectSubTree", protected_session.isProtectedSessionAvailable()); - // Activate node on right-click node.setActive(); // Disable tree keyboard handling @@ -65,13 +62,13 @@ const contextMenu = (function() { noteEditor.createNote(node, parentNoteTreeId, 'after', isProtected); } else if (ui.cmd === "insertChildNote") { - noteEditor.createNote(node, node.key, 'into'); + noteEditor.createNote(node, node.data.note_id, 'into'); } else if (ui.cmd === "protectSubTree") { - protected_session.protectSubTree(node.key, true); + protected_session.protectSubTree(node.data.note_id, true); } else if (ui.cmd === "unprotectSubTree") { - protected_session.protectSubTree(node.key, false); + protected_session.protectSubTree(node.data.note_id, false); } else if (ui.cmd === "cut") { cut(node); diff --git a/public/javascripts/protected_session.js b/public/javascripts/protected_session.js index 0da7f07cb..58aef9d39 100644 --- a/public/javascripts/protected_session.js +++ b/public/javascripts/protected_session.js @@ -152,6 +152,8 @@ const protected_session = (function() { } async function protectSubTree(noteId, protect) { + await ensureProtectedSession(true, true); + await $.ajax({ url: baseApiUrl + 'tree/' + noteId + "/protectSubTree/" + (protect ? 1 : 0), type: 'PUT',