Adds resource scheduling and unavailability tracking

Introduces comprehensive schedule management for resources:
- Adds DateService with advanced time and date utilities
- Implements ResourceScheduleService for managing work hours
- Creates ScheduleRenderer to visualize unavailable time zones
- Extends resource model to support default weekly schedules

Enables granular tracking of resource availability and working hours
This commit is contained in:
Janus C. H. Knudsen 2025-12-10 00:27:19 +01:00
parent 400de8c9d5
commit a2b95515fd
17 changed files with 563 additions and 36 deletions

View file

@ -1,6 +1,8 @@
import { ICalendarEvent } from '../../types/CalendarTypes';
import { EventService } from '../../storage/events/EventService';
import { calculateEventPosition, getDateKey, formatTimeRange, GridConfig } from '../../utils/PositionUtils';
import { DateService } from '../../core/DateService';
import { IGridConfig } from '../../core/IGridConfig';
import { calculateEventPosition } from '../../utils/PositionUtils';
/**
* EventRenderer - Renders calendar events to the DOM
@ -11,13 +13,11 @@ import { calculateEventPosition, getDateKey, formatTimeRange, GridConfig } from
* - Event data retrieved via EventService when needed
*/
export class EventRenderer {
private readonly gridConfig: GridConfig = {
dayStartHour: 6,
dayEndHour: 18,
hourHeight: 64
};
constructor(private eventService: EventService) {}
constructor(
private eventService: EventService,
private dateService: DateService,
private gridConfig: IGridConfig
) {}
/**
* Render events for visible dates into day columns
@ -53,7 +53,7 @@ export class EventRenderer {
// Filter events for this column
const columnEvents = events.filter(event => {
// Must match date
if (getDateKey(event.start) !== dateKey) return false;
if (this.dateService.getDateKey(event.start) !== dateKey) return false;
// If column has resourceId, event must match
if (columnResourceId && event.resourceId !== columnResourceId) return false;
@ -110,7 +110,7 @@ export class EventRenderer {
// Visible content only
element.innerHTML = `
<swp-event-time>${formatTimeRange(event.start, event.end)}</swp-event-time>
<swp-event-time>${this.dateService.formatTimeRange(event.start, event.end)}</swp-event-time>
<swp-event-title>${this.escapeHtml(event.title)}</swp-event-title>
${event.description ? `<swp-event-description>${this.escapeHtml(event.description)}</swp-event-description>` : ''}
`;