diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js index 95d9e6510..b04e8602c 100644 --- a/src/public/app/services/branches.js +++ b/src/public/app/services/branches.js @@ -7,6 +7,7 @@ import ws from "./ws.js"; async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { branchIdsToMove = filterRootNote(branchIdsToMove); + branchIdsToMove = filterSearchBranches(branchIdsToMove); if (beforeBranchId === 'root') { alert('Cannot move notes before root note.'); @@ -25,6 +26,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { async function moveAfterBranch(branchIdsToMove, afterBranchId) { branchIdsToMove = filterRootNote(branchIdsToMove); + branchIdsToMove = filterSearchBranches(branchIdsToMove); const afterNote = await treeCache.getBranch(afterBranchId).getNote(); @@ -142,6 +144,10 @@ async function moveNodeUpInHierarchy(node) { } } +function filterSearchBranches(branchIds) { + return branchIds.filter(branchId => !branchId.startsWith('virt-')); +} + function filterRootNote(branchIds) { const hoistedNoteId = hoistedNoteService.getHoistedNoteId(); diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 26518f7b9..0530f1f77 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -392,12 +392,6 @@ export default class NoteTreeWidget extends TabAwareWidget { autoExpandMS: 600, preventLazyParents: false, dragStart: (node, data) => { - // don't allow dragging root node - if (node.data.noteId === hoistedNoteService.getHoistedNoteId() - || node.getParent().data.noteType === 'search') { - return false; - } - const notes = this.getSelectedOrActiveNodes(node).map(node => ({ noteId: node.data.noteId, branchId: node.data.branchId, diff --git a/src/public/stylesheets/relation_map.css b/src/public/stylesheets/relation_map.css index 343274a46..31f512197 100644 --- a/src/public/stylesheets/relation_map.css +++ b/src/public/stylesheets/relation_map.css @@ -5,7 +5,7 @@ .note-detail-relation-map { height: 100%; overflow: hidden !important; - padding-top: 10px; + padding: 10px; position: relative; } diff --git a/src/routes/api/branches.js b/src/routes/api/branches.js index 1b11ad8a3..bae85d01b 100644 --- a/src/routes/api/branches.js +++ b/src/routes/api/branches.js @@ -54,9 +54,17 @@ function moveBranchBeforeNote(req) { const {branchId, beforeBranchId} = req.params; const branchToMove = repository.getBranch(branchId); - const beforeNote = repository.getBranch(beforeBranchId); + const beforeBranch = repository.getBranch(beforeBranchId); - const validationResult = treeService.validateParentChild(beforeNote.parentNoteId, branchToMove.noteId, branchId); + if (!branchToMove) { + return [404, `Can't find branch ${branchId}`]; + } + + if (!beforeBranch) { + return [404, `Can't find branch ${beforeBranchId}`]; + } + + const validationResult = treeService.validateParentChild(beforeBranch.parentNoteId, branchToMove.noteId, branchId); if (!validationResult.success) { return [200, validationResult]; @@ -65,16 +73,16 @@ function moveBranchBeforeNote(req) { // we don't change utcDateModified so other changes are prioritized in case of conflict // also we would have to sync all those modified branches otherwise hash checks would fail sql.execute("UPDATE branches SET notePosition = notePosition + 10 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0", - [beforeNote.parentNoteId, beforeNote.notePosition]); + [beforeBranch.parentNoteId, beforeBranch.notePosition]); - entityChangesService.addNoteReorderingEntityChange(beforeNote.parentNoteId); + entityChangesService.addNoteReorderingEntityChange(beforeBranch.parentNoteId); - if (branchToMove.parentNoteId === beforeNote.parentNoteId) { - branchToMove.notePosition = beforeNote.notePosition; + if (branchToMove.parentNoteId === beforeBranch.parentNoteId) { + branchToMove.notePosition = beforeBranch.notePosition; branchToMove.save(); } else { - const newBranch = branchToMove.createClone(beforeNote.parentNoteId, beforeNote.notePosition); + const newBranch = branchToMove.createClone(beforeBranch.parentNoteId, beforeBranch.notePosition); newBranch.save(); branchToMove.isDeleted = true;