diff --git a/public/js/postlesson.js b/public/js/postlesson.js index 5e63afa..0c089cd 100644 --- a/public/js/postlesson.js +++ b/public/js/postlesson.js @@ -22,7 +22,9 @@ function filteredTasks() { const q = (document.getElementById('plSearch').value || '').trim().toLowerCase(); const status = document.getElementById('plStatus').value; const showClosed = document.getElementById('plShowDismissed').checked; - return allPostTasks.filter(t => { + const sortEl = document.getElementById('plSort'); + const sort = sortEl ? sortEl.value : 'date_desc'; + const list = allPostTasks.filter(t => { if (q && !String(t.group_name || '').toLowerCase().includes(q)) return false; const isClosed = !!t.closed; if (!showClosed && isClosed) return false; @@ -31,6 +33,12 @@ function filteredTasks() { if (status === 'overdue' && !(t.overdue && !t.all_done)) return false; return true; }); + list.sort((a, b) => { + const byDate = String(a.lesson_date || '').localeCompare(String(b.lesson_date || '')); + if (byDate !== 0) return sort === 'date_asc' ? byDate : -byDate; + return String(a.group_name || '').localeCompare(String(b.group_name || '')); + }); + return list; } function fmtInstant(v) { @@ -251,6 +259,8 @@ function openCloseReasonModal(taskKey, currentReason) { document.getElementById('plSearch').addEventListener('input', () => { plPage = 1; renderPostLessonTasks(); }); document.getElementById('plStatus').addEventListener('change', () => { plPage = 1; renderPostLessonTasks(); }); +const plSortEl = document.getElementById('plSort'); +if (plSortEl) plSortEl.addEventListener('change', () => { plPage = 1; renderPostLessonTasks(); }); document.getElementById('plDays').addEventListener('change', () => { plPage = 1; loadPostLessonTasks(); }); document.getElementById('plShowDismissed').addEventListener('change', () => { plPage = 1; renderPostLessonTasks(); }); const plPageSizeEl = document.getElementById('plPageSize'); diff --git a/public/postlesson.html b/public/postlesson.html index b572d38..0c4c081 100644 --- a/public/postlesson.html +++ b/public/postlesson.html @@ -121,6 +121,13 @@ +
+ + +