mirror of
https://github.com/zadam/trilium.git
synced 2026-01-18 04:24:23 +01:00
feat(collections): add setting to hide subtree
This commit is contained in:
parent
d77d30f29e
commit
a3a9de6fdd
@ -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...",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,9 @@ type Labels = {
|
||||
pageUrl: string;
|
||||
dateNote: string;
|
||||
|
||||
// Tree specific
|
||||
subtreeHidden: boolean;
|
||||
|
||||
// Search
|
||||
searchString: string;
|
||||
ancestorDepth: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user