From 294de5276bb9b18e036b85b08aae43b6c44fea60 Mon Sep 17 00:00:00 2001 From: Ferdinand Urban Date: Tue, 28 Apr 2026 11:37:31 +0000 Subject: [PATCH] feat(history): sort by date desc + name asc, delete single entry --- js/history.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/history.js b/js/history.js index 49ff213..4868ad9 100644 --- a/js/history.js +++ b/js/history.js @@ -103,7 +103,13 @@ function renderHistoryTable() { } const nameById = Object.fromEntries(state.employees.map(e => [e.id, e.name])); - const sorted = [...state.history].sort((a, b) => b.date.localeCompare(a.date)); + const sorted = [...state.history].sort((a, b) => { + const dateCmp = b.date.localeCompare(a.date); + if (dateCmp !== 0) return dateCmp; + const nameA = nameById[a.employeeId] ?? ''; + const nameB = nameById[b.employeeId] ?? ''; + return nameA.localeCompare(nameB, 'de'); + }); const table = document.createElement('table'); const thead = document.createElement('thead'); @@ -137,7 +143,7 @@ function renderHistoryTable() { delBtn.textContent = '✕'; delBtn.style.cssText = 'font-size:11px;padding:2px 6px'; delBtn.addEventListener('click', () => { - removeHistoryEntry(state, h.date); + removeHistoryEntry(state, h.date, h.employeeId); saveState(); renderHistoryTable(); });