Renders all-day events based on header data
Refactors all-day event rendering to use header column data. This ensures events are rendered based on the actual visible dates in the header, improving accuracy and responsiveness to view changes. Removes direct dependency on week dates in `AllDayManager` and `EventRenderingService`, instead, the all-day manager is instantiated with event manager. Updates `HeaderManager` to emit header bounds.
This commit is contained in:
parent
ae3aab5dd0
commit
d7867d4a9f
7 changed files with 108 additions and 157 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { CalendarEvent } from '../types/CalendarTypes';
|
||||
import { SwpAllDayEventElement } from '../elements/SwpEventElement';
|
||||
import { EventLayout } from '../utils/AllDayLayoutEngine';
|
||||
|
||||
import { ColumnBounds } from '../utils/ColumnDetectionUtils';
|
||||
import { EventManager } from '../managers/EventManager';
|
||||
/**
|
||||
* AllDayEventRenderer - Simple rendering of all-day events
|
||||
* Handles adding and removing all-day events from the header container
|
||||
|
|
@ -38,7 +39,7 @@ export class AllDayEventRenderer {
|
|||
/**
|
||||
* Render an all-day event with pre-calculated layout
|
||||
*/
|
||||
public renderAllDayEventWithLayout(
|
||||
private renderAllDayEventWithLayout(
|
||||
event: CalendarEvent,
|
||||
layout: EventLayout
|
||||
) {
|
||||
|
|
@ -71,4 +72,41 @@ export class AllDayEventRenderer {
|
|||
public clearCache(): void {
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render all-day events for specific period using AllDayEventRenderer
|
||||
*/
|
||||
public renderAllDayEventsForPeriod(eventLayouts: EventLayout[]): void {
|
||||
// Get events from EventManager for the period
|
||||
// const events = this.eventManager.getEventsForPeriod(startDate, endDate);
|
||||
|
||||
|
||||
|
||||
// Clear existing all-day events first
|
||||
this.clearAllDayEvents();
|
||||
|
||||
// Get actual visible dates from DOM headers instead of generating them
|
||||
|
||||
// const layouts = this.allDayManager.initAllDayEventsLayout(allDayEvents, weekDates);
|
||||
|
||||
// Render each all-day event with pre-calculated layout
|
||||
eventLayouts.forEach(layout => {
|
||||
this.renderAllDayEventWithLayout(layout.calenderEvent, layout);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Clear only all-day events
|
||||
*/
|
||||
private clearAllDayEvents(): void {
|
||||
const allDayContainer = document.querySelector('swp-allday-container');
|
||||
if (allDayContainer) {
|
||||
allDayContainer.querySelectorAll('swp-event').forEach(event => event.remove());
|
||||
}
|
||||
}
|
||||
|
||||
public handleViewChanged(event: CustomEvent): void {
|
||||
this.clearAllDayEvents();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue