Tag a company All roles to read its big boards with the agents' wide reach; favourite scores only
Migration 21 adds companies.all_roles, tags every favourite of any agent and each company whose board had params {"reach": "all"} (logged per board, the param removed). reach.plan reads a tagged company's boards with the union of the enabled agents' require reach and the base reach; favourite no longer widens the fetch. POST /api/companies/{key}/all-roles sets it and queues a pull when on. The Companies list, the reader and the company strip draw the toggle beside the affinity buttons, the list filters on it, and the board's reach editor drops its All roles option.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d9a059e24
commit
5d5b7e7d3f
20 files changed
+422
-124
No files matched your search
@@ -1113,6 +1113,11 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
.affinity button[data-value="-1"][aria-pressed="true"] {
|
||||
color: var(--accent-fg); background: var(--error); border-color: var(--error);
|
||||
}
|
||||
/* The All roles tag, global and apart from the stances: green, the colour
|
||||
the app gives what widens (`--good`). */
|
||||
.affinity button[data-value="all"][aria-pressed="true"] {
|
||||
color: var(--accent-fg); background: var(--good); border-color: var(--good);
|
||||
}
|
||||
|
||||
/* agents */
|
||||
|
||||
@@ -1302,6 +1307,8 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
font-size: .96rem; text-decoration: none; color: inherit;
|
||||
}
|
||||
.crow .name { font-weight: 600; }
|
||||
/* A company row has one control more: the All roles tag after the stances. */
|
||||
#companies-list .crow { grid-template-columns: 1fr auto auto auto; }
|
||||
/* Only a name that is a link: the Watchlist draws one without a page to
|
||||
open as text, which must not look as if it led somewhere. */
|
||||
@media (hover: hover) {
|
||||
|
||||
+50
-1
@@ -16,7 +16,8 @@
|
||||
* Beside `api` on `window`, the few helpers more than one page script uses:
|
||||
* `count`, `cell`, `debounce`, `safeUrl`, and the company list with its
|
||||
* affinity control (`loadCompanies`, `companies`, `affinityControl`,
|
||||
* `setAffinity`). One copy each, since two copies of a helper is one of them
|
||||
* `setAffinity`) and the All roles tag beside it (`allRolesControl`). One
|
||||
* copy each, since two copies of a helper is one of them
|
||||
* being fixed.
|
||||
*
|
||||
* Affinity is per search agent. The three company helpers take the agent's
|
||||
@@ -183,7 +184,55 @@
|
||||
if (onChange) await onChange(updated);
|
||||
}
|
||||
|
||||
/* The All roles tag, one more toggle in the affinity buttons' fragment
|
||||
beside them, in a group of its own since it is global rather than an
|
||||
agent's stance: every board of the company is read with the agents'
|
||||
wide reach, Europe today, rather than their places (app/jobs/reach.py). On queues a pull on the server, as the other
|
||||
reopening switches do; off asks nothing, since no role closes until the
|
||||
next pull reads the board with its filter again. `onChange` runs after
|
||||
the server accepted it, with the company it answered. */
|
||||
function allRolesControl(companyKey, current, onChange) {
|
||||
const span = document.createElement("span");
|
||||
span.className = "affinity";
|
||||
span.setAttribute("role", "group");
|
||||
span.setAttribute("aria-label", "Company tag");
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.dataset.value = "all";
|
||||
button.textContent = "All";
|
||||
button.title = current
|
||||
? "All roles within the agents' wide reach (Europe), not only their places. Turning it "
|
||||
+ "off asks nothing first: no role closes until the next pull reads the board again."
|
||||
: "All roles: read this company's boards for all roles within the agents' wide reach "
|
||||
+ "(Europe), not only their places. Turning it on queues a pull.";
|
||||
button.setAttribute("aria-label", "All roles");
|
||||
button.setAttribute("aria-pressed", String(Boolean(current)));
|
||||
button.addEventListener("click", () => setAllRoles(companyKey, !current, onChange));
|
||||
span.appendChild(button);
|
||||
return span;
|
||||
}
|
||||
|
||||
async function setAllRoles(companyKey, on, onChange) {
|
||||
if (!companyKey) return;
|
||||
let updated;
|
||||
try {
|
||||
updated = await api(`/api/companies/${encodeURIComponent(companyKey)}/all-roles`, {
|
||||
method: "POST", body: { on },
|
||||
});
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
const company = companies.get(companyKey);
|
||||
if (company) company.all_roles = Boolean(updated.all_roles);
|
||||
window.toast.info(on
|
||||
? `${updated.name}: all roles within the agents' wide reach. `
|
||||
+ "Reading now, or with the pull right after."
|
||||
: `${updated.name}: back to its reach from the next pull.`);
|
||||
if (onChange) await onChange(updated);
|
||||
}
|
||||
|
||||
Object.assign(window, {
|
||||
api, count, cell, debounce, safeUrl, companies, loadCompanies, affinityControl, setAffinity,
|
||||
allRolesControl,
|
||||
});
|
||||
})();
|
||||
+26
-10
@@ -4,7 +4,9 @@
|
||||
* The list is app.js's shared company list (`/api/companies`), already
|
||||
* joined with each company's board subscription — its id and whether it is
|
||||
* on — so nothing here fetches `/api/sources` as well. The affinity buttons
|
||||
* are `affinityControl`, the same ones the Roles tab and the read page draw.
|
||||
* are `affinityControl`, the same ones the Roles tab and the read page draw,
|
||||
* and beside them `allRolesControl`, the All roles tag, which is global and
|
||||
* drawn with or without an agent.
|
||||
*
|
||||
* Liked and hidden are per search agent, so the `#c-agent` select above the
|
||||
* list says whose the list shows and whose the buttons set. It opens on the
|
||||
@@ -20,13 +22,17 @@
|
||||
*
|
||||
* A row with a board says what a pull asks it for ("reads DK, SE · agents",
|
||||
* `reach` from app/jobs/reach.py), and its editor has a second line that
|
||||
* sets the board's own reach: the agents', all roles, or its own countries
|
||||
* and remote, posted to `/api/sources/{id}/reach`.
|
||||
* sets the board's own reach: the agents', or its own countries and remote,
|
||||
* posted to `/api/sources/{id}/reach`. All roles within the agents' wide
|
||||
* reach (Europe) is the company's All roles tag instead, which the board's
|
||||
* own countries win over.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const { api, count, debounce, safeUrl, companies, loadCompanies, affinityControl } = window;
|
||||
const {
|
||||
api, count, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
|
||||
} = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
/** @type {object[]} the search agents, by id */
|
||||
@@ -205,8 +211,9 @@
|
||||
return form;
|
||||
}
|
||||
|
||||
/** The open row's reach editor, for a row with a board: the agents' reach,
|
||||
all roles, or the board's own countries and remote. */
|
||||
/** The open row's reach editor, for a row with a board: the agents' reach
|
||||
or the board's own countries and remote. The wide reach is the
|
||||
company's All roles tag, which the editor points to. */
|
||||
function reachEditor(company, rerender) {
|
||||
if (company.subscription_id == null) return null;
|
||||
const own = company.reach_params || {};
|
||||
@@ -215,11 +222,10 @@
|
||||
form.autocomplete = "off";
|
||||
const mode = document.createElement("select");
|
||||
mode.setAttribute("aria-label", `What ${company.name}'s board is asked for`);
|
||||
for (const [value, label] of [["agents", "Agents' reach"], ["all", "All roles"],
|
||||
["own", "These countries"]]) {
|
||||
for (const [value, label] of [["agents", "Agents' reach"], ["own", "These countries"]]) {
|
||||
mode.appendChild(new Option(label, value));
|
||||
}
|
||||
mode.value = own.reach === "all" ? "all" : (own.countries || own.remote != null ? "own" : "agents");
|
||||
mode.value = own.countries || own.remote != null ? "own" : "agents";
|
||||
const codes = document.createElement("input");
|
||||
codes.type = "text";
|
||||
codes.spellcheck = false;
|
||||
@@ -236,7 +242,12 @@
|
||||
const shown = () => { codes.hidden = remote.hidden = mode.value !== "own"; };
|
||||
mode.addEventListener("change", shown);
|
||||
shown();
|
||||
form.append(mode, codes, remote, save);
|
||||
const note = document.createElement("span");
|
||||
note.className = "muted small";
|
||||
note.textContent = company.all_roles
|
||||
? "The All roles tag is on; a reach set here wins over it."
|
||||
: "All roles within the agents' wide reach (Europe): the All tag beside the stars.";
|
||||
form.append(mode, codes, remote, save, note);
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
save.disabled = true;
|
||||
@@ -298,6 +309,7 @@
|
||||
case "favourite": return company.affinity === 2;
|
||||
case "liked": return company.affinity === 1;
|
||||
case "hidden": return company.affinity === -1;
|
||||
case "all_roles": return company.all_roles === true;
|
||||
case "on": return company.on === true;
|
||||
case "off": return company.on === false;
|
||||
case "unreadable": return company.subscription_id == null && !company.from_search;
|
||||
@@ -331,6 +343,10 @@
|
||||
if (agent != null) {
|
||||
row.appendChild(affinityControl(company.key, company.affinity, async () => render(), agent));
|
||||
}
|
||||
row.appendChild(allRolesControl(company.key, company.all_roles, async () => {
|
||||
await loadCompanies(agentId());
|
||||
render();
|
||||
}));
|
||||
row.appendChild(subLine(company, render));
|
||||
if (editing === company.key) {
|
||||
row.appendChild(boardEditor(company, render));
|
||||
|
||||
+18
-9
@@ -81,8 +81,8 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, judgeButtons,
|
||||
loadTracked, chipInput } = window;
|
||||
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, allRolesControl,
|
||||
judgeButtons, loadTracked, chipInput } = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
// Below this the rail is over the feed rather than beside it, and the reader
|
||||
@@ -1071,15 +1071,19 @@
|
||||
el.querySelector(".strip-drop").onclick = dropCompany;
|
||||
}
|
||||
const slot = el.querySelector(".affinity-slot");
|
||||
if (slot.dataset.affinity !== String(affinity)) {
|
||||
slot.dataset.affinity = String(affinity);
|
||||
const drawn = `${affinity}:${company ? company.all_roles : ""}`;
|
||||
if (slot.dataset.affinity !== drawn) {
|
||||
slot.dataset.affinity = drawn;
|
||||
slot.replaceChildren(affinityControl(key, affinity,
|
||||
(updated) => affinityChanged(key, company, updated), state.filter.agent));
|
||||
// The All roles tag needs a company row, which a first stance makes.
|
||||
if (company) slot.append(" ", allRolesControl(key, company.all_roles, renderStrip));
|
||||
// What ★ does, before; what it did, after.
|
||||
el.querySelector(".strip-note").textContent = affinity === 2
|
||||
? "★ Favourite: roles from every place the agent's required gates allow are listed."
|
||||
? "★ Favourite: roles from every place the agent's required gates allow are listed. "
|
||||
+ "All fetches them from a big board."
|
||||
: "★ Favourite also lists this company's roles outside your places, as far as the "
|
||||
+ "agent's required gates allow.";
|
||||
+ "agent's required gates allow. All fetches them from a big board.";
|
||||
}
|
||||
const n = state.total;
|
||||
el.querySelector(".strip-count").textContent = state.loaded
|
||||
@@ -1358,9 +1362,10 @@
|
||||
}
|
||||
|
||||
/* The company's ★ ▲ ⊘, the one place a company is judged outside the
|
||||
Companies page. A company seen only through a search has no row until
|
||||
its first change creates one, so the list is reloaded then. A change
|
||||
dims or undims its rows in the feed. */
|
||||
Companies page, and its All roles tag beside them. A company seen only
|
||||
through a search has no row until its first change creates one, so the
|
||||
list is reloaded then, and the tag, which needs a row, waits for it. A
|
||||
change dims or undims its rows in the feed. */
|
||||
function renderAffinity(slot, r) {
|
||||
const company = companies.get(r.company_key);
|
||||
if (!r.company_key) { slot.replaceChildren(); return; }
|
||||
@@ -1369,6 +1374,10 @@
|
||||
renderAffinity(slot, r);
|
||||
renderFeed();
|
||||
}, state.filter.agent));
|
||||
if (company) {
|
||||
slot.append(" ", allRolesControl(r.company_key, company.all_roles,
|
||||
async () => renderAffinity(slot, r)));
|
||||
}
|
||||
}
|
||||
|
||||
/* The answer, into the role on screen and into its row, whose excerpt is
|
||||
|
||||
Reference in new issue
Block a user