From eb3b5a2aa4ea2781c23ba9329b4af18e62293a40 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Wed, 27 Aug 2025 08:51:36 -0600 Subject: [PATCH] Fix recurrent event splitting being broken after prior refactoring. --- src/components/EventOverlay.vue | 14 +++++++++++--- src/stores/CalendarStore.js | 5 +++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/EventOverlay.vue b/src/components/EventOverlay.vue index f88735d..b138298 100644 --- a/src/components/EventOverlay.vue +++ b/src/components/EventOverlay.vue @@ -206,6 +206,7 @@ function handleEventPointerDown(span, event) { anchorDate, startDate: span.startDate, endDate: span.endDate, + n: span.n, }, event, ) @@ -224,6 +225,7 @@ function handleResizePointerDown(span, mode, event) { anchorDate: null, startDate: span.startDate, endDate: span.endDate, + n: span.n, }, event, ) @@ -323,7 +325,7 @@ function onDragPointerMove(e) { if (st.mode === 'move') { if (st.n && st.n > 0) { if (!st.realizedId) { - const newId = store.splitMoveVirtualOccurrence(st.id, st.startDate, ns, ne) + const newId = store.splitMoveVirtualOccurrence(st.id, st.startDate, ns, ne, st.n) if (newId) { st.realizedId = newId st.id = newId @@ -355,7 +357,13 @@ function onDragPointerMove(e) { if (!st.realizedId) { const initialStart = ns const initialEnd = ne - const newId = store.splitMoveVirtualOccurrence(st.id, st.startDate, initialStart, initialEnd) + const newId = store.splitMoveVirtualOccurrence( + st.id, + st.startDate, + initialStart, + initialEnd, + st.n, + ) if (newId) { st.realizedId = newId st.id = newId @@ -438,7 +446,7 @@ function applyRangeDuringDrag(st, startDate, endDate) { if (st.n && st.n > 0) { if (st.mode !== 'move') return // no resize for virtual occurrence // Split-move: occurrence being dragged treated as first of new series - store.splitMoveVirtualOccurrence(st.id, st.startDate, startDate, endDate) + store.splitMoveVirtualOccurrence(st.id, st.startDate, startDate, endDate, st.n) return } store.setEventRange(st.id, startDate, endDate, { mode: st.mode }) diff --git a/src/stores/CalendarStore.js b/src/stores/CalendarStore.js index fa99a7d..971143c 100644 --- a/src/stores/CalendarStore.js +++ b/src/stores/CalendarStore.js @@ -289,7 +289,7 @@ export const useCalendarStore = defineStore('calendar', { this.notifyEventsChanged() }, - splitMoveVirtualOccurrence(baseId, occurrenceDateStr, newStartStr, newEndStr) { + splitMoveVirtualOccurrence(baseId, occurrenceDateStr, newStartStr, newEndStr, occurrenceIndex) { const base = this.events.get(baseId) if (!base || !base.recur) return const originalCountRaw = base.recur.count @@ -310,7 +310,8 @@ export const useCalendarStore = defineStore('calendar', { this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move', rotatePattern: true }) return baseId } - if (occurrenceDate <= baseStart) { + // Use occurrenceIndex when provided to detect first occurrence (n == 0) + if (occurrenceIndex === 0 || occurrenceDate.getTime() === baseStart.getTime()) { this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move' }) return baseId }