Batch update, WIP
This commit is contained in:
parent
8ec5f52872
commit
989c9bd69d
25 changed files with 68 additions and 123 deletions
|
|
@ -1,179 +0,0 @@
|
|||
import { ICalendarConfig } from './ICalendarConfig';
|
||||
import { IGridSettings } from './GridSettings';
|
||||
import { IDateViewSettings } from './DateViewSettings';
|
||||
import { ITimeFormatConfig } from './TimeFormatConfig';
|
||||
import { IWorkWeekSettings } from './WorkWeekSettings';
|
||||
|
||||
/**
|
||||
* All-day event layout constants
|
||||
*/
|
||||
export const ALL_DAY_CONSTANTS = {
|
||||
EVENT_HEIGHT: 22,
|
||||
EVENT_GAP: 2,
|
||||
CONTAINER_PADDING: 4,
|
||||
MAX_COLLAPSED_ROWS: 4,
|
||||
get SINGLE_ROW_HEIGHT() {
|
||||
return this.EVENT_HEIGHT + this.EVENT_GAP; // 28px
|
||||
}
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Work week presets
|
||||
*/
|
||||
export const WORK_WEEK_PRESETS: { [key: string]: IWorkWeekSettings } = {
|
||||
'standard': {
|
||||
id: 'standard',
|
||||
workDays: [1, 2, 3, 4, 5],
|
||||
totalDays: 5,
|
||||
firstWorkDay: 1
|
||||
},
|
||||
'compressed': {
|
||||
id: 'compressed',
|
||||
workDays: [1, 2, 3, 4],
|
||||
totalDays: 4,
|
||||
firstWorkDay: 1
|
||||
},
|
||||
'midweek': {
|
||||
id: 'midweek',
|
||||
workDays: [3, 4, 5],
|
||||
totalDays: 3,
|
||||
firstWorkDay: 3
|
||||
},
|
||||
'weekend': {
|
||||
id: 'weekend',
|
||||
workDays: [6, 7],
|
||||
totalDays: 2,
|
||||
firstWorkDay: 6
|
||||
},
|
||||
'fullweek': {
|
||||
id: 'fullweek',
|
||||
workDays: [1, 2, 3, 4, 5, 6, 7],
|
||||
totalDays: 7,
|
||||
firstWorkDay: 1
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Configuration - DTO container for all configuration
|
||||
* Pure data object loaded from JSON via ConfigManager
|
||||
*/
|
||||
export class Configuration {
|
||||
private static _instance: Configuration | null = null;
|
||||
|
||||
public config: ICalendarConfig;
|
||||
public gridSettings: IGridSettings;
|
||||
public dateViewSettings: IDateViewSettings;
|
||||
public timeFormatConfig: ITimeFormatConfig;
|
||||
public currentWorkWeek: string;
|
||||
public selectedDate: Date;
|
||||
|
||||
constructor(
|
||||
config: ICalendarConfig,
|
||||
gridSettings: IGridSettings,
|
||||
dateViewSettings: IDateViewSettings,
|
||||
timeFormatConfig: ITimeFormatConfig,
|
||||
currentWorkWeek: string,
|
||||
selectedDate: Date = new Date()
|
||||
) {
|
||||
this.config = config;
|
||||
this.gridSettings = gridSettings;
|
||||
this.dateViewSettings = dateViewSettings;
|
||||
this.timeFormatConfig = timeFormatConfig;
|
||||
this.currentWorkWeek = currentWorkWeek;
|
||||
this.selectedDate = selectedDate;
|
||||
|
||||
// Store as singleton instance for web components
|
||||
Configuration._instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Configuration instance
|
||||
* Used by web components that can't use dependency injection
|
||||
*/
|
||||
public static getInstance(): Configuration {
|
||||
if (!Configuration._instance) {
|
||||
throw new Error('Configuration has not been initialized. Call ConfigManager.load() first.');
|
||||
}
|
||||
return Configuration._instance;
|
||||
}
|
||||
|
||||
// Computed properties
|
||||
get minuteHeight(): number {
|
||||
return this.gridSettings.hourHeight / 60;
|
||||
}
|
||||
|
||||
get totalHours(): number {
|
||||
return this.gridSettings.dayEndHour - this.gridSettings.dayStartHour;
|
||||
}
|
||||
|
||||
get totalMinutes(): number {
|
||||
return this.totalHours * 60;
|
||||
}
|
||||
|
||||
get slotsPerHour(): number {
|
||||
return 60 / this.gridSettings.snapInterval;
|
||||
}
|
||||
|
||||
get totalSlots(): number {
|
||||
return this.totalHours * this.slotsPerHour;
|
||||
}
|
||||
|
||||
get slotHeight(): number {
|
||||
return this.gridSettings.hourHeight / this.slotsPerHour;
|
||||
}
|
||||
|
||||
// Backward compatibility getters
|
||||
getGridSettings(): IGridSettings {
|
||||
return this.gridSettings;
|
||||
}
|
||||
|
||||
getDateViewSettings(): IDateViewSettings {
|
||||
return this.dateViewSettings;
|
||||
}
|
||||
|
||||
getWorkWeekSettings(): IWorkWeekSettings {
|
||||
return WORK_WEEK_PRESETS[this.currentWorkWeek] || WORK_WEEK_PRESETS['standard'];
|
||||
}
|
||||
|
||||
getCurrentWorkWeek(): string {
|
||||
return this.currentWorkWeek;
|
||||
}
|
||||
|
||||
getTimezone(): string {
|
||||
return this.timeFormatConfig.timezone;
|
||||
}
|
||||
|
||||
getLocale(): string {
|
||||
return this.timeFormatConfig.locale;
|
||||
}
|
||||
|
||||
getTimeFormatSettings(): ITimeFormatConfig {
|
||||
return this.timeFormatConfig;
|
||||
}
|
||||
|
||||
is24HourFormat(): boolean {
|
||||
return this.timeFormatConfig.use24HourFormat;
|
||||
}
|
||||
|
||||
getDateFormat(): 'locale' | 'technical' {
|
||||
return this.timeFormatConfig.dateFormat;
|
||||
}
|
||||
|
||||
setWorkWeek(workWeekId: string): void {
|
||||
if (WORK_WEEK_PRESETS[workWeekId]) {
|
||||
this.currentWorkWeek = workWeekId;
|
||||
this.dateViewSettings.weekDays = WORK_WEEK_PRESETS[workWeekId].totalDays;
|
||||
}
|
||||
}
|
||||
|
||||
setSelectedDate(date: Date): void {
|
||||
this.selectedDate = date;
|
||||
}
|
||||
|
||||
isValidSnapInterval(interval: number): boolean {
|
||||
return [5, 10, 15, 30, 60].includes(interval);
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility alias
|
||||
export { Configuration as CalendarConfig };
|
||||
Loading…
Add table
Add a link
Reference in a new issue