Refactors date handling for ISO week compatibility

Centralizes all date calculations into a new `DateCalculator` class for better maintainability and consistency.

Ensures correct ISO week handling (Monday as the first day) throughout the calendar.

Updates `CalendarConfig` to use ISO day numbering (1-7 for Mon-Sun) for work week definitions.

Fixes issue where date calculations were inconsistent.
Enhances event rendering and navigation.
Updates navigation logic to use pre-rendered events.
Removes the need for `CONTAINER_READY_FOR_EVENTS` event.
This commit is contained in:
Janus Knudsen 2025-08-20 00:39:31 +02:00
parent efc1742dad
commit 7d513600d8
13 changed files with 230 additions and 343 deletions

View file

@ -31,11 +31,7 @@ export class EventRenderingService {
* Render events in a specific container for a given period
*/
public renderEvents(context: RenderContext): void {
console.log('EventRenderer: Rendering events for period', {
startDate: context.startDate,
endDate: context.endDate,
container: context.container
});
console.log(` 📅 Getting events for ${context.startDate.toDateString()} - ${context.endDate.toDateString()}`);
// Get events from EventManager for the period
const events = this.eventManager.getEventsForPeriod(
@ -43,17 +39,17 @@ export class EventRenderingService {
context.endDate
);
console.log(`EventRenderer: Found ${events.length} events for period`);
console.log(` 📊 Found ${events.length} events for period`);
if (events.length === 0) {
console.log('EventRenderer: No events to render for this period');
console.log(' ⚠️ No events to render for this period');
return;
}
// Use cached strategy to render events in the specific container
this.strategy.renderEvents(events, context.container, calendarConfig);
console.log(`EventRenderer: Successfully rendered ${events.length} events`);
console.log(` ✅ Rendered ${events.length} events successfully`);
}
private setupEventListeners(): void {
@ -63,10 +59,11 @@ export class EventRenderingService {
this.handleGridRendered(event as CustomEvent);
});
this.eventBus.on(EventTypes.CONTAINER_READY_FOR_EVENTS, (event: Event) => {
console.log('EventRenderer: Received CONTAINER_READY_FOR_EVENTS event');
this.handleContainerReady(event as CustomEvent);
});
// CONTAINER_READY_FOR_EVENTS removed - events are now pre-rendered synchronously
// this.eventBus.on(EventTypes.CONTAINER_READY_FOR_EVENTS, (event: Event) => {
// console.log('EventRenderer: Received CONTAINER_READY_FOR_EVENTS event');
// this.handleContainerReady(event as CustomEvent);
// });
this.eventBus.on(EventTypes.VIEW_CHANGED, (event: Event) => {
console.log('EventRenderer: Received VIEW_CHANGED event');