Adds work week configuration feature

Implements configurable work week presets, allowing users to customize the days displayed in the calendar.

This includes:
- Defining work week settings (work days, day names, total days).
- Providing predefined work week presets (standard, compressed, weekend, full week).
- Adding UI elements to switch between presets.
- Updating grid and header rendering logic to reflect the selected work week.
- Emitting events when the work week changes, triggering necessary UI updates and data re-renders.

This provides a more flexible and personalized calendar experience.
This commit is contained in:
Janus Knudsen 2025-08-18 22:27:17 +02:00
parent 26f0cb8aaa
commit d017d48bd6
11 changed files with 283 additions and 34 deletions

View file

@ -26,7 +26,7 @@ export class DateColumnRenderer implements ColumnRenderer {
render(columnContainer: HTMLElement, context: ColumnRenderContext): void {
const { currentWeek, config } = context;
const dates = this.getWeekDates(currentWeek);
const dates = this.getWeekDates(currentWeek, config);
const dateSettings = config.getDateViewSettings();
const daysToShow = dates.slice(0, dateSettings.weekDays);
@ -43,13 +43,20 @@ export class DateColumnRenderer implements ColumnRenderer {
});
}
private getWeekDates(weekStart: Date): Date[] {
private getWeekDates(weekStart: Date, config: CalendarConfig): Date[] {
const dates: Date[] = [];
for (let i = 0; i < 7; i++) {
const workWeekSettings = config.getWorkWeekSettings();
// Calculate dates based on actual work days (e.g., [1,2,3,4] for Mon-Thu)
workWeekSettings.workDays.forEach(dayOfWeek => {
const date = new Date(weekStart);
date.setDate(weekStart.getDate() + i);
// Set to the start of the week (Sunday = 0)
date.setDate(weekStart.getDate() - weekStart.getDay());
// Add the specific day of week
date.setDate(date.getDate() + dayOfWeek);
dates.push(date);
}
});
return dates;
}