diff --git a/src/lib/components/calendar/CalendarEventModal.svelte b/src/lib/components/calendar/CalendarEventModal.svelte index 3ab37f866a..6cd9a584a0 100644 --- a/src/lib/components/calendar/CalendarEventModal.svelte +++ b/src/lib/components/calendar/CalendarEventModal.svelte @@ -33,9 +33,31 @@ let allDay = false; let location = ''; let alertMinutes: number = 10; + let repeatFrequency = ''; let loading = false; let showDeleteConfirmDialog = false; + const REPEAT_RRULE_MAP: Record = { + daily: 'FREQ=DAILY', + weekdays: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR', + weekly: 'FREQ=WEEKLY', + monthly: 'FREQ=MONTHLY', + yearly: 'FREQ=YEARLY' + }; + + function getRepeatRrule(): string | undefined { + return REPEAT_RRULE_MAP[repeatFrequency] || undefined; + } + + function parseRepeatFromRrule(rrule: string | null): string { + if (!rrule) return ''; + const normalized = rrule.toUpperCase().replace(/\s/g, ''); + for (const [key, value] of Object.entries(REPEAT_RRULE_MAP)) { + if (normalized === value) return key; + } + return ''; + } + const NS = 1_000_000; function nsToDateStr(ns: number): string { @@ -62,6 +84,7 @@ allDay = event.all_day; location = event.location || ''; alertMinutes = event.meta?.alert_minutes ?? 10; + repeatFrequency = parseRepeatFromRrule(event.rrule); } else { title = ''; description = ''; @@ -83,6 +106,7 @@ allDay = false; location = ''; alertMinutes = 10; + repeatFrequency = ''; } } @@ -103,11 +127,12 @@ const result = await updateCalendarEvent(localStorage.token, event.id, { calendar_id: calendarId, title: title.trim(), - description: description.trim() || null, + description: description.trim() || undefined, start_at: startNs, end_at: endNs, all_day: allDay, - location: location.trim() || null, + rrule: getRepeatRrule(), + location: location.trim() || undefined, meta: { alert_minutes: alertMinutes } }); if (result) { @@ -123,6 +148,7 @@ start_at: startNs, end_at: endNs, all_day: allDay, + rrule: getRepeatRrule(), location: location.trim() || undefined, meta: { alert_minutes: alertMinutes } }; @@ -234,6 +260,22 @@ + +
+
{$i18n.t('Repeat')}
+ +
+
{$i18n.t('Description')}