2025-09-12 00:36:02 +02:00
|
|
|
import { CalendarEvent } from '../types/CalendarTypes';
|
|
|
|
|
import { SwpAllDayEventElement } from '../elements/SwpEventElement';
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-13 00:39:56 +02:00
|
|
|
* AllDayEventRenderer - Simple rendering of all-day events
|
|
|
|
|
* Handles adding and removing all-day events from the header container
|
2025-09-12 00:36:02 +02:00
|
|
|
*/
|
|
|
|
|
export class AllDayEventRenderer {
|
2025-09-13 00:39:56 +02:00
|
|
|
private container: HTMLElement | null = null;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.getContainer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-18 17:55:52 +02:00
|
|
|
* Get or cache all-day container, create if it doesn't exist - SIMPLIFIED (no ghost columns)
|
2025-09-13 00:39:56 +02:00
|
|
|
*/
|
|
|
|
|
private getContainer(): HTMLElement | null {
|
|
|
|
|
if (!this.container) {
|
|
|
|
|
const header = document.querySelector('swp-calendar-header');
|
|
|
|
|
if (header) {
|
2025-09-13 20:47:42 +02:00
|
|
|
// Try to find existing container
|
2025-09-13 00:39:56 +02:00
|
|
|
this.container = header.querySelector('swp-allday-container');
|
2025-09-13 20:47:42 +02:00
|
|
|
|
|
|
|
|
// If not found, create it
|
|
|
|
|
if (!this.container) {
|
|
|
|
|
this.container = document.createElement('swp-allday-container');
|
|
|
|
|
header.appendChild(this.container);
|
2025-09-17 22:08:27 +02:00
|
|
|
|
2025-09-18 17:55:52 +02:00
|
|
|
console.log('🏗️ AllDayEventRenderer: Created all-day container (NO ghost columns)');
|
|
|
|
|
|
|
|
|
|
// NO MORE GHOST COLUMNS! 🎉
|
|
|
|
|
// Mouse detection handled by HeaderManager coordinate calculation
|
2025-09-13 20:47:42 +02:00
|
|
|
}
|
2025-09-13 00:39:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this.container;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-18 17:55:52 +02:00
|
|
|
// REMOVED: createGhostColumns() method - no longer needed!
|
2025-09-17 22:08:27 +02:00
|
|
|
|
2025-09-13 00:39:56 +02:00
|
|
|
/**
|
|
|
|
|
* Render an all-day event using factory pattern
|
|
|
|
|
*/
|
2025-09-18 00:05:54 +02:00
|
|
|
public renderAllDayEvent(event: CalendarEvent, targetDate?: string): HTMLElement | null {
|
2025-09-13 00:39:56 +02:00
|
|
|
const container = this.getContainer();
|
|
|
|
|
if (!container) return null;
|
|
|
|
|
|
|
|
|
|
const allDayElement = SwpAllDayEventElement.fromCalendarEvent(event, targetDate);
|
|
|
|
|
const element = allDayElement.getElement();
|
|
|
|
|
|
|
|
|
|
container.appendChild(element);
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove an all-day event by ID
|
|
|
|
|
*/
|
|
|
|
|
public removeAllDayEvent(eventId: string): void {
|
|
|
|
|
const container = this.getContainer();
|
|
|
|
|
if (!container) return;
|
|
|
|
|
|
2025-09-21 16:03:34 +02:00
|
|
|
const eventElement = container.querySelector(`swp-event[data-event-id="${eventId}"]`);
|
2025-09-13 00:39:56 +02:00
|
|
|
if (eventElement) {
|
|
|
|
|
eventElement.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-12 00:36:02 +02:00
|
|
|
|
2025-09-13 00:39:56 +02:00
|
|
|
/**
|
|
|
|
|
* Clear cache when DOM changes
|
|
|
|
|
*/
|
|
|
|
|
public clearCache(): void {
|
|
|
|
|
this.container = null;
|
|
|
|
|
}
|
2025-09-12 00:36:02 +02:00
|
|
|
}
|