diff --git a/web/assets/app.js b/web/assets/app.js index 5239271..2d77853 100644 --- a/web/assets/app.js +++ b/web/assets/app.js @@ -1715,6 +1715,8 @@ var count = resultsRoot.querySelector('.results-count'); var noun = (count && count.dataset.noun) || 'trails'; var empty = resultsRoot.querySelector('.empty-state'); + var unseasoned = resultsRoot.querySelector('[data-unseasoned]'); + var unseasonedText = resultsRoot.querySelector('[data-unseasoned-text]'); var active = form.querySelector('.filters__active'); var lenHint = document.getElementById('len-hint'); var listHead = resultsRoot.querySelector('.list-head'); @@ -2088,6 +2090,17 @@ count.appendChild(document.createTextNode(' ' + words)); } if (empty) empty.hidden = shown.length > 0; + /* With a month chosen, say how many trails that pass everything else are left out for having no + season on file, counted over the same rows as the list. */ + if (unseasoned && el.month) { + var noSeason = 0; + if (s.month) rows.forEach(function (d) { if (!d.months.length && FacetCount.passes(d, s, 'month')) noSeason++; }); + unseasoned.hidden = noSeason === 0; + if (noSeason) { + unseasonedText.textContent = noSeason + (noSeason === 1 ? ' trail with no season on file is not shown.' + : ' trails with no season on file are not shown.'); + } + } if (listHead) listHead.hidden = shown.length === 0; relabel(s, c); setText(lenHint, describeLength(s)); @@ -2115,6 +2128,14 @@ form.addEventListener('change', function () { apply(true); }); form.addEventListener('submit', function (e) { e.preventDefault(); }); form.addEventListener('reset', function () { setTimeout(function () { apply(true); }, 0); }); + resultsRoot.querySelectorAll('[data-unseasoned-show]').forEach(function (b) { + /* Showing them is clearing the month; the rest of the filters stay. */ + b.addEventListener('click', function () { + if (!el.month) return; + el.month.value = ''; + el.month.dispatchEvent(new Event('change', { bubbles: true })); + }); + }); resultsRoot.querySelectorAll('[data-reset]').forEach(function (b) { b.addEventListener('click', function () { form.reset(); el.q.focus(); }); }); diff --git a/web/assets/style.css b/web/assets/style.css index c3cb1e3..342659e 100644 --- a/web/assets/style.css +++ b/web/assets/style.css @@ -1244,6 +1244,9 @@ html.js .filters__panels:not([data-open]) { display: none; } .results[data-finder] .results-sort__label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } .results[data-finder] .results-count { flex: none; } } +.results-note { margin-block: calc(-1 * var(--space-1)) var(--space-3); color: var(--ink-2); font: 400 var(--step--1)/1.4 var(--font-sans); } +.results-note[hidden] { display: none; } +.results-note__show { padding: 0; border: 0; background: none; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; } .key { display: flex; flex-wrap: wrap; diff --git a/web/olt/home.py b/web/olt/home.py index a0493e1..ffd053a 100644 --- a/web/olt/home.py +++ b/web/olt/home.py @@ -618,13 +618,18 @@ def results(recs=None, *, finder=False, groups=None, routes_list=False, default_ tools = sort_select(default_sort, saved=saved, ranked=ranked, wholly=wholly) dflt = SAVED_ORDER[0] if saved else "rank" if ranked else HERE_ORDER if wholly else default_sort finder_attr = " data-finder" if finder else "" + # Under the count, while a month is chosen: how many trails are left out for having no season on + # file, and a way to see them (app.js fills it in from the rows, the same ones the list is). + unseasoned = ('\n ' + if finder else "") return Markup(f"""
{count}
{tools}
-
+
{unseasoned} {key(official=not only_routes)} {list_head(default_sort)}{lists}{empty} """) diff --git a/web/tests/test_filter_bar.py b/web/tests/test_filter_bar.py index ba17859..0985e84 100644 --- a/web/tests/test_filter_bar.py +++ b/web/tests/test_filter_bar.py @@ -365,5 +365,46 @@ class PanelInTheFlowTest(unittest.TestCase): self.assertIn("if (window.location.hash === '#filters') showPanels(true);", js) +class UnseasonedNoteTest(unittest.TestCase): + """A month filter says how many trails it leaves out for having no season on file.""" + + def test_a_finder_list_has_the_note_and_it_starts_hidden(self): + recs = recordsmod.load_records(ROOT) + body = str(home.results(recs, finder=True)) + self.assertIn('