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;
|
title: string;
|
||||||
start: string | Date;
|
start: string | Date;
|
||||||
end: string | Date;
|
end: string | Date;
|
||||||
|
type : string;
|
||||||
color?: string;
|
color?: string;
|
||||||
allDay?: boolean;
|
allDay?: boolean;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
|
|
@ -88,7 +89,7 @@ export class EventManager {
|
||||||
...event,
|
...event,
|
||||||
start: new Date(event.start),
|
start: new Date(event.start),
|
||||||
end: new Date(event.end),
|
end: new Date(event.end),
|
||||||
type: 'event',
|
type : event.type,
|
||||||
allDay: event.allDay || false,
|
allDay: event.allDay || false,
|
||||||
syncStatus: 'synced' as const
|
syncStatus: 'synced' as const
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ export class NavigationManager {
|
||||||
private currentWeek: Date;
|
private currentWeek: Date;
|
||||||
private targetWeek: Date;
|
private targetWeek: Date;
|
||||||
private animationQueue: number = 0;
|
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) {
|
constructor(eventBus: IEventBus, eventRenderer: EventRenderingService) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
@ -33,38 +29,15 @@ export class NavigationManager {
|
||||||
|
|
||||||
private init(): void {
|
private init(): void {
|
||||||
this.setupEventListeners();
|
this.setupEventListeners();
|
||||||
// Don't update week info immediately - wait for DOM to be ready
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cached calendar container element
|
|
||||||
*/
|
|
||||||
private getCalendarContainer(): HTMLElement | null {
|
private getCalendarContainer(): HTMLElement | null {
|
||||||
if (!this.cachedCalendarContainer) {
|
return document.querySelector('swp-calendar-container');
|
||||||
this.cachedCalendarContainer = document.querySelector('swp-calendar-container');
|
|
||||||
}
|
|
||||||
return this.cachedCalendarContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cached current grid element
|
|
||||||
*/
|
|
||||||
private getCurrentGrid(): HTMLElement | null {
|
private getCurrentGrid(): HTMLElement | null {
|
||||||
const container = this.getCalendarContainer();
|
return document.querySelector('swp-calendar-container swp-grid-container:not([data-prerendered])');
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupEventListeners(): void {
|
private setupEventListeners(): void {
|
||||||
|
|
@ -274,28 +247,6 @@ export class NavigationManager {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
root.style.setProperty('--all-day-row-height', '0px');
|
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
|
// Update state
|
||||||
this.currentWeek = new Date(targetWeek);
|
this.currentWeek = new Date(targetWeek);
|
||||||
this.animationQueue--;
|
this.animationQueue--;
|
||||||
|
|
@ -361,5 +312,4 @@ export class NavigationManager {
|
||||||
this.updateWeekInfo();
|
this.updateWeekInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering methods moved to NavigationRenderer for better separation of concerns
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue