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): move the nesting depth into the properties dialogs
Elian Doranacb75871f578
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex f6717998da..f82f14b56c 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3524,7 +3524,7 @@"hide-weekends": "Hide weekends","display-week-numbers": "Display week numbers","map-style": "Map style",- "max-nesting-depth": "Max nesting depth:",+ "max-nesting-depth": "Maximum nesting depth","raster": "Raster","vector_light": "Vector (Light)","vector_dark": "Vector (Dark)",@@ -3532,7 +3532,8 @@"show-scale": "Show scale","show-labels": "Show marker names","cluster-markers": "Group nearby markers",- "presentation-theme": "Theme"+ "presentation-theme": "Theme",+ "max-nesting-depth-description": "How many levels below the collection's children are shown: 0 shows only the children, 1 also shows their children, and so on. Leave it empty to show every level."},"table_context_menu": {"delete_row": "Delete row...",diff --git a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsxindex 8cc5624e82..ecf84a5b1e 100644--- a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx+++ b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx@@ -140,9 +140,12 @@ describe("CalendarProperties", () => {"calendar_view.time_slots","calendar_view.slot_duration","calendar_view.slot_label_interval",- "book_properties_config.max-nesting-depth",- "book_properties.include_archived_notes"+ "book_properties.include_archived_notes",+ "book_properties_config.max-nesting-depth"]);+ const depth = [ ...general?.querySelectorAll(".tn-card-option-label") ?? [] ].at(-1);+ expect(depth?.querySelector(".tn-card-option-description")?.textContent)+ .toBe("book_properties_config.max-nesting-depth-description");expect(general?.compareDocumentPosition(document.querySelector(".templates-stub") as Node)).toBe(Node.DOCUMENT_POSITION_FOLLOWING);});diff --git a/apps/client/src/widgets/collections/calendar/CalendarProperties.tsx b/apps/client/src/widgets/collections/calendar/CalendarProperties.tsxindex 1ac31c2a15..eec7aa2cad 100644--- a/apps/client/src/widgets/collections/calendar/CalendarProperties.tsx+++ b/apps/client/src/widgets/collections/calendar/CalendarProperties.tsx@@ -4,7 +4,7 @@ import type FNote from "../../../entities/fnote";import froca from "../../../services/froca";import { t } from "../../../services/i18n";import {- CollectionPropertiesDialog, INCLUDE_ARCHIVED_PROPERTY+ CollectionPropertiesDialog, INCLUDE_ARCHIVED_PROPERTY, MAX_NESTING_DEPTH_PROPERTY} from "../../note_bars/CollectionProperties";import { bookPropertiesConfig } from "../../note_bars/collection-properties-config";import { Card } from "../../react/Card";@@ -87,7 +87,9 @@ export default function CalendarProperties({);}-/** What the settings dropdown offers for a calendar, which the General card repeats. */+/** The settings dropdown's calendar settings and the depth, for the General card. */const GENERAL_PROPERTIES = [- ...bookPropertiesConfig.calendar.properties, INCLUDE_ARCHIVED_PROPERTY+ ...bookPropertiesConfig.calendar.properties,+ INCLUDE_ARCHIVED_PROPERTY,+ MAX_NESTING_DEPTH_PROPERTY];diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx b/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsxindex faa524cb6e..87330fd4bc 100644--- a/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx@@ -152,8 +152,8 @@ describe("GeoMapProperties", () => {"book_properties_config.show-scale","book_properties_config.show-labels","book_properties_config.cluster-markers",- "book_properties_config.max-nesting-depth",- "book_properties.include_archived_notes"+ "book_properties.include_archived_notes",+ "book_properties_config.max-nesting-depth"]);});diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx b/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsxindex 7c4618f8b2..c6b63b3352 100644--- a/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx@@ -6,7 +6,7 @@ import type FNote from "../../../entities/fnote";import attributes from "../../../services/attributes";import { t } from "../../../services/i18n";import {- CollectionPropertiesDialog, INCLUDE_ARCHIVED_PROPERTY+ CollectionPropertiesDialog, INCLUDE_ARCHIVED_PROPERTY, MAX_NESTING_DEPTH_PROPERTY} from "../../note_bars/CollectionProperties";import { bookPropertiesConfig } from "../../note_bars/collection-properties-config";import Admonition from "../../react/Admonition";@@ -69,10 +69,11 @@ export default function GeoMapProperties({ note, image, onClose }: {/** The settings dropdown's map style, which the Background card holds instead of General. */const MAP_STYLE_PROPERTY = bookPropertiesConfig.geoMap.properties.find(isMapStyle);-/** What the settings dropdown offers for a geo map, which the General card repeats. */+/** The settings dropdown's geo map settings and the depth, for the General card. */const GENERAL_PROPERTIES = [...bookPropertiesConfig.geoMap.properties.filter((property) => !isMapStyle(property)),- INCLUDE_ARCHIVED_PROPERTY+ INCLUDE_ARCHIVED_PROPERTY,+ MAX_NESTING_DEPTH_PROPERTY];function isMapStyle(property: BookProperty) {diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.spec.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.spec.tsxindex dec44794cf..6883d1bd9b 100644--- a/apps/client/src/widgets/note_bars/CollectionProperties.spec.tsx+++ b/apps/client/src/widgets/note_bars/CollectionProperties.spec.tsx@@ -9,9 +9,18 @@ import server from "../../services/server";import { buildNote } from "../../test/easy-froca";import { renderInto } from "../../test/render";import { NoteContextContext, ParentComponent } from "../react/react_utils";+import { bookPropertiesConfig } from "./collection-properties-config";import CollectionProperties from "./CollectionProperties";describe("CollectionProperties", () => {+ it("leaves the nesting depth to the properties dialogs, out of every settings dropdown", () => {+ for (const { properties } of Object.values(bookPropertiesConfig)) {+ const bindsDepth = properties.some((property) =>+ "bindToLabel" in property && property.bindToLabel === "maxNestingDepth");+ expect(bindsDepth).toBe(false);+ }+ });+it("focuses the view type switcher on its shortcut only for its own note context", async () => {const note = buildNote({ title: "Collection", type: "book" });const noteContext = new NoteContext("ntx-split-2");diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsxindex 911e2df94d..6bc172b342 100644--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx@@ -20,7 +20,9 @@ import { FormDropdownDivider, FormListItem } from "../react/FormList";import { useNoteContext, useNoteLabel, useNoteProperty, useTriliumEvent } from "../react/hooks";import Icon from "../react/Icon";import Modal from "../react/Modal";-import { CheckBoxProperty, ViewProperty } from "../react/NotePropertyMenu";+import {+ CheckBoxProperty, NumberProperty, PropertyHelp, ViewProperty+} from "../react/NotePropertyMenu";import { bookPropertiesConfig } from "./collection-properties-config";export const ICON_MAPPINGS: Record<ViewTypeOptions, string> = {@@ -55,6 +57,19 @@ export const INCLUDE_ARCHIVED_PROPERTY: CheckBoxProperty = {bindToLabel: "includeArchived"};+/**+ * How many levels below its children a collection shows, for the views that show a whole subtree.+ * Offered in a view's properties dialog only.+ */+export const MAX_NESTING_DEPTH_PROPERTY: NumberProperty & PropertyHelp = {+ type: "number",+ icon: "bx bx-subdirectory-right",+ label: t("book_properties_config.max-nesting-depth"),+ helpTooltip: t("book_properties_config.max-nesting-depth-description"),+ bindToLabel: "maxNestingDepth",+ disabled: (note) => note.type === "search"+};+interface CollectionPropertiesProps {note: FNote;centerChildren?: ComponentChildren;diff --git a/apps/client/src/widgets/note_bars/collection-properties-config.tsx b/apps/client/src/widgets/note_bars/collection-properties-config.tsxindex 7a27118286..a3e0551dcd 100644--- a/apps/client/src/widgets/note_bars/collection-properties-config.tsx+++ b/apps/client/src/widgets/note_bars/collection-properties-config.tsx@@ -89,9 +89,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {options: slotDurationOptions([15, 30, 60])}]- },- maxNestingDepthProperty((note) =>- note.hasLabel("calendarRoot") || note.hasLabel("workspaceCalendarRoot"))+ }]},geoMap: {@@ -149,14 +147,11 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {icon: "bx bx-collection",type: "checkbox",bindToLabel: "map:cluster"- },- maxNestingDepthProperty()+ }]},table: {- properties: [- maxNestingDepthProperty()- ]+ properties: []},board: {properties: [@@ -196,21 +191,6 @@ function buildMapLayer([ id, layer ]: [ string, MapLayer ]): ComboBoxItem {};}-/**- * The `#maxNestingDepth` input, disabled for a search collection, which shows only its results.- * @param isDisabled disables the input for further notes.- */-function maxNestingDepthProperty(isDisabled?: (note: FNote) => boolean): BookProperty {- return {- label: t("book_properties_config.max-nesting-depth"),- icon: "bx bx-subdirectory-right",- type: "number",- bindToLabel: "maxNestingDepth",- width: 65,- disabled: (note) => note.type === "search" || !!isDisabled?.(note)- };-}-/** Builds FullCalendar duration options (`HH:MM:00`) from a list of whole minutes, with localized labels. */function slotDurationOptions(minutes: number[]): ComboBoxItem[] {return minutes.map((total) => ({diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.htmlindex da35524b75..c220d235fc 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html@@ -154,8 +154,6 @@<li>Set the slot duration (the length of each time row in day/week view).</li><li>Set the slot label interval (how often time labels appear on the axisin day/week view).</li>- <li>Limit how deep below the calendar events are looked for, with <em>Max nesting depth</em> (see <a- href="#limiting-the-depth">below</a>).</li></ul><p>The same settings, together with whether archived notes are shown, arealso listed under <em>General</em> in the <span class="tn-icon bx bx-cog"></span> <em>Calendar properties</em> dialog@@ -433,8 +431,9 @@ class="table">look for events not just in its child notes but also in the children ofthese child notes.</p><h3>Limiting the depth</h3>-<p>To limit how deep the calendar looks for events, set <em>Max nesting depth</em> in- the <a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>,+<p>To limit how deep the calendar looks for events, set <em>Maximum nesting depth</em> under <em>General</em> in+ the <span class="tn-icon bx bx-cog"></span><em>Calendar properties</em> dialog+ (see <a href="#event-templates">Event templates</a> for how to open it),or the <code>#maxNestingDepth</code> label: <code>0</code> shows only the childnotes, <code>1</code> adds their children, and so on. Without a value, eventsare looked for at every level. The setting doesn't apply in a Journal.</p>diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.htmlindex 45c6bbf751..e355de3cb3 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html@@ -587,14 +587,14 @@ class="admonition note">markers that make up the cluster are now visible.</li></ul></li>- <li>The map shows the notes of its whole subtree, not only its children. <em>Max nesting depth</em> (<code>#maxNestingDepth</code>)- limits how deep below the map it looks: <code>0</code> shows only the children, <code>1</code> adds- their children, and so on. Without a value, every level is shown.</li></ul>-<p>The same options, together with whether archived notes are shown, are- also listed in the <span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> dialog,+<p>The same options, together with whether archived notes are shown and the <em>Maximum nesting depth</em>,+ are also listed in the <span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> dialog,opened from the <a class="reference-link" href="#root/_help_8YBEPzcpUgxw">Note menu</a> orfrom the settings menu of the <a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>.Its <em>Background</em> section holds the map style, or, with <em>Type</em> setto <em>Custom image</em>, draws the map over an image of your own instead,- as described in <a class="reference-link" href="#root/_help_ZRDXGc0nAIh4">Image maps</a>.</p>\ No newline at end of file+ as described in <a class="reference-link" href="#root/_help_ZRDXGc0nAIh4">Image maps</a>.</p>+<p>The map shows the notes of its whole subtree, not only its children. <em>Maximum nesting depth</em> (<code>#maxNestingDepth</code>)+ limits how deep below the map it looks: <code>0</code> shows only the children, <code>1</code> adds+ their children, and so on. Without a value, every level is shown.</p>\ No newline at end of filediff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Table.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Table.htmlindex 98ef2a1d35..fddc55ffac 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Table.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Table.html@@ -157,19 +157,14 @@<p>Next to the title of each element there will be a button to expand orcollapse. By default, all items are expanded.</p><p>Since nesting is not always desirable, it is possible to limit the nesting- to a certain number of levels or even disable it completely. To do so,- either:</p>+ to a certain number of levels or even disable it completely, by setting+ the <code>#maxNestingDepth</code> <a href="#root/_help_HI6GBBIduIgv">label</a> of+ the collection:</p><ul>- <li>Go to <a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a> and- look for the <em>Max nesting depth</em> section.- <ul>- <li>To disable nesting, type 0 and press Enter.</li>- <li>To limit to a certain depth, type in the desired number (e.g. 2 to only- display children and sub-children).</li>- <li>To re-enable unlimited nesting, remove the number and press Enter.</li>- </ul>- </li>- <li>Manually set <code>maxNestingDepth</code> to the desired value.</li>+ <li><code>0</code> disables nesting, showing only the children of the collection.</li>+ <li><code>1</code> also shows their children, <code>2</code> the level below+ that, and so on.</li>+ <li>Removing the label shows every level again.</li></ul><p>Limitations:</p><ul>diff --git a/docs/User Guide/User Guide/Collections/Calendar.md b/docs/User Guide/User Guide/Collections/Calendar.mdindex 612d4a9135..38d591b018 100644--- a/docs/User Guide/User Guide/Collections/Calendar.md+++ b/docs/User Guide/User Guide/Collections/Calendar.md@@ -96,7 +96,6 @@ In the <a class="reference-link" href="Collection%20Properties.md">Collection P* Display week numbers on the calendar.* Set the slot duration (the length of each time row in day/week view).* Set the slot label interval (how often time labels appear on the axis in day/week view).-* Limit how deep below the calendar events are looked for, with _Max nesting depth_ (see [below](#limiting-the-depth)).The same settings, together with whether archived notes are shown, are also listed under _General_ in the <span class="tn-icon bx bx-cog"></span> _Calendar properties_ dialog (see [Event templates](#event-templates) for how to open it). The time slots are listed there whichever view the calendar is in.@@ -215,7 +214,7 @@ When not used in a Journal, the calendar is recursive. That is, it will look for### Limiting the depth-To limit how deep the calendar looks for events, set _Max nesting depth_ in the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>, or the `#maxNestingDepth` label: `0` shows only the child notes, `1` adds their children, and so on. Without a value, events are looked for at every level. The setting doesn't apply in a Journal.+To limit how deep the calendar looks for events, set _Maximum nesting depth_ under _General_ in the <span class="tn-icon bx bx-cog"></span>_Calendar properties_ dialog (see [Event templates](#event-templates) for how to open it), or the `#maxNestingDepth` label: `0` shows only the child notes, `1` adds their children, and so on. Without a value, events are looked for at every level. The setting doesn't apply in a Journal.## Recurrencediff --git a/docs/User Guide/User Guide/Collections/Geo Map.md b/docs/User Guide/User Guide/Collections/Geo Map.mdindex b8995bf8b4..430e3d95f1 100644--- a/docs/User Guide/User Guide/Collections/Geo Map.md+++ b/docs/User Guide/User Guide/Collections/Geo Map.md@@ -394,6 +394,7 @@ The following options can be configured either via the <a class="reference-link* v0.105.0 also introduces a feature called _Group nearby markers_ which will cluster multiple markers together at low zoom.* The clusters display the number of items they contain. The color also changes based on the count.* Clicking on a cluster will automatically zoom in so that the individual markers that make up the cluster are now visible.-* The map shows the notes of its whole subtree, not only its children. _Max nesting depth_ (`#maxNestingDepth`) limits how deep below the map it looks: `0` shows only the children, `1` adds their children, and so on. Without a value, every level is shown.-The same options, together with whether archived notes are shown, are also listed in the <span class="tn-icon bx bx-cog"></span>_Geo map properties_ dialog, opened from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> or from the settings menu of the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>. Its _Background_ section holds the map style, or, with _Type_ set to _Custom image_, draws the map over an image of your own instead, as described in <a class="reference-link" href="Geo%20Map/Image%20maps.md">Image maps</a>.\ No newline at end of file+The same options, together with whether archived notes are shown and the _Maximum nesting depth_, are also listed in the <span class="tn-icon bx bx-cog"></span>_Geo map properties_ dialog, opened from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> or from the settings menu of the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>. Its _Background_ section holds the map style, or, with _Type_ set to _Custom image_, draws the map over an image of your own instead, as described in <a class="reference-link" href="Geo%20Map/Image%20maps.md">Image maps</a>.++The map shows the notes of its whole subtree, not only its children. _Maximum nesting depth_ (`#maxNestingDepth`) limits how deep below the map it looks: `0` shows only the children, `1` adds their children, and so on. Without a value, every level is shown.\ No newline at end of filediff --git a/docs/User Guide/User Guide/Collections/Table.md b/docs/User Guide/User Guide/Collections/Table.mdindex d8874e5a60..c485f9a73d 100644--- a/docs/User Guide/User Guide/Collections/Table.md+++ b/docs/User Guide/User Guide/Collections/Table.md@@ -123,13 +123,11 @@ If the child notes of the collection also have their own child notes, then theyNext to the title of each element there will be a button to expand or collapse. By default, all items are expanded.-Since nesting is not always desirable, it is possible to limit the nesting to a certain number of levels or even disable it completely. To do so, either:+Since nesting is not always desirable, it is possible to limit the nesting to a certain number of levels or even disable it completely, by setting the `#maxNestingDepth` [label](../Advanced%20Usage/Attributes/Labels.md) of the collection:-* Go to <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a> and look for the _Max nesting depth_ section.- * To disable nesting, type 0 and press Enter.- * To limit to a certain depth, type in the desired number (e.g. 2 to only display children and sub-children).- * To re-enable unlimited nesting, remove the number and press Enter.-* Manually set `maxNestingDepth` to the desired value.+* `0` disables nesting, showing only the children of the collection.+* `1` also shows their children, `2` the level below that, and so on.+* Removing the label shows every level again.Limitations: