fix(calendar): use dynamic year range instead of hardcoded 2026 (#1)
currentYear now initializes to the current year and the year selector offers a rolling range (this year -1 to +2) so plans can be created for years other than 2026. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
6736021af1
commit
700ec6de1c
1 file changed
+9
-6
+9
-6
@@ -7,7 +7,7 @@ const MONTHS = ['Januar','Februar','März','April','Mai','Juni',
|
|||||||
'Juli','August','September','Oktober','November','Dezember'];
|
'Juli','August','September','Oktober','November','Dezember'];
|
||||||
const WD_LABELS = ['Mo','Di','Mi','Do','Fr','Sa','So'];
|
const WD_LABELS = ['Mo','Di','Mi','Do','Fr','Sa','So'];
|
||||||
|
|
||||||
let currentYear = 2026;
|
let currentYear = new Date().getFullYear();
|
||||||
let currentMonth = Math.min(Math.max(new Date().getMonth() + 1, 1), 12);
|
let currentMonth = Math.min(Math.max(new Date().getMonth() + 1, 1), 12);
|
||||||
let currentPlan = []; // [{ date, employeeId, manual }] for displayed month
|
let currentPlan = []; // [{ date, employeeId, manual }] for displayed month
|
||||||
|
|
||||||
@@ -41,11 +41,14 @@ export function renderCalendar() {
|
|||||||
yearLabel.textContent = 'Jahr:';
|
yearLabel.textContent = 'Jahr:';
|
||||||
|
|
||||||
const yearSel = document.createElement('select');
|
const yearSel = document.createElement('select');
|
||||||
const yearOpt = document.createElement('option');
|
const thisYear = new Date().getFullYear();
|
||||||
yearOpt.value = '2026';
|
for (let y = thisYear - 1; y <= thisYear + 2; y++) {
|
||||||
yearOpt.textContent = '2026';
|
const opt = document.createElement('option');
|
||||||
yearOpt.selected = true;
|
opt.value = String(y);
|
||||||
yearSel.appendChild(yearOpt);
|
opt.textContent = String(y);
|
||||||
|
if (y === currentYear) opt.selected = true;
|
||||||
|
yearSel.appendChild(opt);
|
||||||
|
}
|
||||||
|
|
||||||
const slotsLabel = document.createElement('label');
|
const slotsLabel = document.createElement('label');
|
||||||
slotsLabel.textContent = 'Pro Tag:';
|
slotsLabel.textContent = 'Pro Tag:';
|
||||||
|
|||||||
Reference in new issue
Block a user