Event deletion
This commit is contained in:
parent
a92ef0479a
commit
00936b33ea
@ -331,7 +331,7 @@ export class EventManager {
|
||||
</div>
|
||||
</div>
|
||||
<footer class="ec-footer">
|
||||
<button type="button" class="ec-btn" data-action="cancel">Cancel</button>
|
||||
<button type="button" class="ec-btn" data-action="delete">Delete</button>
|
||||
<button type="submit" class="ec-btn primary">Save</button>
|
||||
</footer>
|
||||
</form>
|
||||
@ -387,7 +387,24 @@ export class EventManager {
|
||||
this.hideEventDialog()
|
||||
})
|
||||
|
||||
this.eventForm.querySelector('[data-action="cancel"]').addEventListener('click', () => {
|
||||
this.eventForm.querySelector('[data-action="delete"]').addEventListener('click', () => {
|
||||
if (this._dialogMode === 'edit' && this._editingEventId) {
|
||||
// Find and remove the event from ALL dates it spans across
|
||||
const datesToCleanup = []
|
||||
for (const [dateStr, eventList] of this.events) {
|
||||
const eventIndex = eventList.findIndex(event => event.id === this._editingEventId)
|
||||
if (eventIndex !== -1) {
|
||||
eventList.splice(eventIndex, 1)
|
||||
// Mark date for cleanup if empty
|
||||
if (eventList.length === 0) {
|
||||
datesToCleanup.push(dateStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Clean up empty date entries
|
||||
datesToCleanup.forEach(dateStr => this.events.delete(dateStr))
|
||||
this.calendar.forceUpdateVisibleWeeks()
|
||||
}
|
||||
this.hideEventDialog()
|
||||
if (this._dialogMode === 'create') this.clearSelection()
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user