Refactors event emission for date and workweek changes
Moves event emission responsibilities for date and workweek changes to the calling components. This allows for consolidated updates and optimized event handling, avoiding redundant emissions and ensuring that events are triggered with the correct payload.
This commit is contained in:
parent
5b0ae0ca5c
commit
ee4b9b3707
3 changed files with 12 additions and 31 deletions
|
|
@ -207,20 +207,6 @@ export class GridManager {
|
|||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to today
|
||||
*/
|
||||
public navigateToToday(): void {
|
||||
this.currentDate = new Date();
|
||||
|
||||
eventBus.emit(CoreEvents.DATE_CHANGED, {
|
||||
newDate: this.currentDate,
|
||||
periodLabel: this.getCurrentPeriodLabel()
|
||||
});
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current view's display dates
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -139,14 +139,18 @@ export class ViewManager {
|
|||
* Optimized workweek change with consolidated updates
|
||||
*/
|
||||
private changeWorkweek(workweekId: string): void {
|
||||
// Update the calendar config
|
||||
// Update the calendar config (does not emit events)
|
||||
calendarConfig.setWorkWeek(workweekId);
|
||||
|
||||
|
||||
// Update button states using cached elements
|
||||
this.updateAllButtons();
|
||||
|
||||
// Trigger a workweek change to apply the new workweek
|
||||
this.eventBus.emit(CoreEvents.WORKWEEK_CHANGED);
|
||||
|
||||
// Emit workweek change event with full payload
|
||||
const settings = calendarConfig.getWorkWeekSettings();
|
||||
this.eventBus.emit(CoreEvents.WORKWEEK_CHANGED, {
|
||||
workWeekId: workweekId,
|
||||
settings: settings
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue