CalendarView.kt
CalendarView is an enum that bridges ProjectForge's calendar view concepts with the FullCalendar JavaScript library's view name conventions. Each enum value carries a key property that is the string used to request a specific view from FullCalendar. The companion object provides a from() factory that resolves both enum names and FullCalendar keys, with a fallback to MONTH.
| Enum Value | FullCalendar Key | Description |
|---|---|---|
MONTH | dayGridMonth | Standard month grid view. |
WORK_MONTH | dayGridWorkingMonth | Month grid showing only working days (custom extension). |
WEEK | timeGridWeek | Full week with time grid (7 days, hourly slots). |
WORK_WEEK | timeGridWorkingWeek | Working week — typically Monday–Friday — with time grid. |
DAY | timeGridDay | Single day with time grid (hourly slots). |
WEEK_LIST | dayGridWeek | Week displayed as a day-grid (no time slots), useful as a compact list. |
AGENDA | listWeek | List/agenda view for a single week. |
MONTH_AGENDA | listMonth | List/agenda view spanning a full month. |
from(name: String?): CalendarViewLooks up a CalendarView by either its enum name (e.g., "WEEK") or its FullCalendar key (e.g., "timeGridWeek"). If the input is null or not found, returns MONTH as the safe default. This makes it resilient to mismatches between stored view preferences and current enum definitions.
The dual-keyed from() lookup (accepting both enum names and FullCalendar keys) provides flexibility in both serialization and migration. When stored preferences use the FullCalendar key (as they might after a library upgrade), the enum still resolves correctly. The default fallback to MONTH prevents crashes from unrecognized values, ensuring the calendar always renders something. The key property on each enum value is the single source of truth for how FullCalendar views are addressed, centralizing what would otherwise be string constants scattered across frontend and backend code.