Refactors header drag interaction to eliminate ghost columns

Updates the `HeaderManager` to utilize `mouseenter` and `mouseleave` events on the calendar header for improved performance and accuracy.
Calculates the target date based on the mouse's X-coordinate within the header.

Removes the need for 'ghost columns' by simplifying the logic. This significantly reduces complexity.
The `AllDayEventRenderer` is modified to reflect this change, omitting ghost column creation.

Updates `DragDropManager` to accommodate the new interaction model.
Various console logs are added for debugging purposes.
This commit is contained in:
Janus Knudsen 2025-09-18 17:55:52 +02:00
parent 18e80bbce2
commit fb40279009
5 changed files with 353 additions and 55 deletions

View file

@ -30,13 +30,27 @@ export class AllDayManager {
private setupEventListeners(): void {
eventBus.on('drag:convert-to-allday', (event) => {
const { targetDate, originalElement } = (event as CustomEvent).detail;
console.log('🔄 AllDayManager: Received drag:convert-to-allday', {
targetDate,
originalElementId: originalElement?.dataset?.eventId,
originalElementTag: originalElement?.tagName
});
this.handleConvertToAllDay(targetDate, originalElement);
});
eventBus.on('drag:convert-from-allday', (event) => {
const { draggedEventId } = (event as CustomEvent).detail;
console.log('🔄 AllDayManager: Received drag:convert-from-allday', {
draggedEventId
});
this.handleConvertFromAllDay(draggedEventId);
});
// Listen for requests to ensure all-day container exists
eventBus.on('allday:ensure-container', () => {
console.log('🏗️ AllDayManager: Received request to ensure all-day container exists');
this.ensureAllDayContainer();
});
}
/**
@ -325,6 +339,41 @@ export class AllDayManager {
this.checkAndAnimateAllDayHeight();
}
/**
* Ensure all-day container exists, create if needed
*/
public ensureAllDayContainer(): HTMLElement | null {
console.log('🔍 AllDayManager: Checking if all-day container exists...');
// Try to get existing container first
let container = this.getAllDayContainer();
if (!container) {
console.log('🏗️ AllDayManager: Container not found, creating via AllDayEventRenderer...');
// Use the renderer to create container (which will call getContainer internally)
this.allDayEventRenderer.clearCache(); // Clear cache to force re-check
// The renderer's getContainer method will create the container if it doesn't exist
// We can trigger this by trying to get the container
const header = this.getCalendarHeader();
if (header) {
container = document.createElement('swp-allday-container');
header.appendChild(container);
console.log('✅ AllDayManager: Created all-day container');
// Update our cache
this.cachedAllDayContainer = container;
} else {
console.log('❌ AllDayManager: No calendar header found, cannot create container');
}
} else {
console.log('✅ AllDayManager: All-day container already exists');
}
return container;
}
/**
* Clean up cached elements and resources
*/