From a680bb4612f720b89bd51004145079f08d116f2a Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 13 Dec 2018 23:28:48 +0100 Subject: [PATCH] unhoist note when activating note outside of the hoisted note subtree --- src/public/javascripts/services/tree.js | 12 ++++++++++++ src/routes/routes.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 1bfe15f4f..7389f733f 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -15,6 +15,7 @@ import treeKeyBindings from "./tree_keybindings.js"; import Branch from '../entities/branch.js'; import NoteShort from '../entities/note_short.js'; import hoistedNoteService from '../services/hoisted_note.js'; +import confirmDialog from "../dialogs/confirm.js"; const $tree = $("#tree"); const $createTopLevelNoteButton = $("#create-top-level-note-button"); @@ -113,6 +114,17 @@ async function expandToNote(notePath, expandOpts) { async function activateNote(notePath, newNote) { utils.assertArguments(notePath); + const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); + + if (!notePath.includes(hoistedNoteId)) { + if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree. Do you want to unhoist?")) { + return; + } + + // unhoist so we can activate the note + await hoistedNoteService.setHoistedNoteId('root'); + } + if (glob.activeDialog) { glob.activeDialog.modal('hide'); } diff --git a/src/routes/routes.js b/src/routes/routes.js index 93b7314e5..0bed2b54a 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -151,7 +151,7 @@ function register(app) { apiRoute(GET, '/api/recent-changes', recentChangesApiRoute.getRecentChanges); apiRoute(GET, '/api/options', optionsApiRoute.getOptions); - apiRoute(PUT, '/api/options/:name/:value', optionsApiRoute.updateOption); + apiRoute(PUT, '/api/options/:name/:value*', optionsApiRoute.updateOption); apiRoute(PUT, '/api/options', optionsApiRoute.updateOptions); apiRoute(POST, '/api/password/change', passwordApiRoute.changePassword);