diff --git a/sources/task-list-mockup.html b/sources/task-list-mockup.html index e16560ba..8772f40e 100644 --- a/sources/task-list-mockup.html +++ b/sources/task-list-mockup.html @@ -254,7 +254,7 @@ .task-title { font-weight: 600; white-space: normal; min-width: 200px; } .task-id { display: block; font-size: 12px; color: var(--text-muted); } - /* Status badge — neutral until badge colors are specified */ + /* Status badge: base + modifier from ListOfTaskStatus.task_higher_order_status (lowercased) */ .badge { display: inline-block; padding: 2px 8px; @@ -264,6 +264,14 @@ background: #eaecef; color: var(--text); } + /* Higher-order Backlog: New, Backlog */ + .badge-backlog { background: #f5efe0; color: #7a1f1f; } + /* Higher-order Normal: In Progress, Test/Review */ + .badge-normal { background: #cff4fc; color: #000000; } + /* Higher-order Blocked: Blocked */ + .badge-blocked { background: #f8d7da; color: #7a1f1f; } + /* Higher-order Closed: Closed */ + .badge-closed { background: #d4edda; color: #155724; } /* Priority: 8px dot + label */ .priority { display: inline-flex; align-items: center; gap: 6px; } @@ -279,6 +287,59 @@ .btn-sm { padding: 3px 12px; font-size: 12px; } + /* ---------- Pagination ---------- */ + .pagination { + display: flex; + justify-content: center; + } + .pagination-list { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 4px; + margin: 0; + padding: 0; + list-style: none; + } + .page-link { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 32px; + height: 32px; + padding: 0 10px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--surface); + color: var(--text); + text-decoration: none; + } + a.page-link:hover { background: var(--secondary-hover); } + .page-link.active { + background: var(--primary); + border-color: var(--primary); + color: #fff; + font-weight: 600; + } + .page-link.disabled { + color: var(--text-muted); + background: var(--secondary-bg); + opacity: 0.6; + cursor: not-allowed; + } + .page-ellipsis { + border-color: transparent; + background: none; + color: var(--text-muted); + } + + /* Empty state: single row spanning all columns */ + .empty-row td { + padding: 32px 16px; + text-align: center; + color: var(--text-muted); + } + .placeholder { color: var(--text-muted); text-align: center; @@ -306,6 +367,7 @@ + Last submitted query: (none) @@ -456,7 +518,7 @@ Migrate customer table to new schema#T-1287 - In Progress + In Progress High sam.patel Data Migration @@ -479,7 +543,7 @@ Design new pricing page layout#T-1284 - New + New Medium - Website Redesign @@ -490,7 +554,7 @@ Push notification permissions on Android 15#T-1279 - Blocked + Blocked High jordan.lee Mobile App v2 @@ -501,7 +565,7 @@ Review accessibility audit findings#T-1275 - Test/Review + Test/Review Medium alex.chen Website Redesign @@ -512,7 +576,7 @@ Add CSV export to admin reports#T-1270 - Backlog + Backlog Low - Internal Tools @@ -523,7 +587,7 @@ Set up staging environment for v2 beta#T-1266 - Closed + Closed High taylor.kim Mobile App v2 @@ -534,7 +598,7 @@ Validate migrated invoice totals#T-1261 - Test/Review + Test/Review High riley.ng Data Migration @@ -545,7 +609,7 @@ Refresh onboarding illustrations#T-1258 - In Progress + In Progress Low alex.chen Website Redesign @@ -556,7 +620,7 @@ Clean up unused feature flags#T-1252 - Backlog + Backlog Medium sam.patel Internal Tools @@ -567,7 +631,7 @@ Offline mode for task checklist#T-1247 - New + New Low - Mobile App v2 @@ -576,13 +640,42 @@ 2026-10-04 View + + + No tasks found + -
- Pagination to be specified -
+ + @@ -606,16 +699,23 @@ applyUserLevel(); // Standalone file has no server: show the GET URL instead of navigating. - function showQuery() { + function buildQuery(page) { var params = new URLSearchParams(); new FormData(form).forEach(function (value, key) { if (value !== '') params.append(key, value); }); - var qs = params.toString(); + if (page) params.set('page', page); + return params.toString(); + } + function showQuery(page) { + var qs = buildQuery(page); queryOut.textContent = form.getAttribute('action') + (qs ? '?' + qs : ''); } + // Applying filters returns to page 1. form.addEventListener('submit', function (e) { e.preventDefault(); + currentPage = 1; + renderPagination(); showQuery(); }); @@ -644,7 +744,8 @@ if (activeIndex < 0) return; // Mockup-only: reorder sample rows. The real page sorts the queryset server-side. - var rows = Array.prototype.slice.call(tbody.rows); + var emptyRow = document.getElementById('empty-row'); + var rows = Array.prototype.slice.call(tbody.querySelectorAll('tr:not(.empty-row)')); rows.sort(function (a, b) { var x = a.cells[activeIndex].textContent.trim(); var y = b.cells[activeIndex].textContent.trim(); @@ -653,7 +754,7 @@ : x.localeCompare(y); return desc ? -cmp : cmp; }); - rows.forEach(function (row) { tbody.appendChild(row); }); + rows.forEach(function (row) { tbody.insertBefore(row, emptyRow); }); } sortHeaders.forEach(function (th) { @@ -662,24 +763,119 @@ var field = th.dataset.sortField; sortInput.value = sortInput.value === field ? '-' + field : field; renderSort(); + currentPage = 1; + renderPagination(); showQuery(); }); }); - // Page size auto-submits on change; update the sample range to match. + // Pagination. Mockup has a fixed sample total; every page shows the same sample rows. + var SAMPLE_TOTAL = 142; + var currentPage = 1; var pageSize = document.getElementById('page-size'); + var demoEmpty = document.getElementById('demo-empty'); + var pagination = document.getElementById('pagination'); + + function totalTasks() { return demoEmpty.checked ? 0 : SAMPLE_TOTAL; } + function numPages() { return Math.max(1, Math.ceil(totalTasks() / Number(pageSize.value))); } + + // Same output as Django's Paginator.get_elided_page_range(number, on_each_side=2, on_ends=1). + function elidedPageRange(number, count) { + var onEachSide = 2, onEnds = 1, out = [], i; + if (count <= (onEachSide + onEnds) * 2) { + for (i = 1; i <= count; i++) out.push(i); + return out; + } + if (number > 1 + onEachSide + onEnds + 1) { + for (i = 1; i <= onEnds; i++) out.push(i); + out.push('…'); + for (i = number - onEachSide; i <= number; i++) out.push(i); + } else { + for (i = 1; i <= number; i++) out.push(i); + } + if (number < count - onEachSide - onEnds - 1) { + for (i = number + 1; i <= number + onEachSide; i++) out.push(i); + out.push('…'); + for (i = count - onEnds + 1; i <= count; i++) out.push(i); + } else { + for (i = number + 1; i <= count; i++) out.push(i); + } + return out; + } + + function pageItem(label, page, kind) { + var li = document.createElement('li'); + var el; + if (kind === 'link') { + el = document.createElement('a'); + el.href = '?' + buildQuery(page); + el.dataset.page = page; + } else { + el = document.createElement('span'); + if (kind === 'disabled') el.setAttribute('aria-disabled', 'true'); + if (kind === 'active') el.setAttribute('aria-current', 'page'); + } + el.className = 'page-link' + (kind === 'link' ? '' : ' ' + (kind === 'ellipsis' ? 'page-ellipsis' : kind)); + el.textContent = label; + li.appendChild(el); + return li; + } + + function renderPagination() { + var total = totalTasks(); + var size = Number(pageSize.value); + var count = numPages(); + if (currentPage > count) currentPage = count; + + document.getElementById('range-start').textContent = total ? (currentPage - 1) * size + 1 : 0; + document.getElementById('range-end').textContent = Math.min(currentPage * size, total); + document.getElementById('total-count').textContent = total; + + pagination.innerHTML = ''; + pagination.appendChild(currentPage > 1 + ? pageItem('◀ Prev', currentPage - 1, 'link') + : pageItem('◀ Prev', null, 'disabled')); + elidedPageRange(currentPage, count).forEach(function (n) { + if (n === '…') pagination.appendChild(pageItem('…', null, 'ellipsis')); + else if (n === currentPage) pagination.appendChild(pageItem(String(n), null, 'active')); + else pagination.appendChild(pageItem(String(n), n, 'link')); + }); + pagination.appendChild(currentPage < count + ? pageItem('Next ▶', currentPage + 1, 'link') + : pageItem('Next ▶', null, 'disabled')); + } + + pagination.addEventListener('click', function (e) { + var link = e.target.closest('a.page-link'); + if (!link) return; + e.preventDefault(); + currentPage = Number(link.dataset.page); + renderPagination(); + showQuery(currentPage); + }); + + // Page size auto-submits on change and returns to page 1. pageSize.addEventListener('change', function () { - var total = Number(document.getElementById('total-count').textContent); - document.getElementById('range-start').textContent = 1; - document.getElementById('range-end').textContent = Math.min(Number(pageSize.value), total); form.requestSubmit(); }); + // Mockup-only: preview the empty state (paginator gives 0–0 of 0, one page). + demoEmpty.addEventListener('change', function () { + tbody.querySelectorAll('tr:not(.empty-row)').forEach(function (row) { row.hidden = demoEmpty.checked; }); + document.getElementById('empty-row').hidden = !demoEmpty.checked; + currentPage = 1; + renderPagination(); + }); + + renderPagination(); + clearLink.addEventListener('click', function (e) { e.preventDefault(); form.reset(); sortInput.value = '-date_created'; renderSort(); + currentPage = 1; + renderPagination(); queryOut.textContent = clearLink.getAttribute('href'); }); })();