feat(history): sort by date desc + name asc, delete single entry
This commit is contained in:
1 parent
078d74f09f
commit
294de5276b
1 file changed
+8
-2
+8
-2
@@ -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();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user