Updates event data after drag and drop

Updates event start and end times in the dataset after a successful drag and drop operation. This ensures the event element reflects the new time position.

Also resets the z-index of the dropped element if no overlaps are detected, keeping the element's original appearance.
This commit is contained in:
Janus Knudsen 2025-09-09 18:03:37 +02:00
parent 69f4a71062
commit 5cffc233c5

View file

@ -390,6 +390,12 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
this.draggedClone.style.userSelect = ''; this.draggedClone.style.userSelect = '';
// Behold z-index hvis det er et stacked event // Behold z-index hvis det er et stacked event
// Update dataset with new times after successful drop
const newEvent = this.elementToCalendarEventWithNewPosition(this.draggedClone, finalColumn);
if (newEvent) {
this.draggedClone.dataset.start = newEvent.start.toISOString();
this.draggedClone.dataset.end = newEvent.end.toISOString();
}
// Detect overlaps with other events in the target column and reposition if needed // Detect overlaps with other events in the target column and reposition if needed
this.handleDragDropOverlaps(this.draggedClone, finalColumn); this.handleDragDropOverlaps(this.draggedClone, finalColumn);
@ -498,8 +504,10 @@ export abstract class BaseEventRenderer implements EventRendererStrategy {
// Re-render affected events with overlap handling // Re-render affected events with overlap handling
const affectedEvents = [droppedEvent, ...overlappingEvents]; const affectedEvents = [droppedEvent, ...overlappingEvents];
this.new_handleEventOverlaps(affectedEvents, eventsLayer); this.new_handleEventOverlaps(affectedEvents, eventsLayer);
} else {
// Reset z-index for non-overlapping events
droppedElement.style.zIndex = '';
} }
// If no overlaps, the dropped element stays as is
} }
/** /**