import { WorkHoursManager } from '../managers/WorkHoursManager'; import { IColumnRenderer, IColumnRenderContext } from './ColumnRenderer'; import { DateService } from '../utils/DateService'; /** * Resource-based column renderer * * In resource mode, columns represent resources (people, rooms, etc.) * Work hours are hardcoded (09:00-18:00) for all columns. * TODO: Each resource should have its own work hours. */ export class ResourceColumnRenderer implements IColumnRenderer { private workHoursManager: WorkHoursManager; private dateService: DateService; constructor(workHoursManager: WorkHoursManager, dateService: DateService) { this.workHoursManager = workHoursManager; this.dateService = dateService; } render(columnContainer: HTMLElement, context: IColumnRenderContext): void { const { columns, currentDate } = context; if (!currentDate) { throw new Error('ResourceColumnRenderer requires currentDate in context'); } // Hardcoded work hours for all resources: 09:00 - 18:00 const workHours = { start: 9, end: 18 }; columns.forEach((columnInfo) => { const column = document.createElement('swp-day-column'); column.dataset.columnId = columnInfo.identifier; column.dataset.date = this.dateService.formatISODate(currentDate); // Apply hardcoded work hours to all resource columns this.applyWorkHoursToColumn(column, workHours); const eventsLayer = document.createElement('swp-events-layer'); column.appendChild(eventsLayer); columnContainer.appendChild(column); }); } private applyWorkHoursToColumn(column: HTMLElement, workHours: { start: number; end: number }): void { const nonWorkStyle = this.workHoursManager.calculateNonWorkHoursStyle(workHours); if (nonWorkStyle) { column.style.setProperty('--before-work-height', `${nonWorkStyle.beforeWorkHeight}px`); column.style.setProperty('--after-work-top', `${nonWorkStyle.afterWorkTop}px`); } } }