feat(orchestrator): draw agents and chairs as a matrix organigram
The agents hierarchy gains a matrix org chart: agents as columns, chairs as rows, so one agent with several chairs shows every one of them; a Home tile can pin it. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14). 🎯 Fix: 82 % 💥 Break: 8 % 💸 Tokens: 90 % ⏱️ Velocity: 90 % 🛡️ Security: 100 % 🏆 Score: 93 🚦 Gate: ⛔ fix 82 % < 90, break 8 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48f26b678a
commit
2b4c3baaa0
8 files changed
+641
-68
No files matched your search
@@ -503,6 +503,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
|
||||
{% include "plan.js" %}
|
||||
|
||||
{% include "kanban.js" %}
|
||||
|
||||
{% include "organigram.js" %}
|
||||
</script>
|
||||
<script nonce="{{ nonce }}">
|
||||
{# Jinja drops each file's last newline and trim_blocks the one after the tag: the blank lines keep consecutive modules on separate lines #}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
const Organigram = (() => {
|
||||
"use strict";
|
||||
const LINE_KINDS = ["line", "work"];
|
||||
const RANK = ["chair", "line", "work", "cluster", "other"];
|
||||
const SUPERIOR = ["A", "C"];
|
||||
const PRESIDENTS = {id: "group:work", kind: "work", label: "Presidents"};
|
||||
const BEND = 36;
|
||||
|
||||
const byName = (a, b) => a.localeCompare(b, "en");
|
||||
const byOffice = (a, b) => byName(a.office, b.office);
|
||||
const rankOf = (claim) => (RANK.includes(claim.kind) ? RANK.indexOf(claim.kind) : RANK.length);
|
||||
const ranked = (a, b) => rankOf(a) - rankOf(b) || byOffice(a, b);
|
||||
|
||||
/**
|
||||
* @param claim - a council claim with its kind: chair, line, work, cluster or other.
|
||||
* @returns "chair" for the chair; "line" for a domain chair (<dimension>/<line>) and a work/* president, both in line
|
||||
* under the chair; "staff" for a cluster/* organizer and every single-segment office, drawn beside the chair.
|
||||
*/
|
||||
function position(claim) {
|
||||
if (claim.kind === "chair") {
|
||||
return "chair";
|
||||
}
|
||||
return LINE_KINDS.includes(claim.kind) ? "line" : "staff";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param claims - the council claims.
|
||||
* @returns {chair, staff, units}: chair the chair's claim or null; staff the staff positions, organizers before the
|
||||
* other offices, each by office; units the line units, one per dimension by name and then the presidents, each
|
||||
* {id, kind, label, positions} with its positions by office.
|
||||
*/
|
||||
function chart(claims) {
|
||||
const lines = claims.filter((claim) => position(claim) === "line").sort(byOffice);
|
||||
const dimensions = [...new Set(lines.filter((claim) => claim.kind === "line").map((claim) => claim.dimension))].sort(byName);
|
||||
const units = dimensions.map((dimension) => ({id: `dimension:${dimension}`, kind: "dimension", label: dimension, positions: lines.filter((claim) => claim.kind === "line" && claim.dimension === dimension)}));
|
||||
const presidents = lines.filter((claim) => claim.kind === "work");
|
||||
return {
|
||||
chair: claims.find((claim) => claim.kind === "chair") || null,
|
||||
staff: claims.filter((claim) => position(claim) === "staff").sort(ranked),
|
||||
units: presidents.length ? [...units, {...PRESIDENTS, positions: presidents}] : units,
|
||||
};
|
||||
}
|
||||
|
||||
function officesOf(claims) {
|
||||
const offices = new Map();
|
||||
for (const claim of claims.filter((entry) => entry.agent).sort(ranked)) {
|
||||
offices.set(claim.agent, [...(offices.get(claim.agent) || []), claim]);
|
||||
}
|
||||
return offices;
|
||||
}
|
||||
|
||||
function doers(row, offices) {
|
||||
const responsible = Object.entries(row.roles).filter(([, letters]) => letters.includes("R")).map(([party]) => party);
|
||||
return [...new Set([...responsible, row.worker])].filter((name) => offices.has(name));
|
||||
}
|
||||
|
||||
function superiors(row, agent, offices) {
|
||||
return Object.entries(row.roles)
|
||||
.map(([party, letters]) => ({party, letters: SUPERIOR.filter((letter) => letters.includes(letter)).join("")}))
|
||||
.filter(({party, letters}) => party !== agent && letters && offices.has(party))
|
||||
.map(({party, letters}) => ({office: offices.get(party)[0], letters}))
|
||||
.filter(({office}) => office.kind !== "chair");
|
||||
}
|
||||
|
||||
function targets(row, own) {
|
||||
const named = own.filter((claim) => claim.office === row.task || claim.work === row.task);
|
||||
return named.length ? named : [own[0]];
|
||||
}
|
||||
|
||||
function join(edges, from, to, letters, task) {
|
||||
const key = `${from.office}\n${to.office}`;
|
||||
const edge = edges.get(key) || {from: from.office, to: to.office, letters: "", tasks: []};
|
||||
edges.set(key, {...edge, letters: SUPERIOR.filter((letter) => edge.letters.includes(letter) || letters.includes(letter)).join(""), tasks: [...new Set([...edge.tasks, task])].sort(byName)});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param claims - the council claims, each with its holder as agent.
|
||||
* @param tasks - the register's task rows, each {task, ended, worker, roles: {party: letters}}.
|
||||
* @returns the dashed edges, one {from, to, letters, tasks} per pair of offices, by from then to: an open task whose R
|
||||
* (or worker) holds an office and that names another office holder A or C makes that holder's first office (chair,
|
||||
* domain chair, president, organizer, other office; then by name) an additional superior of the agent's office for
|
||||
* the task (the office or the claimed work named like the task, else the agent's first office). letters holds the A
|
||||
* and C of the pair, tasks its tasks by name. A superior holding the chair adds no edge: the solid line runs there.
|
||||
*/
|
||||
function dotted(claims, tasks) {
|
||||
const offices = officesOf(claims);
|
||||
const edges = new Map();
|
||||
for (const row of tasks.filter((entry) => !entry.ended && entry.roles)) {
|
||||
for (const agent of doers(row, offices)) {
|
||||
for (const {office, letters} of superiors(row, agent, offices)) {
|
||||
targets(row, offices.get(agent)).forEach((to) => join(edges, office, to, letters, row.task));
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...edges.values()].sort((a, b) => byName(a.from, b.from) || byName(a.to, b.to));
|
||||
}
|
||||
|
||||
const round = (value) => Math.round(value * 10) / 10;
|
||||
const centerX = (box) => (box.left + box.right) / 2;
|
||||
const centerY = (box) => (box.top + box.bottom) / 2;
|
||||
const segment = (x1, y1, x2, y2) => `M ${round(x1)} ${round(y1)} L ${round(x2)} ${round(y2)}`;
|
||||
|
||||
function elbow(from, to) {
|
||||
const middle = round((from.bottom + to.top) / 2);
|
||||
return `M ${round(centerX(from))} ${round(from.bottom)} V ${middle} H ${round(centerX(to))} V ${round(to.top)}`;
|
||||
}
|
||||
|
||||
function stem(chair, staff, units) {
|
||||
if (!staff.length && !units.length) {
|
||||
return [];
|
||||
}
|
||||
const x = centerX(chair);
|
||||
const tops = units.map((unit) => unit.box.top);
|
||||
const bus = tops.length ? Math.min(...tops) - BEND / 2 : null;
|
||||
const lowest = Math.max(chair.bottom, ...staff.map(centerY), ...(bus === null ? [] : [bus]));
|
||||
const branches = staff.map((box) => segment(x, centerY(box), centerX(box) < x ? box.right : box.left, centerY(box)));
|
||||
const drops = units.map((unit) => segment(centerX(unit.box), bus, centerX(unit.box), unit.box.top));
|
||||
const rail = units.length ? [segment(Math.min(...units.map((unit) => centerX(unit.box)), x), bus, Math.max(...units.map((unit) => centerX(unit.box)), x), bus)] : [];
|
||||
return [segment(x, chair.bottom, x, lowest), ...branches, ...rail, ...drops];
|
||||
}
|
||||
|
||||
function comb(unit) {
|
||||
if (!unit.positions.length) {
|
||||
return [];
|
||||
}
|
||||
const x = unit.box.left + BEND / 2;
|
||||
const last = centerY(unit.positions[unit.positions.length - 1]);
|
||||
return [segment(x, unit.box.bottom, x, last), ...unit.positions.map((box) => segment(x, centerY(box), box.left, centerY(box)))];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boxes - the drawn boxes as {left, top, right, bottom} in chart coordinates, folded ones left out:
|
||||
* {root, chair, staff: [box], units: [{box, positions: [box]}]}; root and chair may be null.
|
||||
* @returns the path data of the solid lines: root to chair, the chair's stem with its staff branches, the rail and
|
||||
* drops to the units, and each unit's comb to its positions.
|
||||
*/
|
||||
function solid(boxes) {
|
||||
const top = boxes.root && boxes.chair ? [elbow(boxes.root, boxes.chair)] : [];
|
||||
const below = boxes.chair ? stem(boxes.chair, boxes.staff, boxes.units) : [];
|
||||
return [...top, ...below, ...boxes.units.flatMap(comb)];
|
||||
}
|
||||
|
||||
function anchors(from, to) {
|
||||
if (from.left < to.right && to.left < from.right) {
|
||||
const side = Math.max(from.right, to.right) + BEND;
|
||||
return [[from.right, centerY(from)], [side, centerY(from)], [side, centerY(to)], [to.right, centerY(to)]];
|
||||
}
|
||||
if (to.top >= from.bottom || to.bottom <= from.top) {
|
||||
const [a, b] = to.top >= from.bottom ? [from.bottom, to.top] : [from.top, to.bottom];
|
||||
const middle = (a + b) / 2;
|
||||
return [[centerX(from), a], [centerX(from), middle], [centerX(to), middle], [centerX(to), b]];
|
||||
}
|
||||
const [a, b] = centerX(to) > centerX(from) ? [from.right, to.left] : [from.left, to.right];
|
||||
const middle = (a + b) / 2;
|
||||
return [[a, centerY(from)], [middle, centerY(from)], [middle, centerY(to)], [b, centerY(to)]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param from - the superior's box as {left, top, right, bottom}.
|
||||
* @param to - the subordinate's box.
|
||||
* @returns the path data of a curve from the superior's box to the subordinate's: around the right side when the two
|
||||
* share a column, else from the facing edges.
|
||||
*/
|
||||
function dashed(from, to) {
|
||||
const [start, one, two, end] = anchors(from, to).map((point) => point.map(round).join(" "));
|
||||
return `M ${start} C ${one} ${two} ${end}`;
|
||||
}
|
||||
|
||||
return {position, chart, dotted, solid, dashed};
|
||||
})();
|
||||
if (typeof module === "object" && module.exports) {
|
||||
module.exports = Organigram;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
const hier = {chart: null, sig: "", closed: new Set(), ids: 0};
|
||||
const OFFICE_ICONS = {chair: "bi-award", line: "bi-person-badge", cluster: "bi-collection", work: "bi-briefcase", other: "bi-signpost-split"};
|
||||
const OFFICE_GROUPS = [["cluster", "Organizers", "Organizer"], ["work", "Presidents", "President"], ["other", "Other offices", "Office"]];
|
||||
const OFFICE_TITLES = {chair: "Chair", line: "Domain chair", work: "President", cluster: "Organizer", other: "Office"};
|
||||
const UNIT_ICONS = {dimension: "bi-diagram-2", work: "bi-briefcase"};
|
||||
|
||||
function hierarchyScreen() {
|
||||
hier.chart = h("section", {class: "card org-chart", "data-panel": "agents/hierarchy", "aria-labelledby": "org-title"});
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
function hierarchySig() {
|
||||
const held = state.claims.map((claim) => [claim.office, claim.session, claim.agent, claim.work, claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT]);
|
||||
return JSON.stringify([held, state.agent_order, state.people, state.presence, [...look.hidden]]);
|
||||
return JSON.stringify([held, Organigram.dotted(state.claims, state.tasks), state.agent_order, state.people, state.presence, [...look.hidden]]);
|
||||
}
|
||||
|
||||
function drawHierarchy(force) {
|
||||
@@ -51,38 +52,14 @@
|
||||
return claim.agent || (claim.session === "-" ? "" : claim.session);
|
||||
}
|
||||
|
||||
function officeRow(claim, label, title) {
|
||||
const who = holderOf(claim);
|
||||
const active = claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT;
|
||||
return h("div", {class: "org-row", "data-office": claim.office},
|
||||
h("span", {class: "org-office", title: `${title} ${claim.office}`}, icon(OFFICE_ICONS[claim.kind]), h("strong", {}, label)),
|
||||
who ? h("button", {type: "button", class: "linkish org-holder", "data-focus": `agent:${claim.office}`, title: `Open ${who}`, on: {click: () => openAgent(who, near(`#main [data-focus="agent:${CSS.escape(claim.office)}"]`))}}, face(who, false), who) : h("span", {class: "muted"}, "–"),
|
||||
claim.session === "-" ? null : presenceMark(claim.session, false),
|
||||
active ? chip("bi-play-circle", "active", "ok") : chip("bi-pause-circle", "no heartbeat", "neutral"),
|
||||
claim.work && claim.work !== "-" ? h("span", {class: "muted org-work", title: claim.work}, short(claim.work)) : null,
|
||||
h("span", {class: "org-actions"},
|
||||
officeBtn("bi-arrow-left-right", "Hand over", `Hand over: ${claim.office} to another session, with a passkey signature`, () => officeSheet("takeover", claim), `takeover:${claim.office}`),
|
||||
officeBtn("bi-person-x", "Recall", `Recall: free ${claim.office}, with a passkey signature`, () => officeSheet("recall", claim), `recall:${claim.office}`)));
|
||||
}
|
||||
|
||||
function vacantRow(office, label) {
|
||||
return h("div", {class: "org-row vacant", "data-office": office},
|
||||
h("span", {class: "org-office"}, icon(OFFICE_ICONS.chair), h("strong", {}, label)),
|
||||
pill("vacant", "warn"),
|
||||
h("span", {class: "org-actions"}, officeBtn("bi-person-plus", "Appoint", `Appoint: give ${office} to a session, with a passkey signature`, () => officeSheet("appoint", {office, session: "", work: ""}), `appoint:${office}`)));
|
||||
}
|
||||
|
||||
function groupRow(glyph, label, count, note) {
|
||||
return h("div", {class: "org-row group"}, h("span", {class: "org-office"}, icon(glyph), h("strong", {}, label)), counter(count), h("span", {class: "muted"}, note));
|
||||
}
|
||||
|
||||
function orgNode(id, label, row, children) {
|
||||
if (!children.length) {
|
||||
return h("li", {}, h("div", {class: "org-line"}, h("span", {class: "org-gap", "aria-hidden": "true"}), row));
|
||||
}
|
||||
const open = !hier.closed.has(id);
|
||||
function nextOrgId() {
|
||||
hier.ids += 1;
|
||||
const list = h("ul", {class: "org-tree", id: `org-${hier.ids}`, hidden: !open}, children);
|
||||
return `org-${hier.ids}`;
|
||||
}
|
||||
|
||||
function folder(id, label, list) {
|
||||
const open = !hier.closed.has(id);
|
||||
list.hidden = !open;
|
||||
const toggle = h("button", {type: "button", class: "btn small ghost icon-only org-toggle", "aria-expanded": String(open), "aria-controls": list.id, "data-focus": `toggle:${id}`, ...named(`${open ? "Collapse" : "Expand"}: ${label}`)}, icon(open ? "bi-chevron-down" : "bi-chevron-right"));
|
||||
toggle.addEventListener("click", () => {
|
||||
const now = list.hidden;
|
||||
@@ -94,37 +71,144 @@
|
||||
} else {
|
||||
hier.closed.add(id);
|
||||
}
|
||||
drawLinks(list.closest(".organigram"));
|
||||
});
|
||||
return h("li", {"data-node": id}, h("div", {class: "org-line"}, toggle, row), list);
|
||||
return toggle;
|
||||
}
|
||||
|
||||
function chartTree() {
|
||||
const claims = state.claims;
|
||||
const dimensions = new Map();
|
||||
for (const claim of claims.filter((entry) => entry.kind === "line")) {
|
||||
dimensions.set(claim.dimension, [...(dimensions.get(claim.dimension) || []), claim]);
|
||||
function officeHead(claim, toggle) {
|
||||
const title = OFFICE_TITLES[claim.kind] || OFFICE_TITLES.other;
|
||||
return h("div", {class: "org-head"}, toggle,
|
||||
h("span", {class: "org-office", title: `${title} ${claim.office}`}, icon(OFFICE_ICONS[claim.kind] || OFFICE_ICONS.other),
|
||||
h("span", {class: "org-name"}, claim.kind === "chair" ? h("strong", {}, title) : [h("span", {class: "org-title"}, title), h("strong", {}, claim.office)])));
|
||||
}
|
||||
|
||||
function holderLine(claim) {
|
||||
const who = holderOf(claim);
|
||||
const active = claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT;
|
||||
return h("div", {class: "org-who"},
|
||||
who ? h("button", {type: "button", class: "linkish org-holder", "data-focus": `agent:${claim.office}`, title: `Open ${who}`, on: {click: () => openAgent(who, near(`#main [data-focus="agent:${CSS.escape(claim.office)}"]`))}}, face(who, false), who) : h("span", {class: "muted"}, "–"),
|
||||
claim.session === "-" ? null : presenceMark(claim.session, false),
|
||||
active ? chip("bi-play-circle", "active", "ok") : chip("bi-pause-circle", "no heartbeat", "neutral"));
|
||||
}
|
||||
|
||||
function dottedLines(claim, edges) {
|
||||
return edges.filter((edge) => edge.to === claim.office).map((edge) => h("div", {class: "org-dotted", "data-from": edge.from, title: `Additional superior from the register: ${edge.letters} on ${edge.tasks.join(", ")}`},
|
||||
icon("bi-bezier2"), `Also under ${edge.from} (${edge.letters})`));
|
||||
}
|
||||
|
||||
function officeBox(claim, edges, toggle) {
|
||||
return h("div", {class: `org-row org-box${claim.kind === "chair" ? " org-chair" : ""}`, "data-office": claim.office, "data-kind": claim.kind, "data-position": Organigram.position(claim)},
|
||||
officeHead(claim, toggle),
|
||||
holderLine(claim),
|
||||
claim.work && claim.work !== "-" ? h("span", {class: "muted org-work", title: claim.work}, short(claim.work)) : null,
|
||||
dottedLines(claim, edges),
|
||||
h("span", {class: "org-actions"},
|
||||
officeBtn("bi-arrow-left-right", "Hand over", `Hand over: ${claim.office} to another session, with a passkey signature`, () => officeSheet("takeover", claim), `takeover:${claim.office}`),
|
||||
officeBtn("bi-person-x", "Recall", `Recall: free ${claim.office}, with a passkey signature`, () => officeSheet("recall", claim), `recall:${claim.office}`)));
|
||||
}
|
||||
|
||||
function vacantBox(toggle) {
|
||||
return h("div", {class: "org-row org-box org-chair vacant", "data-office": "chair", "data-kind": "chair", "data-position": "chair"},
|
||||
h("div", {class: "org-head"}, toggle, h("span", {class: "org-office"}, icon(OFFICE_ICONS.chair), h("strong", {}, "Chair"))),
|
||||
pill("vacant", "warn"),
|
||||
h("span", {class: "org-actions"}, officeBtn("bi-person-plus", "Appoint", "Appoint: give chair to a session, with a passkey signature", () => officeSheet("appoint", {office: "chair", session: "", work: ""}), "appoint:chair")));
|
||||
}
|
||||
|
||||
function unitNode(unit, edges) {
|
||||
const list = h("ul", {class: "org-positions", id: nextOrgId()}, unit.positions.map((claim) => h("li", {}, officeBox(claim, edges, null))));
|
||||
const note = unit.kind === "work" ? "work/…" : unit.positions.length === 1 ? "line" : "lines";
|
||||
return h("li", {class: "org-unit", "data-node": unit.id},
|
||||
h("div", {class: "org-row group org-box org-unit-box", "data-unit": unit.id},
|
||||
h("div", {class: "org-head"}, folder(unit.id, unit.label, list), h("span", {class: "org-office"}, icon(UNIT_ICONS[unit.kind]), h("strong", {}, unit.label)), counter(unit.positions.length), h("span", {class: "muted"}, note))),
|
||||
list);
|
||||
}
|
||||
|
||||
function chairPart(chair, staff, units, edges) {
|
||||
const below = h("div", {class: "org-below", id: nextOrgId()},
|
||||
staff.length ? h("ul", {class: "org-staff", "aria-label": "Staff positions"}, staff.map((claim) => h("li", {}, officeBox(claim, edges, null)))) : null,
|
||||
units.length ? h("ul", {class: "org-units", "aria-label": "Line positions"}, units.map((unit) => unitNode(unit, edges))) : null);
|
||||
const toggle = staff.length || units.length ? folder("chair", "Chair", below) : null;
|
||||
return [h("div", {class: "org-level org-chair-level"}, chair ? officeBox(chair, edges, toggle) : vacantBox(toggle)), below];
|
||||
}
|
||||
|
||||
function organigram() {
|
||||
const edges = Organigram.dotted(state.claims, state.tasks);
|
||||
const {chair, staff, units} = Organigram.chart(state.claims);
|
||||
const under = h("div", {class: "org-below", id: nextOrgId()}, chairPart(chair, staff, units, edges));
|
||||
const root = h("div", {class: "org-row org-box org-root"},
|
||||
h("div", {class: "org-head"}, folder("operator", HUMAN, under), h("span", {class: "org-office"}, icon("bi-person-circle"), h("strong", {}, HUMAN))),
|
||||
h("span", {class: "muted"}, "assigns every office with a passkey signature"));
|
||||
const links = s("svg", {class: "org-links", "aria-hidden": "true", focusable: "false"});
|
||||
const canvas = h("div", {class: "organigram", "data-edges": String(edges.length)}, links, h("div", {class: "org-level"}, root), under);
|
||||
canvas.orgEdges = edges;
|
||||
const observer = new ResizeObserver(() => (canvas.isConnected ? drawLinks(canvas) : observer.disconnect()));
|
||||
observer.observe(canvas);
|
||||
return h("div", {class: "org-scroll", role: "region", tabindex: "0", "aria-label": "Organigram"}, canvas);
|
||||
}
|
||||
|
||||
function chartBox(base, node) {
|
||||
if (!node || !node.getClientRects().length) {
|
||||
return null;
|
||||
}
|
||||
const lines = [...dimensions].sort(([a], [b]) => a.localeCompare(b)).map(([dimension, held]) => orgNode(`dimension:${dimension}`, dimension,
|
||||
groupRow("bi-diagram-2", dimension, held.length, held.length === 1 ? "line" : "lines"),
|
||||
held.map((claim) => orgNode(claim.office, claim.office, officeRow(claim, claim.line, "Representative"), []))));
|
||||
const groups = OFFICE_GROUPS.map(([kind, label, title]) => [kind, label, title, claims.filter((entry) => entry.kind === kind)]).filter(([, , , held]) => held.length)
|
||||
.map(([kind, label, title, held]) => orgNode(`group:${kind}`, label, groupRow(OFFICE_ICONS[kind], label, held.length, kind === "other" ? "" : `${kind}/…`),
|
||||
held.map((claim) => orgNode(claim.office, claim.office, officeRow(claim, kind === "other" ? claim.office : claim.office.slice(kind.length + 1), title), []))));
|
||||
const chair = claims.find((entry) => entry.kind === "chair");
|
||||
const chairNode = orgNode("chair", "Chair", chair ? officeRow(chair, "Chair", "Office") : vacantRow("chair", "Chair"), [...lines, ...groups]);
|
||||
const root = h("div", {class: "org-row org-root"}, h("span", {class: "org-office"}, icon("bi-person-circle"), h("strong", {}, HUMAN)), h("span", {class: "muted"}, "assigns every office with a passkey signature"));
|
||||
return h("ul", {class: "org-tree root"}, orgNode("operator", HUMAN, root, [chairNode]));
|
||||
const found = node.getBoundingClientRect();
|
||||
return {left: found.left - base.left, top: found.top - base.top, right: found.right - base.left, bottom: found.bottom - base.top};
|
||||
}
|
||||
|
||||
function solidBoxes(canvas, boxOf) {
|
||||
const units = [...canvas.querySelectorAll(".org-units > .org-unit")].map((unit) => ({box: boxOf(unit.querySelector(".org-unit-box")), positions: [...unit.querySelectorAll(".org-positions > li > .org-box")].map(boxOf).filter(Boolean)}));
|
||||
return {root: boxOf(canvas.querySelector(".org-root")), chair: boxOf(canvas.querySelector(".org-chair")), staff: [...canvas.querySelectorAll(".org-staff > li > .org-box")].map(boxOf).filter(Boolean), units: units.filter((unit) => unit.box)};
|
||||
}
|
||||
|
||||
function drawLinks(canvas) {
|
||||
if (!canvas || !canvas.isConnected) {
|
||||
return;
|
||||
}
|
||||
const base = canvas.getBoundingClientRect();
|
||||
const boxOf = (node) => chartBox(base, node);
|
||||
const office = (name) => boxOf([...canvas.querySelectorAll(".org-box[data-office]")].find((node) => node.dataset.office === name));
|
||||
const dashed = (canvas.orgEdges || []).map((edge) => [edge, office(edge.from), office(edge.to)]).filter(([, from, to]) => from && to);
|
||||
const svg = canvas.querySelector(":scope > .org-links");
|
||||
svg.setAttribute("width", String(canvas.scrollWidth));
|
||||
svg.setAttribute("height", String(canvas.scrollHeight));
|
||||
svg.replaceChildren(...Organigram.solid(solidBoxes(canvas, boxOf)).map((d) => s("path", {class: "org-solid", d})),
|
||||
...dashed.map(([edge, from, to]) => s("path", {class: "org-dashed", d: Organigram.dashed(from, to), "data-from": edge.from, "data-to": edge.to}, s("title", {}, `${edge.from} to ${edge.to}: ${edge.letters} on ${edge.tasks.join(", ")}`))));
|
||||
}
|
||||
|
||||
function orgLegend() {
|
||||
const sample = (kind) => s("svg", {class: `org-sample ${kind}`, viewBox: "0 0 28 8", "aria-hidden": "true", focusable: "false"}, s("line", {x1: "1", y1: "4", x2: "27", y2: "4"}));
|
||||
return h("div", {class: "org-legend", role: "note"},
|
||||
h("span", {}, sample("solid"), "Line: domain chairs and presidents under the Chair"),
|
||||
h("span", {}, h("span", {class: "org-swatch", "aria-hidden": "true"}), "Staff: organizers and single offices beside the Chair"),
|
||||
h("span", {}, sample("dashed"), "Additional superior: A or C on a task in the register"));
|
||||
}
|
||||
|
||||
function drawChart() {
|
||||
const key = focusKey(hier.chart);
|
||||
hier.ids = 0;
|
||||
const old = hier.chart.querySelector(".org-scroll");
|
||||
const kept = old ? [old.scrollLeft, old.scrollTop] : null;
|
||||
const count = state.claims.length;
|
||||
const chart = organigram();
|
||||
hier.chart.replaceChildren(
|
||||
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title", id: "org-title"}, "Hierarchy", counter(count)),
|
||||
h("span", {class: "muted"}, "Formal offices from the council: Operator → Chair → dimensions → lines, plus organizers and presidents"),
|
||||
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title", id: "org-title"}, "Organigram", counter(count)),
|
||||
h("span", {class: "muted"}, "Formal offices from the council: Operator, Chair, line and staff positions"),
|
||||
h("span", {class: "spacer"}),
|
||||
h("button", {type: "button", class: "btn small soft", "data-focus": "appoint:new", ...named("New office", "New office: give a free office to a session, with a passkey signature"), on: {click: () => officeSheet("appoint", null)}}, icon("bi-person-plus"), "New office")),
|
||||
chartTree());
|
||||
orgLegend(),
|
||||
chart);
|
||||
if (kept) {
|
||||
[chart.scrollLeft, chart.scrollTop] = kept;
|
||||
} else {
|
||||
centerChair(chart);
|
||||
}
|
||||
refocus(hier.chart, key);
|
||||
}
|
||||
|
||||
function centerChair(chart) {
|
||||
const box = chart.querySelector(".org-chair");
|
||||
if (box) {
|
||||
const found = box.getBoundingClientRect();
|
||||
const frame = chart.getBoundingClientRect();
|
||||
chart.scrollLeft += found.left + found.width / 2 - (frame.left + frame.width / 2);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@
|
||||
Panels.panel("agents/swimlane", "Agents: Swimlane", () => swimlane());
|
||||
Panels.panel("agents/3d", "Agents: 3D", () => home3d("agents"), "3d");
|
||||
Panels.panel("agents/tree", "Agents: spawn tree", () => h("ul", {class: "spawn-tree root"}, spawnItem(spawnTree())));
|
||||
Panels.panel("agents/hierarchy", "Agents: hierarchy", () => chartTree());
|
||||
Panels.panel("agents/hierarchy", "Agents: organigram", () => organigram());
|
||||
Panels.panel("artifacts/orbit", "Artifacts: Orbit", () => homeArt("orbit"));
|
||||
Panels.panel("artifacts/chord", "Artifacts: Chord", () => homeArt("chord"));
|
||||
Panels.panel("artifacts/swimlane", "Artifacts: Swimlane", () => homeArt("swimlane"));
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
.hierarchy-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
|
||||
@media (max-width: 960px) { .hierarchy-body { grid-template-columns: minmax(0, 1fr); } }
|
||||
.org-chart { min-width: 0; }
|
||||
.org-chart .inbox-head { flex-wrap: wrap; }
|
||||
.org-tree { display: grid; gap: 4px; margin: 0; padding: 0 0 0 16px; list-style: none; border-left: 1px solid var(--line); margin-left: 14px; }
|
||||
.org-tree.root { margin-left: 0; padding-left: 0; border-left: 0; }
|
||||
.org-tree[hidden] { display: none; }
|
||||
.org-line { display: flex; align-items: flex-start; gap: 4px; }
|
||||
.org-toggle { margin-top: 3px; }
|
||||
.org-gap { flex: none; width: 30px; }
|
||||
.org-row { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; padding: 5px 8px; border-radius: 8px; }
|
||||
.org-row:hover { background: var(--hover); }
|
||||
.org-row.vacant { border: 1px dashed var(--line-strong); }
|
||||
.org-row.group .org-office { color: var(--muted); }
|
||||
.org-office, .org-holder { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
|
||||
.org-work { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.org-actions { display: inline-flex; gap: 2px; margin-left: auto; }
|
||||
.org-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; color: var(--muted); font-size: var(--fs-sm); }
|
||||
.org-legend > span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.org-sample { flex: none; width: 28px; height: 8px; }
|
||||
.org-sample line { stroke: var(--line-strong); stroke-width: 2; }
|
||||
.org-sample.dashed line { stroke: var(--violet); stroke-dasharray: 5 4; }
|
||||
.org-swatch { flex: none; width: 18px; height: 12px; border: 1px solid color-mix(in srgb, var(--info) 55%, var(--line-strong)); border-radius: 4px; background: color-mix(in srgb, var(--info) 12%, var(--panel)); }
|
||||
.org-scroll { max-width: 100%; overflow: auto; overscroll-behavior-x: contain; border-radius: var(--radius-sm); }
|
||||
.organigram { --org-box: 236px; position: relative; display: flex; flex-direction: column; align-items: center; width: max-content; min-width: 100%; padding: 8px 56px 18px 12px; }
|
||||
.org-links { position: absolute; top: 0; left: 0; z-index: 0; overflow: visible; pointer-events: none; }
|
||||
.org-links .org-solid { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
|
||||
.org-links .org-dashed { fill: none; stroke: var(--violet); stroke-width: 1.5; stroke-dasharray: 6 5; }
|
||||
.org-level { display: flex; justify-content: center; }
|
||||
.org-chair-level { margin-top: 30px; }
|
||||
.org-below { display: flex; flex-direction: column; align-items: center; align-self: stretch; }
|
||||
.org-below[hidden], .org-positions[hidden] { display: none; }
|
||||
.org-box { position: relative; z-index: 1; display: grid; gap: 4px; width: var(--org-box); min-width: 0; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
|
||||
.org-box:hover { background: color-mix(in srgb, var(--hover) 60%, var(--panel)); }
|
||||
.org-box.org-chair { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow); }
|
||||
.org-box.vacant { border-style: dashed; }
|
||||
.org-box[data-position="staff"] { border-color: color-mix(in srgb, var(--info) 55%, var(--line-strong)); background: color-mix(in srgb, var(--info) 12%, var(--panel)); }
|
||||
.org-box.org-root { width: auto; max-width: 300px; }
|
||||
.org-unit-box { background: color-mix(in srgb, var(--neutral-soft) 70%, var(--panel)); }
|
||||
.org-unit-box .org-office { color: var(--muted); }
|
||||
.org-head { display: flex; align-items: center; gap: 4px 6px; min-width: 0; }
|
||||
.org-office { display: inline-flex; flex: 1; align-items: center; gap: 6px; min-width: 0; }
|
||||
.org-name { display: grid; min-width: 0; line-height: var(--lh-tight); }
|
||||
.org-name strong, .org-unit-box strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.org-title { color: var(--muted); font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
|
||||
.org-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
|
||||
.org-holder { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
|
||||
.org-work { min-width: 0; overflow: hidden; font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
|
||||
.org-dotted { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--violet); font-size: var(--fs-sm); overflow-wrap: anywhere; }
|
||||
.org-actions { display: flex; justify-content: flex-end; gap: 2px; }
|
||||
.org-staff { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: row dense; gap: 10px calc(var(--org-box) + 48px); align-self: stretch; margin: 22px 0 0; padding: 0; list-style: none; }
|
||||
.org-staff > li:nth-child(odd) { grid-column: 2; justify-self: start; }
|
||||
.org-staff > li:nth-child(even) { grid-column: 1; justify-self: end; }
|
||||
.org-units { display: flex; align-items: flex-start; justify-content: center; gap: 22px; margin: 40px 0 0; padding: 0; list-style: none; }
|
||||
.org-unit { display: grid; justify-items: start; }
|
||||
.org-positions { display: grid; gap: 10px; margin: 12px 0 0; padding: 0 0 0 32px; list-style: none; }
|
||||
.agent-order .order-list li { gap: 8px; padding: 6px 8px; }
|
||||
.agent-order .order-list .linkish { min-width: 0; }
|
||||
.agent-order .grip { flex: none; color: var(--muted); }
|
||||
|
||||
Reference in new issue
Block a user