mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
allow search result to be moved from tree to relation map, fixes #1650
This commit is contained in:
parent
859465841d
commit
2cfd093cae
@ -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();
|
||||
|
||||
|
@ -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,
|
||||
|
@ -5,7 +5,7 @@
|
||||
.note-detail-relation-map {
|
||||
height: 100%;
|
||||
overflow: hidden !important;
|
||||
padding-top: 10px;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user