Fixes all-day event dragging issues
Addresses issues with dragging all-day events, ensuring correct event placement and layout calculations after a drag and drop operation. Specifically, ensures the correct event ID is used and updates the event layout when dragging all day events.
This commit is contained in:
parent
89e8a3f7b2
commit
576367974b
2 changed files with 6 additions and 2 deletions
|
|
@ -250,6 +250,7 @@ export class SwpAllDayEventElement extends BaseEventElement {
|
||||||
const endDateStr = this.event.end.toISOString().split('T')[0];
|
const endDateStr = this.event.end.toISOString().split('T')[0];
|
||||||
this.element.dataset.start = `${startDateStr}T00:00:00`;
|
this.element.dataset.start = `${startDateStr}T00:00:00`;
|
||||||
this.element.dataset.end = `${endDateStr}T23:59:59`;
|
this.element.dataset.end = `${endDateStr}T23:59:59`;
|
||||||
|
this.element.dataset.allday = 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ export class AllDayManager {
|
||||||
|
|
||||||
// 2. Normalize clone ID
|
// 2. Normalize clone ID
|
||||||
dragEndEvent.draggedClone.dataset.eventId = dragEndEvent.draggedClone.dataset.eventId?.replace('clone-', '');
|
dragEndEvent.draggedClone.dataset.eventId = dragEndEvent.draggedClone.dataset.eventId?.replace('clone-', '');
|
||||||
|
dragEndEvent.originalElement.dataset.eventId += '_';
|
||||||
|
|
||||||
// 3. Create temporary array with existing events + the dropped event
|
// 3. Create temporary array with existing events + the dropped event
|
||||||
let eventId = dragEndEvent.draggedClone.dataset.eventId;
|
let eventId = dragEndEvent.draggedClone.dataset.eventId;
|
||||||
|
|
@ -390,7 +390,10 @@ export class AllDayManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use current events + dropped event for calculation
|
// Use current events + dropped event for calculation
|
||||||
const tempEvents = [...this.currentAllDayEvents, droppedEvent].except(dragEndEvent.originalElement);
|
const tempEvents = [
|
||||||
|
...this.currentAllDayEvents.filter(event => event.id !== eventId),
|
||||||
|
droppedEvent
|
||||||
|
];
|
||||||
|
|
||||||
// 4. Calculate new layouts for ALL events
|
// 4. Calculate new layouts for ALL events
|
||||||
this.newLayouts = this.calculateAllDayEventsLayout(tempEvents, this.currentWeekDates);
|
this.newLayouts = this.calculateAllDayEventsLayout(tempEvents, this.currentWeekDates);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue