fix(robustness): parseInt radix, minGapDays null-guard, log silent catches (#14)
- parseInt(month/year) now passes radix 10 consistently. - minGap eligibility guards null/undefined (c.minGapDays != null && > 0). - The corrupt-localStorage load and the createEmployee catch now console.warn instead of swallowing the error silently. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd9870871b
commit
7ab2911c2f
4 files changed
+8
-6
No files matched your search
+1
-1
@@ -37,7 +37,7 @@ function isEligible(employee, isoDate, monthAssignments, allHistory) {
|
|||||||
if (count >= c.maxPerMonth) return false;
|
if (count >= c.maxPerMonth) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.minGapDays > 0) {
|
if (c.minGapDays != null && c.minGapDays > 0) {
|
||||||
// Latest prior assignment date for this employee — single pass, no sort/alloc
|
// Latest prior assignment date for this employee — single pass, no sort/alloc
|
||||||
let lastDate = null;
|
let lastDate = null;
|
||||||
const isLater = a => a.employeeId === employee.id && a.date < isoDate &&
|
const isLater = a => a.employeeId === employee.id && a.date < isoDate &&
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ try {
|
|||||||
state.settings = { moderatorsPerDay: parsed.settings.moderatorsPerDay };
|
state.settings = { moderatorsPerDay: parsed.settings.moderatorsPerDay };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (e) {
|
||||||
// Corrupt storage — start fresh
|
// Corrupt storage — start fresh, but leave a breadcrumb for debugging
|
||||||
|
console.warn('Gespeicherter Zustand konnte nicht gelesen werden, starte leer:', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persist immediately. Used by the debounced saveState and the flush handlers.
|
// Persist immediately. Used by the debounced saveState and the flush handlers.
|
||||||
|
|||||||
+2
-2
@@ -99,13 +99,13 @@ export function renderCalendar() {
|
|||||||
renderGrid(wrapper, exportBtn);
|
renderGrid(wrapper, exportBtn);
|
||||||
|
|
||||||
monthSel.addEventListener('change', () => {
|
monthSel.addEventListener('change', () => {
|
||||||
currentMonth = parseInt(monthSel.value);
|
currentMonth = parseInt(monthSel.value, 10);
|
||||||
loadPlanFromHistory();
|
loadPlanFromHistory();
|
||||||
renderGrid(wrapper, exportBtn);
|
renderGrid(wrapper, exportBtn);
|
||||||
});
|
});
|
||||||
|
|
||||||
yearSel.addEventListener('change', () => {
|
yearSel.addEventListener('change', () => {
|
||||||
currentYear = parseInt(yearSel.value);
|
currentYear = parseInt(yearSel.value, 10);
|
||||||
loadPlanFromHistory();
|
loadPlanFromHistory();
|
||||||
renderGrid(wrapper, exportBtn);
|
renderGrid(wrapper, exportBtn);
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-1
@@ -54,7 +54,8 @@ export function renderEmployees() {
|
|||||||
if (!name) return;
|
if (!name) return;
|
||||||
try {
|
try {
|
||||||
state.employees.push(createEmployee(name));
|
state.employees.push(createEmployee(name));
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
console.warn('Mitarbeiter konnte nicht angelegt werden:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nameInput.value = '';
|
nameInput.value = '';
|
||||||
|
|||||||
Reference in new issue
Block a user