feat(calendar): pass slotsPerDay to generator, show skipped-dates warning
This commit is contained in:
1 parent
fa28640c28
commit
078d74f09f
1 file changed
+40
-2
+40
-2
@@ -80,6 +80,11 @@ export function renderCalendar() {
|
||||
'<span><span class="cal-legend-dot" style="background:#fecaca"></span>Betriebsurlaub</span>';
|
||||
container.appendChild(legend);
|
||||
|
||||
const warnBox = document.createElement('div');
|
||||
warnBox.id = 'skipped-warning';
|
||||
warnBox.style.display = 'none';
|
||||
container.appendChild(warnBox);
|
||||
|
||||
// Calendar grid wrapper
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'calendar-outer';
|
||||
@@ -114,12 +119,15 @@ export function renderCalendar() {
|
||||
}
|
||||
const workdays = getWorkdays(currentYear, currentMonth,
|
||||
state.calendar.holidays, state.calendar.companyClosures);
|
||||
const prefix = currentYear + '-' + String(currentMonth).padStart(2,'0');
|
||||
const prefix = currentYear + '-' + String(currentMonth).padStart(2, '0');
|
||||
const historyWithoutMonth = state.history.filter(h => !h.date.startsWith(prefix));
|
||||
const result = generatePlan(workdays, state.employees, historyWithoutMonth);
|
||||
// Reset month entries from history so dedup-by-(date,employeeId) doesn't keep stale rows
|
||||
state.history = historyWithoutMonth;
|
||||
const result = generatePlan(workdays, state.employees, historyWithoutMonth, Math.random, state.settings.moderatorsPerDay);
|
||||
currentPlan = result.assignments;
|
||||
addHistoryEntries(state, currentPlan);
|
||||
saveState();
|
||||
renderSkippedWarning(warnBox, result.skippedDates);
|
||||
renderGrid(wrapper, exportBtn);
|
||||
});
|
||||
|
||||
@@ -291,3 +299,33 @@ function renderGrid(wrapper, exportBtn) {
|
||||
wrapper.appendChild(bodyGrid);
|
||||
exportBtn.style.display = currentPlan.length > 0 ? 'inline-block' : 'none';
|
||||
}
|
||||
|
||||
function renderSkippedWarning(box, skippedDates) {
|
||||
box.replaceChildren();
|
||||
if (!skippedDates || skippedDates.length === 0) {
|
||||
box.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
box.style.display = 'flex';
|
||||
box.className = 'skipped-warning';
|
||||
|
||||
const formatted = skippedDates.map(d => {
|
||||
const [y, m, day] = d.split('-');
|
||||
return day + '.' + m + '.';
|
||||
}).join(', ');
|
||||
|
||||
const text = document.createElement('span');
|
||||
text.textContent = skippedDates.length === 1
|
||||
? '1 Tag konnte nicht vollständig besetzt werden: ' + formatted
|
||||
: skippedDates.length + ' Tage konnten nicht vollständig besetzt werden: ' + formatted;
|
||||
box.appendChild(text);
|
||||
|
||||
const closeBtn = document.createElement('button');
|
||||
closeBtn.type = 'button';
|
||||
closeBtn.textContent = '✕';
|
||||
closeBtn.addEventListener('click', () => {
|
||||
box.replaceChildren();
|
||||
box.style.display = 'none';
|
||||
});
|
||||
box.appendChild(closeBtn);
|
||||
}
|
||||
Reference in new issue
Block a user