Drop Advanced › Other rules from the agent form, so an agent's gates are the fetch gate's four parts: a stored gate the parts cannot say is named in a note under the fetch gate and sent back unchanged on Save, and the card still says it in words
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
136047023e
commit
1913101061
7 files changed
+193
-125
No files matched your search
+54
-83
@@ -9,13 +9,15 @@
|
||||
* ADR's order: the world (the scope select), the location (a short list of
|
||||
* lines a role passes by matching any one of: countries, towns, remote), the
|
||||
* role exclusion (the titles to leave out) and the role fetch (the fetch
|
||||
* terms), over a row per remaining rule under Advanced; a gate the four parts
|
||||
* cannot say lands in a row, so a load and a save lose nothing. A gate is a
|
||||
* field, values and a mode (must, one of, not), with no weight. After it come
|
||||
* the analytics filter (the best N by prompt closeness and the best M by CV
|
||||
* closeness, each with a minimum level), the want feed score weights (prompt
|
||||
* closeness, newness, company like, job like), the CV match weights and the
|
||||
* size of summarise. Edit turns a card
|
||||
* terms), and nothing else: seniority, pay and the like are filters on Roles.
|
||||
* A gate is a field, values and a mode (must, one of, not), with no weight.
|
||||
* A stored gate the four parts cannot say, which only the config or the API
|
||||
* writes, is named in a note under the fetch gate and sent back as it came,
|
||||
* so a load and a save lose nothing. After the fetch gate come the analytics
|
||||
* filter (the best N by prompt closeness and the best M by CV closeness, each
|
||||
* with a minimum level), the want feed score weights (prompt closeness,
|
||||
* newness, company like, job like), the CV match weights and the size of
|
||||
* summarise. Edit turns a card
|
||||
* into the form from the page's `<template>`, in place, and New agent puts a
|
||||
* blank card on top in the same state. One card edits at a time, so the
|
||||
* form's ids stay unique. Votes, liked companies and scores are the agent's,
|
||||
@@ -61,9 +63,8 @@
|
||||
const NEW = "new";
|
||||
// Europe as the starter agents spell it (static/remote.js).
|
||||
const EUROPE = rh.EUROPE;
|
||||
const FIELDS = ["place", "country", "remote", "remote_from", "seniority", "function", "salary_min",
|
||||
"currency", "permit", "languages", "company", "title"];
|
||||
const MODES = [["require", "must"], ["any", "one of"], ["exclude", "not"]];
|
||||
// A gate's mode in the words of the note on the gates the form keeps.
|
||||
const MODES = { require: "must", any: "one of", exclude: "not" };
|
||||
|
||||
/** @type {object[]} every agent, as the server lists them */
|
||||
let agents = [];
|
||||
@@ -263,8 +264,8 @@
|
||||
}
|
||||
|
||||
// The region and place in words, one sentence led by the region, then the lines a
|
||||
// role may match, with the one-of rows among them since they are the same
|
||||
// group: "Within Europe: keeps roles anywhere in Denmark, in Malmö, Lund or
|
||||
// role may match, with any other one-of gates among them since they are the
|
||||
// same group: "Within Europe: keeps roles anywhere in Denmark, in Malmö, Lund or
|
||||
// Helsingborg, or remote, and leaves out the rest." The lines add up, which
|
||||
// the first wording ("Roles in ...") left the owner to guess.
|
||||
function whereSentence(where, others) {
|
||||
@@ -381,7 +382,7 @@
|
||||
// ---------------------------------------------------------------- the form
|
||||
|
||||
// Tell the form something changed that no field typed: a chip or a row
|
||||
// added or removed. It marks the form dirty and redraws the gates view.
|
||||
// added or removed. It marks the form dirty and redraws the gates' sentence.
|
||||
function changed(node) {
|
||||
node.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}
|
||||
@@ -556,9 +557,9 @@
|
||||
return box;
|
||||
}
|
||||
|
||||
// A language as a row, after the rule rows: a code, a level, Remove. The
|
||||
// code is two letters, which the server turns into the language; its name
|
||||
// is the row's title where the browser knows it.
|
||||
// A language as a row: a code, a level, Remove. The code is two letters,
|
||||
// which the server turns into the language; its name is the row's title
|
||||
// where the browser knows it.
|
||||
function languageRow(language, remove) {
|
||||
const row = el("div", "rule-row");
|
||||
const code = el("input");
|
||||
@@ -584,32 +585,32 @@
|
||||
return { node: row, read: () => ({ language: code.value.trim().toLowerCase(), level: level.value }) };
|
||||
}
|
||||
|
||||
// A gate as a row: field, mode, values and Remove. Values untouched since the load are sent as they came, so a
|
||||
// value with a comma in it survives a save.
|
||||
function ruleRow(gate, remove) {
|
||||
const row = el("div", "rule-row");
|
||||
const field = select(FIELDS.map((f) => [f, f.replace("_", " ")]), gate.field, "Field");
|
||||
const mode = select(MODES, gate.mode, "Mode");
|
||||
const values = el("input");
|
||||
values.type = "text";
|
||||
values.required = true;
|
||||
values.spellcheck = false;
|
||||
values.placeholder = "senior, staff";
|
||||
values.value = gate.values.join(", ");
|
||||
values.setAttribute("aria-label", "Values, separated by commas");
|
||||
const loaded = values.value;
|
||||
const drop = linky("Remove");
|
||||
drop.addEventListener("click", () => remove(row));
|
||||
row.append(field, mode, values, drop);
|
||||
// The gates the fetch gate's four parts say, in the order the starter
|
||||
// agents have them: the world, the location lines and the titles left out,
|
||||
// then `kept`, the stored gates the parts cannot say, as they came. `parts`
|
||||
// holds what the form reads: `scope` (europe, countries, everywhere) and
|
||||
// its `scoped` countries, the `within` countries, the `towns`, `remote`
|
||||
// (none, scope, from) and its `from` areas, and the `titles`.
|
||||
function formGates(parts, kept = []) {
|
||||
const out = [];
|
||||
const { scope, scoped, within, towns: lines, remote, from, titles } = parts;
|
||||
if (scope === "europe") out.push({ field: "country", values: rh.europeWith(within), mode: "require" });
|
||||
if (scope === "countries" && scoped.length) out.push({ field: "country", values: scoped, mode: "require" });
|
||||
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
||||
if (remote === "scope") out.push({ field: "remote", values: ["remote"], mode: "any" });
|
||||
if (remote === "from" && from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
||||
if (lines.length) out.push({ field: "place", values: lines, mode: "any" });
|
||||
if (titles.length) out.push({ field: "title", values: titles, mode: "exclude" });
|
||||
return out.concat(kept);
|
||||
}
|
||||
|
||||
function read() {
|
||||
const parts = values.value === loaded
|
||||
? gate.values
|
||||
: values.value.split(",").map((v) => v.trim()).filter(Boolean)
|
||||
.map((v) => (field.value === "salary_min" ? Number(v) : v));
|
||||
return { field: field.value, values: parts, mode: mode.value };
|
||||
}
|
||||
return { node: row, read };
|
||||
// The note on the gates the form keeps: "The form cannot edit these rules,
|
||||
// and Save keeps them as stored: must: with seniority senior; not: at Acme."
|
||||
function keptNote(kept) {
|
||||
if (!kept.length) return "";
|
||||
const said = kept.map((g) => `${MODES[g.mode] || g.mode}: ${phrase(g)}`).join("; ");
|
||||
return `The form cannot edit ${kept.length > 1 ? "these rules" : "this rule"}, and Save keeps `
|
||||
+ `${kept.length > 1 ? "them" : "it"} as stored: ${said}.`;
|
||||
}
|
||||
|
||||
function form(row) {
|
||||
@@ -710,51 +711,18 @@
|
||||
remoteFrom.node.hidden = remoteMode.value !== "from";
|
||||
};
|
||||
offer();
|
||||
$("details.advanced", f).open = rest.length > 0;
|
||||
const kept = $("#a-kept", f);
|
||||
kept.textContent = keptNote(rest);
|
||||
kept.hidden = !rest.length;
|
||||
|
||||
const rules = [];
|
||||
const dropRule = (node) => {
|
||||
rules.splice(rules.findIndex((r) => r.node === node), 1);
|
||||
node.remove();
|
||||
changed(f);
|
||||
};
|
||||
const addRule = (gate) => {
|
||||
const entry = ruleRow(gate, dropRule);
|
||||
rules.push(entry);
|
||||
$("#a-rules", f).appendChild(entry.node);
|
||||
return entry;
|
||||
};
|
||||
rest.forEach(addRule);
|
||||
$("#a-add-rule", f).addEventListener("click", () => {
|
||||
$("select", addRule({ field: "seniority", values: [], mode: "require" }).node).focus();
|
||||
changed(f);
|
||||
});
|
||||
|
||||
// The gates the fetch gate's three parts say, in the order the starter
|
||||
// agents have them: the region, the place lines, and the titles left out.
|
||||
function whereGates() {
|
||||
const out = [];
|
||||
const within = countries.values();
|
||||
const towns = places.values();
|
||||
const from = remoteFrom.values();
|
||||
if (scope.value === "europe") out.push({ field: "country", values: rh.europeWith(within), mode: "require" });
|
||||
if (scope.value === "countries" && scoped.values().length) {
|
||||
out.push({ field: "country", values: scoped.values(), mode: "require" });
|
||||
}
|
||||
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
||||
if (remoteMode.value === "scope") out.push({ field: "remote", values: ["remote"], mode: "any" });
|
||||
if (remoteMode.value === "from" && from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
||||
if (towns.length) out.push({ field: "place", values: towns, mode: "any" });
|
||||
const left = titles.values();
|
||||
if (left.length) out.push({ field: "title", values: left, mode: "exclude" });
|
||||
return out;
|
||||
}
|
||||
// The gates Save sends: the fetch gate's, then the rows. The sentence
|
||||
// under it says them all, as the card will, rows included.
|
||||
const gates = () => whereGates().concat(rules.map((r) => r.read()));
|
||||
// The gates Save sends: the four parts', then the kept ones. The sentence
|
||||
// under them says them all, as the card will, the kept ones included.
|
||||
const gates = () => formGates({
|
||||
scope: scope.value, scoped: scoped.values(), within: countries.values(), towns: places.values(),
|
||||
remote: remoteMode.value, from: remoteFrom.values(), titles: titles.values(),
|
||||
}, rest);
|
||||
const view = () => {
|
||||
offer();
|
||||
$("#a-gates", f).value = JSON.stringify(gates(), null, 2);
|
||||
$("#a-where-sum", f).textContent = rulesLine(gates()) || "Passes every role.";
|
||||
};
|
||||
view();
|
||||
@@ -978,6 +946,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// For tests/js/agents.test.mjs: what Save sends and how it is said.
|
||||
window.agentGates = { formGates, keptNote, rulesLine };
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
if (!$("#agents-list")) return;
|
||||
$("#a-new").addEventListener("click", () => open(null));
|
||||
|
||||
+3
-9
@@ -1300,8 +1300,6 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
background: var(--bg); border: 1px solid var(--line);
|
||||
border-radius: .3rem; padding: .35rem .5rem; width: 100%;
|
||||
}
|
||||
/* Prose in a textarea is read in the page face; JSON is in the mono one. */
|
||||
.agent-form textarea.code { font-family: var(--mono); font-size: .85rem; }
|
||||
.agent-form .hint { color: var(--dim); font-size: .8rem; overflow-wrap: anywhere; }
|
||||
.weights { display: flex; gap: .75rem; flex-wrap: wrap; border: 1px solid var(--line); border-radius: .3rem; }
|
||||
/* A label that wraps to two lines pushes its box down; the boxes stay in line. */
|
||||
@@ -1316,14 +1314,13 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
}
|
||||
/* The fieldsets that hold rows: a column, the Add button under the rows. */
|
||||
.agent-form fieldset.prompts, .agent-form fieldset.where, .agent-form fieldset.titles,
|
||||
.agent-form fieldset.terms,
|
||||
.agent-form fieldset.rules {
|
||||
.agent-form fieldset.terms {
|
||||
display: flex; flex-direction: column; align-items: stretch; gap: .5rem; min-width: 0;
|
||||
border: 1px solid var(--line); border-radius: .3rem;
|
||||
}
|
||||
.agent-form fieldset > button { align-self: flex-start; }
|
||||
/* A prompt or a rule as a row of a list, after `.crow`: the name and Remove
|
||||
on line one, the text spanning the row under them. A rule row wraps like
|
||||
/* A prompt or a language as a row of a list, after `.crow`: the name and Remove
|
||||
on line one, the text spanning the row under them. A language row wraps like
|
||||
`.crow .board-edit`, so a phone takes it in two lines rather than scrolling. */
|
||||
.prompt-row {
|
||||
display: grid; grid-template-columns: 1fr auto; align-items: center;
|
||||
@@ -1353,9 +1350,6 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
.agent-form .chips input[type="text"] { flex: 1 1 6rem; width: auto; min-width: 0; }
|
||||
.agent-form .chips select { flex: 0 1 12rem; min-width: 0; max-width: 100%; }
|
||||
.chips .tag span { color: var(--faint); }
|
||||
.agent-form details summary { cursor: pointer; color: var(--dim); font-size: .9rem; }
|
||||
.agent-form details[open] summary { margin-bottom: .5rem; }
|
||||
.agent-form .advanced-body { display: flex; flex-direction: column; gap: .6rem; }
|
||||
|
||||
/* ================================================================ */
|
||||
/* companies and sources — the Sources page's sections, */
|
||||
|
||||
+12
-10
@@ -1,7 +1,8 @@
|
||||
/* Where a remote role may be worked from, as the pages say it: the words of
|
||||
* the badge, the picks of the agent's "Remote, open to someone in" chips, and
|
||||
* how an agent's gates share out between the fetch gate's blocks and Other rules. No
|
||||
* DOM in it, so `tests/js/remote.test.mjs` can walk it without a browser.
|
||||
* how an agent's gates share out between the fetch gate's blocks and the rest
|
||||
* the form keeps as stored. No DOM in it, so `tests/js/remote.test.mjs` can
|
||||
* walk it without a browser.
|
||||
*
|
||||
* The area is a place token in three spellings, one per layer: `remote:<place
|
||||
* token>` on the Roles rail and in the address, `<place token>` in a
|
||||
@@ -61,18 +62,19 @@
|
||||
}
|
||||
|
||||
/** Share out an agent's gates between the fetch gate's blocks (region,
|
||||
place, titles to leave out) and Other rules. Each line takes the first
|
||||
gate it can say whole; the rest are rows. A gate has a field, values and
|
||||
a mode (require, any, exclude) and no weight; a gate with a mode the
|
||||
form does not know, such as an old prefer, stays a row.
|
||||
place, titles to leave out) and the rest, which the form cannot edit
|
||||
and keeps as stored. Each line takes the first gate it can say whole.
|
||||
A gate has a field, values and a mode (require, any, exclude) and no
|
||||
weight; a gate with a mode the form does not know, such as an old
|
||||
prefer, is in the rest.
|
||||
|
||||
The scope line is the first plain require gate on country: `europe`
|
||||
when it is exactly Europe and the countries line (`europeWith`),
|
||||
`countries` with its codes as chips otherwise, `everywhere` when there
|
||||
is none. Any other require gate on country is a row. The remote line is
|
||||
`scope` for the one-of on `remote: [remote]` (remote, within the
|
||||
scope), `from` for a one-of on `remote_from`, else `none`; when both
|
||||
are there `remote_from` wins and the plain one stays a row. */
|
||||
is none. Any other require gate on country is in the rest. The remote
|
||||
line is `scope` for the one-of on `remote: [remote]` (remote, within
|
||||
the scope), `from` for a one-of on `remote_from`, else `none`; when
|
||||
both are there `remote_from` wins and the plain one is in the rest. */
|
||||
function distribute(gates) {
|
||||
const where = { scope: null, countries: null, places: null, remote: { mode: "none", values: [] }, titles: null };
|
||||
const rest = [];
|
||||
|
||||
Reference in new issue
Block a user