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
+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));
|
||||
|
||||
Reference in new issue
Block a user