diff --git a/templates/focus.html b/templates/focus.html index d7d4097..631a6cc 100644 --- a/templates/focus.html +++ b/templates/focus.html @@ -27,28 +27,44 @@ + + + # + + Done + ! + Due + P + Title + Domain + Area + Project + Est + + + {% for item in items %} - {{ loop.index }} + {{ loop.index }} {% with reorder_url="/focus/reorder", item_id=item.id %}{% include 'partials/reorder_arrows.html' %}{% endwith %} - +
- +
- {{ item.due_date or '' }} - {% if item.task_id %}{% elif item.list_item_id %}{% else %}{% endif %} - {% if item.task_id %}{% if item.task_title %}{{ item.task_title }}{% else %}[Deleted]{% endif %}{% elif item.list_item_id %}{% if item.list_item_content %}{{ item.list_item_content }}{% else %}[Deleted]{% endif %}{% else %}{{ item.title }}{% endif %} - {% if item.domain_name %}{{ item.domain_name }}{% endif %} - {% if item.area_name %}{{ item.area_name }}{% endif %} - {% if item.project_name %}{{ item.project_name }}{% elif item.list_item_id and item.list_name %}{{ item.list_name }}{% endif %} - {{ '~%smin'|format(item.estimated_minutes) if item.estimated_minutes else '' }} + {{ item.due_date or '' }} + {% if item.task_id %}{% elif item.list_item_id %}{% else %}{% endif %} + {% if item.task_id %}{% if item.task_title %}{{ item.task_title }}{% else %}[Deleted]{% endif %}{% elif item.list_item_id %}{% if item.list_item_content %}{{ item.list_item_content }}{% else %}[Deleted]{% endif %}{% else %}{{ item.title }}{% endif %} + {% if item.domain_name %}{{ item.domain_name }}{% endif %} + {% if item.area_name %}{{ item.area_name }}{% endif %} + {% if item.project_name %}{{ item.project_name }}{% elif item.list_item_id and item.list_name %}{{ item.list_name }}{% endif %} + {{ '~%smin'|format(item.estimated_minutes) if item.estimated_minutes else '' }}
@@ -257,6 +273,47 @@ renumberFocusRows(); }); }); + + // Column sorting + var sortCol = -1; + var sortAsc = true; + document.querySelectorAll('.focus-sort-head').forEach(function(th) { + th.addEventListener('click', function() { + var col = parseInt(th.dataset.col); + if (sortCol === col) { + sortAsc = !sortAsc; + } else { + sortCol = col; + sortAsc = true; + } + // Update header indicators + document.querySelectorAll('.focus-sort-head').forEach(function(h) { + h.style.color = 'var(--muted)'; + var arrow = h.querySelector('.sort-arrow'); + if (arrow) arrow.remove(); + }); + th.style.color = 'var(--text)'; + var indicator = document.createElement('span'); + indicator.className = 'sort-arrow'; + indicator.textContent = sortAsc ? ' \u25B2' : ' \u25BC'; + indicator.style.fontSize = '0.6rem'; + th.appendChild(indicator); + + var tbody = document.querySelector('.focus-drag-group'); + var rows = Array.from(tbody.querySelectorAll('.focus-drag-row')); + rows.sort(function(a, b) { + var aVal = a.cells[col].getAttribute('data-sort') || ''; + var bVal = b.cells[col].getAttribute('data-sort') || ''; + // Critical and Done: sort descending by default (critical/done first) + var defaultDesc = (col === 3); + var eff = defaultDesc ? !sortAsc : sortAsc; + var cmp = aVal.localeCompare(bVal, undefined, {numeric: true}); + return eff ? cmp : -cmp; + }); + rows.forEach(function(r) { tbody.appendChild(r); }); + renumberFocusRows(); + }); + }); })(); {% endblock %}