From 6c1cb71c9fbdd5cff1dbef8c3e1fe68a7ebe331d Mon Sep 17 00:00:00 2001 From: "Romain DEP." Date: Sun, 9 Mar 2025 13:03:15 +0100 Subject: [PATCH] feat(calendar): make it so that events with customized `calendar:startDate` and `calendar:endDate` can be drag&dropped on the calendar view --- src/public/app/widgets/view_widgets/calendar_view.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.ts index c429f4924..5510f0412 100644 --- a/src/public/app/widgets/view_widgets/calendar_view.ts +++ b/src/public/app/widgets/view_widgets/calendar_view.ts @@ -229,8 +229,13 @@ export default class CalendarView extends ViewMode { return; } - attributes.setAttribute(note, "label", "startDate", startDate); - attributes.setAttribute(note, "label", "endDate", endDate); + // Since they can be customized via calendar:startDate=$foo and calendar:endDate=$bar we need to determine the + // attributes to be effectively updated + const startAttribute = note.getAttributes("label").filter(attr => attr.name == "calendar:startDate").shift()?.value.replace("#", "")||"startDate" + const endAttribute = note.getAttributes("label").filter(attr => attr.name == "calendar:endDate").shift()?.value.replace("#", "")||"endDate" + + attributes.setAttribute(note, "label", startAttribute, startDate); + attributes.setAttribute(note, "label", endAttribute, endDate); } onEntitiesReloaded({ loadResults }: EventData<"entitiesReloaded">) {