Refactors calendar type to calendar mode

Updates the codebase to utilize `CalendarMode` instead of the deprecated `CalendarType`.

Simplifies `CalendarConfig` by removing legacy methods and related type aliases, enhancing code maintainability and clarity.

Improves event rendering by ensuring `GRID_RENDERED` events include explicit start and end dates, preventing errors and ensuring correct data filtering.
This commit is contained in:
Janus Knudsen 2025-08-20 21:51:49 +02:00
parent 83c0ce801c
commit 0ea4e47324
10 changed files with 61 additions and 91 deletions

View file

@ -142,6 +142,22 @@ export class MonthViewStrategy implements ViewStrategy {
return this.getMonthDates(baseDate);
}
getPeriodRange(baseDate: Date): { startDate: Date; endDate: Date } {
// Month view shows events for the entire month grid (including partial weeks)
const firstOfMonth = new Date(baseDate.getFullYear(), baseDate.getMonth(), 1);
// Get Monday of the week containing first day
const startDate = this.dateCalculator.getISOWeekStart(firstOfMonth);
// End date is 41 days after start (42 total days)
const endDate = this.dateCalculator.addDays(startDate, 41);
return {
startDate,
endDate
};
}
destroy(): void {
console.log('MonthViewStrategy: Cleaning up');
}

View file

@ -60,6 +60,11 @@ export interface ViewStrategy {
*/
getDisplayDates(baseDate: Date): Date[];
/**
* Get the period start and end dates for event filtering
*/
getPeriodRange(baseDate: Date): { startDate: Date; endDate: Date };
/**
* Clean up any view-specific resources
*/

View file

@ -67,6 +67,16 @@ export class WeekViewStrategy implements ViewStrategy {
return this.dateCalculator.getWorkWeekDates(baseDate);
}
getPeriodRange(baseDate: Date): { startDate: Date; endDate: Date } {
const weekStart = this.dateCalculator.getISOWeekStart(baseDate);
const weekEnd = this.dateCalculator.addDays(weekStart, 6);
return {
startDate: weekStart,
endDate: weekEnd
};
}
destroy(): void {
// Clean up any week-specific resources
// For now, just log