Refactor calendar event constants and imports
Separates calendar-specific events into a dedicated CalendarEvents constant Removes calendar command events from CoreEvents Updates imports and event bus references across related files
This commit is contained in:
parent
66dfe9f2ef
commit
b2c81dc163
4 changed files with 28 additions and 24 deletions
|
|
@ -67,13 +67,5 @@ export const CoreEvents = {
|
||||||
AUDIT_LOGGED: 'audit:logged',
|
AUDIT_LOGGED: 'audit:logged',
|
||||||
|
|
||||||
// Rendering events
|
// Rendering events
|
||||||
EVENTS_RENDERED: 'events:rendered',
|
EVENTS_RENDERED: 'events:rendered'
|
||||||
|
|
||||||
// Calendar command events
|
|
||||||
CALENDAR_CMD_NAVIGATE_PREV: 'calendar:cmd:navigate:prev',
|
|
||||||
CALENDAR_CMD_NAVIGATE_NEXT: 'calendar:cmd:navigate:next',
|
|
||||||
CALENDAR_CMD_DRAWER_TOGGLE: 'calendar:cmd:drawer:toggle',
|
|
||||||
CALENDAR_CMD_RENDER: 'calendar:cmd:render',
|
|
||||||
CALENDAR_CMD_WORKWEEK_CHANGE: 'calendar:cmd:workweek:change',
|
|
||||||
CALENDAR_CMD_VIEW_UPDATE: 'calendar:cmd:view:update'
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { ResourceService } from '../storage/resources/ResourceService';
|
||||||
import { ViewConfigService } from '../storage/viewconfigs/ViewConfigService';
|
import { ViewConfigService } from '../storage/viewconfigs/ViewConfigService';
|
||||||
import { IWorkweekPreset } from '../types/SettingsTypes';
|
import { IWorkweekPreset } from '../types/SettingsTypes';
|
||||||
import { IEventBus } from '../types/CalendarTypes';
|
import { IEventBus } from '../types/CalendarTypes';
|
||||||
import { CoreEvents } from '../constants/CoreEvents';
|
import { CalendarEvents } from './CalendarEvents';
|
||||||
|
|
||||||
export class CalendarApp {
|
export class CalendarApp {
|
||||||
private animator!: NavigationAnimator;
|
private animator!: NavigationAnimator;
|
||||||
|
|
@ -79,33 +79,33 @@ export class CalendarApp {
|
||||||
|
|
||||||
private setupEventListeners(): void {
|
private setupEventListeners(): void {
|
||||||
// Navigation commands via EventBus
|
// Navigation commands via EventBus
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_NAVIGATE_PREV, () => {
|
this.eventBus.on(CalendarEvents.CMD_NAVIGATE_PREV, () => {
|
||||||
this.handleNavigatePrev();
|
this.handleNavigatePrev();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_NAVIGATE_NEXT, () => {
|
this.eventBus.on(CalendarEvents.CMD_NAVIGATE_NEXT, () => {
|
||||||
this.handleNavigateNext();
|
this.handleNavigateNext();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Drawer toggle via EventBus
|
// Drawer toggle via EventBus
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_DRAWER_TOGGLE, () => {
|
this.eventBus.on(CalendarEvents.CMD_DRAWER_TOGGLE, () => {
|
||||||
this.headerDrawerManager.toggle();
|
this.headerDrawerManager.toggle();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Render command via EventBus
|
// Render command via EventBus
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_RENDER, ((e: CustomEvent) => {
|
this.eventBus.on(CalendarEvents.CMD_RENDER, ((e: CustomEvent) => {
|
||||||
const { viewId } = e.detail;
|
const { viewId } = e.detail;
|
||||||
this.handleRenderCommand(viewId);
|
this.handleRenderCommand(viewId);
|
||||||
}) as EventListener);
|
}) as EventListener);
|
||||||
|
|
||||||
// Workweek change via EventBus
|
// Workweek change via EventBus
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_WORKWEEK_CHANGE, ((e: CustomEvent) => {
|
this.eventBus.on(CalendarEvents.CMD_WORKWEEK_CHANGE, ((e: CustomEvent) => {
|
||||||
const { presetId } = e.detail;
|
const { presetId } = e.detail;
|
||||||
this.handleWorkweekChange(presetId);
|
this.handleWorkweekChange(presetId);
|
||||||
}) as EventListener);
|
}) as EventListener);
|
||||||
|
|
||||||
// View update via EventBus
|
// View update via EventBus
|
||||||
this.eventBus.on(CoreEvents.CALENDAR_CMD_VIEW_UPDATE, ((e: CustomEvent) => {
|
this.eventBus.on(CalendarEvents.CMD_VIEW_UPDATE, ((e: CustomEvent) => {
|
||||||
const { type, values } = e.detail;
|
const { type, values } = e.detail;
|
||||||
this.handleViewUpdate(type, values);
|
this.handleViewUpdate(type, values);
|
||||||
}) as EventListener);
|
}) as EventListener);
|
||||||
|
|
|
||||||
12
src/v2/core/CalendarEvents.ts
Normal file
12
src/v2/core/CalendarEvents.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
/**
|
||||||
|
* CalendarEvents - Command and status events for CalendarApp
|
||||||
|
*/
|
||||||
|
export const CalendarEvents = {
|
||||||
|
// Command events (host → calendar)
|
||||||
|
CMD_NAVIGATE_PREV: 'calendar:cmd:navigate:prev',
|
||||||
|
CMD_NAVIGATE_NEXT: 'calendar:cmd:navigate:next',
|
||||||
|
CMD_DRAWER_TOGGLE: 'calendar:cmd:drawer:toggle',
|
||||||
|
CMD_RENDER: 'calendar:cmd:render',
|
||||||
|
CMD_WORKWEEK_CHANGE: 'calendar:cmd:workweek:change',
|
||||||
|
CMD_VIEW_UPDATE: 'calendar:cmd:view:update'
|
||||||
|
} as const;
|
||||||
|
|
@ -5,7 +5,7 @@ import { CalendarApp } from '../core/CalendarApp';
|
||||||
import { DateService } from '../core/DateService';
|
import { DateService } from '../core/DateService';
|
||||||
import { ResourceService } from '../storage/resources/ResourceService';
|
import { ResourceService } from '../storage/resources/ResourceService';
|
||||||
import { IEventBus } from '../types/CalendarTypes';
|
import { IEventBus } from '../types/CalendarTypes';
|
||||||
import { CoreEvents } from '../constants/CoreEvents';
|
import { CalendarEvents } from '../core/CalendarEvents';
|
||||||
|
|
||||||
export class DemoApp {
|
export class DemoApp {
|
||||||
private container!: HTMLElement;
|
private container!: HTMLElement;
|
||||||
|
|
@ -50,16 +50,16 @@ export class DemoApp {
|
||||||
this.setupStatusListeners();
|
this.setupStatusListeners();
|
||||||
|
|
||||||
// Initial render
|
// Initial render
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_RENDER, { viewId: this.currentView });
|
this.eventBus.emit(CalendarEvents.CMD_RENDER, { viewId: this.currentView });
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupNavigation(): void {
|
private setupNavigation(): void {
|
||||||
document.getElementById('btn-prev')!.onclick = () => {
|
document.getElementById('btn-prev')!.onclick = () => {
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_NAVIGATE_PREV);
|
this.eventBus.emit(CalendarEvents.CMD_NAVIGATE_PREV);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById('btn-next')!.onclick = () => {
|
document.getElementById('btn-next')!.onclick = () => {
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_NAVIGATE_NEXT);
|
this.eventBus.emit(CalendarEvents.CMD_NAVIGATE_NEXT);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ export class DemoApp {
|
||||||
if (view) {
|
if (view) {
|
||||||
this.currentView = view;
|
this.currentView = view;
|
||||||
this.updateSelectorVisibility();
|
this.updateSelectorVisibility();
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_RENDER, { viewId: view });
|
this.eventBus.emit(CalendarEvents.CMD_RENDER, { viewId: view });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -88,7 +88,7 @@ export class DemoApp {
|
||||||
|
|
||||||
private setupDrawerToggle(): void {
|
private setupDrawerToggle(): void {
|
||||||
document.getElementById('btn-drawer')!.onclick = () => {
|
document.getElementById('btn-drawer')!.onclick = () => {
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_DRAWER_TOGGLE);
|
this.eventBus.emit(CalendarEvents.CMD_DRAWER_TOGGLE);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ export class DemoApp {
|
||||||
const workweekSelect = document.getElementById('workweek-select') as HTMLSelectElement;
|
const workweekSelect = document.getElementById('workweek-select') as HTMLSelectElement;
|
||||||
workweekSelect?.addEventListener('change', () => {
|
workweekSelect?.addEventListener('change', () => {
|
||||||
const presetId = workweekSelect.value;
|
const presetId = workweekSelect.value;
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_WORKWEEK_CHANGE, { presetId });
|
this.eventBus.emit(CalendarEvents.CMD_WORKWEEK_CHANGE, { presetId });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ export class DemoApp {
|
||||||
container.addEventListener('change', () => {
|
container.addEventListener('change', () => {
|
||||||
const checked = container.querySelectorAll('input:checked') as NodeListOf<HTMLInputElement>;
|
const checked = container.querySelectorAll('input:checked') as NodeListOf<HTMLInputElement>;
|
||||||
const values = Array.from(checked).map(cb => cb.value);
|
const values = Array.from(checked).map(cb => cb.value);
|
||||||
this.eventBus.emit(CoreEvents.CALENDAR_CMD_VIEW_UPDATE, { type: 'resource', values });
|
this.eventBus.emit(CalendarEvents.CMD_VIEW_UPDATE, { type: 'resource', values });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue