Major refactorering to get a hold on all these events

This commit is contained in:
Janus Knudsen 2025-08-09 00:31:44 +02:00
parent 2a766cf685
commit 59b3c64c55
18 changed files with 1901 additions and 357 deletions

View file

@ -1,15 +1,38 @@
// Calendar event type constants
// Legacy Calendar event type constants
/**
* Calendar event type constants for DOM CustomEvents
* Legacy event type constants for DOM CustomEvents
*
* IMPORTANT: This file contains events for specific UI interactions and config updates.
* For initialization and coordination events, use StateEvents from ../types/CalendarState.ts
*
* This file has been cleaned up to remove redundant/unused events.
*/
export const EventTypes = {
// View events
// Configuration events
CONFIG_UPDATE: 'calendar:configupdate',
CALENDAR_TYPE_CHANGED: 'calendar:calendartypechanged',
SELECTED_DATE_CHANGED: 'calendar:selecteddatechanged',
// View change events
VIEW_CHANGE: 'calendar:viewchange',
VIEW_CHANGED: 'calendar:viewchanged',
VIEW_CHANGE_REQUESTED: 'calendar:viewchangerequested',
VIEW_RENDERED: 'calendar:viewrendered',
PERIOD_CHANGE: 'calendar:periodchange',
// Event CRUD
// Navigation events
WEEK_CHANGED: 'calendar:weekchanged',
WEEK_INFO_UPDATED: 'calendar:weekinfoupdated',
NAV_PREV: 'calendar:navprev',
NAV_NEXT: 'calendar:navnext',
NAV_TODAY: 'calendar:navtoday',
NAVIGATE_TO_DATE: 'calendar:navigatetodate',
NAVIGATE_TO_TODAY: 'calendar:navigatetotoday',
NAVIGATE_NEXT: 'calendar:navigatenext',
NAVIGATE_PREVIOUS: 'calendar:navigateprevious',
// Event CRUD (still used for UI layer)
EVENT_CREATE: 'calendar:eventcreate',
EVENT_CREATED: 'calendar:eventcreated',
EVENT_UPDATE: 'calendar:eventupdate',
@ -19,9 +42,12 @@ export const EventTypes = {
EVENT_RENDERED: 'calendar:eventrendered',
EVENT_SELECTED: 'calendar:eventselected',
EVENTS_LOADED: 'calendar:eventsloaded',
RESOURCE_DATA_LOADED: 'calendar:resourcedataloaded',
// Interaction events
// User interaction events
GRID_CLICK: 'calendar:gridclick',
GRID_DBLCLICK: 'calendar:griddblclick',
// Drag and drop events
DRAG_START: 'calendar:dragstart',
DRAG_MOVE: 'calendar:dragmove',
DRAG_END: 'calendar:dragend',
@ -40,62 +66,50 @@ export const EventTypes = {
SEARCH_UPDATE: 'calendar:searchupdate',
SEARCH_CLEAR: 'calendar:searchclear',
// Grid events
GRID_CLICK: 'calendar:gridclick',
GRID_DBLCLICK: 'calendar:griddblclick',
GRID_RENDERED: 'calendar:gridrendered',
// Data events
// Data events (legacy - prefer StateEvents)
DATE_CHANGED: 'calendar:datechanged',
DATA_FETCH_START: 'calendar:datafetchstart',
DATA_FETCH_SUCCESS: 'calendar:datafetchsuccess',
DATA_FETCH_SUCCESS: 'calendar:datafetchsuccess',
DATA_FETCH_ERROR: 'calendar:datafetcherror',
DATA_SYNC_START: 'calendar:datasyncstart',
DATA_SYNC_SUCCESS: 'calendar:datasyncsuccess',
DATA_SYNC_ERROR: 'calendar:datasyncerror',
// State events
STATE_UPDATE: 'calendar:stateupdate',
CONFIG_UPDATE: 'calendar:configupdate',
CALENDAR_TYPE_CHANGED: 'calendar:calendartypechanged',
SELECTED_DATE_CHANGED: 'calendar:selecteddatechanged',
// Initialization events (legacy - prefer StateEvents)
CALENDAR_INITIALIZED: 'calendar:initialized',
CALENDAR_DATA_LOADED: 'calendar:calendardataloaded',
GRID_RENDERED: 'calendar:gridrendered',
// Management events (legacy - prefer StateEvents)
REFRESH_REQUESTED: 'calendar:refreshrequested',
RESET_REQUESTED: 'calendar:resetrequested',
CALENDAR_REFRESH_REQUESTED: 'calendar:refreshrequested',
CALENDAR_RESET: 'calendar:reset',
// System events
ERROR: 'calendar:error',
// Time events
TIME_UPDATE: 'calendar:timeupdate',
// Navigation events
NAV_PREV: 'calendar:navprev',
NAV_NEXT: 'calendar:navnext',
NAV_TODAY: 'calendar:navtoday',
NAVIGATE_TO_DATE: 'calendar:navigatetodate',
WEEK_CHANGED: 'calendar:weekchanged',
WEEK_INFO_UPDATED: 'calendar:weekinfoupdated',
WEEK_CONTAINER_CREATED: 'calendar:weekcontainercreated',
// Loading events
// Loading events
LOADING_START: 'calendar:loadingstart',
LOADING_END: 'calendar:loadingend',
// Error events
ERROR: 'calendar:error',
// Init events
READY: 'calendar:ready',
DESTROY: 'calendar:destroy',
// Calendar Manager Events
CALENDAR_INITIALIZING: 'calendar:initializing',
CALENDAR_INITIALIZED: 'calendar:initialized',
VIEW_CHANGED: 'calendar:viewchanged',
DATE_CHANGED: 'calendar:datechanged',
CALENDAR_REFRESH_REQUESTED: 'calendar:refreshrequested',
CALENDAR_RESET: 'calendar:reset',
VIEW_CHANGE_REQUESTED: 'calendar:viewchangerequested',
NAVIGATE_TO_TODAY: 'calendar:navigatetotoday',
NAVIGATE_NEXT: 'calendar:navigatenext',
NAVIGATE_PREVIOUS: 'calendar:navigateprevious',
REFRESH_REQUESTED: 'calendar:refreshrequested',
RESET_REQUESTED: 'calendar:resetrequested'
LOADING_END: 'calendar:loadingend'
} as const;
// Type for event type values
export type EventType = typeof EventTypes[keyof typeof EventTypes];
// Type for event bus event type values
export type EventBusType = typeof EventTypes[keyof typeof EventTypes];
/**
* REMOVED EVENTS (now handled by StateEvents):
* - CALENDAR_INITIALIZING: Use StateEvents.CALENDAR_STATE_CHANGED
* - CALENDAR_INITIALIZED: Use StateEvents.CALENDAR_STATE_CHANGED
* - CALENDAR_DATA_LOADED: Use StateEvents.DATA_LOADED
* - GRID_RENDERED: Use StateEvents.GRID_RENDERED
* - VIEW_CHANGE_REQUESTED: Use StateEvents.VIEW_CHANGE_REQUESTED
* - VIEW_CHANGED: Use StateEvents.VIEW_CHANGED
* - DATA_FETCH_*: Use StateEvents.DATA_LOADING_STARTED/DATA_LOADED/DATA_FAILED
* - DATA_SYNC_*: Use StateEvents for better coordination
* - CALENDAR_READY: Use StateEvents.CALENDAR_READY
* - RENDERING_*: Use StateEvents.RENDERING_STARTED/RENDERING_COMPLETE
*/