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
+4 -4
View File
@@ -34,7 +34,7 @@ function getNoteStartingWith(parentNoteId, startsWith) {
return becca.getNote(noteId);
}
/** @return {Note} */
/** @returns {Note} */
function getRootCalendarNote() {
let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL);
@@ -57,7 +57,7 @@ function getRootCalendarNote() {
return rootNote;
}
/** @return {Note} */
/** @returns {Note} */
function getYearNote(dateStr, rootNote) {
if (!rootNote) {
rootNote = getRootCalendarNote();
@@ -97,7 +97,7 @@ function getMonthNoteTitle(rootNote, monthNumber, dateObj) {
.replace(/{month}/g, monthName);
}
/** @return {Note} */
/** @returns {Note} */
function getMonthNote(dateStr, rootNote) {
if (!rootNote) {
rootNote = getRootCalendarNote();
@@ -152,7 +152,7 @@ function getDateNoteTitle(rootNote, dayNumber, dateObj) {
.replace(/{weekDay2}/g, weekDay.substr(0, 2));
}
/** @return {Note} */
/** @returns {Note} */
function getDateNote(dateStr) {
let dateNote = attributeService.getNoteWithLabel(DATE_LABEL, dateStr);
+1 -1
View File
@@ -393,7 +393,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
}
}
/** @return {string} path without leading or trailing slash and backslashes converted to forward ones*/
/** @returns {string} path without leading or trailing slash and backslashes converted to forward ones*/
function normalizeFilePath(filePath) {
filePath = filePath.replace(/\\/g, "/");
+27 -10
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() {
+1 -1
View File
@@ -22,7 +22,7 @@ class TaskContext {
this.increaseProgressCount();
}
/** @return {TaskContext} */
/** @returns {TaskContext} */
static getInstance(taskId, taskType, data) {
if (!taskContexts[taskId]) {
taskContexts[taskId] = new TaskContext(taskId, taskType, data);