Refactors grid date handling and event rendering

Replaces getPeriodRange with getDisplayDates approach
Simplifies event rendering by using flexible date array
Updates event rendering to work with dynamic date lists

Improves code modularity and reduces complexity
This commit is contained in:
Janus C. H. Knudsen 2025-11-13 21:22:28 +01:00
parent 5075b71eb2
commit f0cc9bb6ce
3 changed files with 9 additions and 38 deletions

View file

@ -94,8 +94,8 @@ export class GridManager {
this.currentDate
);
// Calculate period range
const periodRange = this.getPeriodRange();
// Get display dates for current view
const dates = this.getDisplayDates();
// Get layout config based on current view
const layoutConfig = this.getLayoutConfig();
@ -104,8 +104,7 @@ export class GridManager {
eventBus.emit(CoreEvents.GRID_RENDERED, {
container: this.container,
currentDate: this.currentDate,
startDate: periodRange.startDate,
endDate: periodRange.endDate,
dates: dates,
layoutConfig: layoutConfig,
columnCount: layoutConfig.columnCount
});
@ -131,37 +130,6 @@ export class GridManager {
}
}
/**
* Get period range for current view
*/
private getPeriodRange(): { startDate: Date; endDate: Date } {
switch (this.currentView) {
case 'week':
const weekStart = this.getISOWeekStart(this.currentDate);
const weekEnd = this.getWeekEnd(this.currentDate);
return {
startDate: weekStart,
endDate: weekEnd
};
case 'month':
return {
startDate: this.getMonthStart(this.currentDate),
endDate: this.getMonthEnd(this.currentDate)
};
case 'day':
return {
startDate: this.currentDate,
endDate: this.currentDate
};
default:
const defaultWeekStart = this.getISOWeekStart(this.currentDate);
const defaultWeekEnd = this.getWeekEnd(this.currentDate);
return {
startDate: defaultWeekStart,
endDate: defaultWeekEnd
};
}
}
/**
* Get layout config for current view