diff --git a/routers/focus.py b/routers/focus.py index 9420f64..d21ad0a 100644 --- a/routers/focus.py +++ b/routers/focus.py @@ -71,7 +71,7 @@ async def focus_view( dl = item.get("domain_name") or "General" dc = item.get("domain_color") or "" if dk not in domain_map: - domain_map[dk] = {"label": dl, "color": dc, "rows": []} + domain_map[dk] = {"key": dk, "label": dl, "color": dc, "rows": []} domain_map[dk]["rows"].append(item) hierarchy = list(domain_map.values()) diff --git a/static/style.css b/static/style.css index 01fc77c..b30a62e 100644 --- a/static/style.css +++ b/static/style.css @@ -1107,6 +1107,9 @@ a:hover { color: var(--accent-hover); } transition: width 0.3s; } +/* ---- Focus Domain Toggle ---- */ +.focus-domain-header:hover td { background: var(--surface3); } + /* ---- Focus Drag-and-Drop ---- */ .focus-drag-row { cursor: grab; } .focus-drag-row.dragging { opacity: 0.4; background: var(--accent-soft); } diff --git a/templates/focus.html b/templates/focus.html index 8728beb..c3f1122 100644 --- a/templates/focus.html +++ b/templates/focus.html @@ -22,14 +22,18 @@ {% for domain in hierarchy %} - - - - {{ domain.label }} - - + + + + + + {{ domain.label }} + {{ domain.rows|length }} + + + - + {% for item in domain.rows %} {% with reorder_url="/focus/reorder", item_id=item.id, extra_fields={"focus_date": focus_date|string} %}{% include 'partials/reorder_arrows.html' %}{% endwith %} @@ -191,6 +195,26 @@ }); } + // Domain group collapse/expand + document.querySelectorAll('.focus-domain-header').forEach(function(header) { + var key = 'focus-domain-' + header.dataset.domainKey; + var tbody = document.querySelector('tbody.focus-drag-group[data-domain-key="' + header.dataset.domainKey + '"]'); + var chevron = header.querySelector('.focus-domain-chevron'); + // Restore saved state + if (localStorage.getItem(key) === 'true') { + tbody.style.display = 'none'; + chevron.style.transform = 'rotate(0deg)'; + } else { + chevron.style.transform = 'rotate(90deg)'; + } + header.addEventListener('click', function() { + var hidden = tbody.style.display === 'none'; + tbody.style.display = hidden ? '' : 'none'; + chevron.style.transform = hidden ? 'rotate(90deg)' : 'rotate(0deg)'; + localStorage.setItem(key, !hidden); + }); + }); + // Drag-and-drop reorder within domain groups var dragRow = null; var dragGroup = null;