Fix recurrent event splitting being broken after prior refactoring.

This commit is contained in:
Leo Vasanko 2025-08-27 08:51:36 -06:00
parent 5a0d6804bc
commit eb3b5a2aa4
2 changed files with 14 additions and 5 deletions

View File

@ -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 })

View File

@ -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
}