when saving Saved Search or SQL console, move it to their home (i.e. remove from hidden subtree)

This commit is contained in:
zadam
2021-10-24 14:53:45 +02:00
parent 33aa72eb97
commit 3413074235
17 changed files with 94 additions and 59 deletions

View File

@@ -137,7 +137,15 @@ function saveSqlConsole(sqlConsoleNoteId) {
attributeService.getNoteWithLabel('sqlConsoleHome')
|| dateNoteService.getDateNote(today);
return sqlConsoleNote.cloneTo(sqlConsoleHome.noteId);
const result = sqlConsoleNote.cloneTo(sqlConsoleHome.noteId);
for (const parentBranch of sqlConsoleNote.getParentBranches()) {
if (parentBranch.parentNote.hasAncestor("hidden")) {
parentBranch.markAsDeleted();
}
}
return result;
}
function createSearchNote(searchString, ancestorNoteId) {
@@ -158,25 +166,34 @@ function createSearchNote(searchString, ancestorNoteId) {
return note;
}
function saveSearchNote(searchNoteId) {
const searchNote = becca.getNote(searchNoteId);
function getSearchHome() {
const hoistedNote = getHoistedNote();
let searchHome;
if (!hoistedNote.isRoot()) {
searchHome = hoistedNote.searchNoteInSubtree('#hoistedSearchHome')
return hoistedNote.searchNoteInSubtree('#hoistedSearchHome')
|| hoistedNote.searchNoteInSubtree('#searchHome')
|| hoistedNote;
}
else {
} else {
const today = dateUtils.localNowDate();
searchHome = hoistedNote.searchNoteInSubtree('#searchHome')
return hoistedNote.searchNoteInSubtree('#searchHome')
|| dateNoteService.getDateNote(today);
}
}
return searchNote.cloneTo(searchHome.noteId);
function saveSearchNote(searchNoteId) {
const searchNote = becca.getNote(searchNoteId);
const searchHome = getSearchHome();
const result = searchNote.cloneTo(searchHome.noteId);
for (const parentBranch of searchNote.getParentBranches()) {
if (parentBranch.parentNote.hasAncestor("hidden")) {
parentBranch.markAsDeleted();
}
}
return result;
}
function getHoistedNote() {