Refactor calendar datasource architecture
Centralizes date calculation logic into DateColumnDataSource Improves separation of concerns across rendering components Key changes: - Introduces IColumnInfo interface for flexible column data - Moves date calculation from multiple managers to dedicated datasource - Removes duplicate date rendering logic - Prepares architecture for future resource-based views
This commit is contained in:
parent
75a2d4913e
commit
f86ae09ec3
15 changed files with 885 additions and 76 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { IColumnDataSource } from '../types/ColumnDataSource';
|
||||
import { IColumnDataSource, IColumnInfo } from '../types/ColumnDataSource';
|
||||
import { DateService } from '../utils/DateService';
|
||||
import { Configuration } from '../configurations/CalendarConfig';
|
||||
import { CalendarView } from '../types/CalendarTypes';
|
||||
|
|
@ -32,17 +32,28 @@ export class DateColumnDataSource implements IColumnDataSource {
|
|||
/**
|
||||
* Get columns (dates) to display
|
||||
*/
|
||||
public getColumns(): Date[] {
|
||||
public getColumns(): IColumnInfo[] {
|
||||
let dates: Date[];
|
||||
|
||||
switch (this.currentView) {
|
||||
case 'week':
|
||||
return this.getWeekDates();
|
||||
dates = this.getWeekDates();
|
||||
break;
|
||||
case 'month':
|
||||
return this.getMonthDates();
|
||||
dates = this.getMonthDates();
|
||||
break;
|
||||
case 'day':
|
||||
return [this.currentDate];
|
||||
dates = [this.currentDate];
|
||||
break;
|
||||
default:
|
||||
return this.getWeekDates();
|
||||
dates = this.getWeekDates();
|
||||
}
|
||||
|
||||
// Convert Date[] to IColumnInfo[]
|
||||
return dates.map(date => ({
|
||||
identifier: this.dateService.formatISODate(date),
|
||||
data: date
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue