Skip to content

Build your personal knowledge base with Trilium Notes

feat(collections): group the included notes in their own card

Elian Doranef5102dcac9d
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index f82f14b56c..16bf2b84ca 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1320,7 +1320,8 @@
"open_all_in_tabs_tooltip": "Open all results in new tabs",
"open_all_confirm_one": "This will open {{count}} note in new tabs. Continue?",
"open_all_confirm_other": "This will open {{count}} notes in new tabs. Continue?",
- "open_all_limit_exceeded": "Too many notes to open at once ({{count}}). The maximum is {{max}}, try narrowing the results first."
+ "open_all_limit_exceeded": "Too many notes to open at once ({{count}}). The maximum is {{max}}, try narrowing the results first.",
+ "included_notes": "Included notes"
},
"edited_notes": {
"no_edited_notes_found": "No edited notes on this day yet..."
diff --git a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
index ecf84a5b1e..79779cc8ca 100644
--- a/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
+++ b/apps/client/src/widgets/collections/calendar/CalendarProperties.spec.tsx
@@ -139,14 +139,33 @@ describe("CalendarProperties", () => {
"book_properties_config.display-week-numbers",
"calendar_view.time_slots",
"calendar_view.slot_duration",
- "calendar_view.slot_label_interval",
+ "calendar_view.slot_label_interval"
+ ]);
+ expect(general?.compareDocumentPosition(document.querySelector(".templates-stub") as Node))
+ .toBe(Node.DOCUMENT_POSITION_FOLLOWING);
+ });
+
+ it("holds which notes the calendar gathers in a card of their own, after General", () => {
+ draw(undefined);
+ const dialog = document.querySelector(".calendar-properties-dialog");
+ const general = dialog?.querySelector(".calendar-properties-general");
+ const included = dialog?.querySelector(".collection-included-notes");
+ const titles = [ ...included?.querySelectorAll(".tn-card-option-title") ?? [] ]
+ .map((title) => title.textContent);
+
+ expect(included?.querySelector(".tn-card-heading")?.textContent)
+ .toContain("book_properties.included_notes");
+ expect(titles).toEqual([
"book_properties.include_archived_notes",
"book_properties_config.max-nesting-depth"
]);
- const depth = [ ...general?.querySelectorAll(".tn-card-option-label") ?? [] ].at(-1);
+ const depth = [ ...included?.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))
+ expect(general?.compareDocumentPosition(included as Node))
+ .toBe(Node.DOCUMENT_POSITION_FOLLOWING);
+ const attributes = document.querySelector(".attributes-stub");
+ expect(included?.compareDocumentPosition(attributes 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.tsx
index eec7aa2cad..dee2697254 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, MAX_NESTING_DEPTH_PROPERTY
+ CollectionPropertiesDialog, IncludedNotesCard
} from "../../note_bars/CollectionProperties";
import { bookPropertiesConfig } from "../../note_bars/collection-properties-config";
import { Card } from "../../react/Card";
@@ -56,11 +56,13 @@ export default function CalendarProperties({
onHidden={onClose}
>
<Card className="calendar-properties-general" heading={t("calendar_view.general")}>
- {GENERAL_PROPERTIES.map((property, index) => (
+ {bookPropertiesConfig.calendar.properties.map((property, index) => (
<ViewPropertySection key={index} note={note} property={property} />
))}
</Card>
+ <IncludedNotesCard note={note} />
+
<PromotedAttributesCard
heading={t("calendar_view.event_attributes")}
instruction={displayedLabel === null || displayedLabel === undefined
@@ -87,9 +89,3 @@ export default function CalendarProperties({
);
}
-/** The settings dropdown's calendar settings and the depth, for the General card. */
-const GENERAL_PROPERTIES = [
- ...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.tsx
index 87330fd4bc..4f03125783 100644
--- a/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx
+++ b/apps/client/src/widgets/collections/geomap/GeoMapProperties.spec.tsx
@@ -151,10 +151,21 @@ describe("GeoMapProperties", () => {
expect(optionTitles(".geo-map-properties-general")).toEqual([
"book_properties_config.show-scale",
"book_properties_config.show-labels",
- "book_properties_config.cluster-markers",
+ "book_properties_config.cluster-markers"
+ ]);
+ });
+
+ it("holds which notes the map gathers in a card of their own, after General", () => {
+ draw({});
+ const included = query(".collection-included-notes");
+ expect(optionTitles(".collection-included-notes")).toEqual([
"book_properties.include_archived_notes",
"book_properties_config.max-nesting-depth"
]);
+ expect(query(".geo-map-properties-general")?.compareDocumentPosition(included as Node))
+ .toBe(Node.DOCUMENT_POSITION_FOLLOWING);
+ expect(included?.compareDocumentPosition(query(".geo-map-properties-background") as Node))
+ .toBe(Node.DOCUMENT_POSITION_FOLLOWING);
});
it("draws a world map with a style, until a custom image is chosen and picked", () => {
diff --git a/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx b/apps/client/src/widgets/collections/geomap/GeoMapProperties.tsx
index c6b63b3352..860f4a9722 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, MAX_NESTING_DEPTH_PROPERTY
+ CollectionPropertiesDialog, IncludedNotesCard
} from "../../note_bars/CollectionProperties";
import { bookPropertiesConfig } from "../../note_bars/collection-properties-config";
import Admonition from "../../react/Admonition";
@@ -61,6 +61,8 @@ export default function GeoMapProperties({ note, image, onClose }: {
))}
</Card>
+ <IncludedNotesCard note={note} />
+
<BackgroundCard note={note} image={image} />
</CollectionPropertiesDialog>
);
@@ -69,12 +71,9 @@ 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);
-/** 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,
- MAX_NESTING_DEPTH_PROPERTY
-];
+/** What the settings dropdown offers for a geo map, which the General card repeats. */
+const GENERAL_PROPERTIES = bookPropertiesConfig.geoMap.properties
+ .filter((property) => !isMapStyle(property));
function isMapStyle(property: BookProperty) {
return "bindToLabel" in property && property.bindToLabel === "map:style";
diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsx
index 6bc172b342..bb5442a1e9 100644
--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx
+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx
@@ -15,13 +15,14 @@ import { getErrorMessage, isShare } from "../../services/utils";
import { ViewTypeOptions } from "../collections/interface";
import { searchTermsFor } from "../collections/search/SearchResultCard";
import ActionButton from "../react/ActionButton";
+import { Card } from "../react/Card";
import Dropdown from "../react/Dropdown";
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, NumberProperty, PropertyHelp, ViewProperty
+ CheckBoxProperty, NumberProperty, PropertyHelp, ViewProperty, ViewPropertySection
} from "../react/NotePropertyMenu";
import { bookPropertiesConfig } from "./collection-properties-config";
@@ -258,6 +259,19 @@ function ViewOptions({ note, viewType, optionsChildren }: {
);
}
+/**
+ * Which notes a collection gathers, as opposed to how its view draws them: a card shared by the
+ * properties dialogs, placed after their General card.
+ */
+export function IncludedNotesCard({ note }: { note: FNote }) {
+ return (
+ <Card className="collection-included-notes" heading={t("book_properties.included_notes")}>
+ <ViewPropertySection note={note} property={INCLUDE_ARCHIVED_PROPERTY} />
+ <ViewPropertySection note={note} property={MAX_NESTING_DEPTH_PROPERTY} />
+ </Card>
+ );
+}
+
/**
* The dialog holding a collection's settings beyond its bar, such as its templates, as a column of
* cards.
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.html
index c220d235fc..7bb72ae10b 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
@@ -155,10 +155,11 @@
<li>Set the slot label interval (how often time labels appear on the axis
in day/week view).</li>
</ul>
-<p>The same settings, together with whether archived notes are shown, are
- also listed under <em>General</em> in the <span class="tn-icon bx bx-cog"></span> <em>Calendar properties</em> dialog
+<p>The same settings are also listed 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).
- The time slots are listed there whichever view the calendar is in.</p>
+ The time slots are listed there whichever view the calendar is in. Its <em>Included notes</em> section
+ sets whether archived notes are shown and how deep the calendar looks for
+ events (see <a href="#limiting-the-depth">Limiting the depth</a>).</p>
<h3>Event templates</h3>
<p>By default, a new event is a&nbsp;<a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a> note.
To make events from other note types, or from&nbsp;<a class="reference-link"
@@ -431,7 +432,7 @@ class="table">
look for events not just in its child notes but also in the children of
these child notes.</p>
<h3>Limiting the depth</h3>
-<p>To limit how deep the calendar looks for events, set <em>Maximum nesting depth</em> under <em>General</em> in
+<p>To limit how deep the calendar looks for events, set <em>Maximum nesting depth</em> under <em>Included notes</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 child
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.html
index e355de3cb3..51bdbe3203 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
@@ -588,13 +588,14 @@ class="admonition note">
</ul>
</li>
</ul>
-<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,
+<p>The same options are also listed under <em>General</em> in the <span class="tn-icon bx bx-cog"></span><em>Geo map properties</em> dialog,
opened from the&nbsp;<a class="reference-link" href="#root/_help_8YBEPzcpUgxw">Note menu</a> or
from the settings menu of the&nbsp;<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> set
- to <em>Custom image</em>, draws the map over an image of your own instead,
- as described in&nbsp;<a class="reference-link" href="#root/_help_ZRDXGc0nAIh4">Image maps</a>.</p>
+ Its <em>Included notes</em> section sets whether archived notes are shown
+ and the <em>Maximum nesting depth</em> (see below), and its <em>Background</em> section
+ holds the map style, or, with <em>Type</em> set to <em>Custom image</em>,
+ draws the map over an image of your own instead, as described in&nbsp;<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 file
diff --git a/docs/User Guide/User Guide/Collections/Calendar.md b/docs/User Guide/User Guide/Collections/Calendar.md
index 38d591b018..28d88872e0 100644
--- a/docs/User Guide/User Guide/Collections/Calendar.md
+++ b/docs/User Guide/User Guide/Collections/Calendar.md
@@ -97,7 +97,7 @@ In the <a class="reference-link" href="Collection%20Properties.md">Collection P
* 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).
-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.
+The same settings 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. Its _Included notes_ section sets whether archived notes are shown and how deep the calendar looks for events (see [Limiting the depth](#limiting-the-depth)).
### Event templates
@@ -214,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 _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.
+To limit how deep the calendar looks for events, set _Maximum nesting depth_ under _Included notes_ 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.
## Recurrence
diff --git a/docs/User Guide/User Guide/Collections/Geo Map.md b/docs/User Guide/User Guide/Collections/Geo Map.md
index 430e3d95f1..0bbaa242a4 100644
--- a/docs/User Guide/User Guide/Collections/Geo Map.md
+++ b/docs/User Guide/User Guide/Collections/Geo Map.md
@@ -395,6 +395,6 @@ The following options can be configured either via the <a class="reference-link
* 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 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 same options are also listed under _General_ 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 _Included notes_ section sets whether archived notes are shown and the _Maximum nesting depth_ (see below), and 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 file