Major new version #2
@ -302,7 +302,9 @@ function onDragPointerMove(e) {
|
|||||||
} else if (st.isVirtual && (st.mode === 'resize-left' || st.mode === 'resize-right')) {
|
} else if (st.isVirtual && (st.mode === 'resize-left' || st.mode === 'resize-right')) {
|
||||||
// For virtual occurrence resize: convert to real once, then adjust range
|
// For virtual occurrence resize: convert to real once, then adjust range
|
||||||
if (!st.realizedId) {
|
if (!st.realizedId) {
|
||||||
const newId = store.splitMoveVirtualOccurrence(st.id, st.startDate, st.startDate, st.endDate)
|
const initialStart = ns
|
||||||
|
const initialEnd = ne
|
||||||
|
const newId = store.splitMoveVirtualOccurrence(st.id, st.startDate, initialStart, initialEnd)
|
||||||
if (newId) {
|
if (newId) {
|
||||||
st.realizedId = newId
|
st.realizedId = newId
|
||||||
st.id = newId
|
st.id = newId
|
||||||
|
@ -309,6 +309,22 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
const originalCountRaw = base.repeatCount
|
const originalCountRaw = base.repeatCount
|
||||||
const occurrenceDate = fromLocalString(occurrenceDateStr, DEFAULT_TZ)
|
const occurrenceDate = fromLocalString(occurrenceDateStr, DEFAULT_TZ)
|
||||||
const baseStart = fromLocalString(base.startDate, DEFAULT_TZ)
|
const baseStart = fromLocalString(base.startDate, DEFAULT_TZ)
|
||||||
|
// If series effectively has <=1 occurrence, treat as simple move (no split) and flatten
|
||||||
|
let totalOccurrences = Infinity
|
||||||
|
if (originalCountRaw !== 'unlimited') {
|
||||||
|
const parsed = parseInt(originalCountRaw, 10)
|
||||||
|
if (!isNaN(parsed)) totalOccurrences = parsed
|
||||||
|
}
|
||||||
|
if (totalOccurrences <= 1) {
|
||||||
|
// Flatten to non-repeating if not already
|
||||||
|
if (base.isRepeating) {
|
||||||
|
base.repeat = 'none'
|
||||||
|
base.isRepeating = false
|
||||||
|
this.events.set(baseId, { ...base })
|
||||||
|
}
|
||||||
|
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move', rotatePattern: true })
|
||||||
|
return baseId
|
||||||
|
}
|
||||||
if (occurrenceDate <= baseStart) {
|
if (occurrenceDate <= baseStart) {
|
||||||
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move' })
|
this.setEventRange(baseId, newStartStr, newEndStr, { mode: 'move' })
|
||||||
return baseId
|
return baseId
|
||||||
@ -341,6 +357,11 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._terminateRepeatSeriesAtIndex(baseId, keptOccurrences)
|
this._terminateRepeatSeriesAtIndex(baseId, keptOccurrences)
|
||||||
|
// After truncation compute base kept count
|
||||||
|
const truncated = this.events.get(baseId)
|
||||||
|
if (truncated && truncated.repeatCount && truncated.repeatCount !== 'unlimited') {
|
||||||
|
// keptOccurrences already reflects number before split; adjust not needed further
|
||||||
|
}
|
||||||
let remainingCount = 'unlimited'
|
let remainingCount = 'unlimited'
|
||||||
if (originalCountRaw !== 'unlimited') {
|
if (originalCountRaw !== 'unlimited') {
|
||||||
const total = parseInt(originalCountRaw, 10)
|
const total = parseInt(originalCountRaw, 10)
|
||||||
@ -369,6 +390,27 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
repeatCount: remainingCount,
|
repeatCount: remainingCount,
|
||||||
repeatWeekdays,
|
repeatWeekdays,
|
||||||
})
|
})
|
||||||
|
// Flatten base if single occurrence now
|
||||||
|
if (truncated && truncated.isRepeating) {
|
||||||
|
const baseCountNum =
|
||||||
|
truncated.repeatCount === 'unlimited' ? Infinity : parseInt(truncated.repeatCount, 10)
|
||||||
|
if (baseCountNum <= 1) {
|
||||||
|
truncated.repeat = 'none'
|
||||||
|
truncated.isRepeating = false
|
||||||
|
this.events.set(baseId, { ...truncated })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Flatten new if single occurrence only
|
||||||
|
const newly = this.events.get(newId)
|
||||||
|
if (newly && newly.isRepeating) {
|
||||||
|
const newCountNum =
|
||||||
|
newly.repeatCount === 'unlimited' ? Infinity : parseInt(newly.repeatCount, 10)
|
||||||
|
if (newCountNum <= 1) {
|
||||||
|
newly.repeat = 'none'
|
||||||
|
newly.isRepeating = false
|
||||||
|
this.events.set(newId, { ...newly })
|
||||||
|
}
|
||||||
|
}
|
||||||
this.notifyEventsChanged()
|
this.notifyEventsChanged()
|
||||||
return newId
|
return newId
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user