refactor: use removeHistoryEntry API and remove unnecessary spread in calendar
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { state } from './app.js';
|
||||
import { getWorkdays, generatePlan } from './algorithm.js';
|
||||
import { toggleHoliday, toggleClosure, addHistoryEntries } from './data.js';
|
||||
import { toggleHoliday, toggleClosure, addHistoryEntries, removeHistoryEntry } from './data.js';
|
||||
import { exportSchedule, downloadBlob } from './excel.js';
|
||||
|
||||
const MONTHS = ['Januar','Februar','März','April','Mai','Juni',
|
||||
@@ -106,7 +106,7 @@ function loadPlanFromHistory() {
|
||||
const prefix = currentYear + '-' + String(currentMonth).padStart(2,'0');
|
||||
currentPlan = state.history
|
||||
.filter(h => h.date.startsWith(prefix))
|
||||
.map(h => ({ ...h }));
|
||||
.slice();
|
||||
}
|
||||
|
||||
function renderGrid(wrapper, exportBtn) {
|
||||
@@ -208,7 +208,7 @@ function renderGrid(wrapper, exportBtn) {
|
||||
const idx = currentPlan.findIndex(a => a.date === iso);
|
||||
if (idx >= 0) currentPlan[idx] = entry; else currentPlan.push(entry);
|
||||
} else {
|
||||
state.history = state.history.filter(h => h.date !== iso);
|
||||
removeHistoryEntry(state, iso);
|
||||
currentPlan = currentPlan.filter(a => a.date !== iso);
|
||||
}
|
||||
exportBtn.style.display = currentPlan.length > 0 ? 'inline-block' : 'none';
|
||||
|
||||
Reference in New Issue
Block a user