Refactors grid date handling and event rendering
Replaces getPeriodRange with getDisplayDates approach Simplifies event rendering by using flexible date array Updates event rendering to work with dynamic date lists Improves code modularity and reduces complexity
This commit is contained in:
parent
5075b71eb2
commit
f0cc9bb6ce
3 changed files with 9 additions and 38 deletions
|
|
@ -94,8 +94,8 @@ export class GridManager {
|
|||
this.currentDate
|
||||
);
|
||||
|
||||
// Calculate period range
|
||||
const periodRange = this.getPeriodRange();
|
||||
// Get display dates for current view
|
||||
const dates = this.getDisplayDates();
|
||||
|
||||
// Get layout config based on current view
|
||||
const layoutConfig = this.getLayoutConfig();
|
||||
|
|
@ -104,8 +104,7 @@ export class GridManager {
|
|||
eventBus.emit(CoreEvents.GRID_RENDERED, {
|
||||
container: this.container,
|
||||
currentDate: this.currentDate,
|
||||
startDate: periodRange.startDate,
|
||||
endDate: periodRange.endDate,
|
||||
dates: dates,
|
||||
layoutConfig: layoutConfig,
|
||||
columnCount: layoutConfig.columnCount
|
||||
});
|
||||
|
|
@ -131,37 +130,6 @@ export class GridManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get period range for current view
|
||||
*/
|
||||
private getPeriodRange(): { startDate: Date; endDate: Date } {
|
||||
switch (this.currentView) {
|
||||
case 'week':
|
||||
const weekStart = this.getISOWeekStart(this.currentDate);
|
||||
const weekEnd = this.getWeekEnd(this.currentDate);
|
||||
return {
|
||||
startDate: weekStart,
|
||||
endDate: weekEnd
|
||||
};
|
||||
case 'month':
|
||||
return {
|
||||
startDate: this.getMonthStart(this.currentDate),
|
||||
endDate: this.getMonthEnd(this.currentDate)
|
||||
};
|
||||
case 'day':
|
||||
return {
|
||||
startDate: this.currentDate,
|
||||
endDate: this.currentDate
|
||||
};
|
||||
default:
|
||||
const defaultWeekStart = this.getISOWeekStart(this.currentDate);
|
||||
const defaultWeekEnd = this.getWeekEnd(this.currentDate);
|
||||
return {
|
||||
startDate: defaultWeekStart,
|
||||
endDate: defaultWeekEnd
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout config for current view
|
||||
|
|
|
|||
|
|
@ -91,12 +91,16 @@ export class EventRenderingService {
|
|||
* Handle GRID_RENDERED event - render events in the current grid
|
||||
*/
|
||||
private handleGridRendered(event: CustomEvent): void {
|
||||
const { container, startDate, endDate } = event.detail;
|
||||
const { container, dates } = event.detail;
|
||||
|
||||
if (!container || !startDate || !endDate) {
|
||||
if (!container || !dates || dates.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate startDate and endDate from dates array
|
||||
const startDate = dates[0];
|
||||
const endDate = dates[dates.length - 1];
|
||||
|
||||
this.renderEvents({
|
||||
container,
|
||||
startDate,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ export interface IEventRenderingService extends IManager {
|
|||
|
||||
export interface IGridManager extends IManager {
|
||||
render(): Promise<void>;
|
||||
getDisplayDates(): Date[];
|
||||
}
|
||||
|
||||
export interface IScrollManager extends IManager {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue