Enables all-day event conversion on column hover
Allows users to convert all-day events to timed events by dragging them over a day column. This implementation adds logic to the DragDropManager to detect when an all-day event is dragged over a column. It then emits a new event, 'drag:mouseenter-column', carrying the event data and target column information. The event rendering service handles this event.
This commit is contained in:
parent
7a79297854
commit
78ca23c07a
5 changed files with 69 additions and 125 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
DragEndEventPayload,
|
||||
DragMouseEnterHeaderEventPayload,
|
||||
DragMouseLeaveHeaderEventPayload,
|
||||
DragMouseEnterColumnEventPayload,
|
||||
DragColumnChangeEventPayload
|
||||
} from '../types/EventTypes';
|
||||
import { MousePosition } from '../types/DragDropTypes';
|
||||
|
|
@ -116,6 +117,8 @@ export class DragDropManager {
|
|||
const target = e.target as HTMLElement;
|
||||
if (target.closest('swp-calendar-header')) {
|
||||
this.handleHeaderMouseEnter(e as MouseEvent);
|
||||
} else if (target.closest('swp-day-column')) {
|
||||
this.handleColumnMouseEnter(e as MouseEvent);
|
||||
} else if (target.closest('swp-event')) {
|
||||
// Entered an event - activate hover tracking and set color
|
||||
const eventElement = target.closest<HTMLElement>('swp-event');
|
||||
|
|
@ -652,6 +655,46 @@ export class DragDropManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle mouse enter on day column - for converting all-day to timed events
|
||||
*/
|
||||
private handleColumnMouseEnter(event: MouseEvent): void {
|
||||
// Only handle if we're dragging an all-day event
|
||||
if (!this.isDragStarted || !this.draggedClone || !this.draggedClone.hasAttribute('data-allday')) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🎯 DragDropManager: Mouse entered day column');
|
||||
|
||||
const position: MousePosition = { x: event.clientX, y: event.clientY };
|
||||
const targetColumn = ColumnDetectionUtils.getColumnBounds(position);
|
||||
|
||||
if (!targetColumn) {
|
||||
console.warn("No column detected when entering day column");
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate snapped Y position
|
||||
const snappedY = this.calculateSnapPosition(position.y, targetColumn);
|
||||
|
||||
// Extract CalendarEvent from the dragged clone
|
||||
const calendarEvent = SwpEventElement.extractCalendarEventFromElement(this.draggedClone);
|
||||
|
||||
const dragMouseEnterPayload: DragMouseEnterColumnEventPayload = {
|
||||
targetColumn: targetColumn,
|
||||
mousePosition: position,
|
||||
snappedY: snappedY,
|
||||
originalElement: this.draggedElement,
|
||||
draggedClone: this.draggedClone,
|
||||
calendarEvent: calendarEvent,
|
||||
// Delegate pattern - allows EventRenderer to replace the clone
|
||||
replaceClone: (newClone: HTMLElement) => {
|
||||
this.draggedClone = newClone;
|
||||
}
|
||||
};
|
||||
this.eventBus.emit('drag:mouseenter-column', dragMouseEnterPayload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle mouse leave from calendar header - simplified using native events
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue