58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
/**
|
|
* ViewStrategy - Strategy pattern for different calendar view types
|
|
* Allows clean separation between week view, month view, day view etc.
|
|
*/
|
|
import { ResourceCalendarData } from '../types/CalendarTypes';
|
|
/**
|
|
* Context object passed to strategy methods
|
|
*/
|
|
export interface ViewContext {
|
|
currentDate: Date;
|
|
container: HTMLElement;
|
|
resourceData: ResourceCalendarData | null;
|
|
}
|
|
/**
|
|
* Layout configuration specific to each view type
|
|
*/
|
|
export interface ViewLayoutConfig {
|
|
needsTimeAxis: boolean;
|
|
columnCount: number;
|
|
scrollable: boolean;
|
|
eventPositioning: 'time-based' | 'cell-based';
|
|
}
|
|
/**
|
|
* Base strategy interface for all view types
|
|
*/
|
|
export interface ViewStrategy {
|
|
/**
|
|
* Get the layout configuration for this view
|
|
*/
|
|
getLayoutConfig(): ViewLayoutConfig;
|
|
/**
|
|
* Render the grid structure for this view
|
|
*/
|
|
renderGrid(context: ViewContext): void;
|
|
/**
|
|
* Calculate next period for navigation
|
|
*/
|
|
getNextPeriod(currentDate: Date): Date;
|
|
/**
|
|
* Calculate previous period for navigation
|
|
*/
|
|
getPreviousPeriod(currentDate: Date): Date;
|
|
/**
|
|
* Get display label for current period
|
|
*/
|
|
getPeriodLabel(date: Date): string;
|
|
/**
|
|
* Get the dates that should be displayed in this view
|
|
*/
|
|
getDisplayDates(baseDate: Date): Date[];
|
|
/**
|
|
* Get the period start and end dates for event filtering
|
|
*/
|
|
getPeriodRange(baseDate: Date): {
|
|
startDate: Date;
|
|
endDate: Date;
|
|
};
|
|
}
|