mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
small fixes for collapse/expand
This commit is contained in:
parent
2a3091f788
commit
43e12fbea2
@ -231,7 +231,7 @@ class TreeCache {
|
|||||||
/** @return {Promise<NoteShort>} */
|
/** @return {Promise<NoteShort>} */
|
||||||
async getNote(noteId, silentNotFoundError = false) {
|
async getNote(noteId, silentNotFoundError = false) {
|
||||||
if (noteId === 'none') {
|
if (noteId === 'none') {
|
||||||
console.log(`No 'none' note.`);
|
console.trace(`No 'none' note.`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (!noteId) {
|
else if (!noteId) {
|
||||||
|
@ -40,9 +40,9 @@ class TreeContextMenu {
|
|||||||
async getMenuItems() {
|
async getMenuItems() {
|
||||||
const note = await treeCache.getNote(this.node.data.noteId);
|
const note = await treeCache.getNote(this.node.data.noteId);
|
||||||
const branch = treeCache.getBranch(this.node.data.branchId);
|
const branch = treeCache.getBranch(this.node.data.branchId);
|
||||||
const parentNote = await treeCache.getNote(branch.parentNoteId);
|
|
||||||
const isNotRoot = note.noteId !== 'root';
|
const isNotRoot = note.noteId !== 'root';
|
||||||
const isHoisted = note.noteId === hoistedNoteService.getHoistedNoteId();
|
const isHoisted = note.noteId === hoistedNoteService.getHoistedNoteId();
|
||||||
|
const parentNote = isNotRoot ? await treeCache.getNote(branch.parentNoteId) : null;
|
||||||
|
|
||||||
// some actions don't support multi-note so they are disabled when notes are selected
|
// some actions don't support multi-note so they are disabled when notes are selected
|
||||||
// the only exception is when the only selected note is the one that was right-clicked, then
|
// the only exception is when the only selected note is the one that was right-clicked, then
|
||||||
|
@ -606,7 +606,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
await this.batchUpdate(async () => {
|
await this.batchUpdate(async () => {
|
||||||
await node.load(true);
|
await node.load(true);
|
||||||
|
|
||||||
await node.setExpanded(isExpanded, {noEvents: true});
|
if (node.data.noteId !== 'root') { // root is always expanded
|
||||||
|
await node.setExpanded(isExpanded, {noEvents: true});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,14 +114,16 @@ async function moveBranchAfterNote(req) {
|
|||||||
async function setExpanded(req) {
|
async function setExpanded(req) {
|
||||||
const {branchId, expanded} = req.params;
|
const {branchId, expanded} = req.params;
|
||||||
|
|
||||||
await sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
|
if (branchId !== 'root') {
|
||||||
// we don't sync expanded label
|
await sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
|
||||||
|
// we don't sync expanded label
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setExpandedForSubtree(req) {
|
async function setExpandedForSubtree(req) {
|
||||||
const {branchId, expanded} = req.params;
|
const {branchId, expanded} = req.params;
|
||||||
|
|
||||||
const branchIds = await sql.getColumn(`
|
let branchIds = await sql.getColumn(`
|
||||||
WITH RECURSIVE
|
WITH RECURSIVE
|
||||||
tree(branchId, noteId) AS (
|
tree(branchId, noteId) AS (
|
||||||
SELECT branchId, noteId FROM branches WHERE branchId = ?
|
SELECT branchId, noteId FROM branches WHERE branchId = ?
|
||||||
@ -132,6 +134,9 @@ async function setExpandedForSubtree(req) {
|
|||||||
)
|
)
|
||||||
SELECT branchId FROM tree`, [branchId]);
|
SELECT branchId FROM tree`, [branchId]);
|
||||||
|
|
||||||
|
// root is always expanded
|
||||||
|
branchIds = branchIds.filter(branchId => branchId !== 'root');
|
||||||
|
|
||||||
await sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);
|
await sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user