Fix recurrent event splitting being broken after prior refactoring.
This commit is contained in:
parent
5a0d6804bc
commit
eb3b5a2aa4
@ -206,6 +206,7 @@ function handleEventPointerDown(span, event) {
|
|||||||
anchorDate,
|
anchorDate,
|
||||||
startDate: span.startDate,
|
startDate: span.startDate,
|
||||||
endDate: span.endDate,
|
endDate: span.endDate,
|
||||||
|
n: span.n,
|
||||||
},
|
},
|
||||||
event,
|
event,
|
||||||
)
|
)
|
||||||
@ -224,6 +225,7 @@ function handleResizePointerDown(span, mode, event) {
|
|||||||
anchorDate: null,
|
anchorDate: null,
|
||||||
startDate: span.startDate,
|
startDate: span.startDate,
|
||||||
endDate: span.endDate,
|
endDate: span.endDate,
|
||||||
|
n: span.n,
|
||||||
},
|
},
|
||||||
event,
|
event,
|
||||||
)
|
)
|
||||||
@ -323,7 +325,7 @@ function onDragPointerMove(e) {
|
|||||||
if (st.mode === 'move') {
|
if (st.mode === 'move') {
|
||||||
if (st.n && st.n > 0) {
|
if (st.n && st.n > 0) {
|
||||||
if (!st.realizedId) {
|
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) {
|
if (newId) {
|
||||||
st.realizedId = newId
|
st.realizedId = newId
|
||||||
st.id = newId
|
st.id = newId
|
||||||
@ -355,7 +357,13 @@ function onDragPointerMove(e) {
|
|||||||
if (!st.realizedId) {
|
if (!st.realizedId) {
|
||||||
const initialStart = ns
|
const initialStart = ns
|
||||||
const initialEnd = ne
|
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) {
|
if (newId) {
|
||||||
st.realizedId = newId
|
st.realizedId = newId
|
||||||
st.id = newId
|
st.id = newId
|
||||||
@ -438,7 +446,7 @@ function applyRangeDuringDrag(st, startDate, endDate) {
|
|||||||
if (st.n && st.n > 0) {
|
if (st.n && st.n > 0) {
|
||||||
if (st.mode !== 'move') return // no resize for virtual occurrence
|
if (st.mode !== 'move') return // no resize for virtual occurrence
|
||||||
// Split-move: occurrence being dragged treated as first of new series
|
// 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
|
return
|
||||||
}
|
}
|
||||||
store.setEventRange(st.id, startDate, endDate, { mode: st.mode })
|
store.setEventRange(st.id, startDate, endDate, { mode: st.mode })
|
||||||
|
@ -289,7 +289,7 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
this.notifyEventsChanged()
|
this.notifyEventsChanged()
|
||||||
},
|
},
|
||||||
|
|
||||||
splitMoveVirtualOccurrence(baseId, occurrenceDateStr, newStartStr, newEndStr) {
|
splitMoveVirtualOccurrence(baseId, occurrenceDateStr, newStartStr, newEndStr, occurrenceIndex) {
|
||||||
const base = this.events.get(baseId)
|
const base = this.events.get(baseId)
|
||||||
if (!base || !base.recur) return
|
if (!base || !base.recur) return
|
||||||
const originalCountRaw = base.recur.count
|
const originalCountRaw = base.recur.count
|
||||||
@ -310,7 +310,8 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move', rotatePattern: true })
|
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move', rotatePattern: true })
|
||||||
return baseId
|
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' })
|
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move' })
|
||||||
return baseId
|
return baseId
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user