diff --git a/app/static/roles.js b/app/static/roles.js index c4a94ea..e590031 100644 --- a/app/static/roles.js +++ b/app/static/roles.js @@ -42,8 +42,10 @@ * the same three whichever agent is viewed, and all carry the agent's votes. * What fits me needs a CV: an agent without one is shown What I'm looking * for, as an agentless page is shown Newest. Every order keeps to the - * roles the agent's fetch gate passes, which a note under Viewing as says; - * Show gated (`gated=true`) adds the ones it rejects, with the reason. + * roles the agent's fetch gate passes, which a note under Viewing as says, + * and for a phone, whose rail is shut, the end of the list and the empty + * state; Show gated (`gated=true`) adds the ones it rejects, with the + * reason. The reader says when the gate rejects the role open. * * Saved filters belong to the viewing agent (`/api/agents/{id}/filters`): * pills in the rail, newsdesk's `#active` row, each the query string @@ -1413,15 +1415,24 @@ const retry = empty.querySelector("[data-retry]"); if (retry) retry.onclick = () => (state.agentsLoaded ? loadFeed() : start()); } else { + // An agent's list is what its fetch gate passes, which a phone, + // whose rail is shut, learns here and at the end of the list. const filtered = state.q || filtersOn(); + const gate = gateKept() ? `${esc(gateOwner())} fetch gate` : ""; empty.innerHTML = filtered ? `

Nothing matches

-

No open role fits these filters. +

No open role ${gate ? `that passes ${gate} ` : ""}fits these filters. and start again.

` - : `

No roles yet

-

Nothing has been pulled yet. Runs starts one; - Job boards and - Company boards decide what it brings in.

`; + : gate + ? `

No roles yet

+

No open role passes ${gate} yet. Runs + starts a pull; Job boards and + Company boards decide what it + brings in, Search agents what the gate passes.

` + : `

No roles yet

+

Nothing has been pulled yet. Runs starts one; + Job boards and + Company boards decide what it brings in.

`; const clear = empty.querySelector("[data-clear]"); if (clear) clear.onclick = () => { state.q = ""; $("#search").value = ""; clearFilters(); }; } @@ -1434,9 +1445,32 @@ const end = $("#feed-end"); const n = state.items.length; end.hidden = !state.loaded || !n; - end.textContent = state.more - ? "Loading more…" - : `${number.format(n)} ${n === 1 ? "role" : "roles"} — that is all of them.`; + end.textContent = state.more ? "Loading more…" : `${listSaid(n)} — that is all of them.`; + } + + /** Whether the list keeps to the viewing agent's fetch gate: there is an + agent, and Show gated is off. */ + const gateKept = () => state.filter.agent !== null && !state.filter.gated; + + /** Whose fetch gate, for a sentence: the viewing agent's name, or "this + agent's" until the agents are in. */ + function gateOwner() { + const agent = viewed(); + return agent ? `${agent.name}'s` : "this agent's"; + } + + /** The rows on screen in words, for the end of the list: how many and, + with an agent viewing, that they are what its fetch gate passes (and + the filters keep), or with Show gated that they hold what it rejects. */ + function listSaid(n) { + const roles = `${number.format(n)} ${n === 1 ? "role" : "roles"}`; + if (state.filter.agent === null) return roles; + const gate = `${gateOwner()} fetch gate`; + const filtered = Boolean(state.q) || filtersOn() > (state.filter.gated ? 1 : 0); + if (state.filter.gated) { + return `${roles}${filtered ? " in these filters" : ""}, the ones ${gate} rejects included`; + } + return `${roles} ${n === 1 ? "passes" : "pass"} ${gate}${filtered ? " and these filters" : ""}`; } /* With exactly one company filtered, which is where its name leads, a @@ -1808,6 +1842,10 @@ const waiting = state.summarising === state.readingUid; const teaser = loaded && !r.article_text && out && (r.description || "").length < TEASER; + // Under the title, in the copy note's style: that the viewing agent's + // fetch gate rejects the role and why (`gated_reason`), since a link + // from elsewhere, a saved role on Applications say, opens one the feed + // never lists. el.innerHTML = `
@@ -1831,6 +1869,9 @@

${esc(r.title || "")}

${loaded && r.dup_of ? `

A copy of a posting the feed lists once.

` : ""} + ${loaded && state.filter.agent !== null && r.gated_reason + ? `

Rejected by ${esc(gateOwner())} fetch gate: + ${esc(r.gated_reason)}. The feed lists it only with Show gated.

` : ""} ${pay ? `

${esc(pay.range)}

${pay.detail ? `

${esc(pay.detail)}

` : ""} ${pay.note ? `

${esc(pay.note)}

` : ""}` : ""} diff --git a/tests/test_feed_ui.py b/tests/test_feed_ui.py index 799b19c..ad3ba38 100644 --- a/tests/test_feed_ui.py +++ b/tests/test_feed_ui.py @@ -119,3 +119,16 @@ def test_a_company_on_settings_sources_links_to_its_company_view_by_key() -> Non script = (STATIC / "companies.js").read_text() assert "`/?company_keys=${encodeURIComponent(company.key)}`" in script assert "/?company=" not in script + + +def test_the_end_of_the_list_the_empty_state_and_the_reader_name_the_fetch_gate() -> None: + """A phone's rail, which holds the note, is shut, so the end of the list + and the empty state say whose fetch gate the list keeps to, and the + reader says when that gate rejects the role open (`gated_reason`).""" + script = (STATIC / "roles.js").read_text() + assert "`${listSaid(n)} — that is all of them.`" in script + assert '${n === 1 ? "passes" : "pass"} ${gate}' in script + assert "No open role ${gate ? `that passes ${gate} ` : \"\"}fits these filters." in script + assert "No open role passes ${gate} yet." in script + assert "Rejected by ${esc(gateOwner())} fetch gate:" in script + assert "loaded && state.filter.agent !== null && r.gated_reason" in script