From a3a9de6fdd9e532a96718899b0ea429f0a93db32 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 10 Jan 2026 10:34:06 +0200 Subject: [PATCH] feat(collections): add setting to hide subtree --- .../src/translations/en/translation.json | 3 ++- .../note_bars/CollectionProperties.tsx | 7 +++++++ apps/client/src/widgets/react/hooks.tsx | 19 +++++++++++++++---- packages/commons/src/lib/attribute_names.ts | 3 +++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 25499ecbf..ab07ad188 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.tsx index 6fc510fc7..d5c9ffb42 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 && } + + { 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.ts index afb45fcb3..b524b409f 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; + // Search searchString: string; ancestorDepth: string;