2025-11-22 19:42:12 +01:00
|
|
|
import { WorkHoursManager } from '../managers/WorkHoursManager';
|
|
|
|
|
import { IColumnRenderer, IColumnRenderContext } from './ColumnRenderer';
|
2025-11-25 19:04:06 +01:00
|
|
|
import { DateService } from '../utils/DateService';
|
2025-11-22 19:42:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
2025-11-25 19:04:06 +01:00
|
|
|
private dateService: DateService;
|
2025-11-22 19:42:12 +01:00
|
|
|
|
2025-11-25 19:04:06 +01:00
|
|
|
constructor(workHoursManager: WorkHoursManager, dateService: DateService) {
|
2025-11-22 19:42:12 +01:00
|
|
|
this.workHoursManager = workHoursManager;
|
2025-11-25 19:04:06 +01:00
|
|
|
this.dateService = dateService;
|
2025-11-22 19:42:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(columnContainer: HTMLElement, context: IColumnRenderContext): void {
|
2025-11-25 19:04:06 +01:00
|
|
|
const { columns, currentDate } = context;
|
|
|
|
|
|
|
|
|
|
if (!currentDate) {
|
|
|
|
|
throw new Error('ResourceColumnRenderer requires currentDate in context');
|
|
|
|
|
}
|
2025-11-22 19:42:12 +01:00
|
|
|
|
|
|
|
|
// 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;
|
2025-11-25 19:04:06 +01:00
|
|
|
column.dataset.date = this.dateService.formatISODate(currentDate);
|
2025-11-22 19:42:12 +01:00
|
|
|
|
|
|
|
|
// 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`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|