Refactors dependency injection and configuration management

Replaces global singleton configuration with dependency injection
Introduces more modular and testable approach to configuration
Removes direct references to calendarConfig in multiple components
Adds explicit configuration passing to constructors

Improves code maintainability and reduces global state dependencies
This commit is contained in:
Janus C. H. Knudsen 2025-10-30 23:47:30 +01:00
parent fb48e410ea
commit 8bbb2f05d3
30 changed files with 365 additions and 559 deletions

View file

@ -25,17 +25,20 @@ export interface ColumnRenderContext {
* Date-based column renderer (original functionality)
*/
export class DateColumnRenderer implements ColumnRenderer {
private dateService!: DateService;
private workHoursManager!: WorkHoursManager;
private dateService: DateService;
private workHoursManager: WorkHoursManager;
constructor(
dateService: DateService,
workHoursManager: WorkHoursManager
) {
this.dateService = dateService;
this.workHoursManager = workHoursManager;
}
render(columnContainer: HTMLElement, context: ColumnRenderContext): void {
const { currentWeek, config } = context;
// Initialize date service and work hours manager
const timezone = config.getTimezone?.() || 'Europe/Copenhagen';
this.dateService = new DateService(timezone);
this.workHoursManager = new WorkHoursManager();
const workWeekSettings = config.getWorkWeekSettings();
const dates = this.dateService.getWorkWeekDates(currentWeek, workWeekSettings.workDays);
const dateSettings = config.getDateViewSettings();