Refactor data source and configuration management
Abstracts column data source with interface Updates managers to use configuration-driven view and date Decouples datasource creation from individual managers Improves flexibility and dependency injection for calendar components
This commit is contained in:
parent
0f10d44037
commit
9d270217bd
6 changed files with 31 additions and 17 deletions
|
|
@ -19,14 +19,12 @@ export class DateColumnDataSource implements IColumnDataSource {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
dateService: DateService,
|
dateService: DateService,
|
||||||
config: Configuration,
|
config: Configuration
|
||||||
currentDate: Date,
|
|
||||||
currentView: CalendarView
|
|
||||||
) {
|
) {
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.currentDate = currentDate;
|
this.currentDate = new Date();
|
||||||
this.currentView = currentView;
|
this.currentView = this.config.currentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export class CalendarManager {
|
||||||
private eventRenderer: EventRenderingService;
|
private eventRenderer: EventRenderingService;
|
||||||
private scrollManager: ScrollManager;
|
private scrollManager: ScrollManager;
|
||||||
private config: Configuration;
|
private config: Configuration;
|
||||||
private currentView: CalendarView = 'week';
|
private currentView: CalendarView;
|
||||||
private currentDate: Date = new Date();
|
private currentDate: Date = new Date();
|
||||||
private isInitialized: boolean = false;
|
private isInitialized: boolean = false;
|
||||||
|
|
||||||
|
|
@ -34,6 +34,7 @@ export class CalendarManager {
|
||||||
this.eventRenderer = eventRenderingService;
|
this.eventRenderer = eventRenderingService;
|
||||||
this.scrollManager = scrollManager;
|
this.scrollManager = scrollManager;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.currentView = this.config.currentView;
|
||||||
this.setupEventListeners();
|
this.setupEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { CoreEvents } from '../constants/CoreEvents';
|
||||||
import { CalendarView } from '../types/CalendarTypes';
|
import { CalendarView } from '../types/CalendarTypes';
|
||||||
import { GridRenderer } from '../renderers/GridRenderer';
|
import { GridRenderer } from '../renderers/GridRenderer';
|
||||||
import { DateService } from '../utils/DateService';
|
import { DateService } from '../utils/DateService';
|
||||||
import { DateColumnDataSource } from '../datasources/DateColumnDataSource';
|
import { IColumnDataSource } from '../types/ColumnDataSource';
|
||||||
import { Configuration } from '../configurations/CalendarConfig';
|
import { Configuration } from '../configurations/CalendarConfig';
|
||||||
import { EventManager } from './EventManager';
|
import { EventManager } from './EventManager';
|
||||||
|
|
||||||
|
|
@ -22,20 +22,21 @@ export class GridManager {
|
||||||
private gridRenderer: GridRenderer;
|
private gridRenderer: GridRenderer;
|
||||||
private dateService: DateService;
|
private dateService: DateService;
|
||||||
private config: Configuration;
|
private config: Configuration;
|
||||||
private dataSource: DateColumnDataSource;
|
private dataSource: IColumnDataSource;
|
||||||
private eventManager: EventManager;
|
private eventManager: EventManager;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
gridRenderer: GridRenderer,
|
gridRenderer: GridRenderer,
|
||||||
dateService: DateService,
|
dateService: DateService,
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
eventManager: EventManager
|
eventManager: EventManager,
|
||||||
|
dataSource: IColumnDataSource
|
||||||
) {
|
) {
|
||||||
this.gridRenderer = gridRenderer;
|
this.gridRenderer = gridRenderer;
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.eventManager = eventManager;
|
this.eventManager = eventManager;
|
||||||
this.dataSource = new DateColumnDataSource(dateService, config, this.currentDate, this.currentView);
|
this.dataSource = dataSource;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { CoreEvents } from '../constants/CoreEvents';
|
||||||
import { IHeaderRenderer, IHeaderRenderContext } from '../renderers/DateHeaderRenderer';
|
import { IHeaderRenderer, IHeaderRenderContext } from '../renderers/DateHeaderRenderer';
|
||||||
import { IDragMouseEnterHeaderEventPayload, IDragMouseLeaveHeaderEventPayload, IHeaderReadyEventPayload } from '../types/EventTypes';
|
import { IDragMouseEnterHeaderEventPayload, IDragMouseLeaveHeaderEventPayload, IHeaderReadyEventPayload } from '../types/EventTypes';
|
||||||
import { ColumnDetectionUtils } from '../utils/ColumnDetectionUtils';
|
import { ColumnDetectionUtils } from '../utils/ColumnDetectionUtils';
|
||||||
import { DateColumnDataSource } from '../datasources/DateColumnDataSource';
|
import { IColumnDataSource } from '../types/ColumnDataSource';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HeaderManager - Handles all header-related event logic
|
* HeaderManager - Handles all header-related event logic
|
||||||
|
|
@ -14,9 +14,9 @@ import { DateColumnDataSource } from '../datasources/DateColumnDataSource';
|
||||||
export class HeaderManager {
|
export class HeaderManager {
|
||||||
private headerRenderer: IHeaderRenderer;
|
private headerRenderer: IHeaderRenderer;
|
||||||
private config: Configuration;
|
private config: Configuration;
|
||||||
private dataSource: DateColumnDataSource;
|
private dataSource: IColumnDataSource;
|
||||||
|
|
||||||
constructor(headerRenderer: IHeaderRenderer, config: Configuration, dataSource: DateColumnDataSource) {
|
constructor(headerRenderer: IHeaderRenderer, config: Configuration, dataSource: IColumnDataSource) {
|
||||||
this.headerRenderer = headerRenderer;
|
this.headerRenderer = headerRenderer;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { CoreEvents } from '../constants/CoreEvents';
|
||||||
import { WeekInfoRenderer } from '../renderers/WeekInfoRenderer';
|
import { WeekInfoRenderer } from '../renderers/WeekInfoRenderer';
|
||||||
import { GridRenderer } from '../renderers/GridRenderer';
|
import { GridRenderer } from '../renderers/GridRenderer';
|
||||||
import { INavButtonClickedEventPayload } from '../types/EventTypes';
|
import { INavButtonClickedEventPayload } from '../types/EventTypes';
|
||||||
import { DateColumnDataSource } from '../datasources/DateColumnDataSource';
|
import { IColumnDataSource } from '../types/ColumnDataSource';
|
||||||
import { Configuration } from '../configurations/CalendarConfig';
|
import { Configuration } from '../configurations/CalendarConfig';
|
||||||
|
|
||||||
export class NavigationManager {
|
export class NavigationManager {
|
||||||
|
|
@ -14,7 +14,7 @@ export class NavigationManager {
|
||||||
private gridRenderer: GridRenderer;
|
private gridRenderer: GridRenderer;
|
||||||
private dateService: DateService;
|
private dateService: DateService;
|
||||||
private config: Configuration;
|
private config: Configuration;
|
||||||
private dataSource: DateColumnDataSource;
|
private dataSource: IColumnDataSource;
|
||||||
private currentWeek: Date;
|
private currentWeek: Date;
|
||||||
private targetWeek: Date;
|
private targetWeek: Date;
|
||||||
private animationQueue: number = 0;
|
private animationQueue: number = 0;
|
||||||
|
|
@ -25,7 +25,8 @@ export class NavigationManager {
|
||||||
gridRenderer: GridRenderer,
|
gridRenderer: GridRenderer,
|
||||||
dateService: DateService,
|
dateService: DateService,
|
||||||
weekInfoRenderer: WeekInfoRenderer,
|
weekInfoRenderer: WeekInfoRenderer,
|
||||||
config: Configuration
|
config: Configuration,
|
||||||
|
dataSource: IColumnDataSource
|
||||||
) {
|
) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
|
|
@ -34,7 +35,7 @@ export class NavigationManager {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.currentWeek = this.getISOWeekStart(new Date());
|
this.currentWeek = this.getISOWeekStart(new Date());
|
||||||
this.targetWeek = new Date(this.currentWeek);
|
this.targetWeek = new Date(this.currentWeek);
|
||||||
this.dataSource = new DateColumnDataSource(dateService, config, this.currentWeek, 'week' as CalendarView);
|
this.dataSource = dataSource;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { IResource } from './ResourceTypes';
|
import { IResource } from './ResourceTypes';
|
||||||
|
import { CalendarView } from './CalendarTypes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Column information container
|
* Column information container
|
||||||
|
|
@ -26,4 +27,16 @@ export interface IColumnDataSource {
|
||||||
* Get the type of columns this datasource provides
|
* Get the type of columns this datasource provides
|
||||||
*/
|
*/
|
||||||
getType(): 'date' | 'resource';
|
getType(): 'date' | 'resource';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the current date for column calculations
|
||||||
|
* @param date - The new current date
|
||||||
|
*/
|
||||||
|
setCurrentDate(date: Date): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the current view (day/week/month)
|
||||||
|
* @param view - The new calendar view
|
||||||
|
*/
|
||||||
|
setCurrentView(view: CalendarView): void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue