mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
WIP per-tab hoisting
This commit is contained in:
parent
52b8162d01
commit
ac636b6649
@ -25,7 +25,7 @@ function isRootNode(node) {
|
|||||||
|| node.data.noteId === getHoistedNoteId();
|
|| node.data.noteId === getHoistedNoteId();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkNoteAccess(notePath) {
|
async function checkNoteAccess(notePath, tabContext) {
|
||||||
// notePath argument can contain only noteId which is not good when hoisted since
|
// notePath argument can contain only noteId which is not good when hoisted since
|
||||||
// then we need to check the whole note path
|
// then we need to check the whole note path
|
||||||
const resolvedNotePath = await treeService.resolveNotePath(notePath);
|
const resolvedNotePath = await treeService.resolveNotePath(notePath);
|
||||||
@ -35,11 +35,11 @@ async function checkNoteAccess(notePath) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hoistedNoteId = getHoistedNoteId();
|
const hoistedNoteId = tabContext.hoistedNoteId;
|
||||||
|
|
||||||
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
|
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
|
||||||
const confirmDialog = await import('../dialogs/confirm.js');
|
const confirmDialog = await import('../dialogs/confirm.js');
|
||||||
|
console.trace("HI!", hoistedNoteId, notePath);
|
||||||
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
|
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class TabContext extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await hoistedNoteService.checkNoteAccess(resolvedNotePath) === false) {
|
if (await hoistedNoteService.checkNoteAccess(resolvedNotePath, this) === false) {
|
||||||
return; // note is outside of hoisted subtree and user chose not to unhoist
|
return; // note is outside of hoisted subtree and user chose not to unhoist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ const searchService = require('../../services/search/services/search.js');
|
|||||||
const repository = require('../../services/repository');
|
const repository = require('../../services/repository');
|
||||||
const log = require('../../services/log');
|
const log = require('../../services/log');
|
||||||
const utils = require('../../services/utils');
|
const utils = require('../../services/utils');
|
||||||
const optionService = require('../../services/options');
|
const cls = require('../../services/cls');
|
||||||
|
|
||||||
function getAutocomplete(req) {
|
function getAutocomplete(req) {
|
||||||
const query = req.query.query.trim();
|
const query = req.query.query.trim();
|
||||||
@ -35,7 +35,7 @@ function getRecentNotes(activeNoteId) {
|
|||||||
let extraCondition = '';
|
let extraCondition = '';
|
||||||
const params = [activeNoteId];
|
const params = [activeNoteId];
|
||||||
|
|
||||||
const hoistedNoteId = optionService.getOption('hoistedNoteId');
|
const hoistedNoteId = cls.getHoistedNoteId();
|
||||||
if (hoistedNoteId !== 'root') {
|
if (hoistedNoteId !== 'root') {
|
||||||
extraCondition = `AND recent_notes.notePath LIKE ?`;
|
extraCondition = `AND recent_notes.notePath LIKE ?`;
|
||||||
params.push(hoistedNoteId + '%');
|
params.push(hoistedNoteId + '%');
|
||||||
|
@ -84,7 +84,7 @@ function getTree(req) {
|
|||||||
)
|
)
|
||||||
SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);
|
SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);
|
||||||
|
|
||||||
noteIds.push(subTreeNoteId);console.log("noteIds", noteIds);
|
noteIds.push(subTreeNoteId);
|
||||||
|
|
||||||
return getNotesAndBranchesAndAttributes(noteIds);
|
return getNotesAndBranchesAndAttributes(noteIds);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,10 @@ function getNoteTitle(childNoteId, parentNoteId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNoteTitleArrayForPath(notePathArray) {
|
function getNoteTitleArrayForPath(notePathArray) {
|
||||||
|
if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) {
|
||||||
|
return [getNoteTitle(cls.getHoistedNoteId())];
|
||||||
|
}
|
||||||
|
|
||||||
const titles = [];
|
const titles = [];
|
||||||
|
|
||||||
let parentNoteId = 'root';
|
let parentNoteId = 'root';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user