2025-08-20 19:52:18 +02:00
|
|
|
/**
|
|
|
|
|
* WeekViewStrategy - Strategy for week/day view rendering
|
|
|
|
|
* Extracts the time-based grid logic from GridManager
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { ViewStrategy, ViewContext, ViewLayoutConfig } from './ViewStrategy';
|
|
|
|
|
import { DateCalculator } from '../utils/DateCalculator';
|
|
|
|
|
import { calendarConfig } from '../core/CalendarConfig';
|
|
|
|
|
import { GridRenderer } from '../renderers/GridRenderer';
|
|
|
|
|
import { GridStyleManager } from '../renderers/GridStyleManager';
|
|
|
|
|
|
|
|
|
|
export class WeekViewStrategy implements ViewStrategy {
|
|
|
|
|
private dateCalculator: DateCalculator;
|
|
|
|
|
private gridRenderer: GridRenderer;
|
|
|
|
|
private styleManager: GridStyleManager;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.dateCalculator = new DateCalculator(calendarConfig);
|
|
|
|
|
this.gridRenderer = new GridRenderer(calendarConfig);
|
|
|
|
|
this.styleManager = new GridStyleManager(calendarConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLayoutConfig(): ViewLayoutConfig {
|
|
|
|
|
return {
|
|
|
|
|
needsTimeAxis: true,
|
|
|
|
|
columnCount: calendarConfig.getWorkWeekSettings().totalDays,
|
|
|
|
|
scrollable: true,
|
|
|
|
|
eventPositioning: 'time-based'
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderGrid(context: ViewContext): void {
|
|
|
|
|
// Update grid styles
|
|
|
|
|
this.styleManager.updateGridStyles(context.resourceData);
|
|
|
|
|
|
|
|
|
|
// Render the grid structure (time axis + day columns)
|
|
|
|
|
this.gridRenderer.renderGrid(
|
|
|
|
|
context.container,
|
|
|
|
|
context.currentDate,
|
2025-08-24 00:13:07 +02:00
|
|
|
context.resourceData
|
2025-08-20 19:52:18 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getNextPeriod(currentDate: Date): Date {
|
|
|
|
|
return this.dateCalculator.addWeeks(currentDate, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPreviousPeriod(currentDate: Date): Date {
|
|
|
|
|
return this.dateCalculator.addWeeks(currentDate, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPeriodLabel(date: Date): string {
|
|
|
|
|
const weekStart = this.dateCalculator.getISOWeekStart(date);
|
|
|
|
|
const weekEnd = this.dateCalculator.addDays(weekStart, 6);
|
|
|
|
|
const weekNumber = this.dateCalculator.getWeekNumber(date);
|
|
|
|
|
|
|
|
|
|
return `Week ${weekNumber}: ${this.dateCalculator.formatDateRange(weekStart, weekEnd)}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDisplayDates(baseDate: Date): Date[] {
|
|
|
|
|
return this.dateCalculator.getWorkWeekDates(baseDate);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-20 21:51:49 +02:00
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-20 19:52:18 +02:00
|
|
|
destroy(): void {
|
|
|
|
|
// Clean up any week-specific resources
|
|
|
|
|
}
|
|
|
|
|
}
|