fix(import): validate/normalize imported data, guard Excel I/O (#3)
- loadFromJSON and the localStorage startup load now run employees through normalizeEmployees(): fills missing constraints, drops unusable rows, de-duplicates ids, and discards invalid vacation ranges — preventing later crashes (e.g. c.neverDays on undefined) and same-day double-books. - Excel import is wrapped in try/catch with a typeof XLSX guard and user feedback; the Excel export button gets the same guard. - createEmployee reuses the shared defaultConstraints() factory. Adds normalizeEmployees tests (defaults, dropping, dedup, vacations) and a loadFromJSON normalization test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
e851bb2833
commit
065876ced4
5 files changed
+118
-18
No files matched your search
@@ -138,6 +138,10 @@ export function renderCalendar() {
|
||||
});
|
||||
|
||||
exportBtn.addEventListener('click', () => {
|
||||
if (typeof XLSX === 'undefined') {
|
||||
alert('Excel-Export nicht verfügbar (SheetJS konnte nicht geladen werden).');
|
||||
return;
|
||||
}
|
||||
const blob = exportSchedule(currentPlan, state.employees);
|
||||
downloadBlob(blob, 'Moderationsplan-' + MONTHS[currentMonth-1] + '-' + currentYear + '.xlsx');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user