From f7159b9fc3bb05b8129b9c4e3f756c13a7f87d85 Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Tue, 17 Nov 2026 11:11:14 +0100 Subject: [PATCH 1/2] refactor(web): share the greyed icon button, and let a table filter start narrowed or only sort --- app/static/runs/launches.css | 3 --- app/static/style.css | 3 +++ app/static/tables.js | 24 +++++++++++++++--------- app/templates/_tables.html | 14 ++++++++++---- app/templates/runs/_launch_ask.html | 2 +- app/templates/runs/launches.html | 4 ++-- app/ui_tests/test_run_routes.py | 4 ++-- 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/app/static/runs/launches.css b/app/static/runs/launches.css index 24c322f9..e6ab049e 100644 --- a/app/static/runs/launches.css +++ b/app/static/runs/launches.css @@ -127,13 +127,10 @@ dialog.std-how.launch-delete { width: min(520px, calc(100vw - 32px)); } .grid.sortable.inventory thead th:not([data-type])::after { content: none; } .inventory td.inv-acts { position: relative; white-space: nowrap; } /* holds its hidden reason, inside the table's scroll */ /* Add, then Delete, side by side on every row */ .inventory .launch-add-btn:focus-visible { color: var(--text); } -.inventory .launch-delete-btn:hover, .inventory .launch-delete-btn:focus-visible { color: var(--bad); } -.inventory .icon-btn[aria-disabled="true"] { opacity: .4; background: none; border-color: transparent; cursor: default; } /* Delete it cannot: the slot kept, greyed, its reason reachable */ /* State and Launch stay put while the table scrolls sideways; State's header is its name for a screen reader only */ .inventory { --inv-state-w: 2.2rem; } .inventory [data-col="state"] { width: var(--inv-state-w); min-width: var(--inv-state-w); padding-left: 0; padding-right: 0; text-align: center; } .inventory [data-col="launch"] { --sticky-left: var(--inv-state-w); } -.inventory .sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } /* a run's state: its icon, coloured as the Runs page's state dots */ .inventory td[data-col="state"] .ic { vertical-align: middle; } .inventory .st-finished, .inventory .st-running, .inventory .st-preparing { color: var(--resolved); } diff --git a/app/static/style.css b/app/static/style.css index 3ecd015e..d3ae5231 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -1417,6 +1417,9 @@ a.chip { text-decoration: none; } } .rail-toggle:hover, .icon-btn:hover { color: var(--text); background: var(--surface); border-color: var(--border); } .rail-toggle:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; } +.icon-btn.danger:not([aria-disabled="true"]):is(:hover, :focus-visible) { color: var(--bad); } /* it deletes */ +.icon-btn[aria-disabled="true"] { opacity: .4; background: none; border-color: transparent; cursor: default; } /* it cannot here: the slot kept, greyed, its reason reachable */ +.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } /* a name for a screen reader only */ .ic-expand { display: none; } :root[data-rail="collapsed"] .ic-expand { display: block; } :root[data-rail="collapsed"] .ic-collapse { display: none; } diff --git a/app/static/tables.js b/app/static/tables.js index baab63f3..0f497379 100644 --- a/app/static/tables.js +++ b/app/static/tables.js @@ -53,20 +53,22 @@ window.NulliusTable = { macro's, each opened by its caret, or the tools macro's. `allowed`: column -> the Set of values ticked, or null when all are. A row passes when, for each column, one of its values (data-f-, one per line) is - ticked. `changed` runs after each change. */ + ticked; a box unticked at load filters from the start. `changed` runs + after each change. */ filters(scope, changed) { const allowed = {}; scope.querySelectorAll('[data-filter-menu]').forEach(menu => { const col = menu.dataset.filterMenu; const boxes = () => [...menu.querySelectorAll('input[data-value]')]; const btn = scope.querySelector(`.filter-btn[data-filter="${col}"]`); - const sync = () => { + const read = () => { const on = boxes().filter(b => b.checked).map(b => b.dataset.value); // All checked means "no filter": keeps the active marker honest. allowed[col] = on.length === boxes().length ? null : new Set(on); btn?.classList.toggle('on', Boolean(allowed[col])); - changed(); }; + const sync = () => { read(); changed(); }; + read(); menu.addEventListener('change', sync); menu.addEventListener('click', e => { if (e.target.closest('[data-all]')) { boxes().forEach(b => b.checked = true); sync(); } @@ -153,19 +155,24 @@ window.NulliusTable = { /* A table's Filter and Sort by menus (the tools macro), under `tools`, in place of header carets. Filter counts the columns it narrows; Sort by sets the sort, and follows a header click. `changed` runs after either. + A toolbar without Filter (the macro given no filters) only sorts. Returns {passes, resort}, as filters and sortable do. */ toolbar(table, tools, changed) { const [fbtn, fmenu, sbtn, smenu] = ['filter', 'sort'].flatMap(k => [tools.querySelector(`[data-tools-btn="${k}"]`), tools.querySelector(`[data-tools="${k}"]`)]); - const count = fbtn.querySelector('.tools-count'); - const narrowed = () => { + const count = fbtn?.querySelector('.tools-count'); + const mark = () => { const n = Object.values(f.allowed).filter(Boolean).length; count.textContent = n || ''; count.hidden = !n; - changed(); }; - const f = this.filters(fmenu, narrowed); - fmenu.querySelector('[data-clear]').addEventListener('click', () => { f.clear(); narrowed(); }); + const narrowed = () => { mark(); changed(); }; + const f = fmenu ? this.filters(fmenu, narrowed) : {allowed: {}, passes: () => true}; + if (fmenu) { + mark(); + fmenu.querySelector('[data-clear]').addEventListener('click', () => { f.clear(); narrowed(); }); + this.menu(fbtn, fmenu); + } const heads = [...table.tHead.rows[0].cells]; const sync = () => { const {col, dir} = resort.state(), on = col === null ? '' : heads[col].dataset.col; @@ -180,7 +187,6 @@ window.NulliusTable = { resort.set(idx, dir); }); sync(); - this.menu(fbtn, fmenu); this.menu(sbtn, smenu); return {passes: f.passes, resort}; }, diff --git a/app/templates/_tables.html b/app/templates/_tables.html index 9791ac73..fd9e1595 100644 --- a/app/templates/_tables.html +++ b/app/templates/_tables.html @@ -17,9 +17,10 @@ {% endmacro %} {# A table's Filter and Sort by menus, in place of header carets (static/tables.js `toolbar`). `filters`: a list of - (col, label, choices), choices as filter_button's; `sorts`: a list of (col, label), the sortable headers. #} -{% macro tools(filters, sorts) %} -