Renaming part 1
This commit is contained in:
parent
36ac8d18ab
commit
29811fd4b5
20 changed files with 1424 additions and 582 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { eventBus } from './EventBus';
|
||||
import { EventTypes } from '../constants/EventTypes';
|
||||
import { CalendarConfig as ICalendarConfig, ViewType } from '../types/CalendarTypes';
|
||||
import { CalendarConfig as ICalendarConfig, ViewType, CalendarType } from '../types/CalendarTypes';
|
||||
|
||||
/**
|
||||
* View-specific settings interface
|
||||
|
|
@ -18,6 +18,8 @@ interface ViewSettings {
|
|||
*/
|
||||
export class CalendarConfig {
|
||||
private config: ICalendarConfig;
|
||||
private calendarType: CalendarType = 'date';
|
||||
private selectedDate: Date | null = null;
|
||||
|
||||
constructor() {
|
||||
this.config = {
|
||||
|
|
@ -69,10 +71,46 @@ export class CalendarConfig {
|
|||
// Set computed values
|
||||
this.config.minEventDuration = this.config.snapInterval;
|
||||
|
||||
// Load calendar type from URL parameter
|
||||
this.loadCalendarType();
|
||||
|
||||
// Load from data attributes
|
||||
this.loadFromDOM();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load calendar type and date from URL parameters
|
||||
*/
|
||||
private loadCalendarType(): void {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const typeParam = urlParams.get('type');
|
||||
const dateParam = urlParams.get('date');
|
||||
|
||||
// Set calendar type
|
||||
if (typeParam === 'resource' || typeParam === 'date') {
|
||||
this.calendarType = typeParam;
|
||||
console.log(`CalendarConfig: Calendar type set to '${this.calendarType}' from URL parameter`);
|
||||
} else {
|
||||
this.calendarType = 'date'; // Default
|
||||
console.log(`CalendarConfig: Calendar type defaulted to '${this.calendarType}'`);
|
||||
}
|
||||
|
||||
// Set selected date
|
||||
if (dateParam) {
|
||||
const parsedDate = new Date(dateParam);
|
||||
if (!isNaN(parsedDate.getTime())) {
|
||||
this.selectedDate = parsedDate;
|
||||
console.log(`CalendarConfig: Selected date set to '${this.selectedDate.toISOString()}' from URL parameter`);
|
||||
} else {
|
||||
console.warn(`CalendarConfig: Invalid date parameter '${dateParam}', using current date`);
|
||||
this.selectedDate = new Date();
|
||||
}
|
||||
} else {
|
||||
this.selectedDate = new Date(); // Default to today
|
||||
console.log(`CalendarConfig: Selected date defaulted to today: ${this.selectedDate.toISOString()}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration from DOM data attributes
|
||||
*/
|
||||
|
|
@ -194,6 +232,46 @@ export class CalendarConfig {
|
|||
|
||||
return settings[view] || settings.week;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calendar type
|
||||
*/
|
||||
getCalendarType(): CalendarType {
|
||||
return this.calendarType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set calendar type
|
||||
*/
|
||||
setCalendarType(type: CalendarType): void {
|
||||
const oldType = this.calendarType;
|
||||
this.calendarType = type;
|
||||
|
||||
// Emit calendar type change event
|
||||
eventBus.emit(EventTypes.CALENDAR_TYPE_CHANGED, {
|
||||
oldType,
|
||||
newType: type
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected date
|
||||
*/
|
||||
getSelectedDate(): Date | null {
|
||||
return this.selectedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set selected date
|
||||
*/
|
||||
setSelectedDate(date: Date): void {
|
||||
this.selectedDate = date;
|
||||
|
||||
// Emit date change event
|
||||
eventBus.emit(EventTypes.SELECTED_DATE_CHANGED, {
|
||||
date: date
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create singleton instance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue