Refactors calendar configuration and event handling

Streamlines calendar configuration by adopting a singleton pattern for consistent access and simplifies event handling.

- Removes direct `CalendarConfig` dependency injection in favor of the `calendarConfig` singleton, reducing code complexity.
- Replaces specific event emissions for grid, date, and resource settings updates with a general `REFRESH_REQUESTED` event.
- Updates event names to be more descriptive and consistent ("NAVIGATION_COMPLETED", "PERIOD_INFO_UPDATE").
- Removes the need to pass the calendar config to renderers since it is now a singleton.

This improves code maintainability and simplifies the event emission process.
This commit is contained in:
Janus Knudsen 2025-09-03 20:04:47 +02:00
parent d0936d1838
commit 2083c6921e
19 changed files with 139 additions and 173 deletions

View file

@ -298,11 +298,10 @@ export class CalendarConfig {
this.config.minEventDuration = updates.snapInterval;
}
// Emit grid settings update event
// Grid settings changes trigger general refresh - avoid specific event
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'gridSettings',
value: this.gridSettings,
oldValue: this.gridSettings
value: this.gridSettings
});
}
@ -319,11 +318,10 @@ export class CalendarConfig {
updateDateViewSettings(updates: Partial<DateViewSettings>): void {
this.dateViewSettings = { ...this.dateViewSettings, ...updates };
// Emit date view settings update event
// Date view settings changes trigger general refresh - avoid specific event
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'dateViewSettings',
value: this.dateViewSettings,
oldValue: this.dateViewSettings
value: this.dateViewSettings
});
}
@ -340,11 +338,10 @@ export class CalendarConfig {
updateResourceViewSettings(updates: Partial<ResourceViewSettings>): void {
this.resourceViewSettings = { ...this.resourceViewSettings, ...updates };
// Emit resource view settings update event
// Resource view settings changes trigger general refresh - avoid specific event
eventBus.emit(CoreEvents.REFRESH_REQUESTED, {
key: 'resourceViewSettings',
value: this.resourceViewSettings,
oldValue: this.resourceViewSettings
value: this.resourceViewSettings
});
}