diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index 57b04133..fcb76f51 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -26,6 +26,7 @@ Example: ## Fixed +- (#1974) Stopped Calendar and Agenda property-based events from logging date parse errors for entries that do not have the selected date property. Thanks to @Jomo94 for suggesting completed-date Agenda events. - (#1973) Reduced unnecessary Calendar view recreations when external calendar providers are reported in a different order, and preserved Calendar scroll position when a config-driven refresh has to recreate the view. Thanks to @e-zz for reporting this. - (#1972) Fixed ICS calendar event related notes so standalone events with similar numeric IDs no longer show unrelated notes or tasks on every event. Thanks to @ks-studio-net for reporting this. - (#1970) Fixed TaskNotes Bases views still rendering task files from excluded folders. Thanks to @henrim01 for reporting that this still affected 4.9.2. diff --git a/docs/views/default-base-templates.md b/docs/views/default-base-templates.md index 54271470..331c3cb4 100644 --- a/docs/views/default-base-templates.md +++ b/docs/views/default-base-templates.md @@ -536,6 +536,21 @@ views: Used by the **Agenda** command to display tasks in a list-based agenda view. Note: Property-based events are disabled by default to avoid duplicate entries when tasks already have due/scheduled dates. +To build an Agenda variant for completed tasks that do not have due or scheduled dates, enable property-based events and use the completed-date property as the event start date: + +```yaml + options: + showScheduled: false + showDue: false + showRecurring: false + showTimeEntries: false + showPropertyBasedEvents: true + createDailyNotesFromDateLinks: true + calendarView: "listWeek" + startDateProperty: completedDate + listDayCount: 7 + titleProperty: file.basename +``` ```yaml # Agenda diff --git a/src/bases/calendarPropertyEvents.ts b/src/bases/calendarPropertyEvents.ts index 301bba18..8e2a2608 100644 --- a/src/bases/calendarPropertyEvents.ts +++ b/src/bases/calendarPropertyEvents.ts @@ -51,7 +51,10 @@ export type BuildCalendarPropertyEventInput = { export function normalizeDateValueForCalendar(value: unknown): CalendarDateValue | null { if (typeof value === "string") { const trimmed = value.trim(); - if (!trimmed) return null; + const normalizedEmptyValue = trimmed.toLowerCase(); + if (!trimmed || normalizedEmptyValue === "null" || normalizedEmptyValue === "undefined") { + return null; + } if (hasTimeComponent(trimmed)) { const parsed = parseDateToLocal(trimmed); diff --git a/tests/unit/bases/calendarPropertyEvents.test.ts b/tests/unit/bases/calendarPropertyEvents.test.ts index 06220e4c..d2238f98 100644 --- a/tests/unit/bases/calendarPropertyEvents.test.ts +++ b/tests/unit/bases/calendarPropertyEvents.test.ts @@ -23,6 +23,11 @@ describe("calendarPropertyEvents", () => { expect(normalizeDateValueForCalendar(" ")).toBeNull(); expect(normalizeDateValueForCalendar(new Date("not-a-date"))).toBeNull(); }); + + it("treats Bases stringified empty values as missing", () => { + expect(normalizeDateValueForCalendar("null")).toBeNull(); + expect(normalizeDateValueForCalendar("undefined")).toBeNull(); + }); }); describe("buildCalendarPropertyEvent", () => {