feat(collections): add setting to hide subtree

This commit is contained in:
Elian Doran 2026-01-10 10:34:06 +02:00
parent d77d30f29e
commit a3a9de6fdd
No known key found for this signature in database
4 changed files with 27 additions and 5 deletions

View File

@ -800,7 +800,8 @@
"geo-map": "Geo Map",
"board": "Board",
"presentation": "Presentation",
"include_archived_notes": "Show archived notes"
"include_archived_notes": "Show archived notes",
"hide_child_notes": "Hide child notes in tree"
},
"edited_notes": {
"no_edited_notes_found": "No edited notes on this day yet...",

View File

@ -82,6 +82,13 @@ function ViewOptions({ note, viewType }: { note: FNote, viewType: ViewTypeOption
))}
{properties.length > 0 && <FormDropdownDivider />}
<ViewProperty note={note} property={{
type: "checkbox",
icon: "bx bx-hide",
label: t("book_properties.hide_child_notes"),
bindToLabel: "subtreeHidden"
} as CheckBoxProperty} />
<ViewProperty note={note} property={{
type: "checkbox",
icon: "bx bx-archive",

View File

@ -646,17 +646,28 @@ export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: F
const setter = useCallback((value: boolean) => {
if (note) {
const actualValue = note.isLabelTruthy(labelName);
if (actualValue === value) return;
if (value) {
attributes.setLabel(note.noteId, labelName, "");
} else {
if (note.getLabelValue(labelName) === "false") {
// Remove the override so that the inherited true takes effect.
attributes.removeOwnedLabelByName(note, labelName);
} else {
attributes.setLabel(note.noteId, labelName, "");
}
} else if (note.hasOwnedLabel(labelName)) {
attributes.removeOwnedLabelByName(note, labelName);
} else {
// Label is inherited - override to false.
attributes.setLabel(note.noteId, labelName, "false");
}
}
}, [note]);
}, [note, labelName]);
useDebugValue(labelName);
const labelValue = !!note?.hasLabel(labelName);
const labelValue = !!note?.isLabelTruthy(labelName);
return [ labelValue, setter ] as const;
}

View File

@ -22,6 +22,9 @@ type Labels = {
pageUrl: string;
dateNote: string;
// Tree specific
subtreeHidden: boolean;
// Search
searchString: string;
ancestorDepth: string;