create-pmos 0.408.0 → 0.409.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +1 -1
- package/workspace/board-wf-shot.js +45 -0
- package/workspace/board-workflows-test.js +186 -0
- package/workspace/briefing-premium-board-test.js +2 -2
- package/workspace/briefing-premium-initiative-test.js +1 -1
- package/workspace/changelog.json +12 -0
- package/workspace/fixtures/board-workflows-facts.js +49 -0
- package/workspace/fixtures/workflows-facts.js +53 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/workflows.md +58 -0
- package/workspace/ini-workflow-test.js +177 -0
- package/workspace/lib/board-premium.js +30 -5
- package/workspace/lib/board-trail.js +24 -7
- package/workspace/lib/briefing-premium-agent.js +3 -0
- package/workspace/lib/engine/boards.js +30 -2
- package/workspace/lib/engine/workflows.js +204 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/programs.js +22 -7
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +157 -7
- package/workspace/lib/routes-programs.js +5 -0
- package/workspace/lib/routes-workflows.js +105 -0
- package/workspace/lib/workflow-chat.js +26 -0
- package/workspace/lib/workflow-cli.js +141 -0
- package/workspace/lib/workflows-store.js +108 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/program-charter-test.js +243 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +10 -5
- package/workspace/public/pm/bd-asks.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +33 -14
- package/workspace/public/pm/bd-prog.js +11 -3
- package/workspace/public/pm/bd-views.js +128 -45
- package/workspace/public/pm/bd-wf.js +99 -0
- package/workspace/public/pm/cozy-board.css +67 -6
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-panel.css +12 -6
- package/workspace/public/pm/cozy-settings.js +4 -2
- package/workspace/public/pm/cozy-viewer.js +36 -9
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-app.js +14 -9
- package/workspace/public/pm/home-ini-model.js +2 -2
- package/workspace/public/pm/home-ini.css +30 -0
- package/workspace/public/pm/home-ini.js +52 -9
- package/workspace/public/pm/home-list.js +5 -3
- package/workspace/public/pm/home-today.js +4 -4
- package/workspace/public/pm/ini-wf-model.js +91 -0
- package/workspace/public/pm/ini-wf.js +160 -0
- package/workspace/public/pm/premium-board.js +98 -30
- package/workspace/public/pm/premium-initiative-head.js +18 -8
- package/workspace/public/pm/program-charter.css +135 -0
- package/workspace/public/pm/program-charter.js +333 -0
- package/workspace/public/pm/program-model.js +44 -4
- package/workspace/public/pm/wf-edit.js +119 -0
- package/workspace/public/pm/wf-model.js +48 -0
- package/workspace/public/pm/wf-page.css +162 -0
- package/workspace/public/pm/wf-page.js +398 -0
- package/workspace/public/pm/wf-stage.js +187 -0
- package/workspace/public/premium-workflows.html +31 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +1 -1
- package/workspace/skills/workflow-setup.skill +57 -0
- package/workspace/test-lists/ini-workflow.json +6 -0
- package/workspace/test-lists/program-charter.json +9 -0
- package/workspace/test-lists/workflows-board.json +13 -0
- package/workspace/test-lists/workflows-setup.json +13 -0
- package/workspace/test-lists/workflows.json +5 -0
- package/workspace/workflows-setup-test.js +346 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* pm/ini-wf.js — an initiative's own workflow on its page (D99, initiative workflows-per-initiative; canvas WfTriage, WfAChange, WfAWontDo).
|
|
2
|
+
* The pure half is ini-wf-model.js; home-ini.js mounts these on the initiative's page and its ⋯.
|
|
3
|
+
*
|
|
4
|
+
* openPicker(anchor, ui, id) the Change picker under the workflow's icon: every workflow with its stage count, the current one picked,
|
|
5
|
+
* its stage chain and, when PMOS set it from the BRD, why; then New workflow…
|
|
6
|
+
* openSwitch(anchor, ui, id, wfId) Switch <name> to <workflow>?: each done or current stage and where it lands, "It lands in <picker>",
|
|
7
|
+
* the carry-over rule in one line, Switch / Not now (POST /api/boards/ini-wf with `to`)
|
|
8
|
+
* openWontDo(anchor, ui, id) Won't do <name>?: No budget, Out of scope, Done another way, Other, a note (POST /api/boards/wontdo)
|
|
9
|
+
* backToTriage(ui, id) bring a Won't do back to Triage (POST /api/boards/wontdo { back: true })
|
|
10
|
+
* archive(ui, id) Archive it, with Undo (POST /api/boards/archive)
|
|
11
|
+
* pmosNotice(ui, id) once per workflow PMOS set from the BRD: "Set to Tender from the BRD" with Undo (ini-wf back)
|
|
12
|
+
*
|
|
13
|
+
* ui (home-ini.js): { openPop, closePop, undoToast, toast, pmGet, pmPost, load, row(id), title(id), bw(id) }.
|
|
14
|
+
* Every write is the PM's press, file mode only. Nothing here is deleted: a switch keeps every document, Won't do keeps the record. */
|
|
15
|
+
import * as WM from './ini-wf-model.js';
|
|
16
|
+
import { WONTDO_REASONS, wfIcon } from './wf-model.js';
|
|
17
|
+
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
20
|
+
const NEXT = 'M5 12h14M13 6l6 6-6 6', PLUS = 'M12 5v14M5 12h14', CLOSE = 'M6 6l12 12M18 6L6 18';
|
|
21
|
+
|
|
22
|
+
/* ── the library (GET /api/workflows), read again on each picker ── */
|
|
23
|
+
const LIB = { list: null, at: 0 };
|
|
24
|
+
export async function library(ui, force) {
|
|
25
|
+
if (!force && LIB.list && Date.now() - LIB.at < 15000) return LIB.list;
|
|
26
|
+
const r = await ui.pmGet('/api/workflows');
|
|
27
|
+
if (r && r.ok && Array.isArray(r.workflows)) { LIB.list = r.workflows; LIB.at = Date.now(); }
|
|
28
|
+
return LIB.list || [];
|
|
29
|
+
}
|
|
30
|
+
export const _lib = (list) => { LIB.list = list; LIB.at = list ? Date.now() : 0; }; // for a test
|
|
31
|
+
|
|
32
|
+
async function after(ui, r, ok) {
|
|
33
|
+
if (!r || r.ok === false) { ui.toast((r && r.error) || 'Nothing was changed.'); return false; }
|
|
34
|
+
if (ok) ui.toast(ok);
|
|
35
|
+
await ui.load();
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ── the Change picker (WfTriage) ── */
|
|
40
|
+
export async function openPicker(anchor, ui, id) {
|
|
41
|
+
const row = ui.row(id) || {};
|
|
42
|
+
const lib = await library(ui);
|
|
43
|
+
const items = WM.pickerItems(lib, row);
|
|
44
|
+
const cur = lib.find((w) => w.id === ((row.wf || {}).id || 'product-feature'));
|
|
45
|
+
const by = WM.setByPmos(row);
|
|
46
|
+
const html = '<p class="hi-mlbl">Workflow</p>'
|
|
47
|
+
+ (items.length ? items.map((x) => `<button type="button" class="hi-mi${x.on ? ' on' : ''}" role="option" aria-selected="${x.on}" data-wf-pick="${esc(x.id)}">${wfIcon(x, 18)}<span>${esc(x.name)}</span><em>${x.n}</em></button>`).join('')
|
|
48
|
+
: '<p class="hi-small hi-wfpad">The workflows could not be read.</p>')
|
|
49
|
+
+ '<div class="hi-hr"></div>'
|
|
50
|
+
+ `<button type="button" class="hi-mi" data-wf-new>${SVG(PLUS)}<span>New workflow…</span></button>`
|
|
51
|
+
+ (cur ? `<p class="hi-small hi-wfpad hi-wfchain">${esc(WM.chainText(cur))}</p>` : '')
|
|
52
|
+
+ (by && by.why ? `<p class="hi-small hi-wfpad"><span class="hi-mut">Why:</span> ${esc(by.why)}</p>` : '');
|
|
53
|
+
ui.openPop(anchor, 'wf', html, (b) => {
|
|
54
|
+
if ('wfNew' in b.dataset) { ui.closePop(); newWorkflow(ui, id); return; }
|
|
55
|
+
const k = b.dataset.wfPick; if (!k) return;
|
|
56
|
+
if (k === (row.wf || {}).id || (!row.wf && k === 'product-feature')) { ui.closePop(); return; }
|
|
57
|
+
openSwitch(anchor, ui, id, k);
|
|
58
|
+
}, { menu: true, label: 'Pick a workflow', role: 'listbox' });
|
|
59
|
+
}
|
|
60
|
+
/** New workflow…: the PM describes it in the chat and PMOS drafts it in the Viewer (wfRules), on the Workflows page (premium-workflows.html ?new=1). */
|
|
61
|
+
function newWorkflow(ui, id) {
|
|
62
|
+
const ev = new CustomEvent('pmos:wf-new', { cancelable: true, detail: { initiative: id } });
|
|
63
|
+
if (!window.dispatchEvent(ev)) return;
|
|
64
|
+
const ws = new URLSearchParams(location.search).get('ws');
|
|
65
|
+
location.href = '/premium-workflows.html?new=1' + (ws ? '&ws=' + encodeURIComponent(ws) : '');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ── switch to another workflow (WfAChange) ── */
|
|
69
|
+
export async function openSwitch(anchor, ui, id, wfId) {
|
|
70
|
+
const row = ui.row(id) || {};
|
|
71
|
+
const lib = await library(ui);
|
|
72
|
+
const to = lib.find((w) => w.id === wfId);
|
|
73
|
+
if (!to) { ui.toast('That workflow could not be read.'); return; }
|
|
74
|
+
const title = ui.title(id), fromWf = row.wf || { name: 'Product feature', icon: 'feature' };
|
|
75
|
+
let land = null;
|
|
76
|
+
const html = () => {
|
|
77
|
+
const P = WM.switchPlan(row, to, land);
|
|
78
|
+
return `<div class="hi-wfh">${wfIcon(fromWf, 22)}${SVG(NEXT, 14)}${wfIcon(to, 22)}<p class="hi-h3">Switch ${esc(title)} to ${esc(to.name)}?</p><button type="button" class="hi-ib sm" data-wf-x aria-label="Close">${SVG(CLOSE)}</button></div>`
|
|
79
|
+
+ (P.rows.length ? `<div class="hi-wfrows">${P.rows.map((r) => `<div class="hi-wfrow"><span><b>${esc(r.from)}</b><em>${r.state === 'now' ? 'now' : 'done'}</em></span>${SVG(NEXT, 14)}<span><b>${esc(r.to)}</b></span><span class="hi-small">${esc(r.note)}</span></div>`).join('')}</div>` : '')
|
|
80
|
+
+ `<label class="hi-wfland hi-small"><span>It lands in</span><select id="wfLand" aria-label="The stage it lands in">${P.lands.map((s) => `<option value="${esc(s.key)}"${s.key === P.land ? ' selected' : ''}>${s.milestone ? '◆ ' : ''}${esc(s.name)}</option>`).join('')}</select></label>`
|
|
81
|
+
+ '<p class="hi-small">A stage with the same name carries over. Otherwise it lands in the first stage of the same category. Nothing is deleted.</p>'
|
|
82
|
+
+ '<div class="hi-acts"><button type="button" class="hi-btn dark" data-wf-go>Switch</button><button type="button" class="hi-btn ghost" data-wf-x>Not now</button></div>';
|
|
83
|
+
};
|
|
84
|
+
const el = ui.openPop(anchor, 'wf-switch', html(), async (b) => {
|
|
85
|
+
if ('wfX' in b.dataset) { ui.closePop(); return; }
|
|
86
|
+
if ('wfGo' in b.dataset) {
|
|
87
|
+
b.disabled = true;
|
|
88
|
+
const P = WM.switchPlan(row, to, land);
|
|
89
|
+
const r = await ui.pmPost('/api/boards/ini-wf', { ...ui.bw(id), id, wf: to.id, to: P.land });
|
|
90
|
+
ui.closePop();
|
|
91
|
+
const stage = (P.lands.find((s) => s.key === P.land) || {}).name || '';
|
|
92
|
+
if (r && r.ok !== false) {
|
|
93
|
+
const from = (row.wf && row.wf.id) || 'product-feature', back = row.wfStage ? row.wfStage.key : null;
|
|
94
|
+
ui.undoToast(title + ' runs ' + to.name + ' now, in ' + stage, async () => after(ui, await ui.pmPost('/api/boards/ini-wf', { ...ui.bw(id), id, wf: from, ...(back ? { to: back } : {}) }), title + ' is back on ' + fromWf.name + '.'));
|
|
95
|
+
await ui.load();
|
|
96
|
+
} else ui.toast((r && r.error) || 'The workflow did not change.');
|
|
97
|
+
}
|
|
98
|
+
}, { label: 'Switch ' + title + ' to ' + to.name, focus: '[data-wf-go]', wide: true });
|
|
99
|
+
if (!el) return;
|
|
100
|
+
el.addEventListener('change', (e) => { if (e.target.id === 'wfLand') land = e.target.value; });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* ── Won't do (WfAWontDo) ── */
|
|
104
|
+
export function openWontDo(anchor, ui, id) {
|
|
105
|
+
const title = ui.title(id);
|
|
106
|
+
let reason = '';
|
|
107
|
+
const el = ui.openPop(anchor, 'wontdo', `<p class="hi-h3">Won’t do ${esc(title)}?</p>`
|
|
108
|
+
+ `<div class="hi-chips" role="group" aria-label="Why not">${WONTDO_REASONS.map(([k, l]) => `<button type="button" class="cz-chip" aria-pressed="false" data-wf-why="${k}">${esc(l)}</button>`).join('')}</div>`
|
|
109
|
+
+ '<label class="hi-field"><span class="hi-vh">A note</span><textarea id="wfNote" rows="2" maxlength="300" placeholder="A note · kept with it"></textarea></label>'
|
|
110
|
+
+ '<p class="hi-small">PMOS warns you when something close to it comes up again. You can bring it back to Triage at any time.</p>'
|
|
111
|
+
+ '<div class="hi-acts"><button type="button" class="hi-btn dark" data-wf-go disabled>Won’t do</button><button type="button" class="hi-btn ghost" data-wf-x>Cancel</button></div>',
|
|
112
|
+
async (b, pel) => {
|
|
113
|
+
if ('wfX' in b.dataset) { ui.closePop(); return; }
|
|
114
|
+
if (b.dataset.wfWhy) { reason = b.dataset.wfWhy; pel.querySelectorAll('[data-wf-why]').forEach((c) => { c.setAttribute('aria-pressed', String(c === b)); c.classList.toggle('on', c === b); }); sync(); return; }
|
|
115
|
+
if ('wfGo' in b.dataset) {
|
|
116
|
+
const note = pel.querySelector('#wfNote').value.replace(/\s+/g, ' ').trim();
|
|
117
|
+
if (!WM.wontdoReady(reason, note)) return;
|
|
118
|
+
b.disabled = true; ui.closePop();
|
|
119
|
+
const r = await ui.pmPost('/api/boards/wontdo', { ...ui.bw(id), id, reason, ...(note ? { note } : {}) });
|
|
120
|
+
if (r && r.ok !== false) { ui.undoToast(title + ': won’t do', () => backToTriage(ui, id)); await ui.load(); } else ui.toast((r && r.error) || 'Nothing was changed.');
|
|
121
|
+
}
|
|
122
|
+
}, { label: title + ': won’t do', focus: '[data-wf-why]' });
|
|
123
|
+
if (!el) return;
|
|
124
|
+
const sync = () => { el.querySelector('[data-wf-go]').disabled = !WM.wontdoReady(reason, el.querySelector('#wfNote').value); };
|
|
125
|
+
el.querySelector('#wfNote').addEventListener('input', sync);
|
|
126
|
+
}
|
|
127
|
+
export async function backToTriage(ui, id) {
|
|
128
|
+
return after(ui, await ui.pmPost('/api/boards/wontdo', { ...ui.bw(id), id, back: true }), ui.title(id) + ' is back in Triage.');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* ── Archive (WfAWontDo's ⋯): hidden everywhere, kept whole; Undo brings it back ── */
|
|
132
|
+
export async function archive(ui, id) {
|
|
133
|
+
const title = ui.title(id);
|
|
134
|
+
const r = await ui.pmPost('/api/boards/archive', { ...ui.bw(id), id, archived: true });
|
|
135
|
+
if (!r || r.ok === false) { ui.toast((r && r.error) || 'It was not archived.'); return false; }
|
|
136
|
+
ui.undoToast(title + ' is archived', async () => after(ui, await ui.pmPost('/api/boards/archive', { ...ui.bw(id), id, archived: false }), title + ' is back.'));
|
|
137
|
+
await ui.load();
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* ── PMOS set the workflow from the BRD (WfTriage toast) ── */
|
|
142
|
+
const SEEN_KEY = 'pmos.wf.seen';
|
|
143
|
+
const seen = () => { try { return JSON.parse(localStorage.getItem(SEEN_KEY) || '{}') || {}; } catch { return {}; } };
|
|
144
|
+
export function pmosNotice(ui, id) {
|
|
145
|
+
const row = ui.row(id), by = WM.setByPmos(row);
|
|
146
|
+
if (!by) return false;
|
|
147
|
+
const s = seen(), k = id + '|' + by.id;
|
|
148
|
+
if (s[k]) return false;
|
|
149
|
+
s[k] = 1;
|
|
150
|
+
try { localStorage.setItem(SEEN_KEY, JSON.stringify(s)); } catch { /* the toast shows again next time */ }
|
|
151
|
+
ui.undoToast('Set to ' + by.name + ' from the BRD', async () => after(ui, await ui.pmPost('/api/boards/ini-wf', { ...ui.bw(id), id, wf: by.from }), ui.title(id) + ' is back on its earlier workflow.'));
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The line over the page of an initiative in Won't do, with the way back (every gap has its next action). */
|
|
156
|
+
export function endedHtml(row) {
|
|
157
|
+
const line = WM.endedLine(row);
|
|
158
|
+
if (!line) return '';
|
|
159
|
+
return `<div class="hi-end" role="status"><span class="hi-endi" aria-hidden="true">${SVG('M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M6 6l12 12', 16)}</span><p>${esc(line)}</p><button type="button" class="hi-btn sm" data-wf-back>Back to Triage</button></div>`;
|
|
160
|
+
}
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* A phone has List, By stage and the stage track; the timeline needs a wider screen (BdPhone).
|
|
14
14
|
* After the model, GET /api/board-trail (lib/board-trail.js) adds what the model does not carry: days in the step and the usual days, the
|
|
15
15
|
* skipped steps and why, the parts of the output, what waits on you, tickets drafted in PMOS, PRD drift, links, dependencies and themes.
|
|
16
|
+
* Workflows (D99, workflows-per-initiative: WfABoard WfABoardOne WfATrack WfAElse WfAPhone; pm/bd-wf.js): every initiative is on one workflow. The
|
|
17
|
+
* chip row picks one (its own stages become the columns and the track's header) or All (the three categories, each row its own stages).
|
|
16
18
|
* Where no record holds a value for an initiative, the element says so: nothing is invented. */
|
|
17
19
|
import { pmPost } from './http.js';
|
|
18
20
|
import { $, $$, esc, store, crumbHtml, wireCrumb, chatAbout, setPageGaps } from './premium-shell.js';
|
|
@@ -22,6 +24,7 @@ import { stepsHelpHtml, rulesHelpHtml } from './bd-stages.js';
|
|
|
22
24
|
import { timelineHtml, legendHtml, SPANS, GROUPS, md } from './bd-span.js';
|
|
23
25
|
import * as Acts from './bd-acts.js';
|
|
24
26
|
import * as V from './bd-views.js';
|
|
27
|
+
import * as WF from './bd-wf.js';
|
|
25
28
|
import * as Asks from './bd-asks.js';
|
|
26
29
|
import * as PG from './bd-prog.js';
|
|
27
30
|
import { programOf } from './program-model.js';
|
|
@@ -43,7 +46,7 @@ let tab = 'ini';
|
|
|
43
46
|
let readTimer = null;
|
|
44
47
|
let foldOpen = false; // the Monitor and Evaluate rows under the table
|
|
45
48
|
let sprintSet = false; // "This sprint" starts on, once, when the board has a sprint
|
|
46
|
-
const F = { chips: new Set(), q: '', owners: new Set(),
|
|
49
|
+
const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints: new Set() }; // the chip filters, Find and Filter (the workflow is pm/bd-wf.js picked())
|
|
47
50
|
let GR = {}; // the first questions still open per initiative (GET /api/board-grill?ids=): { [id]: { open, total, later } }
|
|
48
51
|
let PGS = []; // the programs (GET /api/programs): every view groups the rows a program holds under it (PgBoard)
|
|
49
52
|
let XR = {}; // the other products' rows a program here holds, read once (GET /api/board-premium?ws=): { [ws]: { name, rows } }
|
|
@@ -230,8 +233,11 @@ function inSprint(r, sp) {
|
|
|
230
233
|
}
|
|
231
234
|
function visible() {
|
|
232
235
|
const sp = M.jira && M.jira.sprint;
|
|
236
|
+
const W = wfState(), only = WF.narrowed(W.list) ? W.cur.id : null;
|
|
233
237
|
return M.initiatives.list.rows.filter((r) => {
|
|
234
238
|
const t = r.track || {};
|
|
239
|
+
if (r.ended) return false; // Won't do and Archived are their own strips (pm/bd-wf.js endedRows)
|
|
240
|
+
if (only && WF.wfOf(r).id !== only) return false;
|
|
235
241
|
if (F.chips.has('late') && !r.late) return false;
|
|
236
242
|
if (F.chips.has('risk') && r.status !== 'at risk') return false;
|
|
237
243
|
if (F.chips.has('blocked') && !t.blocked) return false;
|
|
@@ -239,19 +245,24 @@ function visible() {
|
|
|
239
245
|
if (F.chips.has('sprint') && sp && (view === 'track' || PHONE.matches) && !inSprint(r, sp)) return false;
|
|
240
246
|
if (F.q && !String(r.title || '').toLowerCase().includes(F.q.toLowerCase())) return false;
|
|
241
247
|
if (F.owners.size && !F.owners.has(r.owner || 'No owner')) return false;
|
|
242
|
-
if (F.
|
|
248
|
+
if (F.cats.size && !F.cats.has(WF.catOfRow(r))) return false;
|
|
243
249
|
if (F.sprints.size && !(t.tickets || []).some((k) => F.sprints.has(k.sprint || 'Backlog'))) return false;
|
|
244
250
|
return true;
|
|
245
251
|
});
|
|
246
252
|
}
|
|
247
|
-
const filtered = () => [...F.chips].some((k) => k !== 'sprint') || !!F.q || F.owners.size > 0 || F.
|
|
248
|
-
const clearFilters = () => { F.chips.forEach((k) => { if (k !== 'sprint') F.chips.delete(k); }); F.q = ''; F.owners.clear(); F.
|
|
253
|
+
const filtered = () => [...F.chips].some((k) => k !== 'sprint') || !!F.q || F.owners.size > 0 || F.cats.size > 0 || F.sprints.size > 0 || WF.narrowed(wfState().list);
|
|
254
|
+
const clearFilters = () => { F.chips.forEach((k) => { if (k !== 'sprint') F.chips.delete(k); }); F.q = ''; F.owners.clear(); F.cats.clear(); F.sprints.clear(); WF.setPick(''); };
|
|
255
|
+
/** The workflows on the board, the picked one (null for All) and the rows that ended (pm/bd-wf.js). */
|
|
256
|
+
const wfState = () => { const list = WF.workflowsOf(M); return { list, cur: WF.picked(list), ended: WF.endedRows(M) }; };
|
|
249
257
|
/** The "Showing" bar (BdFilter): what Filter has on, each with its own ×, Clear all, and how many initiatives show. */
|
|
250
258
|
function showingHtml(n) {
|
|
251
|
-
const G = [['owners', 'Owner'], ['
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
259
|
+
const G = [['owners', 'Owner'], ['cats', 'Category'], ['sprints', 'Sprint']].filter(([k]) => F[k].size);
|
|
260
|
+
// the picked workflow shows here only where no chip row says it already: the desktop List (WfAElse)
|
|
261
|
+
const W = wfState(), wfOn = WF.narrowed(W.list) && view === 'list' && !PHONE.matches;
|
|
262
|
+
if (!G.length && !F.q && !wfOn) return '';
|
|
263
|
+
const word = (k, v) => (k === 'cats' ? WF.catLabel(v) : v);
|
|
264
|
+
const chips = (wfOn ? `<button type="button" class="bd-chip on" data-unf="wf" aria-label="Remove Workflow: ${esc(W.cur.name)}">Workflow: ${esc(W.cur.name)}${SV(I.x)}</button>` : '')
|
|
265
|
+
+ G.map(([k, n2]) => `<button type="button" class="bd-chip on" data-unf="${k}" aria-label="Remove ${n2}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}">${esc(n2)}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}${SV(I.x)}</button>`).join('')
|
|
255
266
|
+ (F.q ? `<button type="button" class="bd-chip on" data-unf="q" aria-label="Remove the search">“${esc(F.q)}”${SV(I.x)}</button>` : '');
|
|
256
267
|
return `<div class="bd-showing" role="status"><span class="bd-mlbl">Showing</span>${chips}<button type="button" class="dlink" id="fClear">Clear all</button><span class="bd-sp"></span><span class="bd-amut">${n} of ${M.initiatives.list.rows.length} initiatives</span></div>`;
|
|
257
268
|
}
|
|
@@ -298,31 +309,64 @@ const DAYS = (t) => (t.days != null ? t.days + 'd' : '—');
|
|
|
298
309
|
const usualOf = (t) => { const u = TR && TR.usual && t && TR.usual[t.key]; return u && u.n >= 3 && u.days != null ? u : null; };
|
|
299
310
|
const usualText = (u) => (u.days === 0 ? 'usually under a day' : 'usually ' + u.days + ' ' + plural(u.days, 'day', 'days'));
|
|
300
311
|
const dayTitle = (t) => t.label + ' · ' + (t.days != null ? t.days + ' ' + plural(t.days, 'day', 'days') + ' in this step' : 'days in this step are not on record') + (usualOf(t) ? ' · ' + usualText(usualOf(t)) : '');
|
|
312
|
+
/* What the track draws (WfATrack): Product feature's eight steps (the track as it was), the picked workflow's own stages, or with All the three
|
|
313
|
+
* categories, each row drawing its own stages in their band with ◆ for a milestone. Set by drawTrack for the rows it draws. */
|
|
314
|
+
let TK = { mode: 'pf', steps: null };
|
|
315
|
+
function trackMode(L) {
|
|
316
|
+
const W = wfState();
|
|
317
|
+
if (!W.cur) return { mode: 'cats', steps: null };
|
|
318
|
+
if (WF.isPF(W.cur)) return { mode: 'pf', steps: M.steps || [] };
|
|
319
|
+
return { mode: 'wf', steps: WF.stagesOfWf(W.cur, M.rows || []).map((st) => ({ key: st.key, label: st.name, ms: st.milestone, cat: st.cat, count: L.filter((r) => (WF.stageOfRow(r) || {}).key === st.key).length })) };
|
|
320
|
+
}
|
|
321
|
+
/** With All: one band per category, a bar per stage of the row's own workflow (done grey, the current one dark with its name and days). */
|
|
322
|
+
function bandsHtml(r, t) {
|
|
323
|
+
const S = WF.stagesOfRow(r), cur = WF.stageOfRow(r), at = cur ? S.findIndex((x) => x.key === cur.key) : -1;
|
|
324
|
+
return WF.CATS.map(([c, n]) => `<div class="bnd" role="cell" aria-label="${esc(n)}">${S.map((x, i) => {
|
|
325
|
+
if (x.cat !== c) return '';
|
|
326
|
+
const cls = [x.milestone ? 'm' : '', x.skipped ? 'k' : i < at ? 'dn' : '', i === at ? 'nw' : ''].filter(Boolean).join(' ');
|
|
327
|
+
const title = i === at ? dayTitle({ ...t, label: x.name }) : x.name + (x.skipped ? ' skipped' + (x.skipped.why ? ': ' + x.skipped.why : '') : i < at ? ' · done' : '');
|
|
328
|
+
return `<span class="${cls}" title="${esc(title)}">${i === at ? `<em>${esc(x.name)} · ${DAYS(t)}</em>` : ''}</span>`;
|
|
329
|
+
}).join('')}</div>`).join('');
|
|
330
|
+
}
|
|
301
331
|
function trackRow(r, cls = '') {
|
|
302
|
-
const t = r.track || { k: -1, label: r.stage || 'No stage', output: '', segs: [], skipped: [] }, s = statusOf(r),
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
332
|
+
const t = r.track || { k: -1, label: r.stage || 'No stage', output: '', segs: [], skipped: [] }, s = statusOf(r), pf = TK.mode === 'pf';
|
|
333
|
+
const S = pf ? M.steps : TK.steps || [];
|
|
334
|
+
const own = !pf && TK.mode === 'wf' ? WF.stagesOfRow(r) : null, cur = own ? WF.stageOfRow(r) : null;
|
|
335
|
+
const k = pf ? t.k : cur ? S.findIndex((x) => x.key === cur.key) : -1;
|
|
336
|
+
const sk = pf ? new Set(t.skipped || []) : new Set(S.map((x, j) => ((own || []).find((y) => y.key === x.key && y.skipped) ? j : -1)).filter((j) => j >= 0));
|
|
337
|
+
const E = pf && k >= 0 ? etaOf(r, t) : null;
|
|
338
|
+
const cells = TK.mode === 'cats' ? bandsHtml(r, t) : S.map((st, j) => {
|
|
339
|
+
const cls = ['sc', j === 0 ? 'f0' : '', j === S.length - 1 ? 'l' : '', st.ms ? 'ms' : '', j < k ? 'p' : '', sk.has(j) ? 'k' : '', j === k ? 'c bg' : ''].filter(Boolean).join(' ');
|
|
340
|
+
const why = sk.has(j) && (pf ? (t.skipWhy || []).find((x) => x.stage === st.key) : ((own || []).find((y) => y.key === st.key) || {}).skipped);
|
|
306
341
|
const title = j === k ? dayTitle(t) : sk.has(j) ? st.label + ' skipped' + (why && why.why ? ': ' + why.why : '') : '';
|
|
307
342
|
const eta = E && E.j === j ? E : null;
|
|
308
343
|
const etaH = eta ? `<small class="eta${eta.late ? ' late' : ''}" title="${esc(eta.what + (eta.late ? ', passed' : ''))}">${esc(eta.text)}</small>` : '';
|
|
309
344
|
return `<div class="${cls}" role="cell"${title ? ` title="${esc(title)}"` : ''}>${j === k ? `<span class="cur"><u class="cz-dot ${s.tone} ${s.mo}"></u>${eta ? etaH : `<small>${DAYS(t)}</small>`}</span>` : '<i></i>' + etaH}</div>`;
|
|
310
345
|
}).join('');
|
|
346
|
+
const many = TK.mode === 'cats'; // All: each row names its workflow with its icon (WfATrack)
|
|
311
347
|
return `<div class="bt-r bt-l${cls}${peek && peek.key === r.key && peek.kind !== 'acts' ? ' sel' : ''}${r.acts && r.acts.life === 'hold' ? ' held' : ''}" role="row" data-row="${esc(r.key)}">`
|
|
312
|
-
+ `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${esc(r.title)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
|
|
313
|
-
+ `<div class="
|
|
348
|
+
+ `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${many ? WF.wfIcon(WF.wfOf(r), 18) : ''}${esc(r.title)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
|
|
349
|
+
+ `<div class="${cellsCls()}" role="presentation"${cellsStyle()}>${cells}</div>`
|
|
314
350
|
+ `<div class="bt-dl" role="cell"><div class="t1"><b>${esc(outName(t.output))}</b><span>${esc(t.count || '')}</span></div>${segHtml(r)}<div class="t3">${lineHtml(r)}</div></div></div>`;
|
|
315
351
|
}
|
|
352
|
+
const cellsCls = () => 'bt-cells' + (TK.mode === 'cats' ? ' bands' : TK.mode === 'wf' ? ' wfn' : '');
|
|
353
|
+
const cellsStyle = () => (TK.mode === 'wf' ? ` style="--n:${Math.max(1, TK.steps.length)}"` : '');
|
|
316
354
|
const isME = (r) => r.track && r.track.k >= 6;
|
|
317
355
|
function drawTrack(L) {
|
|
318
|
-
|
|
319
|
-
const
|
|
356
|
+
TK = trackMode(L);
|
|
357
|
+
const S = TK.mode === 'pf' ? M.steps || [] : TK.steps || [];
|
|
358
|
+
const sorted = TK.mode === 'pf' ? L.slice().sort((a, b) => ((a.track ? a.track.k : -1) < 0 ? 99 : a.track.k) - ((b.track ? b.track.k : -1) < 0 ? 99 : b.track.k))
|
|
359
|
+
: L.slice().sort((a, b) => WF.posOf(a) - WF.posOf(b));
|
|
320
360
|
// Monitor and Evaluate fold away after the first row of each (AgBoard: "19 more in Monitor and Evaluate")
|
|
321
361
|
const seen = new Set(), shown = [], folded = [];
|
|
322
362
|
for (const r of sorted) { if (isME(r) && seen.has(r.track.k) && !foldOpen) folded.push(r); else { if (isME(r)) seen.add(r.track.k); shown.push(r); } }
|
|
323
363
|
const meTotal = (S[6] ? S[6].count : 0) + (S[7] ? S[7].count : 0), meShown = shown.filter(isME).length, more = Math.max(folded.length, meTotal - meShown);
|
|
324
364
|
const n = M.initiatives.open || M.initiatives.list.rows.length;
|
|
325
|
-
|
|
365
|
+
// the header: the eight steps (their help opens from them), the picked workflow's stages, or with All the three categories (WfATrack)
|
|
366
|
+
const hcell = (s) => (TK.mode === 'pf' ? `<div role="columnheader" class="${s.ms ? 'msh' : ''}" data-steps title="What finishes each step" aria-haspopup="dialog" tabindex="0">` : `<div role="columnheader" class="${s.ms ? 'msh' : ''}">`)
|
|
367
|
+
+ `<span class="bt-hl">${s.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(s.label)}</span><span>${s.count}</span></div>`;
|
|
368
|
+
const hcells = TK.mode === 'cats' ? WF.CATS.map(([k, label]) => hcell({ label, count: V.catCount(L, k) })) : S.map(hcell);
|
|
369
|
+
const head = `<div class="bt-r bt-h" role="row"><div class="bt-nmh" role="columnheader">Initiative <span>${n}</span></div><div class="${cellsCls()}" role="presentation"${cellsStyle()}>${hcells.join('')}</div><div class="bt-oh" role="columnheader">Output ${LEGEND}</div></div>`;
|
|
326
370
|
const tf = more > 0 && !foldOpen ? `<button type="button" class="dlink" id="fold" aria-expanded="false">${SV(I.chev)}${more} more in Monitor and Evaluate</button>`
|
|
327
371
|
: foldOpen && meTotal > 1 ? `<button type="button" class="dlink" id="fold" aria-expanded="true">${SV(I.chevUp)}Fold Monitor and Evaluate${meTotal > meShown ? ` · ${meTotal - meShown} more are not loaded` : ''}</button>` : '<span></span>';
|
|
328
372
|
if (!L.length) return `<div class="bt" role="table" aria-label="Initiatives by stage">${head}<p class="bt-empty">${filtered() ? 'No initiative matches the chips, Find or Filter. <button type="button" class="dlink" id="fClear">Clear them</button>' : 'No initiatives are on this board\'s now view.'}</p></div>`;
|
|
@@ -335,7 +379,7 @@ function drawTrack(L) {
|
|
|
335
379
|
const rows = G ? G.map((g) => {
|
|
336
380
|
if (g.kind === 'program') {
|
|
337
381
|
const kids = PG.folded(g.key) ? '' : g.products.map((sub) => (g.products.length > 1 ? PG.subHtml(sub.name) : '') + sub.rows.map((r) => trackRow(r, ' bt-kid' + (r === g.rows[g.rows.length - 1] ? ' last' : ''))).join('')).join('');
|
|
338
|
-
return PG.bandHtml(g, progState(g.program), { steps: S }) + kids;
|
|
382
|
+
return PG.bandHtml(g, progState(g.program), { steps: S, plain: TK.mode !== 'pf' }) + kids;
|
|
339
383
|
}
|
|
340
384
|
if (PG.folded(g.key)) return PG.prodHtml(g);
|
|
341
385
|
const f = meFold(g.rows); inGroups += f.off.length;
|
|
@@ -364,7 +408,9 @@ function drawInit() {
|
|
|
364
408
|
const html = v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
|
|
365
409
|
// a phone has no ⋯ menu: Metrics and Cancelled and archived stay one press away in every view, not only the track
|
|
366
410
|
const phx = phone && v !== 'track' ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : '';
|
|
367
|
-
|
|
411
|
+
// the workflow chips (WfABoard, WfATrack, WfAPhone): By stage and the track on a desktop, every view on a phone; the List filters in Filter
|
|
412
|
+
const W = wfState(), wfc = phone || v === 'stages' || v === 'track' ? WF.chipsHtml(W.list, W.cur, { phone }) : '';
|
|
413
|
+
body.innerHTML = (phone ? phoneSeg(v) : '') + wfc + html + phx;
|
|
368
414
|
$('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
|
|
369
415
|
$$('#ibTabs [data-v]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.v === v)));
|
|
370
416
|
$('#bdView').innerHTML = SV(v === 'time' ? I.time : I.track); $('#bdView').setAttribute('aria-label', 'Change view. Now: ' + (v === 'time' ? 'Timeline' : 'Stage track'));
|
|
@@ -398,12 +444,15 @@ $('#bdView').addEventListener('click', () => { if (M) setView(PHONE.matches ? (p
|
|
|
398
444
|
$('#bdShowing').addEventListener('click', (e) => {
|
|
399
445
|
if (e.target.closest('#fClear')) { clearFilters(); drawChips(); drawInit(); return; }
|
|
400
446
|
const u = e.target.closest('[data-unf]'); if (!u) return;
|
|
401
|
-
if (u.dataset.unf === 'q') F.q = ''; else F[u.dataset.unf].clear(); drawChips(); drawInit();
|
|
447
|
+
if (u.dataset.unf === 'q') F.q = ''; else if (u.dataset.unf === 'wf') WF.setPick(''); else F[u.dataset.unf].clear(); drawChips(); drawInit();
|
|
402
448
|
});
|
|
403
449
|
$('#bdSpans').addEventListener('click', (e) => { const b = e.target.closest('[data-sp]'); if (!b || !M) return; span = b.dataset.sp; store.set(SPAN_KEY, span); drawChips(); drawInit(); });
|
|
404
450
|
$('#ibBody').addEventListener('click', (e) => {
|
|
405
451
|
if (e.target.closest('#fold, [data-mefold]')) { foldOpen = !foldOpen; drawInit(); const f = $('#fold') || $('#ibBody [data-mefold]'); if (f) f.focus(); return; }
|
|
406
452
|
const gf = e.target.closest('[data-fold]'); if (gf) { const k = gf.dataset.fold; PG.fold(k); drawInit(); const b = $$('#ibBody [data-fold]').find((x) => x.dataset.fold === k); if (b) b.focus(); return; }
|
|
453
|
+
const wp = e.target.closest('[data-wfpick]'); if (wp) { const id = wp.dataset.wfpick; WF.setPick(wp.getAttribute('aria-pressed') === 'true' ? '' : id); drawChips(); drawInit(); const b = $$('#ibBody [data-wfpick]').find((x) => x.dataset.wfpick === (WF.picked(wfState().list) || { id: '' }).id) || $('#ibBody [data-wfpick]'); if (b) b.focus(); return; }
|
|
454
|
+
const pc = e.target.closest('[data-pcat]'); if (pc) { const k = pc.dataset.pcat; V.togglePcat(k); drawInit(); const b = $$('#ibBody [data-pcat]').find((x) => x.dataset.pcat === k); if (b) b.focus(); return; }
|
|
455
|
+
const pm = e.target.closest('[data-pmore]'); if (pm) { V.morePcat(pm.dataset.pmore); drawInit(); return; }
|
|
407
456
|
const cf = e.target.closest('[data-colfold]'); if (cf) { const k = cf.dataset.colfold; V.toggleCol(k); drawInit(); const b = $$('#ibBody [data-colfold]').find((x) => x.dataset.colfold === k); if (b) b.focus(); return; }
|
|
408
457
|
if (e.target.closest('#fClear')) { clearFilters(); drawChips(); drawInit(); return; }
|
|
409
458
|
const pv = e.target.closest('[data-pv]'); if (pv) { setView(pv.dataset.pv); const b = $(`#ibBody [data-pv="${pv.dataset.pv}"]`); if (b) b.focus(); return; }
|
|
@@ -427,15 +476,25 @@ $('#ibBody').addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.ke
|
|
|
427
476
|
let dragKey = null;
|
|
428
477
|
$('#ibBody').addEventListener('dragstart', (e) => { const c = e.target.closest('.bd-bc[draggable]'); if (!c) return; dragKey = c.dataset.key; e.dataTransfer.effectAllowed = 'move'; try { e.dataTransfer.setData('text/plain', dragKey); } catch { /* some browsers refuse */ } c.classList.add('drag'); });
|
|
429
478
|
$('#ibBody').addEventListener('dragend', () => { dragKey = null; $$('#ibBody .drag, #ibBody .drop').forEach((x) => x.classList.remove('drag', 'drop')); });
|
|
430
|
-
$('#ibBody').addEventListener('dragover', (e) => { const col = dragKey && e.target.closest('.bd-scol[data-step], .bd-kc[data-step]'); if (!col) return; e.preventDefault(); $$('#ibBody .drop').forEach((x) => { if (x !== col) x.classList.remove('drop'); }); col.classList.add('drop'); });
|
|
479
|
+
$('#ibBody').addEventListener('dragover', (e) => { const col = dragKey && e.target.closest('.bd-scol[data-step], .bd-kc[data-step], .bd-kc[data-wfstage]'); if (!col) return; e.preventDefault(); $$('#ibBody .drop').forEach((x) => { if (x !== col) x.classList.remove('drop'); }); col.classList.add('drop'); });
|
|
431
480
|
$('#ibBody').addEventListener('drop', async (e) => {
|
|
432
|
-
const col = e.target.closest('.bd-scol[data-step], .bd-kc[data-step]'); if (!col || !dragKey) return;
|
|
481
|
+
const col = e.target.closest('.bd-scol[data-step], .bd-kc[data-step], .bd-kc[data-wfstage]'); if (!col || !dragKey) return;
|
|
433
482
|
e.preventDefault();
|
|
434
|
-
const r = rowOf(dragKey)
|
|
435
|
-
if (!r || !r.track ||
|
|
436
|
-
|
|
437
|
-
if (
|
|
438
|
-
|
|
483
|
+
const r = rowOf(dragKey); dragKey = null; col.classList.remove('drop');
|
|
484
|
+
if (!r || !r.track || !r.acts) return;
|
|
485
|
+
let to = null, from = r.acts.stage;
|
|
486
|
+
if (col.dataset.wfstage) {
|
|
487
|
+
// a stage of the picked workflow (WfABoardOne): the move names the stage; the server checks it against the initiative's workflow
|
|
488
|
+
const w = WF.wfOf(r), cur = WF.stageOfRow(r), st = WF.stagesOfWf(w, M.rows || []).find((x) => x.key === col.dataset.wfstage);
|
|
489
|
+
if (w.id !== col.dataset.wf || !st) { say('That stage is not on ' + r.title + '\'s workflow, so it did not move.'); return; }
|
|
490
|
+
if (cur && cur.key === st.key) return;
|
|
491
|
+
to = st.name; if (cur) from = cur.name;
|
|
492
|
+
} else {
|
|
493
|
+
const j = +col.dataset.step; if (r.track.k === j) return;
|
|
494
|
+
const step = M.steps[j]; to = (r.acts.stages || []).find((n) => stepOfName(n) === step.key);
|
|
495
|
+
if (!to) { say(step.label + ' is not one of this board\'s stages, so it did not move.'); return; }
|
|
496
|
+
}
|
|
497
|
+
const body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, id: r.id };
|
|
439
498
|
const res = await pmPost('/api/boards/move', { ...body, to }).catch(() => null);
|
|
440
499
|
if (!res || !res.ok) { say((res && res.error) || 'It did not move. The server did not say why.'); return; }
|
|
441
500
|
say('Moved to ' + to + ' · ' + r.title + '.', async () => { const u = await pmPost('/api/boards/move', { ...body, to: from, why: 'Undo' }).catch(() => null); say(u && u.ok ? 'Back in ' + from + '.' : (u && u.error) || 'The undo did not land.'); load(); });
|
|
@@ -709,18 +768,27 @@ async function load() {
|
|
|
709
768
|
return;
|
|
710
769
|
}
|
|
711
770
|
M = r.model; holdNames(); draw();
|
|
712
|
-
focusOnce(); programOnce(); loadOthers();
|
|
771
|
+
focusOnce(); programOnce(); loadOthers(); loadWorkflows();
|
|
713
772
|
if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
|
|
714
773
|
else { loadTrail(); loadGrill(); }
|
|
715
774
|
}
|
|
775
|
+
/** The workflows' own stage lists (GET /api/workflows), once, when a row here is on another workflow than Product feature: a picked workflow
|
|
776
|
+
* draws every one of its stages, the empty ones too (WfABoardOne). Not read: the stages come from the rows (pm/bd-wf.js stagesOfWf). */
|
|
777
|
+
let wfRead = false;
|
|
778
|
+
async function loadWorkflows() {
|
|
779
|
+
if (wfRead || !M || !wfState().list.some((w) => !WF.isPF(w))) return;
|
|
780
|
+
wfRead = true;
|
|
781
|
+
let r = null; try { r = await (await fetch('/api/workflows' + (M.board.ws ? '?ws=' + encodeURIComponent(M.board.ws) : ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
|
|
782
|
+
if (r && r.ok && Array.isArray(r.workflows)) { WF.setDefs(r.workflows); drawInit(); }
|
|
783
|
+
}
|
|
716
784
|
const viewDoc = (path) => { const a = document.createElement('button'); a.dataset.doc = path; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); };
|
|
717
785
|
const anchors = async (ws, board) => { try { const r = await (await fetch('/api/boards/anchors?ws=' + encodeURIComponent(ws || M.board.ws || '') + '&board=' + encodeURIComponent(board || M.board.id || ''), { credentials: 'same-origin' })).json(); return r && r.ok ? r.anchors || [] : []; } catch { return []; } };
|
|
718
786
|
const openIniAny = (r) => openIni(r, $('#bdBell'), 'track');
|
|
719
|
-
V.init({ M: () => M, statusOf, usual: usualOf, trail: TI, docMeta, sel: () => (peek && peek.kind !== 'acts' ? peek.key : null), docSel: () => Acts.docSel(),
|
|
787
|
+
V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, docMeta, sel: () => (peek && peek.kind !== 'acts' ? peek.key : null), docSel: () => Acts.docSel(),
|
|
720
788
|
groups: (L) => groups(L), folded: PG.folded, laneHead: (g) => PG.laneHtml(g, g.kind === 'program' ? progState(g.program) : null), subTile: (n) => PG.tileHtml(n, 'bd-ti s'),
|
|
721
789
|
memberIcon: (id) => PG.memberIcon(PGS, id), product: () => (M.board.product || M.board.name || ''), programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), tileHtml: PG.tileHtml, progTile: PG.progTile });
|
|
722
790
|
Asks.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, rowOf, openIni: openIniAny, openDoc: viewDoc, anchors, programs: () => PGS, reloadPrograms: loadPrograms });
|
|
723
|
-
Acts.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); if (tab === 'docs') drawDocs(); }, F, rowOf, statusOf, openIni: openIniAny,
|
|
791
|
+
Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); if (tab === 'docs') drawDocs(); }, F, rowOf, statusOf, openIni: openIniAny,
|
|
724
792
|
openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, docMeta, loadDocMeta, viewDoc,
|
|
725
793
|
grouping: () => ({ on: groupingOn(), byProduct }), setGrouping });
|
|
726
794
|
BI.mount({ M: () => M, statusOf, dayTitle, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
|
|
@@ -52,10 +52,18 @@ const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso ||
|
|
|
52
52
|
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
53
53
|
|
|
54
54
|
/** The card's model. M: the page model; now: ms. */
|
|
55
|
+
/** The steps of the initiative's own workflow (D99): Product feature is the eight above; another workflow sends its stages on the row
|
|
56
|
+
* (wfStages, scripts/workflows.js stagesOf), and a stage PMOS judged it skips is left out of the ladder. */
|
|
57
|
+
function stepsOf(m) {
|
|
58
|
+
const own = m.wf && m.wf.id && m.wf.id !== 'product-feature' && Array.isArray(m.wfStages) && m.wfStages.length;
|
|
59
|
+
if (!own) return null;
|
|
60
|
+
return m.wfStages.filter((s) => s.status !== 'skipped' || (m.wfStage && s.key === m.wfStage.key)).map((s) => ({ key: s.key, label: s.name, ms: !!s.milestone, out: '' }));
|
|
61
|
+
}
|
|
55
62
|
export function headModel(M, now = Date.now()) {
|
|
56
63
|
const m = M || {}, head = m.head || {}, acts = m.acts || {}, ov = m.overview || {};
|
|
57
|
-
const
|
|
58
|
-
const
|
|
64
|
+
const own = stepsOf(m), LIST = own || STEPS;
|
|
65
|
+
const key = own ? (m.wfStage && m.wfStage.key) || null : stageKey(head.stage || acts.stage), at = key ? LIST.findIndex((s) => s.key === key) : -1;
|
|
66
|
+
const cur = at >= 0 ? LIST[at] : null, next = at >= 0 ? LIST[at + 1] || null : null, prev = at > 0 ? LIST[at - 1] : null;
|
|
59
67
|
const items = [];
|
|
60
68
|
// the workflow engine's checks: done and waiting; Build and Quality are the engineers' (Jira below), so they are not listed as PMOS work
|
|
61
69
|
for (const c of m.checks || []) {
|
|
@@ -78,7 +86,7 @@ export function headModel(M, now = Date.now()) {
|
|
|
78
86
|
const done = items.filter((x) => x.kind === 'done'), rest = items.filter((x) => x.kind !== 'done');
|
|
79
87
|
const life = acts.life || null;
|
|
80
88
|
const turn = rest.some((x) => x.kind === 'you') ? 'you' : life === 'hold' || life === 'cancelled' || rest.some((x) => x.kind === 'risk') ? 'stalled'
|
|
81
|
-
: rest.some((x) => x.kind === 'jira') || key === 'build' || key === 'deliver' ? 'jira' : 'agents';
|
|
89
|
+
: rest.some((x) => x.kind === 'jira') || (!own && (key === 'build' || key === 'deliver')) ? 'jira' : 'agents';
|
|
82
90
|
const TURN = { you: 'Your turn', agents: 'Agents working', jira: 'Engineers on it', stalled: life === 'hold' ? 'On hold' : life === 'cancelled' ? 'Cancelled' : 'Stalled' };
|
|
83
91
|
// time in the stage: a record that holds it (stageSince, usualDays) first, then the planned finish, then say it is not recorded
|
|
84
92
|
let time = '', over = false;
|
|
@@ -98,16 +106,18 @@ export function headModel(M, now = Date.now()) {
|
|
|
98
106
|
: turn === 'jira' ? 'Where do this initiative\'s Jira tickets stand, from the last Jira read? Name the assignee of each where the read holds one, and change nothing.'
|
|
99
107
|
: 'What happens next in this initiative, and who does it? Read this repository and change nothing.';
|
|
100
108
|
const anchor = m.anchor ? ' Moves ' + m.anchor + '.' : '';
|
|
109
|
+
// another workflow's payoff: its next stage starts (its own outputs are the PM's words, not the lifecycle's)
|
|
110
|
+
const payoff = !cur ? '' : own ? (next ? next.label + ' starts.' : 'It is the last stage of ' + m.wf.name + '.') + anchor : PAYOFF[cur.key] + anchor;
|
|
101
111
|
return {
|
|
102
|
-
key, at, total:
|
|
103
|
-
stage: cur ? (at + 1) + ' of ' +
|
|
112
|
+
key, at, total: LIST.length, turn, turnLabel: TURN[turn],
|
|
113
|
+
stage: cur ? (at + 1) + ' of ' + LIST.length + ' · ' + cur.label : head.stage ? head.stage + ' · not on the lifecycle' : 'No stage on record',
|
|
104
114
|
prev: prev ? prev.label : '', cur: cur ? cur.label : head.stage || '', toReach: next ? next.label : cur ? 'Done' : '',
|
|
105
|
-
ladderAria: cur ? 'Stage ' + (at + 1) + ' of ' +
|
|
106
|
-
steps:
|
|
115
|
+
ladderAria: cur ? 'Stage ' + (at + 1) + ' of ' + LIST.length + ': ' + cur.label + '.' + (next ? ' Next stage: ' + next.label + '.' : '') : 'No stage on the lifecycle.',
|
|
116
|
+
steps: LIST.map((s, i) => ({ label: s.label, ms: !!s.ms, cls: at < 0 ? '' : i < at ? 'done' : i === at ? 'now' : '' })),
|
|
107
117
|
checkTitle: next ? 'To reach ' + next.label : cur ? 'To finish ' + cur.label : 'What is next',
|
|
108
118
|
done, rest, doneOf: done.length + ' of ' + items.length + ' done',
|
|
109
119
|
foldSum: done.length + ' of ' + items.length + ' done · ' + ([rest.filter((x) => x.kind === 'you').length ? rest.filter((x) => x.kind === 'you').length + ' for you' : '', rest.filter((x) => x.kind === 'risk').length ? rest.filter((x) => x.kind === 'risk').length + ' blocked' : '', rest.filter((x) => x.kind === 'jira').length ? 'in Jira' : ''].filter(Boolean).join(', ') || (turn === 'agents' ? 'agents on it' : 'nothing waiting')),
|
|
110
|
-
payoff
|
|
120
|
+
payoff, time, over, cta, ask, primary: turn !== 'agents', step: turn === 'you' ? step : '',
|
|
111
121
|
};
|
|
112
122
|
}
|
|
113
123
|
|