mirror of
https://github.com/zadam/trilium.git
synced 2026-01-16 12:22:13 +01:00
fix(note_tree): subtree hidden cannot be overridden through inheritance
This commit is contained in:
@@ -616,7 +616,7 @@ export default class FNote {
|
||||
}
|
||||
|
||||
isFolder() {
|
||||
if (this.hasLabel("subtreeHidden")) return false;
|
||||
if (this.isLabelTruthy("subtreeHidden")) return false;
|
||||
if (this.type === "search") return true;
|
||||
return this.getFilteredChildBranches().length > 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
const noSelectedNotes = selNodes.length === 0 || (selNodes.length === 1 && selNodes[0] === this.node);
|
||||
|
||||
const notSearch = note?.type !== "search";
|
||||
const hasSubtreeHidden = note?.hasLabel("subtreeHidden") ?? false;
|
||||
const hasSubtreeHidden = note?.isLabelTruthy("subtreeHidden") ?? false;
|
||||
const notOptionsOrHelp = !note?.noteId.startsWith("_options") && !note?.noteId.startsWith("_help");
|
||||
const parentNotSearch = !parentNote || parentNote.type !== "search";
|
||||
const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch;
|
||||
|
||||
@@ -37,6 +37,8 @@ export async function setRelation(noteId: string, name: string, value: string =
|
||||
* will be removed. If the label is inherited from a parent note, it will be overridden to `false`. If the label does
|
||||
* not exist, it will be added with an empty value.
|
||||
*
|
||||
* When checking if the boolean value is set, don't use `note.hasLabel`; instead use `note.isLabelTruthy`.
|
||||
*
|
||||
* @param note the note on which to toggle the label.
|
||||
* @param labelName the name of the label to toggle.
|
||||
*/
|
||||
|
||||
@@ -556,7 +556,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
branchService.moveAfterBranch(selectedBranchIds, node.data.branchId);
|
||||
} else if (data.hitMode === "over") {
|
||||
const targetNote = froca.getNoteFromCache(node.data.noteId);
|
||||
if (targetNote?.hasLabel("subtreeHidden")) {
|
||||
if (targetNote?.isLabelTruthy("subtreeHidden")) {
|
||||
toastService.showPersistent({
|
||||
id: `subtree-hidden-moved`,
|
||||
title: t("note_tree.subtree-hidden-moved-title", { count: selectedBranchIds.length, title: targetNote.title }),
|
||||
@@ -724,7 +724,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
childBranches = childBranches.slice(0, MAX_SEARCH_RESULTS_IN_TREE);
|
||||
}
|
||||
|
||||
if (parentNote.hasLabel("subtreeHidden")) {
|
||||
if (parentNote.isLabelTruthy("subtreeHidden")) {
|
||||
// If we have a spotlighted note path, show only the child that leads to it
|
||||
if (this.spotlightedNotePath) {
|
||||
const spotlightPathSegments = this.spotlightedNotePath.split('/');
|
||||
@@ -772,7 +772,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
const parentNote = froca.getNoteFromCache(branch.parentNoteId);
|
||||
if (parentNote?.hasLabel("subtreeHidden")) {
|
||||
if (parentNote?.isLabelTruthy("subtreeHidden")) {
|
||||
const parentNode = node.getParent();
|
||||
if (parentNode) {
|
||||
parentNode.setActive(true);
|
||||
@@ -1040,7 +1040,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
|
||||
// The child note can be part of a note with #subtreeHidden, case in which we need to "spotlight" it.
|
||||
const parentNote = froca.getNoteFromCache(parentNode.data.noteId);
|
||||
if (parentNote?.hasLabel("subtreeHidden")) {
|
||||
if (parentNote?.isLabelTruthy("subtreeHidden")) {
|
||||
// Enable spotlight mode and reload the parent to show only the path to this note
|
||||
this.spotlightedNotePath = notePath;
|
||||
await parentNode.load(true);
|
||||
@@ -1924,7 +1924,7 @@ function buildEnhanceTitle() {
|
||||
}
|
||||
|
||||
// TODO: Deduplicate with server's notes.ts#getAndValidateParent
|
||||
const isSubtreeHidden = note.hasLabel("subtreeHidden");
|
||||
const isSubtreeHidden = note.isLabelTruthy("subtreeHidden");
|
||||
if (!["search", "launcher"].includes(note.type)
|
||||
&& !note.isOptions()
|
||||
&& !note.isLaunchBarConfig()
|
||||
|
||||
Reference in New Issue
Block a user