From 6736021af13eb6d36ebae41802539cb4f85745c1 Mon Sep 17 00:00:00 2001 From: Ferdinand Urban Date: Wed, 3 Jun 2026 12:11:36 +0000 Subject: [PATCH] feat(employees): default minGapDays to 14, robust ID fallback Co-Authored-By: Claude Opus 4.8 --- js/data.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/data.js b/js/data.js index 56337ba..8564a9e 100644 --- a/js/data.js +++ b/js/data.js @@ -1,3 +1,18 @@ +function generateId() { + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } + if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') { + const b = new Uint8Array(16); + crypto.getRandomValues(b); + b[6] = (b[6] & 0x0f) | 0x40; + b[8] = (b[8] & 0x3f) | 0x80; + const h = [...b].map(x => x.toString(16).padStart(2, '0')); + return `${h.slice(0,4).join('')}-${h.slice(4,6).join('')}-${h.slice(6,8).join('')}-${h.slice(8,10).join('')}-${h.slice(10,16).join('')}`; + } + return Date.now().toString(36) + Math.random().toString(36).slice(2, 10); +} + function parseSettings(raw) { const n = raw?.moderatorsPerDay; const valid = Number.isInteger(n) && n >= 1 && n <= 5; @@ -40,14 +55,14 @@ export function createEmployee(name) { const trimmed = (name ?? '').trim(); if (!trimmed) throw new Error('Mitarbeitername darf nicht leer sein'); return { - id: crypto.randomUUID(), + id: generateId(), name: trimmed, constraints: { neverDays: [], lowPriorityDays: [], onlyDays: [], maxPerMonth: null, - minGapDays: 0, + minGapDays: 14, vacations: [] } };