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(calendar): gather the whole recurrence rule behind its Repeats row
Elian Doran7cd4962af9f8
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 83d751fb06..59093aec9e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1018,6 +1018,7 @@},"recurrence": {"repeats": "Repeats",+ "frequency": "Frequency","does_not_repeat": "Does not repeat","daily": "Daily","weekly": "Weekly",diff --git a/apps/client/src/widgets/collections/calendar/RecurrenceEditor.css b/apps/client/src/widgets/collections/calendar/RecurrenceEditor.cssindex 55dc0a2e5b..24e316b8e9 100644--- a/apps/client/src/widgets/collections/calendar/RecurrenceEditor.css+++ b/apps/client/src/widgets/collections/calendar/RecurrenceEditor.css@@ -1,3 +1,27 @@+/* Carried by the in-place wrapper and by the portaled one alike (see portalToBody in Dropdown.tsx),+ so the button is styled here and the menu there under the one class. */+.calendar-recurrence-dropdown {+ flex: 1;+ min-width: 0;++ /* The button stands where a select would, so it takes the row as a select does, and says its+ value from the leading edge with the arrow at the other end. */+ > .select-button {+ flex: 1;+ min-width: 0;+ display: flex;+ align-items: center;+ justify-content: space-between;+ text-align: start;+ }++ .dropdown-menu {+ padding: 10px;+ /* Room for the widest of its rows — the seven weekday pills — to breathe. */+ min-width: 300px;+ }+}+.calendar-recurrence-weekdays {display: flex;gap: 4px;diff --git a/apps/client/src/widgets/collections/calendar/RecurrenceEditor.tsx b/apps/client/src/widgets/collections/calendar/RecurrenceEditor.tsxindex 476166a5dd..5b915ba01e 100644--- a/apps/client/src/widgets/collections/calendar/RecurrenceEditor.tsx+++ b/apps/client/src/widgets/collections/calendar/RecurrenceEditor.tsx@@ -6,10 +6,11 @@ import { useCallback, useEffect, useState } from "preact/hooks";import FNote from "../../../entities/fnote";import { t } from "../../../services/i18n";import LabelValueInput from "../../attribute_widgets/label_value_input";+import Dropdown from "../../react/Dropdown";import FormSelect from "../../react/FormSelect";import FormTextBox, { FormTextBoxWithUnit } from "../../react/FormTextBox";import { useNoteLabel, useUniqueName } from "../../react/hooks";-import { EventField, EventFieldControls } from "./EventField";+import { EventField, EventFieldControls, EventFieldList } from "./EventField";import {FREQUENCIES,Frequency,@@ -53,15 +54,41 @@ export default function RecurrenceEditor({ note }: { note: FNote }) {setStoredValue(serializeRecurrence(next));}, [ setStoredValue ]);+ // One row in the dock, the whole rule behind it: the button says what the rule amounts to, and+ // opening it lays the rule out to edit. Kept open through the edits (`autoClose: "outside"`) —+ // a rule is several choices, and the menu going down after the first would make it three trips.+ // Portaled to the body because the dock clips what overflows it (see DetailDock.css).return (- <>- <FrequencyField model={model} commit={commit} />- {model.kind === "simple" && <SimpleRuleFields rule={model.rule} commit={commit} />}- {model.kind === "custom" && <CustomRuleField value={model.value} commit={commit} />}- </>+ <EventField name={t("calendar.recurrence.repeats")}>+ <Dropdown+ className="calendar-recurrence-dropdown"+ text={modelTitle(model)}+ noDropdownListStyle+ portalToBody+ dropdownOptions={{ autoClose: "outside" }}+ >+ <EventFieldList>+ <FrequencyField model={model} commit={commit} />+ {model.kind === "simple" && <SimpleRuleFields rule={model.rule} commit={commit} />}+ {model.kind === "custom" && <CustomRuleField value={model.value} commit={commit} />}+ </EventFieldList>+ </Dropdown>+ </EventField>);}+/** What the closed row says the rule amounts to: the same wording the frequency choice wears. */+function modelTitle(model: ParsedRecurrence): string {+ switch (model.kind) {+ case "none":+ return t("calendar.recurrence.does_not_repeat");+ case "custom":+ return t("calendar.recurrence.custom");+ case "simple":+ return FREQUENCY_TITLES[model.rule.frequency]();+ }+}+/** What the frequency dropdown offers beside the frequencies themselves. */const NO_REPEAT = "none";const CUSTOM = "custom";@@ -111,7 +138,7 @@ function FrequencyField({ model, commit }: {};return (- <EventField name={t("calendar.recurrence.repeats")} htmlFor={selectId}>+ <EventField name={t("calendar.recurrence.frequency")} htmlFor={selectId}><FormSelectid={selectId}values={choices}