Supports dynamic event types; refactors navigation DOM access
Enables dynamic event types by reading the 'type' field from raw event data instead of using a hardcoded value. Removes DOM element caching for calendar and grid containers in the navigation manager, opting for direct DOM queries. Eliminates associated cache clearing and post-animation header event emission.
This commit is contained in:
parent
48d1fd681c
commit
32894cca82
2 changed files with 5 additions and 54 deletions
|
|
@ -10,6 +10,7 @@ interface RawEventData {
|
|||
title: string;
|
||||
start: string | Date;
|
||||
end: string | Date;
|
||||
type : string;
|
||||
color?: string;
|
||||
allDay?: boolean;
|
||||
[key: string]: unknown;
|
||||
|
|
@ -88,7 +89,7 @@ export class EventManager {
|
|||
...event,
|
||||
start: new Date(event.start),
|
||||
end: new Date(event.end),
|
||||
type: 'event',
|
||||
type : event.type,
|
||||
allDay: event.allDay || false,
|
||||
syncStatus: 'synced' as const
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ export class NavigationManager {
|
|||
private targetWeek: Date;
|
||||
private animationQueue: number = 0;
|
||||
|
||||
// Cached DOM elements to avoid redundant queries
|
||||
private cachedCalendarContainer: HTMLElement | null = null;
|
||||
private cachedCurrentGrid: HTMLElement | null = null;
|
||||
|
||||
constructor(eventBus: IEventBus, eventRenderer: EventRenderingService) {
|
||||
this.eventBus = eventBus;
|
||||
DateCalculator.initialize(calendarConfig);
|
||||
|
|
@ -33,38 +29,15 @@ export class NavigationManager {
|
|||
|
||||
private init(): void {
|
||||
this.setupEventListeners();
|
||||
// Don't update week info immediately - wait for DOM to be ready
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cached calendar container element
|
||||
*/
|
||||
|
||||
private getCalendarContainer(): HTMLElement | null {
|
||||
if (!this.cachedCalendarContainer) {
|
||||
this.cachedCalendarContainer = document.querySelector('swp-calendar-container');
|
||||
}
|
||||
return this.cachedCalendarContainer;
|
||||
return document.querySelector('swp-calendar-container');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cached current grid element
|
||||
*/
|
||||
private getCurrentGrid(): HTMLElement | null {
|
||||
const container = this.getCalendarContainer();
|
||||
if (!container) return null;
|
||||
|
||||
if (!this.cachedCurrentGrid) {
|
||||
this.cachedCurrentGrid = container.querySelector('swp-grid-container:not([data-prerendered])');
|
||||
}
|
||||
return this.cachedCurrentGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear cached DOM elements (call when DOM structure changes)
|
||||
*/
|
||||
private clearCache(): void {
|
||||
this.cachedCalendarContainer = null;
|
||||
this.cachedCurrentGrid = null;
|
||||
return document.querySelector('swp-calendar-container swp-grid-container:not([data-prerendered])');
|
||||
}
|
||||
|
||||
private setupEventListeners(): void {
|
||||
|
|
@ -274,28 +247,6 @@ export class NavigationManager {
|
|||
const root = document.documentElement;
|
||||
root.style.setProperty('--all-day-row-height', '0px');
|
||||
|
||||
const header = newGrid.querySelector('swp-calendar-header') as HTMLElement;
|
||||
if (header) {
|
||||
// Remove the hardcoded 0px height
|
||||
header.style.height = '';
|
||||
header.style.height
|
||||
// NOW emit header:ready for this specific container
|
||||
const weekEnd = DateCalculator.addDays(targetWeek, 6);
|
||||
this.eventBus.emit('header:ready', {
|
||||
headerElement: header,
|
||||
startDate: targetWeek,
|
||||
endDate: weekEnd,
|
||||
isNavigation: true
|
||||
});
|
||||
|
||||
console.log('🎯 NavigationManager: Animation complete, emitted header:ready', {
|
||||
weekStart: targetWeek.toISOString()
|
||||
});
|
||||
}
|
||||
|
||||
// Clear cache since DOM structure changed
|
||||
this.clearCache();
|
||||
|
||||
// Update state
|
||||
this.currentWeek = new Date(targetWeek);
|
||||
this.animationQueue--;
|
||||
|
|
@ -361,5 +312,4 @@ export class NavigationManager {
|
|||
this.updateWeekInfo();
|
||||
}
|
||||
|
||||
// Rendering methods moved to NavigationRenderer for better separation of concerns
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue