Merge branch 'next58'

# Conflicts:
#	src/public/app/widgets/note_tree.js
#	src/services/tree.js
This commit is contained in:
zadam
2022-12-14 23:48:58 +01:00
257 changed files with 5132 additions and 3384 deletions

View File

@@ -30,13 +30,13 @@ function getNotes(noteIds) {
}
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
if (childNoteId === 'root') {
return { success: false, message: 'Cannot move root note.'};
if (['root', 'hidden', 'share', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(childNoteId)) {
return { success: false, message: `Cannot change this note's location.`};
}
if (parentNoteId === 'none') {
// this shouldn't happen
return { success: false, message: 'Cannot move anything into root parent.' };
return { success: false, message: `Cannot move anything into 'none' parent.` };
}
const existing = getExistingBranch(parentNoteId, childNoteId);
@@ -58,6 +58,13 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
};
}
if (parentNoteId !== 'lbBookmarks' && becca.getNote(parentNoteId).type === 'launcher') {
return {
success: false,
message: 'Launcher note cannot have any children.'
};
}
return { success: true };
}
@@ -180,6 +187,10 @@ function sortNotes(parentNoteId, customSortBy = 'title', reverse = false, folder
for (const note of notes) {
const branch = note.getParentBranches().find(b => b.parentNoteId === parentNoteId);
if (branch.branchId === 'hidden') {
position = 999_999_999;
}
if (branch.notePosition !== position) {
sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?",
[position, branch.branchId]);