Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(collections): add setting to hide subtree
Elian Dorana3a9de6fdd9e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 25499ecbf0..ab07ad1887 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -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...",diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsxindex 6fc510fc71..d5c9ffb42d 100644--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx@@ -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",diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex d0031fe071..610f65dedd 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -646,17 +646,28 @@ export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: Fconst 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;}diff --git a/packages/commons/src/lib/attribute_names.ts b/packages/commons/src/lib/attribute_names.tsindex afb45fcb3e..b524b409f0 100644--- a/packages/commons/src/lib/attribute_names.ts+++ b/packages/commons/src/lib/attribute_names.ts@@ -22,6 +22,9 @@ type Labels = {pageUrl: string;dateNote: string;+ // Tree specific+ subtreeHidden: boolean;+// SearchsearchString: string;ancestorDepth: string;