Merge feature/bonus-varianten: 3 variants + vacation + date-stepper

Conflicts resolved:
- sw.js: bumped CACHE_NAME to dienstplan-pro-v4 (was v3 + v2). Both
  variants.js and image-import.js are in ASSETS.
- storage.js: kept STORAGE_KEY_DUTIES + STORAGE_KEY_VACATION (Feature B)
  alongside STORAGE_KEY_OPENROUTER_KEY/MODEL + DEFAULT_MODEL (Feature A).
- styles.css: appended Feature B variants/vacation/date-stepper rules
  after Feature A modal/key rules; both blocks coexist.
This commit is contained in:
Kenearos 2026-05-12 18:45:31 +02:00
commit 9a26d8b9ef
9 changed files with 1375 additions and 423 deletions

View file

@ -6,6 +6,7 @@ class DataStorage {
constructor() {
this.STORAGE_KEY_EMPLOYEES = 'dienstplan_employees';
this.STORAGE_KEY_DUTIES = 'dienstplan_duties';
this.STORAGE_KEY_VACATION = 'dienstplan_vacation';
this.STORAGE_KEY_OPENROUTER_KEY = 'dienstplan_openrouter_key';
this.STORAGE_KEY_OPENROUTER_MODEL = 'dienstplan_openrouter_model';
this.DEFAULT_MODEL = 'anthropic/claude-sonnet-4.6';
@ -263,12 +264,64 @@ class DataStorage {
return result;
}
/**
* Get vacation mode for an employee in a specific month.
* @param {string} employeeName
* @param {string} yearMonth - format "YYYY-MM"
* @returns {boolean}
*/
getVacationMode(employeeName, yearMonth) {
try {
const raw = localStorage.getItem(this.STORAGE_KEY_VACATION);
if (!raw) return false;
const map = JSON.parse(raw);
if (!map || typeof map !== 'object') return false;
return Boolean(map[employeeName] && map[employeeName][yearMonth]);
} catch (e) {
console.error('Fehler beim Laden des Urlaubsmodus:', e);
return false;
}
}
/**
* Set vacation mode for an employee in a specific month.
*/
setVacationMode(employeeName, yearMonth, value) {
try {
const raw = localStorage.getItem(this.STORAGE_KEY_VACATION);
const map = raw ? JSON.parse(raw) : {};
if (!map[employeeName]) map[employeeName] = {};
map[employeeName][yearMonth] = Boolean(value);
localStorage.setItem(this.STORAGE_KEY_VACATION, JSON.stringify(map));
} catch (e) {
console.error('Fehler beim Speichern des Urlaubsmodus:', e);
throw e;
}
}
/**
* Get the full vacation map ({ name: { yearMonth: bool } }).
*/
getAllVacationModes() {
try {
const raw = localStorage.getItem(this.STORAGE_KEY_VACATION);
if (!raw) return {};
const map = JSON.parse(raw);
if (!map || typeof map !== 'object') return {};
return map;
} catch (e) {
console.error('Fehler beim Laden des Urlaubsmodus:', e);
return {};
}
}
/**
* Clear all data
*/
clearAll() {
localStorage.removeItem(this.STORAGE_KEY_EMPLOYEES);
localStorage.removeItem(this.STORAGE_KEY_DUTIES);
localStorage.removeItem(this.STORAGE_KEY_VACATION);
}
/**
@ -279,7 +332,8 @@ class DataStorage {
try {
return JSON.stringify({
employees: this.getEmployees(),
duties: this.getAllDuties()
duties: this.getAllDuties(),
vacation: this.getAllVacationModes()
}, null, 2);
} catch (e) {
console.error('Fehler beim Exportieren der Daten:', e);
@ -299,11 +353,12 @@ class DataStorage {
if (data.employees) {
this.saveEmployees(data.employees);
}
if (data.duties) {
this.saveAllDuties(data.duties);
}
if (data.vacation && typeof data.vacation === 'object') {
localStorage.setItem(this.STORAGE_KEY_VACATION, JSON.stringify(data.vacation));
}
return true;
} catch (e) {
console.error('Import failed:', e);