2025-12-16 17:13:27 +01:00
|
|
|
# CalendarApp Event Specification
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
## 1. Oversigt
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
CalendarApp initialiseres med `CalendarApp.create(container)`.
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
Kommunikation sker via DOM events:
|
|
|
|
|
- **Command events**: Host → Calendar
|
|
|
|
|
- **Status events**: Calendar → Host
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
Settings hentes fra `SettingsService` (IndexedDB).
|
2025-12-16 07:35:29 +01:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
## 2. Command Events (Host → Calendar)
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
| Event | Payload | Beskrivelse |
|
|
|
|
|
|-------|---------|-------------|
|
|
|
|
|
| `calendar:cmd:render` | `{ viewConfig }` | Render kalenderen med ViewConfig |
|
2025-12-16 07:35:29 +01:00
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
interface IRenderCommandPayload {
|
|
|
|
|
viewConfig: ViewConfig;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
**Eksempel:**
|
2025-12-16 07:35:29 +01:00
|
|
|
```typescript
|
|
|
|
|
document.dispatchEvent(new CustomEvent('calendar:cmd:render', {
|
|
|
|
|
detail: {
|
|
|
|
|
viewConfig: {
|
2025-12-16 17:13:27 +01:00
|
|
|
templateId: 'team',
|
2025-12-16 07:35:29 +01:00
|
|
|
groupings: [
|
2025-12-16 17:13:27 +01:00
|
|
|
{ type: 'team', values: ['team1', 'team2'] },
|
|
|
|
|
{ type: 'resource', values: ['EMP001', 'EMP002'], idProperty: 'resourceId', belongsTo: 'team.resourceIds' },
|
|
|
|
|
{ type: 'date', values: ['2025-12-08', '2025-12-09'], idProperty: 'date', derivedFrom: 'start' }
|
2025-12-16 07:35:29 +01:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
---
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
## 3. Status Events (Calendar → Host)
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
| Event | Payload | Beskrivelse |
|
|
|
|
|
|-------|---------|-------------|
|
|
|
|
|
| `calendar:status:ready` | `{}` | Calendar initialiseret |
|
|
|
|
|
| `calendar:status:rendered` | `{ templateId }` | Rendering færdig |
|
|
|
|
|
| `calendar:status:error` | `{ message, code }` | Fejl opstået |
|
2025-12-16 07:35:29 +01:00
|
|
|
|
|
|
|
|
```typescript
|
2025-12-16 17:13:27 +01:00
|
|
|
interface IRenderedStatusPayload {
|
|
|
|
|
templateId: string;
|
|
|
|
|
}
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
interface IErrorStatusPayload {
|
|
|
|
|
message: string;
|
|
|
|
|
code: 'INVALID_PAYLOAD' | 'RENDER_FAILED';
|
|
|
|
|
}
|
2025-12-16 07:35:29 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
## 4. CalendarApp
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
### 4.1 Initialisering
|
2025-12-16 07:35:29 +01:00
|
|
|
```typescript
|
2025-12-16 17:13:27 +01:00
|
|
|
await CalendarApp.create(container);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 4.2 Dependencies (via DI)
|
|
|
|
|
- CalendarOrchestrator
|
|
|
|
|
- SettingsService
|
|
|
|
|
- TimeAxisRenderer
|
|
|
|
|
- ScrollManager
|
|
|
|
|
- DragDropManager
|
|
|
|
|
- EdgeScrollManager
|
|
|
|
|
- ResizeManager
|
|
|
|
|
- HeaderDrawerManager
|
|
|
|
|
- EventBus
|
|
|
|
|
|
|
|
|
|
### 4.3 Ansvar
|
|
|
|
|
- Subscribe på `calendar:cmd:render`
|
|
|
|
|
- Emit `calendar:status:ready` ved init
|
|
|
|
|
- Emit `calendar:status:rendered` efter render
|
|
|
|
|
- Emit `calendar:status:error` ved fejl
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
---
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
## 5. Filer
|
2025-12-16 07:35:29 +01:00
|
|
|
|
2025-12-16 17:13:27 +01:00
|
|
|
| Fil | Beskrivelse |
|
|
|
|
|
|-----|-------------|
|
|
|
|
|
| `src/v2/CalendarApp.ts` | Entry point |
|
|
|
|
|
| `src/v2/types/CommandTypes.ts` | Payload interfaces |
|
|
|
|
|
| `src/v2/constants/CommandEvents.ts` | Event konstanter |
|