create-pmos 0.265.0 → 0.266.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 +1 -1
- 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/briefing-premium-board-test.js +1 -1
- package/workspace/guide/briefing-premium.md +4 -1
- package/workspace/lib/board-premium.js +29 -3
- package/workspace/lib/initiative-premium.js +8 -0
- package/workspace/lib/routes-board-premium.js +15 -4
- package/workspace/lib/routes-initiative-premium.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +209 -0
- package/workspace/public/pm/premium-acts.js +281 -0
- package/workspace/public/pm/premium-board.js +36 -7
- package/workspace/public/pm/premium-initiative.js +9 -2
- package/workspace/public/pm/premium.css +19 -0
- package/workspace/public/premium-board.html +3 -2
- package/workspace/public/premium-initiative.html +1 -1
- package/workspace/test-lists/premium-board-actions.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.266.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T10:48:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -139,7 +139,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
139
139
|
/* B10 dialog */
|
|
140
140
|
await p.locator('#ibBody .ini2').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(700);
|
|
141
141
|
const dlg = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, sub: document.querySelector('#dSub').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), path: document.querySelector('#oMain .dpath').textContent, buttons: [...document.querySelectorAll('#card button')].length, hold: document.querySelector('#holdWhy').textContent, ask: !!document.querySelector('#askGo'), label: document.querySelector('#oLab').textContent }));
|
|
142
|
-
ok('B10 an initiative opens its record as a grid with the path of its file, the read-only agent beside it and no press', dlg.title === 'Self-serve onboarding v2' && /Stage\|Build \(derived\)/.test(dlg.grid) && /Progress\|62%/.test(dlg.grid) && dlg.path === 'planning/initiatives/self-serve-v2.md' && dlg.buttons === 0 && dlg.ask && /
|
|
142
|
+
ok('B10 an initiative opens its record as a grid with the path of its file, the read-only agent beside it and no press', dlg.title === 'Self-serve onboarding v2' && /Stage\|Build \(derived\)/.test(dlg.grid) && /Progress\|62%/.test(dlg.grid) && dlg.path === 'planning/initiatives/self-serve-v2.md' && dlg.buttons === 0 && dlg.ask && /This dialog changes nothing/.test(dlg.hold) && dlg.label === 'Initiative record', JSON.stringify(dlg));
|
|
143
143
|
A.setThread({ ok: true, working: false, turns: [] });
|
|
144
144
|
await p.fill('#askIn', 'Why is this late?'); const nA = A.posts.length; await p.press('#askIn', 'Enter');
|
|
145
145
|
ok('B10 a question posts the initiative key and the text', await until(() => A.posts.length > nA && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'board:self-serve-v2' && A.posts[A.posts.length - 1].body.text === 'Why is this late?'));
|
|
@@ -159,7 +159,10 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
|
|
|
159
159
|
- **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine and keep no history, so they have no chart. Move over a chart, or use the arrow keys, to read a week. A tile that cannot be counted says **Not read** and why. Press a tile for its definition and values, with the read-only agent beside it. There are no targets, and Day and Month are off. It was tested only on made-up repositories, not on a real IDPF or microsite repository.
|
|
160
160
|
- **The crumb** at the top names the board. With more than one board a menu switches between them, and the sparkle opens the board in the dialog with the read-only agent.
|
|
161
161
|
- **Core documents** lists the board's documents with their state, cadence and writer, a summary (drafts to review, not started, up to date), a progress bar, a filter and a search. **Draft it** starts the existing read-only run that writes a draft and sends nothing; **Draft the N not started** does that for each document that can be drafted. **Set it up** and **Open** go to the console. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
|
|
162
|
-
- **Opening an initiative.** A click on an initiative opens its page (see "Initiative page"). The **Page / Popup** switch in the header changes that: Popup opens the initiative's dialog instead, which shows its record as a grid and the path of its file, with the read-only agent beside it. The choice is kept in this browser. The dialog holds no press
|
|
162
|
+
- **Opening an initiative.** A click on an initiative opens its page (see "Initiative page"). The **Page / Popup** switch in the header changes that: Popup opens the initiative's dialog instead, which shows its record as a grid and the path of its file, with the read-only agent beside it. The choice is kept in this browser. The dialog holds no press.
|
|
163
|
+
- **New asks** sits at the top of the right column on a team board. Each ask shows where it came from and the drafted title, lane and anchor. **Accept** makes it an initiative in the first stage, through the console's accept route; **Decline** asks for a reason first. The card says when nothing is left to triage.
|
|
164
|
+
- **New initiative** (beside the Initiatives heading, team boards only) asks for a title, a lane and an anchor (a KR or a health budget). It writes an ask and accepts it, as the console does. An unanchored initiative is refused on the page.
|
|
165
|
+
- **⋯ on a row** (and the bar under an initiative page's heading) moves it to the next or another stage, puts it on hold with a reason and a check-back day, cancels it with a reason, or archives it. Each press writes one line through the console's route, says what it recorded, and offers Undo for a few seconds. An on-hold row offers Resume; a cancelled one offers Reopen; an archived one offers Restore. Cancelled and archived initiatives leave the list and sit under a fold below it. On the PMOS board the workflow engine places each initiative, so the moves are not offered and New asks and New initiative are hidden.
|
|
163
166
|
|
|
164
167
|
Not drawn, because PMOS holds no record for them: the Metrics card on the PMOS board, the mockup's demo measures (Activation, Partner uptime, API p95), targets, and the mockup's demo boards.
|
|
165
168
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* sprints GET /api/boards/sprints → { source: 'jira'|'none', readAt, sprints: [{ name, state, start, end, counts: { todo, doing, done } }] }
|
|
13
13
|
* docs GET /api/core-docs?level=board → { scope, summary, docs: [{ key, title, for, cadence, by, kind, st, act, running }] }
|
|
14
14
|
* nextRelease { id, type, at } | null
|
|
15
|
+
* held, cancelled, archived GET /api/boards/backlog?view=all&status=on hold | status=cancelled | archived=1 → rows (initiative premium-board-actions)
|
|
16
|
+
* asks GET /api/boards/asks → asks [{ id, line, source, by, at, draft: { title, lane, anchor_suggestion } }]; null when it was not read
|
|
15
17
|
*
|
|
16
18
|
* THE RULE THE FILE FOLLOWS (as the other premium models): a figure, chip, bar or date is made only from a field of a record. An owner, an end date,
|
|
17
19
|
* a progress or a sprint that no record holds is not drawn. The header, the list, the stage columns and the dock read ONE set of counts. The Metrics
|
|
@@ -31,10 +33,28 @@ const STATUS_LABEL = { 'at risk': 'At risk', late: 'Late', 'on hold': 'On hold',
|
|
|
31
33
|
const DOC_STATE = { missing: 'Not started', draft: 'Draft', ok: 'Up to date', stale: 'Stale', due: 'Due' };
|
|
32
34
|
const BY = { drafts: 'PMOS drafts it', proposes: 'PMOS proposes', reviews: 'PMOS reviews', you: 'You write it', live: 'Live view' };
|
|
33
35
|
const GO = { reports: 'rep', initiatives: 'init' };
|
|
36
|
+
const LANES = ['feature', 'discovery', 'chore', 'incident', 'content', 'prototype'];
|
|
34
37
|
|
|
35
38
|
let last = null;
|
|
36
39
|
const peekModel = () => last;
|
|
37
40
|
|
|
41
|
+
/** What the row's ⋯ menu and the initiative page's bar can do, from the row's own fields (initiative premium-board-actions): its workflow's stage names,
|
|
42
|
+
* its stage, its lifecycle (on hold or cancelled, with the reason and check-back day the lifecycle line holds) and its archive entry. */
|
|
43
|
+
function actsOf(r, boardNames) {
|
|
44
|
+
const own = Array.isArray(r.workflow) && r.workflow.length ? r.workflow.map((s) => s.name) : boardNames;
|
|
45
|
+
const st = r.stopped || {};
|
|
46
|
+
const life = r.status === 'on hold' ? 'hold' : r.status === 'cancelled' ? 'cancelled' : null;
|
|
47
|
+
return {
|
|
48
|
+
stages: own, stage: r.stage || null, life, reason: life ? clip(st.reason || '', 300) : '', back: life === 'hold' && st.back ? shortDate(st.back) : '', backDay: life === 'hold' && st.back ? String(st.back).slice(0, 10) : null,
|
|
49
|
+
archived: r.archived ? { reason: clip(r.archived.reason || '', 300), into: r.archived.into ? (r.archived.intoTitle || r.archived.into) : null } : null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const askOf = (a) => {
|
|
53
|
+
const d = a.draft || {};
|
|
54
|
+
return { id: a.id, line: clip(a.line, 500), source: a.source || '', by: a.by || '', at: a.at ? shortDate(String(a.at).slice(0, 10)) : '',
|
|
55
|
+
draft: { title: clip(d.title || a.line, 120), lane: LANES.includes(d.lane) ? d.lane : null, anchor: d.anchor_suggestion || '' } };
|
|
56
|
+
};
|
|
57
|
+
|
|
38
58
|
function rowOf(r, wf, today) {
|
|
39
59
|
const names = (wf || []).map((s) => s.name), cur = names.indexOf(r.stage);
|
|
40
60
|
const bad = r.status === 'late' || r.status === 'at risk';
|
|
@@ -51,11 +71,12 @@ function rowOf(r, wf, today) {
|
|
|
51
71
|
stage: r.stage || null, cat: r.cat || null, stageNote: r.stageSource === 'derived' ? 'derived' : null,
|
|
52
72
|
seg: names.map((n, j) => (j < cur ? 'p' : j === cur ? 'n' : '')), progress: r.progress != null ? Math.max(0, Math.min(100, Math.round(r.progress))) : null,
|
|
53
73
|
finish: r.end ? shortDate(r.end) : 'Not planned', over: !!over, start: r.start || null, end: r.end || null,
|
|
74
|
+
acts: actsOf(r, names),
|
|
54
75
|
dialog: {
|
|
55
76
|
eye: 'Initiative', logTitle: 'Read from the board',
|
|
56
77
|
log: ['Read the initiative from the board' + (r.stageSource === 'derived' ? ' (its stage is derived by the workflow engine)' : ''), 'Placed it in the ' + (r.stage || 'unknown') + ' stage', r.status ? 'Took its status from the record: ' + r.status : 'No status is on record'],
|
|
57
78
|
say: r.title + ' is in ' + (r.stage || 'no stage') + (r.status ? ' and its status is ' + r.status : '') + '.' + (r.stageSource === 'derived' ? ' The stage comes from the workflow engine, not from a person.' : ''),
|
|
58
|
-
head: 'Where it stands', facts, hold: '
|
|
79
|
+
head: 'Where it stands', facts, hold: 'This dialog changes nothing. To move it, put it on hold, cancel or archive it, use ⋯ on its row or open its page.',
|
|
59
80
|
pane: { label: 'Initiative record', file: 'planning/initiatives/' + r.id + '.md', rows: facts },
|
|
60
81
|
},
|
|
61
82
|
};
|
|
@@ -69,6 +90,9 @@ function build(f) {
|
|
|
69
90
|
const missing = (f.missing || []).slice();
|
|
70
91
|
const open = Number(counts.open) || 0, on = Number(st['on track']) || 0, risk = Number(st['at risk']) || 0, late = Number(st.late) || 0, hold = Number(st['on hold']) || 0;
|
|
71
92
|
const rows = (f.rows || []).slice(0, MAX_LIST).map((r) => rowOf(r, wf, todayIso));
|
|
93
|
+
// the on-hold rows follow the open ones; the cancelled and archived rows sit under the list's fold (initiative premium-board-actions)
|
|
94
|
+
for (const r of (f.held || [])) if (rows.length < MAX_LIST + 50 && !rows.some((x) => x.id === r.id)) rows.push(rowOf(r, wf, todayIso));
|
|
95
|
+
const gone = { cancelled: (f.cancelled || []).slice(0, MAX_LIST).map((r) => rowOf(r, wf, todayIso)), archived: (f.archived || []).slice(0, MAX_LIST).map((r) => rowOf(r, wf, todayIso)) };
|
|
72
96
|
// the list reads the board's own rank; "Do this first" only where a record says the first row is late
|
|
73
97
|
if (rows[0] && rows[0].late) rows[0].first = true;
|
|
74
98
|
const stages = (f.columns || []).map((c) => ({ stage: c.stage, cat: c.cat, count: Number(c.count) || 0, rows: (c.rows || []).slice(0, STAGE_ROWS).map((r) => rowOf(r, wf, todayIso)), more: Math.max(0, (Number(c.count) || 0) - STAGE_ROWS) }));
|
|
@@ -117,17 +141,19 @@ function build(f) {
|
|
|
117
141
|
const model = {
|
|
118
142
|
pending: !!f.pending,
|
|
119
143
|
header: { text: 'Real data · as of ' + hhmm(now) + (missing.length ? ' · not read: ' + missing.join(', ') : '') + (f.pending ? ' · reading the board' : ''), missing },
|
|
120
|
-
board: { name: board.name || '', id: board.id || null, ws: board.ws || null, switcher: (f.boards || []).length > 1 ? f.boards.map((b) => ({ id: b.id, ws: b.ws, name: b.name })) : null },
|
|
144
|
+
board: { name: board.name || '', id: board.id || null, ws: board.ws || null, self: !!board.self, stages: wf.map((s) => s.name), switcher: (f.boards || []).length > 1 ? f.boards.map((b) => ({ id: b.id, ws: b.ws, name: b.name })) : null },
|
|
121
145
|
initiatives: {
|
|
122
146
|
title: 'Initiatives', open, on, risk, late, hold, total: Number(counts.total) || 0,
|
|
123
147
|
cap: open ? { on, open } : null,
|
|
124
148
|
note: open ? (rows.length >= open ? 'All ' + open + ' open ' + plural(open, 'initiative is', 'initiatives are') + ' listed. Late and at-risk ones come first.' : rows.length + ' of ' + open + ' open initiatives are loaded: late and at-risk ones first, then the board\'s now view.') : 'The board has no open initiatives.',
|
|
125
149
|
list: { rows, total: rows.length },
|
|
150
|
+
gone,
|
|
126
151
|
stages, timeline,
|
|
127
152
|
},
|
|
128
153
|
sprint, release, docs,
|
|
154
|
+
asks: f.asks == null ? { missing: true, rows: [] } : { rows: f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').slice(0, 50).map(askOf) },
|
|
129
155
|
dock: { needs: risk + late, label: 'need a look', next: (rows.find((r) => r.late) || rows.find((r) => r.bad) || {}).title || null },
|
|
130
|
-
rows: rows.concat(stageRows.filter((r) => !rows.some((x) => x.key === r.key))).concat([{ key: 'board:this-board', id: null, title: board.name || 'This board', sub: 'Board', dialog: { eye: 'Board', logTitle: 'Read from the board', log: ['Read the board and its initiatives', 'Counted them by status', 'Changed nothing'], say: (board.name || 'This board') + ' has ' + open + ' open ' + plural(open, 'initiative', 'initiatives') + ': ' + on + ' on track, ' + risk + ' at risk, ' + late + ' late' + (hold ? ', ' + hold + ' on hold' : '') + '.', head: 'Where it stands', facts: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== ''), hold: 'Nothing here changes a board.', pane: { label: 'Board record', file: '', note: 'The board as its records hold it.', rows: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== '') } } }]),
|
|
156
|
+
rows: rows.concat(stageRows.filter((r) => !rows.some((x) => x.key === r.key)), gone.cancelled, gone.archived).concat([{ key: 'board:this-board', id: null, title: board.name || 'This board', sub: 'Board', dialog: { eye: 'Board', logTitle: 'Read from the board', log: ['Read the board and its initiatives', 'Counted them by status', 'Changed nothing'], say: (board.name || 'This board') + ' has ' + open + ' open ' + plural(open, 'initiative', 'initiatives') + ': ' + on + ' on track, ' + risk + ' at risk, ' + late + ' late' + (hold ? ', ' + hold + ' on hold' : '') + '.', head: 'Where it stands', facts: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== ''), hold: 'Nothing here changes a board.', pane: { label: 'Board record', file: '', note: 'The board as its records hold it.', rows: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== '') } } }]),
|
|
131
157
|
};
|
|
132
158
|
last = model;
|
|
133
159
|
return model;
|
|
@@ -139,6 +139,14 @@ function build(f) {
|
|
|
139
139
|
header: { text: 'Real data · as of ' + hhmm(now) + (missing.length ? ' · not read: ' + missing.join(', ') : ''), missing },
|
|
140
140
|
board: { name: board.name || '', id: board.id || null, ws: board.ws || null },
|
|
141
141
|
id, key, title: clip(row.title || id, 160), lane: row.lane || '', anchor: row.anchor || '',
|
|
142
|
+
// the bar's presses (initiative premium-board-actions): the workflow, the lifecycle and the archive entry the row holds
|
|
143
|
+
acts: {
|
|
144
|
+
self: !!board.self, stages: names, stage: row.stage || null,
|
|
145
|
+
life: status === 'on hold' ? 'hold' : status === 'cancelled' ? 'cancelled' : null,
|
|
146
|
+
reason: (status === 'on hold' || status === 'cancelled') && row.stopped ? clip(row.stopped.reason || '', 300) : '',
|
|
147
|
+
back: status === 'on hold' && row.stopped && row.stopped.back ? shortDate(row.stopped.back) : '', backDay: status === 'on hold' && row.stopped && row.stopped.back ? String(row.stopped.back).slice(0, 10) : null,
|
|
148
|
+
archived: row.archived ? { reason: clip(row.archived.reason || '', 300), into: row.archived.into ? (row.archived.intoTitle || row.archived.into) : null } : null,
|
|
149
|
+
},
|
|
142
150
|
head, overview, health, warnings, checks, allSteps, tasks, docs, files, desc, crumbTitle, help,
|
|
143
151
|
boards: f.boards || [], siblings: (f.siblings || []).slice(0, 100),
|
|
144
152
|
dock: { label: head.statusLabel || 'No status', stage: row.stage || '', next: String(overview.h || '').replace(/^Next: /, '') },
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* 200 { ok, state: 'ready', model, as_of } | 202 { ok, state: 'reading' } | 500 { ok: false, state: 'error', error }
|
|
5
5
|
* model is lib/board-premium.js build(), made from the answers of the routes the production Initiatives page reads: /api/boards, /api/boards/board,
|
|
6
6
|
* /backlog, /columns, /sprints and /api/core-docs?level=board. Those routes derive the initiatives in the background and answer 202 while they do, so
|
|
7
|
-
* this route answers 202 too and the page asks again: no request waits for the read. Read-only: the
|
|
8
|
-
* POST /api/core-docs/draft
|
|
7
|
+
* this route answers 202 too and the page asks again: no request waits for the read. Read-only: the page's presses go from the page to the
|
|
8
|
+
* console's own routes (POST /api/core-docs/draft, /api/boards/asks/*, /api/boards/move, /api/lifecycle, /api/boards/archive).
|
|
9
|
+
* initiative premium-board-actions adds the open asks (/api/boards/asks), the on-hold rows and the cancelled and archived rows (/backlog). */
|
|
9
10
|
const BoardPremium = require('./board-premium.js');
|
|
10
11
|
const BoardP = BoardPremium;
|
|
12
|
+
const Rows = require('./initiative-rows.js');
|
|
11
13
|
const boards = require('./routes-boards.js');
|
|
12
14
|
const coreDocs = require('./routes-core-docs.js');
|
|
13
15
|
const Custom = require('./custom-docs.js');
|
|
@@ -65,15 +67,20 @@ module.exports = {
|
|
|
65
67
|
const missing = [];
|
|
66
68
|
// the late and at-risk initiatives first (the board's own `risk` view, late before at risk), then its `now` view, each initiative once
|
|
67
69
|
const listOf = (a, n) => { const seen = new Set(), out = []; const rank = (r) => (r.status === 'late' ? 0 : 1); for (const r of [...((a && a.rows) || [])].sort((x, y) => rank(x) - rank(y))) { if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } } for (const r of (n && n.rows) || []) if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } return out.slice(0, 100); };
|
|
68
|
-
const [risk, now, cols, spr, docs] = await Promise.all([
|
|
70
|
+
const [risk, now, cols, spr, docs, held, can, arc, asks] = await Promise.all([
|
|
69
71
|
via(boards, '/api/boards/backlog' + q + '&view=risk&limit=100', req, ctx),
|
|
70
72
|
via(boards, '/api/boards/backlog' + q + '&view=now&limit=100', req, ctx),
|
|
71
73
|
via(boards, '/api/boards/columns' + q, req, ctx),
|
|
72
74
|
via(boards, '/api/boards/sprints' + q, req, ctx),
|
|
73
75
|
via(coreDocs, '/api/core-docs' + qs({ level: 'board', ws: pick.ws, board: pick.id }), req, ctx),
|
|
76
|
+
via(boards, '/api/boards/backlog' + q + '&view=all&status=' + encodeURIComponent('on hold') + '&limit=100', req, ctx),
|
|
77
|
+
via(boards, '/api/boards/backlog' + q + '&view=all&status=cancelled&limit=100', req, ctx),
|
|
78
|
+
via(boards, '/api/boards/backlog' + q + '&archived=1&limit=100', req, ctx),
|
|
79
|
+
via(boards, '/api/boards/asks' + q, req, ctx),
|
|
74
80
|
]);
|
|
75
81
|
const ok = (r, name) => { if (r.status === 202 || !r.body || r.body.ok === false || r.body.pending) { missing.push(name); return null; } return r.body; };
|
|
76
82
|
const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints'), d = ok(docs, 'core documents');
|
|
83
|
+
const hd = ok(held, 'on-hold initiatives'), cn = ok(can, 'cancelled initiatives'), ar = ok(arc, 'archived initiatives'), ak = ok(asks, 'new asks');
|
|
77
84
|
// the documents the PM added (lib/custom-docs.js): one file read, no route
|
|
78
85
|
let custom = [];
|
|
79
86
|
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; custom = w ? Custom.list(w.root, 'board:' + pick.id) : []; } catch { custom = []; missing.push('added documents'); }
|
|
@@ -81,8 +88,12 @@ module.exports = {
|
|
|
81
88
|
now: Date.now(), pending: false, missing: missing.filter((m) => m !== 'core documents'), boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
|
|
82
89
|
board: head.body.board, counts: head.body.counts, nextRelease: head.body.nextRelease || null,
|
|
83
90
|
rows: listOf(rk, nw), columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] }, docs: d, custom,
|
|
91
|
+
held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
84
92
|
});
|
|
85
|
-
|
|
93
|
+
// a press re-derives the rows in the background; while the answer is stale the page asks again (initiative premium-board-actions)
|
|
94
|
+
let stale = false;
|
|
95
|
+
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; const pk = w ? Rows.peek(w.root) : null; stale = !!(pk && (pk.pending || pk.stale)); } catch { stale = false; }
|
|
96
|
+
ctx.json(res, { ok: true, state: 'ready', model, stale, as_of: Date.now() });
|
|
86
97
|
return true;
|
|
87
98
|
} catch (e) { return fail((e && e.message) || e); }
|
|
88
99
|
},
|
|
@@ -60,7 +60,7 @@ module.exports = {
|
|
|
60
60
|
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; custom = w ? Custom.list(w.root, 'initiative:' + id) : []; } catch { custom = []; missing.push('added documents'); }
|
|
61
61
|
const model = InitPremium.build({
|
|
62
62
|
now: Date.now(), pending: false, missing: missing.filter((m) => m !== 'core documents'),
|
|
63
|
-
board: { ws: own.ws || pick.ws, id: own.id, name: own.name, workflow: own.workflow },
|
|
63
|
+
board: { ws: own.ws || pick.ws, id: own.id, name: own.name, workflow: own.workflow, self: !!own.self },
|
|
64
64
|
row: head.body.row, sheet: sh, items: it ? it.items : [], docs: dd, custom, ladder: lad,
|
|
65
65
|
boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })), siblings: it ? (it.initiatives || []).map((x) => ({ id: x.id, title: x.title })) : [],
|
|
66
66
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.266.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.266.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-board-actions-test.js — the board presses of the premium Board and initiative pages (initiative premium-board-actions; planning/prd/premium-board-actions-prd.md A1 to A12).
|
|
4
|
+
* A real server on a scratch `team` repository (planning/initiatives, pmos/state), never the PMOS checkout. The real pages press the real routes:
|
|
5
|
+
* T triage (accept, decline) · N New initiative · M move and Undo · L hold, resume, cancel, reopen, archive, restore · I the initiative page's bar
|
|
6
|
+
* S the PMOS-self board (a model answer, since only the embedded checkout is self) · P the POST allow-list and the refusals · F floors */
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const { spawn } = require('child_process');
|
|
10
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
11
|
+
const T = require('./test-run').configure({ name: 'premium-board-actions' });
|
|
12
|
+
const { makeRepos, codeRepo, write, git } = require('./plan-test-repos');
|
|
13
|
+
const BP = require('./lib/board-premium.js');
|
|
14
|
+
const F = require('./fixtures/board-premium-facts.js');
|
|
15
|
+
|
|
16
|
+
const BASE = T.BASE;
|
|
17
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
+
const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
19
|
+
const results = [];
|
|
20
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
|
|
21
|
+
const R = makeRepos('premium-board-actions');
|
|
22
|
+
const team = codeRepo(path.join(R.base, 'team'));
|
|
23
|
+
fs.mkdirSync(path.join(team, 'pmos', 'state'), { recursive: true });
|
|
24
|
+
/* a record that declares its id, so the lifecycle route knows it (the synthetic records of plan-test-repos declare none) */
|
|
25
|
+
write(team, 'planning/initiatives/pa-one.md', '---\ntype: Initiative\ntitle: Partner rate limits\ntimestamp: 2026-10-01\nid: pa-one\nlane: chore\nparent_kr: health:tech\nspecimen_test: "description-judgeable — x"\nsurface_check: "greenfield — x"\nstatus: "open — intent: limit partner calls."\n---\n# pa-one\n');
|
|
26
|
+
git(team, ['add', '-A']); git(team, ['commit', '-q', '-m', 'pa-one']);
|
|
27
|
+
let srv = null; let browser = null;
|
|
28
|
+
const finish = async (code) => {
|
|
29
|
+
if (browser) await browser.close().catch(() => {});
|
|
30
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
31
|
+
T.killTmux(); R.cleanup();
|
|
32
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
33
|
+
console.log(`\n${results.length - bad}/${results.length} premium-board-actions assertions passed`);
|
|
34
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
35
|
+
};
|
|
36
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
37
|
+
|
|
38
|
+
/** Every line of a ledger the routes append to, wherever the repository keeps it. */
|
|
39
|
+
const lines = (name) => {
|
|
40
|
+
const out = [];
|
|
41
|
+
const walk = (d) => { for (const e of fs.readdirSync(d, { withFileTypes: true })) { if (e.name === '.git') continue; const p = path.join(d, e.name); if (e.isDirectory()) walk(p); else if (e.name === name) out.push(...fs.readFileSync(p, 'utf8').split('\n').filter(Boolean).map((x) => JSON.parse(x))); } };
|
|
42
|
+
walk(team); if (process.env.PMOS_STATE_DIR && fs.existsSync(process.env.PMOS_STATE_DIR)) walk(process.env.PMOS_STATE_DIR);
|
|
43
|
+
return out;
|
|
44
|
+
};
|
|
45
|
+
/** A press on a choice chip inside the dialog's pane, as a click event on the element (Playwright's pointer check races the dialog's spring). */
|
|
46
|
+
const tap = (pg, sel) => pg.$eval(sel, (b) => b.click());
|
|
47
|
+
const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note)$/;
|
|
48
|
+
|
|
49
|
+
(async () => {
|
|
50
|
+
const exe = findBrowser();
|
|
51
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
52
|
+
let chromium;
|
|
53
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
54
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: team, PMOS_NO_OPEN: '1' }) });
|
|
55
|
+
await T.waitForServer(BASE);
|
|
56
|
+
const ready = await until(async () => { const r = await fetch(BASE + '/api/board-premium'); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' && j.model.initiatives.list.rows.length ? j : null; }, 90000, 400);
|
|
57
|
+
ok('A1 the real route reads the scratch board, with its stages, its new asks and no PMOS-self flag', !!ready && ready.model.board.self === false && ready.model.board.stages.length > 2 && Array.isArray(ready.model.asks.rows) && !ready.model.asks.missing, ready && JSON.stringify(ready.model.board));
|
|
58
|
+
if (!ready) return finish(1);
|
|
59
|
+
const B = ready.model.board, H = await T.pressHeaders(BASE);
|
|
60
|
+
const post = (p, body, h = H) => fetch(BASE + p, { method: 'POST', headers: h, body: JSON.stringify({ ws: B.ws, board: B.id, ...body }) }).then(async (r) => ({ status: r.status, body: await r.json().catch(() => null) }));
|
|
61
|
+
const a1 = await post('/api/boards/asks/add', { line: 'Finance wants a CSV of failed payouts each morning', source: 'Email from Rina' });
|
|
62
|
+
const a2 = await post('/api/boards/asks/add', { line: 'Can the portal get a dark mode', source: 'Support inbox' });
|
|
63
|
+
ok('setup two asks are on the board', a1.status === 200 && a2.status === 200, JSON.stringify([a1, a2]));
|
|
64
|
+
|
|
65
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
66
|
+
const open = async (url, { w = 1280, h = 900 } = {}) => {
|
|
67
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
68
|
+
await ctx.addInitScript(() => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); } catch { /* none */ } });
|
|
69
|
+
const page = await ctx.newPage(), errors = [], posts = [];
|
|
70
|
+
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
71
|
+
page.on('request', (rq) => { if (rq.method() === 'POST') posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); });
|
|
72
|
+
await page.goto(BASE + url);
|
|
73
|
+
return { ctx, page, errors, posts };
|
|
74
|
+
};
|
|
75
|
+
const P = await open('/premium-board.html');
|
|
76
|
+
const p = P.page;
|
|
77
|
+
const listed = (id) => p.evaluate((x) => [...document.querySelectorAll('#ibBody .ini2')].some((b) => b.dataset.key === 'board:' + x), id);
|
|
78
|
+
const toastIs = (re) => until(() => p.evaluate((s) => { const t = document.querySelector('#toast'); return t.classList.contains('on') && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
|
|
79
|
+
const dlgOn = async () => { const v = await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(800); return v; };
|
|
80
|
+
const dlgOff = () => until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
81
|
+
ok('A2 the New asks card lists both asks with Accept and Decline', await until(() => p.evaluate(() => document.querySelectorAll('#cAsks .baa').length === 2 && document.querySelectorAll('#cAsks [data-ask^="acc:"]').length === 2)), await p.evaluate(() => (document.querySelector('#asksHost') || {}).textContent));
|
|
82
|
+
ok('A2 an ask shows its source, not an invented name', await p.evaluate(() => /Email from Rina/.test(document.querySelector('#cAsks').textContent) && !/demo/i.test(document.querySelector('#cAsks').textContent)));
|
|
83
|
+
|
|
84
|
+
/* T triage */
|
|
85
|
+
await p.click(`#cAsks [data-ask="acc:${a1.body.ask.id}"]`); await dlgOn();
|
|
86
|
+
const anc = await until(() => p.evaluate(() => { const s = document.querySelector('#paNA'); return s && s.tagName === 'SELECT' && !s.disabled ? [...s.options].map((o) => o.value) : null; }));
|
|
87
|
+
ok('T1 Accept opens the form with the anchors the board declares', !!anc && anc.includes('health:tech'), JSON.stringify(anc));
|
|
88
|
+
await p.fill('#paNT', ''); await p.click('#paNGo');
|
|
89
|
+
ok('T2 an empty title is refused on the page, before any press', await p.evaluate(() => /Give it a title/.test(document.querySelector('#paNM').textContent)) && !P.posts.some((x) => x.path === '/api/boards/asks/accept'));
|
|
90
|
+
await p.fill('#paNT', 'Daily CSV of failed payouts'); await p.selectOption('#paNA', 'health:tech'); await p.click('#paNGo');
|
|
91
|
+
ok('T3 Accept records the accept line and a new initiative, and says so', !!(await toastIs(/accepted in/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-accept' && l.ask === a1.body.ask.id), JSON.stringify(lines('boards.jsonl').map((l) => l.kind)));
|
|
92
|
+
await dlgOff();
|
|
93
|
+
ok('T4 the accepted ask leaves the card', await until(() => p.evaluate((id) => !document.querySelector(`#cAsks [data-ask="acc:${id}"]`) && document.querySelectorAll('#cAsks .baa').length === 1, a1.body.ask.id)));
|
|
94
|
+
await p.click(`#cAsks [data-ask="dec:${a2.body.ask.id}"]`); await dlgOn();
|
|
95
|
+
ok('T5 Decline waits for a reason', await p.evaluate(() => document.querySelector('#paDGo').disabled));
|
|
96
|
+
await p.fill('#paDW', 'Not tied to a goal this quarter'); await p.click('#paDGo');
|
|
97
|
+
ok('T6 Decline records the reason in the board ledger', !!(await toastIs(/Ask declined/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-decline' && l.why === 'Not tied to a goal this quarter'));
|
|
98
|
+
ok('T7 the card says nothing is left to triage', await until(() => p.evaluate(() => /Nothing new to triage/.test(document.querySelector('#cAsks').textContent))));
|
|
99
|
+
|
|
100
|
+
/* N New initiative */
|
|
101
|
+
ok('N1 New initiative is offered on a team board', await p.evaluate(() => !document.querySelector('#newIni').hidden));
|
|
102
|
+
await p.click('#newIni'); await dlgOn();
|
|
103
|
+
await until(() => p.evaluate(() => { const s = document.querySelector('#paNA'); return s && !s.disabled; }));
|
|
104
|
+
await p.fill('#paNT', 'Partner usage per key'); await p.click('#paNGo');
|
|
105
|
+
ok('N2 an unanchored create is refused on the page', await p.evaluate(() => /Choose an anchor/.test(document.querySelector('#paNM').textContent)));
|
|
106
|
+
await p.selectOption('#paNA', 'health:tech'); await p.click('#paNGo');
|
|
107
|
+
const made = await toastIs(/created in/);
|
|
108
|
+
const recs = fs.readdirSync(path.join(team, 'planning', 'initiatives'));
|
|
109
|
+
ok('N3 Create writes an ask, its accept and a new initiative record, as the console does', !!made && recs.some((f) => /partner-usage/.test(f)) && lines('boards.jsonl').some((l) => l.kind === 'ask' && l.line === 'Partner usage per key'), made + ' / ' + recs.join());
|
|
110
|
+
|
|
111
|
+
/* M move and Undo, from the row's menu */
|
|
112
|
+
await dlgOff();
|
|
113
|
+
await until(() => listed('pa-one'));
|
|
114
|
+
const menuBtn = '#ibBody .inim[data-im="board:pa-one"]';
|
|
115
|
+
await p.click(menuBtn);
|
|
116
|
+
const items = await until(() => p.evaluate(() => { const m = document.querySelector('.bam2'); return m ? [...m.querySelectorAll('[role="menuitem"] b')].map((b) => b.textContent) : null; }));
|
|
117
|
+
ok('M1 the row menu offers the next stage, hold, cancel and archive', !!items && /^Move to /.test(items[0]) && items.includes('Put on hold') && items.includes('Cancel') && items.includes('Archive'), JSON.stringify(items));
|
|
118
|
+
ok('M2 the menu takes the focus and the arrow keys move it; Escape closes it and gives the focus back', await (async () => {
|
|
119
|
+
const f0 = await p.evaluate(() => document.activeElement.closest('.bam2') !== null);
|
|
120
|
+
await p.keyboard.press('ArrowDown'); const f1 = await p.evaluate(() => [...document.querySelectorAll('.bam2 [role="menuitem"]')].indexOf(document.activeElement));
|
|
121
|
+
await p.keyboard.press('Escape'); const gone = await p.evaluate(() => !document.querySelector('.bam2') && document.activeElement.matches('.inim'));
|
|
122
|
+
return f0 && f1 === 1 && gone;
|
|
123
|
+
})());
|
|
124
|
+
const from = ready.model.initiatives.list.rows.find((r) => r.id === 'pa-one').acts.stage;
|
|
125
|
+
await p.click(menuBtn); await p.click('.bam2 [data-pk^="mv:"]');
|
|
126
|
+
const mv = await toastIs(/^Moved to/);
|
|
127
|
+
ok('M3 Move records one move line and says what it recorded', !!mv && lines('boards.jsonl').filter((l) => l.kind === 'move' && l.id === 'pa-one').length === 1, mv);
|
|
128
|
+
await p.click('#paUndo');
|
|
129
|
+
ok('M4 Undo writes the move back', !!(await toastIs(new RegExp('Back in ' + from))) && lines('boards.jsonl').filter((l) => l.kind === 'move' && l.id === 'pa-one').pop().to === from);
|
|
130
|
+
|
|
131
|
+
/* L hold, resume, cancel, reopen, archive, restore */
|
|
132
|
+
await until(() => listed('pa-one'));
|
|
133
|
+
await p.click(menuBtn);
|
|
134
|
+
await p.click('.bam2 [data-pk="hold"]'); await dlgOn();
|
|
135
|
+
await p.fill('#paHR', 'Waiting for the Q1 budget'); await tap(p, '#paHB [data-v="two"]'); await p.click('#paHGo');
|
|
136
|
+
const hl = await until(() => lines('lifecycle.jsonl').find((l) => l.initiative_id === 'pa-one' && l.state === 'on-hold'));
|
|
137
|
+
ok('L1 Put on hold records one on-hold line with the reason and a check-back day', !!hl && hl.reason === 'Waiting for the Q1 budget' && /^\d{4}-\d{2}-\d{2}$/.test(hl.back || ''), JSON.stringify(hl) + ' ' + await p.evaluate(() => (document.querySelector('#paHM') || {}).textContent));
|
|
138
|
+
ok('L2 the row then says On hold and its menu offers Resume', await until(async () => { const t = await p.evaluate(() => { const b = document.querySelector('#ibBody .ini2[data-key="board:pa-one"]'); return b ? b.textContent : ''; }); return /On hold/.test(t); }, 30000));
|
|
139
|
+
await p.click(menuBtn);
|
|
140
|
+
ok('L2 Resume is offered and the moves are not', await until(() => p.evaluate(() => { const m = document.querySelector('.bam2'); return m && !!m.querySelector('[data-pk="resume"]') && !m.querySelector('[data-pk^="mv:"]'); })));
|
|
141
|
+
await p.click('.bam2 [data-pk="resume"]');
|
|
142
|
+
ok('L3 Resume records an active line', await until(() => { const L = lines('lifecycle.jsonl').filter((l) => l.initiative_id === 'pa-one'); return L.length && L[L.length - 1].state === 'active'; }));
|
|
143
|
+
await until(() => p.evaluate(() => { const b = document.querySelector('#ibBody .ini2[data-key="board:pa-one"]'); return b && !/On hold/.test(b.textContent); }), 30000);
|
|
144
|
+
await p.click(menuBtn); await p.click('.bam2 [data-pk="cancel"]'); await dlgOn();
|
|
145
|
+
ok('L4 Cancel waits for a reason', await p.evaluate(() => document.querySelector('#paCGo').disabled));
|
|
146
|
+
await tap(p, '#paCW [data-v="worth"]'); await p.click('#paCGo');
|
|
147
|
+
ok('L4 Cancel records a cancelled line with the reason', await until(() => lines('lifecycle.jsonl').some((l) => l.initiative_id === 'pa-one' && l.state === 'cancelled' && l.reason === 'Not worth it now')));
|
|
148
|
+
ok('L5 the row leaves the list and the fold counts it', await until(() => p.evaluate(() => !document.querySelector('#ibBody .inil .ini2[data-key="board:pa-one"]') && /1 cancelled/.test((document.querySelector('#goneT') || {}).textContent || '')), 30000));
|
|
149
|
+
await p.click('#goneT'); await p.click('#ibBody .inim[data-im="board:pa-one"]');
|
|
150
|
+
ok('L6 a cancelled row offers Reopen only', await until(() => p.evaluate(() => { const m = document.querySelector('.bam2'); return m && [...m.querySelectorAll('[data-pk]')].map((b) => b.dataset.pk).join() === 'reopen'; })));
|
|
151
|
+
await p.click('.bam2 [data-pk="reopen"]');
|
|
152
|
+
ok('L6 Reopen records an active line', await until(() => { const L = lines('lifecycle.jsonl').filter((l) => l.initiative_id === 'pa-one'); return L[L.length - 1].state === 'active'; }));
|
|
153
|
+
await until(() => listed('pa-one'), 30000);
|
|
154
|
+
await p.click(menuBtn); await p.click('.bam2 [data-pk="archive"]'); await dlgOn();
|
|
155
|
+
await tap(p, '#paAW [data-v="dup"]'); await p.fill('#paAN', 'Same as the CSV export'); await p.click('#paAGo');
|
|
156
|
+
ok('L7 Archive records one archive line with the reason', await until(() => lines('boards.jsonl').some((l) => l.kind === 'ini-archive' && l.id === 'pa-one' && l.archived === true && l.reason === 'Duplicate: Same as the CSV export')));
|
|
157
|
+
ok('L8 the fold counts it as archived', await until(() => p.evaluate(() => /1 archived/.test((document.querySelector('#goneT') || {}).textContent || '')), 30000));
|
|
158
|
+
await p.click('#paUndo');
|
|
159
|
+
ok('L9 Undo restores it with a restore line', await until(() => lines('boards.jsonl').some((l) => l.kind === 'ini-archive' && l.id === 'pa-one' && l.archived === false)));
|
|
160
|
+
|
|
161
|
+
/* I the initiative page's bar */
|
|
162
|
+
const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
|
|
163
|
+
const ip = I.page;
|
|
164
|
+
const bar = await until(() => ip.evaluate(() => { const b = document.querySelector('#iBar'); return b && b.querySelector('[data-pk^="mv:"]') ? [...b.querySelectorAll('button')].map((x) => x.textContent.trim()) : null; }), 60000);
|
|
165
|
+
ok('I1 the bar offers the next stage and More', !!bar && bar.some((t) => /^Move to /.test(t)) && bar.includes('More'), JSON.stringify(bar));
|
|
166
|
+
const n0 = lines('boards.jsonl').filter((l) => l.kind === 'move').length;
|
|
167
|
+
await ip.click('#iBar [data-pk^="mv:"]');
|
|
168
|
+
ok('I2 a press on the bar records one move line', await until(() => lines('boards.jsonl').filter((l) => l.kind === 'move').length === n0 + 1));
|
|
169
|
+
await ip.click('#iBar [data-im="bar"]');
|
|
170
|
+
ok('I3 More lists the lifecycle presses and no move', await until(() => ip.evaluate(() => { const m = document.querySelector('.bam2'); return m && [...m.querySelectorAll('[data-pk]')].map((b) => b.dataset.pk).join() === 'hold,cancel,archive'; })));
|
|
171
|
+
await ip.keyboard.press('Escape');
|
|
172
|
+
await ip.click('#paUndo').catch(() => {});
|
|
173
|
+
|
|
174
|
+
/* S the PMOS-self board: the model says self, the page offers no move and no New initiative */
|
|
175
|
+
{
|
|
176
|
+
const m = BP.build(F.facts({ board: Object.assign({}, F.facts().board, { self: true }), asks: [] }));
|
|
177
|
+
const S = await open('/premium-board.html');
|
|
178
|
+
await S.page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: m, as_of: Date.now() }) }));
|
|
179
|
+
await S.page.reload();
|
|
180
|
+
await until(() => S.page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0));
|
|
181
|
+
ok('S1 the PMOS-self board names the router in its asks card and hides New initiative', await S.page.evaluate(() => /pmos-router/.test(document.querySelector('#cAsks').textContent) && document.querySelector('#newIni').hidden));
|
|
182
|
+
await S.page.click('#ibBody .inim');
|
|
183
|
+
ok('S2 its row menu has no move', await until(() => S.page.evaluate(() => { const x = document.querySelector('.bam2'); return x && !x.querySelector('[data-pk^="mv:"]') && !!x.querySelector('[data-pk="hold"]'); })));
|
|
184
|
+
await S.ctx.close();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* P the POST allow-list and the refusals */
|
|
188
|
+
const all = P.posts.concat(I.posts);
|
|
189
|
+
const other = all.filter((x) => !ALLOWED.test(x.path));
|
|
190
|
+
ok('P1 the pages post only to the asks, move, lifecycle and archive routes', all.length > 10 && !other.length, JSON.stringify(other));
|
|
191
|
+
const noNonce = await post('/api/boards/move', { id: 'fx-bare', to: ready.model.board.stages[1] }, { 'Content-Type': 'application/json', Origin: BASE });
|
|
192
|
+
const lifeNo = await post('/api/lifecycle', { initiative_id: 'fx-bare', state: 'on-hold' }, { 'Content-Type': 'application/json', Origin: BASE });
|
|
193
|
+
ok('P2 a press without the launch nonce is refused', noNonce.status === 403 && lifeNo.status === 403, JSON.stringify([noNonce.status, lifeNo.status]));
|
|
194
|
+
ok('P3 no script error on either page', !P.errors.length && !I.errors.length, P.errors.concat(I.errors).join(' | '));
|
|
195
|
+
|
|
196
|
+
/* F floors */
|
|
197
|
+
{
|
|
198
|
+
const S = await open('/premium-board.html', { w: 390, h: 844 });
|
|
199
|
+
await until(() => S.page.evaluate(() => document.querySelectorAll('#ibBody .inim').length > 0), 30000);
|
|
200
|
+
const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#ibBody .inim, #cAsks button, #newIni')].filter((b) => b.offsetParent && (b.getBoundingClientRect().width < 44 || b.getBoundingClientRect().height < 44)).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height)) }));
|
|
201
|
+
ok('F1 at 390 px there is no sideways scroll and every new control is at least 44 px', !f.wide && !f.small.length, JSON.stringify(f));
|
|
202
|
+
await S.page.click('#ibBody .inim');
|
|
203
|
+
const mi = await until(() => S.page.evaluate(() => { const L = [...document.querySelectorAll('.bam2 [role="menuitem"]')]; return L.length ? L.every((b) => b.getBoundingClientRect().height >= 44) && document.documentElement.scrollWidth <= innerWidth + 1 : null; }));
|
|
204
|
+
ok('F2 the menu items are 44 px tall and the open menu adds no sideways scroll', !!mi);
|
|
205
|
+
await S.ctx.close();
|
|
206
|
+
}
|
|
207
|
+
await P.ctx.close(); await I.ctx.close();
|
|
208
|
+
finish();
|
|
209
|
+
})();
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/* pm/premium-acts.js — the board presses of the premium Board and initiative pages (initiative premium-board-actions).
|
|
2
|
+
*
|
|
3
|
+
* Every press is a route the console already uses, behind the launch nonce:
|
|
4
|
+
* triage POST /api/boards/asks/accept { board, ask, title, lane, anchor } · /asks/decline { board, ask, why }
|
|
5
|
+
* new POST /api/boards/asks/add { board, line, source } then /asks/accept, as the console's New initiative does
|
|
6
|
+
* move POST /api/boards/move { board, id, to }; its warnings never block
|
|
7
|
+
* hold, cancel POST /api/lifecycle { initiative_id, state: on-hold | cancelled | active, reason, back? }
|
|
8
|
+
* archive POST /api/boards/archive { board, id, archived, reason? }
|
|
9
|
+
* Each result has Undo, which writes the opposite line through the same route. The anchors of a new initiative are read from
|
|
10
|
+
* GET /api/boards/anchors. Nothing here reads or writes anything else.
|
|
11
|
+
*
|
|
12
|
+
* C, the page's context: { ws, board, boardName, self, first, reload }. A row: { id, title, acts } with acts from lib/board-premium.js actsOf
|
|
13
|
+
* (or lib/initiative-premium.js): { stages, stage, life: hold | cancelled | null, reason, back, backDay, archived: { reason, into } | null }. */
|
|
14
|
+
import { pmPost, pmGet } from './http.js';
|
|
15
|
+
import { $, $$, esc, openDlg, closeDlg, toast, turnA, ptx } from './premium-shell.js';
|
|
16
|
+
|
|
17
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
18
|
+
const CHK = '<path d="M5 12.5l4.5 4.5L19 7.5"/>';
|
|
19
|
+
const SHD = '<path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"/>';
|
|
20
|
+
const DOTS = '<circle cx="5" cy="12" r="1.4"/><circle cx="12" cy="12" r="1.4"/><circle cx="19" cy="12" r="1.4"/>';
|
|
21
|
+
export const LANES = [['feature', 'Feature', 'PRD and rubric'], ['discovery', 'Discovery', 'Spike brief'], ['chore', 'Chore', 'One-paragraph intent'], ['incident', 'Incident', 'Post-hoc record'], ['content', 'Content', 'Content brief'], ['prototype', 'Prototype', 'Quick brief, grilled as dialogue']];
|
|
22
|
+
const BACK = [['two', 'In 2 weeks', 14], ['month', 'In a month', 30], ['quarter', 'Next quarter', 80], ['none', 'No date', null]];
|
|
23
|
+
const WHY = [['needed', 'No longer needed'], ['replaced', 'Replaced by another initiative'], ['worth', 'Not worth it now'], ['kill', 'Hit a kill condition'], ['other', 'Other']];
|
|
24
|
+
const AWHY = [['unrelated', 'Not related to this board'], ['stale', 'Old idea, never started'], ['dup', 'Duplicate'], ['other', 'Other']];
|
|
25
|
+
const errOf = (r, d) => (r && r.error) || d;
|
|
26
|
+
const dayIso = (n) => { const t = new Date(Date.now() + n * 86400000); return t.getFullYear() + '-' + String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0'); };
|
|
27
|
+
|
|
28
|
+
/* ── the writes ── */
|
|
29
|
+
const post = (C, path, body) => pmPost(path, { ws: C.ws, ...body });
|
|
30
|
+
const life = (C, id, state, reason, back) => post(C, '/api/lifecycle', { initiative_id: id, state, reason: reason || '', ...(back ? { back } : {}) });
|
|
31
|
+
const arch = (C, id, archived, reason) => post(C, '/api/boards/archive', { board: C.board, id, archived, ...(reason ? { reason } : {}) });
|
|
32
|
+
const move = (C, id, to) => post(C, '/api/boards/move', { board: C.board, id, to });
|
|
33
|
+
|
|
34
|
+
/* ── the result line with Undo, in the page's own toast ── */
|
|
35
|
+
let undoT = null;
|
|
36
|
+
export function undoToast(msg, undo) {
|
|
37
|
+
const t = $('#toast'); clearTimeout(undoT);
|
|
38
|
+
t.innerHTML = `<span>${esc(msg)}</span>${undo ? '<button type="button" class="undo" id="paUndo">Undo</button>' : ''}`;
|
|
39
|
+
t.classList.add('on');
|
|
40
|
+
if (undo) $('#paUndo').onclick = async () => { const b = $('#paUndo'); b.disabled = true; await undo(); };
|
|
41
|
+
undoT = setTimeout(() => t.classList.remove('on'), undo ? 9000 : 4200);
|
|
42
|
+
}
|
|
43
|
+
async function done(C, r, msg, undo) {
|
|
44
|
+
if (!r || r.ok !== true) { toast(errOf(r, 'Nothing was recorded. The server did not say why.')); return false; }
|
|
45
|
+
undoToast(msg, undo); await C.reload(); return true;
|
|
46
|
+
}
|
|
47
|
+
const prevOf = (r) => ({ life: r.acts.life, reason: r.acts.reason, backDay: r.acts.backDay || null, archived: !!r.acts.archived });
|
|
48
|
+
/** Write the state `p` the row had before a lifecycle press, through the lifecycle route. */
|
|
49
|
+
const lifeBack = (C, r, p) => (p.life === 'hold' ? life(C, r.id, 'on-hold', p.reason, p.backDay) : p.life === 'cancelled' ? life(C, r.id, 'cancelled', p.reason) : life(C, r.id, 'active', 'undo'));
|
|
50
|
+
|
|
51
|
+
/* ── what a row can do ── */
|
|
52
|
+
export function items(C, r) {
|
|
53
|
+
const a = r.acts, cur = a.stages.indexOf(a.stage), out = [];
|
|
54
|
+
if (a.archived) return [['restore', 'Restore', 'Back in the lists, as it was']];
|
|
55
|
+
if (a.life === 'cancelled') return [['reopen', 'Reopen', 'Back to ' + (a.stage || 'its stage') + ', active again']];
|
|
56
|
+
if (!C.self && !a.life && cur >= 0) {
|
|
57
|
+
if (a.stages[cur + 1]) out.push(['mv:' + (cur + 1), 'Move to ' + a.stages[cur + 1], 'The next stage of its workflow']);
|
|
58
|
+
if (cur > 0) out.push(['mv:' + (cur - 1), 'Back to ' + a.stages[cur - 1], 'The stage before']);
|
|
59
|
+
}
|
|
60
|
+
if (a.life === 'hold') out.push(['resume', 'Resume', 'Back to ' + (a.stage || 'its stage') + ', active again']);
|
|
61
|
+
else out.push(['hold', 'Put on hold', 'Pause it; keeps its stage and work']);
|
|
62
|
+
out.push(['cancel', 'Cancel', 'Stop it for good, with a reason'], ['archive', 'Archive', 'Out of every list; restore any time']);
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function run(C, r, k) {
|
|
67
|
+
const a = r.acts, p = prevOf(r);
|
|
68
|
+
if (k.startsWith('mv:')) {
|
|
69
|
+
const to = a.stages[+k.slice(3)], from = a.stage; if (!to) return;
|
|
70
|
+
const res = await move(C, r.id, to);
|
|
71
|
+
const w = res && res.ok && Array.isArray(res.warnings) && res.warnings.length ? ' Warning: ' + res.warnings.join('; ') + '. Warnings never block.' : '';
|
|
72
|
+
await done(C, res, 'Moved to ' + to + '. Recorded as a move line in the board ledger.' + w, async () => done(C, await move(C, r.id, from), 'Back in ' + from + '. Recorded as a move line.'));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (k === 'hold') return openHold(C, r);
|
|
76
|
+
if (k === 'cancel') return openCancel(C, r);
|
|
77
|
+
if (k === 'archive') return openArchive(C, r);
|
|
78
|
+
if (k === 'resume' || k === 'reopen') {
|
|
79
|
+
await done(C, await life(C, r.id, 'active', k === 'resume' ? 'resumed' : 'reopened'), r.title + ' is active again, in ' + (a.stage || 'its stage') + '. Recorded as a lifecycle line.', async () => done(C, await lifeBack(C, r, p), 'Undone. Recorded as a lifecycle line.'));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (k === 'restore') await done(C, await arch(C, r.id, false), r.title + ' is restored. Recorded in the board ledger.', async () => done(C, await arch(C, r.id, true, a.archived.reason), r.title + ' is archived again.'));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ── the row's menu ── */
|
|
86
|
+
let menu = null;
|
|
87
|
+
export const dotsBtn = (r) => `<button type="button" class="inim" data-im="${esc(r.key)}" aria-haspopup="menu" aria-expanded="false" aria-label="Actions for ${esc(r.title)}">${ICO(DOTS)}</button>`;
|
|
88
|
+
/** The key of the row whose menu is open, so a page that redraws can open it again on the new button. */
|
|
89
|
+
export const menuKey = () => (menu ? menu.btn.dataset.im : null);
|
|
90
|
+
export function closeMenu(back) {
|
|
91
|
+
if (!menu) return; const { m, btn } = menu; m.remove(); btn.setAttribute('aria-expanded', 'false'); menu = null; if (back) btn.focus();
|
|
92
|
+
}
|
|
93
|
+
export function openMenu(btn, C, r) {
|
|
94
|
+
if (menu && menu.btn === btn) { closeMenu(true); return; }
|
|
95
|
+
closeMenu();
|
|
96
|
+
const m = document.createElement('div'); m.className = 'dsmn bam2'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'Actions for ' + r.title);
|
|
97
|
+
m.innerHTML = items(C, r).map(([k, l, s]) => `<button type="button" role="menuitem" data-pk="${esc(k)}"><span><b>${esc(l)}</b><small>${esc(s)}</small></span></button>`).join('');
|
|
98
|
+
btn.parentElement.appendChild(m); btn.setAttribute('aria-expanded', 'true'); menu = { m, btn, C, r };
|
|
99
|
+
// a card clips what leaves it: near the card's foot the menu opens upward
|
|
100
|
+
const card = btn.closest('.card'); if (card && m.getBoundingClientRect().bottom > card.getBoundingClientRect().bottom - 8) m.classList.add('up');
|
|
101
|
+
const f = $('button', m); if (f) f.focus();
|
|
102
|
+
}
|
|
103
|
+
document.addEventListener('keydown', (e) => {
|
|
104
|
+
if (!menu) return;
|
|
105
|
+
if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closeMenu(true); return; }
|
|
106
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); const L = $$('button', menu.m), k = L.indexOf(document.activeElement); L[(k + (e.key === 'ArrowDown' ? 1 : L.length - 1)) % L.length].focus(); }
|
|
107
|
+
if (e.key === 'Tab') closeMenu();
|
|
108
|
+
}, true);
|
|
109
|
+
document.addEventListener('click', (e) => {
|
|
110
|
+
if (!menu) return;
|
|
111
|
+
const it = e.target.closest('.bam2 [data-pk]');
|
|
112
|
+
if (it) { const { C, r } = menu; closeMenu(); run(C, r, it.dataset.pk); return; }
|
|
113
|
+
if (!e.target.closest('.bam2') && !e.target.closest('[data-im]')) closeMenu();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/* ── the initiative page's bar ── */
|
|
117
|
+
export function barHtml(C, r) {
|
|
118
|
+
const a = r.acts, cur = a.stages.indexOf(a.stage), nx = a.stages[cur + 1], pv = cur > 0 ? a.stages[cur - 1] : null;
|
|
119
|
+
if (a.archived) return `<div class="lifeb"><div><b>Archived</b><span>${esc(a.archived.into ? 'Merged into ' + a.archived.into : a.archived.reason || 'No reason was given')}. It is out of every list and count of the board. Nothing is deleted.</span></div><button type="button" class="dmcta alt" data-pk="restore">Restore</button></div>`;
|
|
120
|
+
if (a.life === 'cancelled') return `<div class="lifeb"><div><b>Cancelled</b><span>${a.reason ? esc(a.reason) + '. ' : ''}It keeps its stage, work and history.</span></div><button type="button" class="dmcta alt" data-pk="reopen">Reopen</button></div>`;
|
|
121
|
+
if (a.life === 'hold') return `<div class="lifeb"><div><b>On hold${a.back ? ' · check back ' + esc(a.back) : ''}</b><span>${a.reason ? esc(a.reason) + '. ' : ''}It keeps ${esc(a.stage || 'its stage')}, its work and its history.</span></div><span class="baact"><button type="button" class="dmcta alt" data-pk="resume">Resume</button><button type="button" class="dlink" data-pk="cancel">Cancel</button></span></div>`;
|
|
122
|
+
const mv = C.self || cur < 0 ? `<span class="note">${C.self ? 'The stage comes from the repository. It moves when the files land.' : 'Its stage is not one of its workflow\'s stages, so it cannot move from here.'}</span>`
|
|
123
|
+
: `${pv ? `<button type="button" class="dmcta alt" data-pk="mv:${cur - 1}">${ICO('<path d="M15 6l-6 6 6 6"/>')}Back to ${esc(pv)}</button>` : ''}${nx ? `<button type="button" class="dmcta alt" data-pk="mv:${cur + 1}">Move to ${esc(nx)}${ICO('<path d="M9 6l6 6-6 6"/>')}</button>` : ''}`;
|
|
124
|
+
return `<div class="baiact">${mv}<span class="iamw">${dotsBtn({ key: 'bar', title: r.title }).replace('class="inim"', 'class="dmcta alt inmore"').replace(ICO(DOTS), 'More' + ICO('<path d="m6 9 6 6 6-6"/>'))}</span></div>`;
|
|
125
|
+
}
|
|
126
|
+
/** The bar's presses: a stage move or a lifecycle press runs at once, More opens the menu without the moves. */
|
|
127
|
+
export function onBar(e, C, r) {
|
|
128
|
+
if (e.target.closest('.bam2')) return false; // a menu item: the document's listener runs it
|
|
129
|
+
const m = e.target.closest('[data-im="bar"]');
|
|
130
|
+
if (m) { openMenu(m, C, { ...r, acts: { ...r.acts, stages: [] } }); return true; }
|
|
131
|
+
const b = e.target.closest('.baiact [data-pk], .lifeb [data-pk]');
|
|
132
|
+
if (!b || b.disabled) return false;
|
|
133
|
+
b.disabled = true; run(C, r, b.dataset.pk).finally(() => { b.disabled = false; });
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* ── the dialogs: one form in the standard dialog's pane, the conversation box hidden, as Add a document does ── */
|
|
138
|
+
const happens = (L) => `<div class="bahp"><p class="label">What happens</p><ul>${L.map((t) => `<li>${ICO(CHK)}<span>${esc(t)}</span></li>`).join('')}</ul></div>`;
|
|
139
|
+
const rec = (t) => `<p class="note barec">${ICO(SHD)}<span>${esc(t)}</span></p>`;
|
|
140
|
+
const pills = (id, L, cur, lab) => `<div class="chq bapl" id="${id}" role="radiogroup" aria-label="${esc(lab)}">${L.map(([v, l]) => `<button type="button" role="radio" data-v="${v}" aria-checked="${v === cur}" aria-pressed="${v === cur}">${esc(l)}</button>`).join('')}</div>`;
|
|
141
|
+
const pick = (e, id) => { const p = e.target.closest('#' + id + ' [data-v]'); if (!p) return null; $$('#' + id + ' [data-v]').forEach((q) => { q.setAttribute('aria-pressed', q === p); q.setAttribute('aria-checked', q === p); }); return p.dataset.v; };
|
|
142
|
+
const msgP = (id) => `<p class="note" id="${id}" role="status"></p>`;
|
|
143
|
+
function form(o) {
|
|
144
|
+
openDlg({ eye: o.eye, title: o.title, sub: o.sub, say: o.say, stream: turnA(ptx(o.say)), noteKey: null, pane: `<article class="paper doc"><div class="addf">${o.body}</div></article>`, label: o.label || 'Detail' });
|
|
145
|
+
$('#askF').hidden = true; $('#askNote').hidden = true;
|
|
146
|
+
}
|
|
147
|
+
async function press(go, m, fn) {
|
|
148
|
+
go.disabled = true; m.textContent = '';
|
|
149
|
+
const r = await fn();
|
|
150
|
+
if (r && r.ok === true) return r;
|
|
151
|
+
go.disabled = false; m.textContent = errOf(r, 'Nothing was recorded. The server did not say why.'); return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function openHold(C, r) {
|
|
155
|
+
let back = 'month';
|
|
156
|
+
form({ eye: 'Put on hold', title: 'Put on hold', sub: r.title, say: 'Say why it is paused, and when to look at it again.', body: `
|
|
157
|
+
<label><span>Why is it paused <em>optional</em></span><textarea id="paHR" rows="2" maxlength="500" placeholder="For example: waiting for the Q1 budget decision"></textarea></label>
|
|
158
|
+
<div><span class="label">Check back</span>${pills('paHB', BACK.map((q) => [q[0], q[1]]), back, 'Check back')}</div>
|
|
159
|
+
${happens(['Keeps its stage' + (r.acts.stage ? ' (' + r.acts.stage + ')' : '') + ', its work and its history.', 'Shows as On hold and leaves the on-track and need-a-look counts.', 'The check-back day shows on its page.'])}
|
|
160
|
+
${rec('Recorded: one on-hold line in lifecycle.jsonl, with your reason and the check-back day. Undo writes the state it had before.')}
|
|
161
|
+
${msgP('paHM')}<div class="cact"><button type="button" class="cta" id="paHGo">Put on hold</button><button type="button" class="cta alt" id="paHNo">Not now</button></div>` });
|
|
162
|
+
$('#oMain').onclick = async (e) => {
|
|
163
|
+
const v = pick(e, 'paHB'); if (v) { back = v; return; }
|
|
164
|
+
if (e.target.closest('#paHNo')) { closeDlg(); return; }
|
|
165
|
+
if (!e.target.closest('#paHGo')) return;
|
|
166
|
+
const bk = BACK.find((q) => q[0] === back), day = bk[2] != null ? dayIso(bk[2]) : null, why = $('#paHR').value.trim(), p = prevOf(r);
|
|
167
|
+
const res = await press($('#paHGo'), $('#paHM'), () => life(C, r.id, 'on-hold', why, day)); if (!res) return;
|
|
168
|
+
closeDlg(); await done(C, res, r.title + ' is on hold. Recorded as a lifecycle line.', async () => done(C, await lifeBack(C, r, p), r.title + ' is back as it was.'));
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function openCancel(C, r) {
|
|
172
|
+
let why = '';
|
|
173
|
+
form({ eye: 'Cancel', title: 'Cancel the initiative', sub: r.title, say: 'Pick a reason. Cancel needs one before it can record.', body: `
|
|
174
|
+
<div><span class="label">Why</span>${pills('paCW', WHY, '', 'Why')}</div>
|
|
175
|
+
<label><span>Note <em>optional</em></span><textarea id="paCN" rows="2" maxlength="400" placeholder="What did we learn, and who was told"></textarea></label>
|
|
176
|
+
${happens(['Shows as Cancelled. The counts treat it as cancelled, not done.', 'It leaves the lists. Show them, under the list, brings it back into view.', 'Keeps its stage, its work and its history. Reopen it any time.'])}
|
|
177
|
+
${rec('Recorded: one cancelled line in lifecycle.jsonl, with the reason. Undo writes the state it had before.')}
|
|
178
|
+
<p class="note" id="paCM" role="status">Pick a reason to cancel.</p><div class="cact"><button type="button" class="cta" id="paCGo" disabled>Cancel initiative</button><button type="button" class="cta alt" id="paCNo">Not now</button></div>` });
|
|
179
|
+
$('#oMain').onclick = async (e) => {
|
|
180
|
+
const v = pick(e, 'paCW'); if (v) { why = v; $('#paCGo').disabled = false; $('#paCM').textContent = ''; return; }
|
|
181
|
+
if (e.target.closest('#paCNo')) { closeDlg(); return; }
|
|
182
|
+
if (!e.target.closest('#paCGo')) return;
|
|
183
|
+
if (!why) { $('#paCM').textContent = 'Pick a reason to cancel.'; return; }
|
|
184
|
+
const n = $('#paCN').value.trim(), reason = WHY.find((q) => q[0] === why)[1] + (n ? ': ' + n : ''), p = prevOf(r);
|
|
185
|
+
const res = await press($('#paCGo'), $('#paCM'), () => life(C, r.id, 'cancelled', reason)); if (!res) return;
|
|
186
|
+
closeDlg(); await done(C, res, r.title + ' is cancelled. Recorded as a lifecycle line.', async () => done(C, await lifeBack(C, r, p), r.title + ' is back as it was.'));
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function openArchive(C, r) {
|
|
190
|
+
let why = 'unrelated';
|
|
191
|
+
form({ eye: 'Archive', title: 'Archive the initiative', sub: r.title, say: 'Archive takes it out of the board. It is not a status, and nothing is deleted.', body: `
|
|
192
|
+
<div><span class="label">Why</span>${pills('paAW', AWHY, why, 'Why')}</div>
|
|
193
|
+
<label><span>Note <em>optional</em></span><textarea id="paAN" rows="2" maxlength="200" placeholder="Anything you want to remember about it"></textarea></label>
|
|
194
|
+
${happens(['It leaves every list, count and timeline of the board.', 'Nothing is deleted. The record, its work and its history stay in the repository.', 'Restore it any time, as it was.'])}
|
|
195
|
+
${rec('Recorded: one archive line in the board ledger (boards.jsonl), with the reason. Undo and Restore write a restore line.')}
|
|
196
|
+
${msgP('paAM')}<div class="cact"><button type="button" class="cta" id="paAGo">Archive</button><button type="button" class="cta alt" id="paANo">Not now</button></div>` });
|
|
197
|
+
$('#oMain').onclick = async (e) => {
|
|
198
|
+
const v = pick(e, 'paAW'); if (v) { why = v; return; }
|
|
199
|
+
if (e.target.closest('#paANo')) { closeDlg(); return; }
|
|
200
|
+
if (!e.target.closest('#paAGo')) return;
|
|
201
|
+
const n = $('#paAN').value.trim().replace(/\s+/g, ' '), reason = AWHY.find((q) => q[0] === why)[1] + (n ? ': ' + n : '');
|
|
202
|
+
const res = await press($('#paAGo'), $('#paAM'), () => arch(C, r.id, true, reason)); if (!res) return;
|
|
203
|
+
closeDlg(); await done(C, res, r.title + ' is archived. Recorded in the board ledger.', async () => done(C, await arch(C, r.id, false), r.title + ' is restored.'));
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* ── new asks and New initiative ── */
|
|
208
|
+
export function asksHtml(C, A) {
|
|
209
|
+
const ic = ICO('<path d="M4 4h16v12H8l-4 4z"/>');
|
|
210
|
+
if (C.self) return `<section class="card baask" id="cAsks" aria-labelledby="hAsks"><div class="ch"><span class="ic">${ic}</span><h2 id="hAsks">New asks</h2><small>none</small></div><p class="note">PMOS-self has no ask source. New work starts at the pmos-router skill.</p></section>`;
|
|
211
|
+
const L = A.rows;
|
|
212
|
+
const body = A.missing ? '<p class="note">The new asks could not be read, so none is shown.</p>' : L.length ? `<div class="bal" role="list">${L.map((a) => `<div class="baa" role="listitem"><p class="baq">“${esc(a.line)}”</p><small class="bam">${esc([a.source || 'Typed in the console', a.by, a.at].filter(Boolean).join(' · '))}</small><div class="bad2">${a.draft.lane ? `<span>${esc(LANES.find((l) => l[0] === a.draft.lane)[1])}</span>` : ''}<span>${a.draft.anchor ? 'Anchor: ' + esc(a.draft.anchor) : 'No anchor suggested'}</span></div><div class="baact"><button type="button" class="dmcta" data-ask="acc:${esc(a.id)}">Accept</button><button type="button" class="dmcta alt" data-ask="dec:${esc(a.id)}">Decline</button></div></div>`).join('')}</div>` : '<p class="note">Nothing new to triage on this board.</p>';
|
|
213
|
+
return `<section class="card baask" id="cAsks" aria-labelledby="hAsks"><div class="ch"><span class="ic">${ic}</span><h2 id="hAsks">New asks</h2><small>${A.missing ? 'not read' : L.length + ' to triage'}</small></div>${body}
|
|
214
|
+
<p class="note">Accept starts an initiative in ${esc(C.first || 'the first stage')}. Decline records why. The title, lane and anchor come from the intake draft, and you can change them.</p></section>`;
|
|
215
|
+
}
|
|
216
|
+
export function onAsks(e, C, A) {
|
|
217
|
+
const b = e.target.closest('[data-ask]'); if (!b) return false;
|
|
218
|
+
const [k, id] = [b.dataset.ask.slice(0, 3), b.dataset.ask.slice(4)], a = A.rows.find((x) => x.id === id); if (!a) return true;
|
|
219
|
+
if (k === 'acc') openIniForm(C, a); else openDecline(C, a);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let anchors = null;
|
|
224
|
+
async function anchorsOf(C) {
|
|
225
|
+
if (anchors && anchors.key === C.ws + '/' + C.board) return anchors;
|
|
226
|
+
const r = await pmGet('/api/boards/anchors?ws=' + encodeURIComponent(C.ws || '') + '&board=' + encodeURIComponent(C.board || ''));
|
|
227
|
+
anchors = { key: C.ws + '/' + C.board, list: r && r.ok && Array.isArray(r.anchors) ? r.anchors : null };
|
|
228
|
+
return anchors;
|
|
229
|
+
}
|
|
230
|
+
/** The form of New initiative (a = null) and of Accept (a = the ask): title, lane and anchor, from the intake draft when there is one. */
|
|
231
|
+
export async function openIniForm(C, a) {
|
|
232
|
+
const d = a ? a.draft : { title: '', lane: 'feature', anchor: '' };
|
|
233
|
+
const lane0 = d.lane || 'feature';
|
|
234
|
+
form({ eye: a ? 'Accept an ask' : 'New initiative', title: a ? 'Accept ask' : 'New initiative', sub: C.boardName, label: 'Initiative',
|
|
235
|
+
say: a ? 'The intake draft gives the title, lane and anchor. Change any of them, then accept.' : 'Give it a title, a lane and an anchor. It lands in ' + (C.first || 'the first stage') + '.',
|
|
236
|
+
body: `${a ? `<p class="baq">“${esc(a.line)}”</p>` : ''}
|
|
237
|
+
<label>Title<input id="paNT" maxlength="120" value="${esc(d.title)}" placeholder="For example: Per-key API usage for partners"></label>
|
|
238
|
+
<div class="two"><label>Lane<select id="paNL">${LANES.map((l) => `<option value="${l[0]}"${l[0] === lane0 ? ' selected' : ''}>${l[1]}: ${l[2]}</option>`).join('')}</select></label>
|
|
239
|
+
<label id="paNAw">Anchor<select id="paNA" disabled><option>Reading the anchors</option></select></label></div>
|
|
240
|
+
<p class="note" id="paNAh">Every initiative anchors to a KR or a declared health budget. Unanchored work is rejected.</p>
|
|
241
|
+
${rec(a ? 'Recorded: an accept line for the ask in the board ledger, and a new initiative record with the title, lane and anchor.' : 'Recorded: the title as an ask in the board ledger, its accept line, and a new initiative record with the title, lane and anchor, as the console\'s New initiative does.')}
|
|
242
|
+
${msgP('paNM')}<div class="cact"><button type="button" class="cta" id="paNGo">${a ? 'Accept into ' : 'Create in '}${esc(C.first || 'the first stage')}</button><button type="button" class="cta alt" id="paNNo">Cancel</button></div>` });
|
|
243
|
+
const A = await anchorsOf(C);
|
|
244
|
+
if (!$('#paNA')) return;
|
|
245
|
+
if (A.list && A.list.length) {
|
|
246
|
+
const has = A.list.some((x) => x.value === d.anchor);
|
|
247
|
+
$('#paNA').outerHTML = `<select id="paNA"><option value="">Choose a KR or a health budget</option>${d.anchor && !has ? `<option value="${esc(d.anchor)}" selected>Suggested: ${esc(d.anchor)}</option>` : ''}${A.list.map((x) => `<option value="${esc(x.value)}"${x.value === d.anchor ? ' selected' : ''}>${esc(x.label || x.value)}</option>`).join('')}</select>`;
|
|
248
|
+
} else {
|
|
249
|
+
$('#paNA').outerHTML = `<input id="paNA" maxlength="120" value="${esc(d.anchor)}" placeholder="For example: health:tech">`;
|
|
250
|
+
$('#paNAh').textContent = 'The declared anchors could not be read, so type one: a KR id or health:<budget>. Unanchored work is rejected.';
|
|
251
|
+
}
|
|
252
|
+
$('#oMain').onclick = async (e) => {
|
|
253
|
+
if (e.target.closest('#paNNo')) { closeDlg(); return; }
|
|
254
|
+
if (!e.target.closest('#paNGo')) return;
|
|
255
|
+
const title = $('#paNT').value.trim(), lane = $('#paNL').value, anchor = $('#paNA').value.trim(), m = $('#paNM');
|
|
256
|
+
if (!title) { m.textContent = 'Give it a title.'; $('#paNT').focus(); return; }
|
|
257
|
+
if (!anchor) { m.textContent = 'Choose an anchor. Unanchored work is rejected.'; $('#paNA').focus(); return; }
|
|
258
|
+
const res = await press($('#paNGo'), m, async () => {
|
|
259
|
+
let ask = a ? a.id : null;
|
|
260
|
+
if (!ask) { const r0 = await post(C, '/api/boards/asks/add', { board: C.board, line: title, source: 'New initiative, typed by you' }); if (!r0 || r0.ok !== true) return r0; ask = r0.ask && r0.ask.id; }
|
|
261
|
+
return post(C, '/api/boards/asks/accept', { board: C.board, ask, title, lane, anchor });
|
|
262
|
+
});
|
|
263
|
+
if (!res) return;
|
|
264
|
+
closeDlg(); await done(C, res, '“' + title + '” is ' + (a ? 'accepted' : 'created') + ' in ' + (res.stage || C.first || 'the first stage') + ', anchored to ' + anchor + '.' + (res.initiative ? ' Its record is ' + res.initiative + '.' : ''));
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function openDecline(C, a) {
|
|
268
|
+
form({ eye: 'Decline an ask', title: 'Decline ask', sub: [a.source, a.by].filter(Boolean).join(' · ') || C.boardName, say: 'Say why. The reason is kept with the ask.', body: `<p class="baq">“${esc(a.line)}”</p>
|
|
269
|
+
<label>Reason<textarea id="paDW" rows="3" maxlength="500" placeholder="Why not? The reason is kept with the ask."></textarea></label>
|
|
270
|
+
${rec('Recorded: a decline line for the ask in the board ledger, with the reason.')}
|
|
271
|
+
${msgP('paDM')}<div class="cact"><button type="button" class="cta" id="paDGo" disabled>Decline</button><button type="button" class="cta alt" id="paDNo">Cancel</button></div>` });
|
|
272
|
+
$('#oMain').oninput = (e) => { if (e.target.id === 'paDW') $('#paDGo').disabled = !e.target.value.trim(); };
|
|
273
|
+
$('#oMain').onclick = async (e) => {
|
|
274
|
+
if (e.target.closest('#paDNo')) { closeDlg(); return; }
|
|
275
|
+
if (!e.target.closest('#paDGo')) return;
|
|
276
|
+
const why = $('#paDW').value.trim().replace(/\s+/g, ' ');
|
|
277
|
+
if (!why) { $('#paDM').textContent = 'Say why. A decline needs a reason.'; return; }
|
|
278
|
+
const res = await press($('#paDGo'), $('#paDM'), () => post(C, '/api/boards/asks/decline', { board: C.board, ask: a.id, why })); if (!res) return;
|
|
279
|
+
closeDlg(); await done(C, res, 'Ask declined. The reason is kept in the board ledger.');
|
|
280
|
+
};
|
|
281
|
+
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
/* pm/premium-board.js — the premium Board page (initiative briefing-premium-board, slice 5). Reads GET /api/board-premium and draws the model
|
|
2
2
|
* lib/board-premium.js builds from the routes the production Initiatives page reads: the Initiatives card (List, By stage, Timeline), the Sprint and
|
|
3
|
-
* Coming up cards, Core documents, the dock and the standard dialog. The
|
|
4
|
-
*
|
|
3
|
+
* Coming up cards, Core documents, the dock and the standard dialog. The presses are Draft it on a core document, through POST /api/core-docs/draft,
|
|
4
|
+
* and the board's own presses of pm/premium-acts.js (initiative premium-board-actions): the New asks card, New initiative, and a row's menu (move,
|
|
5
|
+
* hold, cancel, archive and their Undo). Nothing here issues a document. */
|
|
5
6
|
import { pmPost } from './http.js';
|
|
6
7
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, CHECK, store, crumbHtml, wireCrumb, kv, H, openAddDoc } from './premium-shell.js';
|
|
8
|
+
import { dotsBtn, openMenu, closeMenu, menuKey, asksHtml, onAsks, openIniForm } from './premium-acts.js';
|
|
7
9
|
|
|
8
10
|
const MODE_KEY = 'pmos.premium.openAs';
|
|
9
11
|
let M = null; // the model
|
|
10
12
|
let view = 'list';
|
|
11
13
|
let shown = 25; // rows of the list on screen
|
|
12
14
|
let readTimer = null;
|
|
15
|
+
let showGone = false; // the cancelled and archived rows under the list
|
|
13
16
|
wireRail('init');
|
|
17
|
+
/** The context of the board presses (pm/premium-acts.js). */
|
|
18
|
+
const ctxOf = () => ({ ws: M.board.ws, board: M.board.id, boardName: M.board.name, self: M.board.self, first: (M.board.stages || [])[0] || '', reload: load });
|
|
14
19
|
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
15
20
|
const DOCI = '<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>';
|
|
16
21
|
const STATE_ICO = { Linked: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>', Live: '<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>', 'Up to date': '<path d="M5 12.5l4.5 4.5L19 7.5"/>', Draft: '<path d="M4 20l4-1 11-11-3-3L5 16z"/>', 'Not started': '<circle cx="12" cy="12" r="9"/><path d="M12 8v5M12 16.5v.5"/>', Stale: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', Due: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>' };
|
|
@@ -32,13 +37,22 @@ function drawHead() {
|
|
|
32
37
|
/* ── initiatives ───────────────────────────────────────────────────────────────────────────────────────────── */
|
|
33
38
|
const sub = (r) => `${esc(r.sub)}${r.statusLabel ? ` · <span class="${r.late ? 'bad' : 'warn'}">${esc(r.statusLabel)}</span>` : ''}`;
|
|
34
39
|
function listRow(r, i) {
|
|
40
|
+
return `<div class="inirw">${listBtn(r)}${r.acts ? dotsBtn(r) : ''}</div>`;
|
|
41
|
+
}
|
|
42
|
+
function listBtn(r) {
|
|
35
43
|
return `<button class="ini2 ibi${r.first ? ' first' : ''}" data-key="${esc(r.key)}"><span class="it"><b>${esc(r.title)}${r.first ? '<em class="tgf">Do this first</em>' : ''}</b><small>${sub(r)}</small></span><span class="wst"><span class="sg2" aria-hidden="true">${r.seg.map((c) => `<i class="${c}"></i>`).join('')}</span><em>${esc(r.stage || 'No stage')}${r.stageNote ? ' · ' + esc(r.stageNote) : ''}</em></span><span class="pg">${r.progress == null ? '' : `<i><b style="width:${r.progress}%"></b></i>`}</span><span class="rl${r.over ? ' over' : ''}">${esc(r.finish)}</span></button>`;
|
|
36
44
|
}
|
|
37
45
|
function drawList() {
|
|
38
46
|
const L = M.initiatives.list.rows;
|
|
39
|
-
if (!L.length) return '<p class="empty3 plain">No initiatives are on this board\'s now view.</p>';
|
|
40
|
-
return `<div class="inih"><span>Initiative</span><span>Where it is</span><span>Progress</span><span>Planned finish</span></div>` + L.slice(0, shown).map(listRow).join('')
|
|
41
|
-
+ (L.length > shown ? `<p class="note" style="margin-top:10px">${L.length - shown} more are loaded. <button class="fold alt" id="more" type="button">Show ${Math.min(25, L.length - shown)} more</button></p>` : '');
|
|
47
|
+
if (!L.length) return '<p class="empty3 plain">No initiatives are on this board\'s now view.</p>' + goneHtml();
|
|
48
|
+
return `<div class="inih"><span>Initiative</span><span>Where it is</span><span>Progress</span><span>Planned finish</span></div><div class="inil">` + L.slice(0, shown).map(listRow).join('') + '</div>'
|
|
49
|
+
+ (L.length > shown ? `<p class="note" style="margin-top:10px">${L.length - shown} more are loaded. <button class="fold alt" id="more" type="button">Show ${Math.min(25, L.length - shown)} more</button></p>` : '') + goneHtml();
|
|
50
|
+
}
|
|
51
|
+
/** The cancelled and archived rows, under a fold (initiative premium-board-actions). Their menu offers Reopen or Restore. */
|
|
52
|
+
function goneHtml() {
|
|
53
|
+
const G = M.initiatives.gone || { cancelled: [], archived: [] }, nc = G.cancelled.length, na = G.archived.length;
|
|
54
|
+
if (!nc && !na) return '';
|
|
55
|
+
return `<div class="bagone"><button class="dlink" type="button" id="goneT" aria-expanded="${showGone}">${[nc ? nc + ' cancelled' : '', na ? na + ' archived' : ''].filter(Boolean).join(' · ')}. ${showGone ? 'Hide them' : 'Show them'}</button>${showGone ? `<div class="inil">${G.cancelled.concat(G.archived).map((r) => `<div class="inirw gone">${listBtn(r)}${dotsBtn(r)}</div>`).join('')}</div>` : ''}</div>`;
|
|
42
56
|
}
|
|
43
57
|
function drawStages() {
|
|
44
58
|
const S = M.initiatives.stages;
|
|
@@ -63,6 +77,8 @@ function drawInit() {
|
|
|
63
77
|
$('#ibTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-v]'); if (!b) return; view = b.dataset.v; drawInit(); });
|
|
64
78
|
$('#ibBody').addEventListener('click', (e) => {
|
|
65
79
|
if (e.target.closest('#more')) { shown += 25; drawInit(); return; }
|
|
80
|
+
if (e.target.closest('#goneT')) { showGone = !showGone; drawInit(); const g = $('#goneT'); if (g) g.focus(); return; }
|
|
81
|
+
const im = e.target.closest('[data-im]'); if (im) { const r = rowOf(im.dataset.im); if (r) openMenu(im, ctxOf(), r); return; }
|
|
66
82
|
const b = e.target.closest('[data-key]'); if (b) openIni(rowOf(b.dataset.key));
|
|
67
83
|
});
|
|
68
84
|
/* A click opens the initiative page, as the mockup's Page setting does; the Popup setting opens the dialog. The choice is kept in this browser. */
|
|
@@ -137,6 +153,14 @@ $('#docBody').addEventListener('click', async (e) => {
|
|
|
137
153
|
|
|
138
154
|
$('#addDoc').onclick = () => openAddDoc({ ws: M.board.ws, scope: M.docs.scope, sub: M.board.name, onAdded: load });
|
|
139
155
|
|
|
156
|
+
/* ── new asks and New initiative (initiative premium-board-actions) ───────────────────────────────────────── */
|
|
157
|
+
function drawAsks() {
|
|
158
|
+
$('#asksHost').innerHTML = asksHtml(ctxOf(), M.asks);
|
|
159
|
+
$('#newIni').hidden = !!M.board.self || !M.board.id;
|
|
160
|
+
}
|
|
161
|
+
$('#asksHost').addEventListener('click', (e) => { if (M) onAsks(e, ctxOf(), M.asks); });
|
|
162
|
+
$('#newIni').onclick = () => { closeMenu(); openIniForm(ctxOf(), null); };
|
|
163
|
+
|
|
140
164
|
/* ── dock ───────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
141
165
|
function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textContent = M.dock.label; $('#dNext').innerHTML = M.dock.next ? `<i></i>First <b>${esc(M.dock.next)}</b>` : 'Nothing is late or at risk'; }
|
|
142
166
|
|
|
@@ -156,7 +180,12 @@ function openRow(r) {
|
|
|
156
180
|
$('#dBody').addEventListener('click', (e) => { const lt = e.target.closest('#logT'); if (lt) { const c = $('#alog').classList.toggle('col'); lt.setAttribute('aria-expanded', !c); } });
|
|
157
181
|
|
|
158
182
|
/* ── load: the routes derive the initiatives in the background, so the first answers are "reading" ───────────── */
|
|
159
|
-
function draw() {
|
|
183
|
+
function draw() {
|
|
184
|
+
const mk = menuKey(); closeMenu();
|
|
185
|
+
drawMode(); drawHead(); drawInit(); drawAsks(); drawSide(); drawDocs(); drawDock(); onScroll();
|
|
186
|
+
// a read that lands while a row's menu is open draws the row again: open its menu again, with what the row holds now
|
|
187
|
+
if (mk) { const b = $$('#ibBody [data-im]').find((x) => x.dataset.im === mk), r = rowOf(mk); if (b && r) openMenu(b, ctxOf(), r); }
|
|
188
|
+
}
|
|
160
189
|
async function load() {
|
|
161
190
|
const p = new URLSearchParams(location.search), q = [p.get('ws') ? 'ws=' + encodeURIComponent(p.get('ws')) : '', p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
|
|
162
191
|
let r = null, status = 0;
|
|
@@ -178,7 +207,7 @@ async function load() {
|
|
|
178
207
|
$('#brief').textContent = '';
|
|
179
208
|
const first = !M; M = r.model; draw();
|
|
180
209
|
if (first && M.board.ws) startMetrics(M.board.ws); // the Metrics card of a tenant's board reads apart from the board
|
|
181
|
-
if (M.docs.rows.some((d) => d.running)) setTimeout(load, 5000); // a core-document run is going: ask again until it ends
|
|
210
|
+
if (M.docs.rows.some((d) => d.running) || r.stale) setTimeout(load, r.stale ? 2000 : 5000); // a core-document run is going, or a press is still being derived: ask again // a core-document run is going: ask again until it ends
|
|
182
211
|
}
|
|
183
212
|
$('#brief').textContent = 'Reading the board.';
|
|
184
213
|
load();
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* model lib/initiative-premium.js builds from the routes the production Initiatives sheet reads: the overview and checks, the Tasks card (PRD requirements and
|
|
3
3
|
* the board's tracker items) and the Core documents card. A document row with a file opens the document sheet (Read, Edit, Proposals, Edit log, Health) in the
|
|
4
4
|
* standard dialog beside the read-only agent. The presses are Draft it (POST /api/core-docs/draft), the sheet's Save, Ask the agent, Accept and Reject (the
|
|
5
|
-
* existing /api/doc-sheet routes, initiative briefing-premium-doc-edit), Add a task and a task's status
|
|
5
|
+
* existing /api/doc-sheet routes, initiative briefing-premium-doc-edit), Add a task and a task's status, and the bar under the stages (initiative
|
|
6
|
+
* premium-board-actions, pm/premium-acts.js): move to the next stage or back, hold, cancel, archive, resume, reopen and restore, each with Undo. Nothing here issues a document. */
|
|
6
7
|
import { pmPost } from './http.js';
|
|
7
8
|
import { proposalsModel, editBody, acceptBody, rejectBody, askBody, askLine } from './premium-doc-edit.js';
|
|
8
9
|
import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, kv, H2, CHECK, crumbHtml, wireCrumb, AI, openAddDoc } from './premium-shell.js';
|
|
10
|
+
import { barHtml, onBar, closeMenu } from './premium-acts.js';
|
|
9
11
|
|
|
10
12
|
let M = null; // the model
|
|
11
13
|
let taskView = 'list';
|
|
@@ -46,6 +48,10 @@ function checksHtml() {
|
|
|
46
48
|
const all = M.allSteps.length ? `<details class="src"><summary>All ${M.allSteps.length} workflow steps</summary><div class="ckl">${M.allSteps.map((c) => `<div class="ckr"><i></i><b>${esc(c.label)}</b><span>${esc(c.stateLabel)}</span><small>${esc(c.note)}</small></div>`).join('')}</div></details>` : '';
|
|
47
49
|
return `<section class="card rise" style="--d:4" id="cIniChk" aria-labelledby="hChk"><div class="ch"><span class="ic">${ICO('<path d="M5 12l5 5L20 7"/>')}</span><h2 id="hChk">Checks</h2><small>from the workflow engine</small></div><div class="ckl">${M.checks.map((c) => `<div class="ckr ${esc(c.state)}${c.cur ? ' cur' : ''}"><i></i><b>${esc(c.label)}</b><span>${esc(c.stateLabel)}</span>${c.owed ? `<small>${esc(c.owed)}</small>` : ''}</div>`).join('')}</div>${all}</section>`;
|
|
48
50
|
}
|
|
51
|
+
/* the bar's presses (pm/premium-acts.js): the page's context and the initiative as a row */
|
|
52
|
+
const actCtx = () => ({ ws: M.board.ws, board: M.board.id, boardName: M.board.name, self: !!M.acts.self, first: M.acts.stages[0] || '', reload: load });
|
|
53
|
+
const actRow = () => ({ id: M.id, key: 'bar', title: M.title, acts: M.acts });
|
|
54
|
+
$('#iMain').addEventListener('click', (e) => { if (M && M.acts && e.target.closest('#iBar')) onBar(e, actCtx(), actRow()); });
|
|
49
55
|
$('#iMain').addEventListener('click', (e) => {
|
|
50
56
|
const h = e.target.closest('[data-help]'); if (!h) return;
|
|
51
57
|
const a = M.help[+h.dataset.help]; if (!a) return;
|
|
@@ -409,7 +415,8 @@ function draw() {
|
|
|
409
415
|
$('#snap').textContent = M.header.text;
|
|
410
416
|
$('#snap').title = 'Every figure on this page comes from a record. A date, owner or progress shows only when one was set.';
|
|
411
417
|
const keepQ = $('#dmQ') && document.activeElement === $('#dmQ');
|
|
412
|
-
|
|
418
|
+
closeMenu();
|
|
419
|
+
$('#iMain').innerHTML = headHtml() + (M.acts ? `<div id="iBar">${barHtml(actCtx(), actRow())}</div>` : '') + `<div class="bcols"><div>${overviewHtml()}</div><div>${checksHtml()}</div></div>` + tasksHtml() + docsHtml();
|
|
413
420
|
if ($('#dmList')) drawDocList();
|
|
414
421
|
if (keepQ) { const q = $('#dmQ'); q.focus(); q.setSelectionRange(q.value.length, q.value.length); }
|
|
415
422
|
pillOf($('#tkTabs'));
|
|
@@ -807,6 +807,25 @@ a.round{color:inherit;text-decoration:none}
|
|
|
807
807
|
.dmcta.alt:hover{filter:none;background:var(--well)}
|
|
808
808
|
.dmcta{min-height:44px}
|
|
809
809
|
|
|
810
|
+
/* ── board actions (initiative premium-board-actions): the row menu, the New asks card, the bar on the initiative page and their dialogs; the mockup's rules, cut by class ── */
|
|
811
|
+
.inirw{position:relative}.inirw>.ini2{padding-right:56px;border-top:1px solid var(--hair)}
|
|
812
|
+
.inim{position:absolute;right:-8px;top:50%;transform:translateY(-50%);width:44px;height:44px;border-radius:14px;display:grid;place-items:center;color:var(--ink-2);transition:background .2s}.inim:hover,.inim[aria-expanded="true"]{background:var(--well);color:var(--ink)}.inim svg{width:20px;height:20px;fill:currentColor;stroke:none}
|
|
813
|
+
.inirw.gone .ini2{opacity:.62}.inirw.gone .ini2 .it b{text-decoration:line-through;text-decoration-thickness:1px}
|
|
814
|
+
.bagone{margin-top:8px;padding-top:8px;border-top:1px solid var(--hair)}.bagone .dlink{min-height:44px}
|
|
815
|
+
.bam2{left:auto;right:0;top:calc(100% - 4px);min-width:250px}.bam2.up{top:auto;bottom:calc(100% - 4px)}.bam2 button{height:auto;min-height:44px;padding:8px 12px;font-family:inherit}.bam2 button span{display:grid;gap:2px}.bam2 button b{font-size:13px;color:var(--ink);font-weight:650}.bam2 button small{font-size:12px;color:var(--ink-3);font-weight:500}
|
|
816
|
+
.baask{margin-bottom:24px}.baask .bal{display:grid;gap:10px}.baa{padding:12px 14px;border-radius:14px;background:var(--well);display:grid;gap:6px}
|
|
817
|
+
.baq{margin:0;font-size:14px;line-height:1.45;color:var(--ink)}.bam{font-size:12.5px;color:var(--ink-3)}
|
|
818
|
+
.bad2{display:flex;flex-wrap:wrap;gap:6px}.bad2 span{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:999px;background:var(--card-solid);font-size:12.5px;font-weight:600;color:var(--ink-2)}
|
|
819
|
+
.baact{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.baa .baact{margin-top:4px}
|
|
820
|
+
.baiact{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 0 20px}.baiact .note{margin:0}.iamw{position:relative}
|
|
821
|
+
.lifeb{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;padding:14px 18px;margin:0 0 20px;border-radius:18px;background:color-mix(in oklab,var(--ink) 6%,transparent);box-shadow:inset 3px 0 0 var(--ink-3)}.lifeb>div{display:grid;gap:3px;flex:1 1 260px}.lifeb b{font-size:15px}.lifeb span{font-size:13px;color:var(--ink-2);line-height:1.45}
|
|
822
|
+
.addf textarea{border-radius:14px;border:1px solid var(--hair);background:var(--card-solid);padding:10px 12px;font:inherit;font-size:15px;color:var(--ink);min-width:0;width:100%;resize:vertical}.addf textarea:focus-visible{outline:2px solid var(--ember);outline-offset:1px}
|
|
823
|
+
.bapl button{min-height:40px}#oMain .addf .bapl button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
824
|
+
.bahp{padding:12px 14px;border-radius:14px;background:var(--well)}.bahp .label{margin:0 0 6px}.bahp ul{list-style:none;margin:0;padding:0;display:grid;gap:6px}.bahp li{display:grid;grid-template-columns:16px minmax(0,1fr);gap:8px;font-size:13px;line-height:1.45;color:var(--ink-2)}.bahp svg{width:14px;height:14px;margin-top:2px;color:var(--ok)}
|
|
825
|
+
.barec{display:flex;gap:8px;margin:0;align-items:flex-start}.barec svg{width:14px;height:14px;flex:none;margin-top:3px}
|
|
826
|
+
.addf .cact{display:flex;flex-wrap:wrap;gap:10px}.addf .note[role="status"]{margin:0;min-height:1.2em}
|
|
827
|
+
@media (max-width:760px){.inirw>.ini2{padding-right:48px}.baiact .dmcta,.lifeb .dmcta,.baa .dmcta{height:44px}.baa .baact .dmcta{flex:1;justify-content:center}.bapl button{min-height:44px}}
|
|
828
|
+
|
|
810
829
|
/* ── initiative page (initiative briefing-premium-initiative) ── */
|
|
811
830
|
.ckr.current i{background:var(--ember)}
|
|
812
831
|
.ckr.done i{background:var(--ok)}
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
<div class="bcols">
|
|
51
51
|
<div>
|
|
52
52
|
<section class="card rise" style="--d:5" id="cIni" aria-labelledby="hIni">
|
|
53
|
-
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M12 3 3 8l9 5 9-5z"/><path d="m3 13 9 5 9-5"/></svg></span><h2 id="hIni">Initiatives</h2><small id="iniCap"></small></div>
|
|
53
|
+
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M12 3 3 8l9 5 9-5z"/><path d="m3 13 9 5 9-5"/></svg></span><h2 id="hIni">Initiatives</h2><small id="iniCap"></small><button class="fold alt dmadd2" id="newIni" type="button" hidden>New initiative</button></div>
|
|
54
54
|
<div class="mprog" id="iniBar" role="progressbar" aria-label="Open initiatives on track" aria-valuemin="0" hidden><b></b></div>
|
|
55
55
|
<div class="seg" id="ibTabs" role="group" aria-label="Initiatives view"><i class="pill"></i><button data-v="list" aria-pressed="true">List</button><button data-v="stages" aria-pressed="false">By stage</button><button data-v="time" aria-pressed="false">Timeline</button></div>
|
|
56
56
|
<div id="ibBody"></div>
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
</section>
|
|
59
59
|
</div>
|
|
60
60
|
<div>
|
|
61
|
+
<div id="asksHost"></div>
|
|
61
62
|
<section class="card rise" style="--d:6" id="cSpr" aria-labelledby="hSpr">
|
|
62
63
|
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span><h2 id="hSpr">Sprint</h2><small id="sprCap"></small></div>
|
|
63
64
|
<div id="sprBody"></div>
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
<div class="dmg two" id="docBody" role="list"></div>
|
|
75
76
|
<p class="note" id="docNote" style="margin-top:12px"></p>
|
|
76
77
|
</section>
|
|
77
|
-
<p class="foot" id="foot">This page reads the board's own records, the same ones the Initiatives page reads. Its presses are Draft it on a core document, which starts the existing read-only run that writes a draft and sends nothing,
|
|
78
|
+
<p class="foot" id="foot">This page reads the board's own records, the same ones the Initiatives page reads. Its presses are Draft it on a core document, which starts the existing read-only run that writes a draft and sends nothing, Add a document, which saves a document on the board's record, and the board's own presses: accept or decline a new ask, New initiative, and move, hold, cancel or archive an initiative, each through the console's route and each with Undo. Issue and Drop are not built here. The Metrics charts are not drawn, because PMOS holds no metric series for a board. A sprint appears only when a session has read Jira.</p>
|
|
78
79
|
</main>
|
|
79
80
|
<noscript>This page needs JavaScript.</noscript>
|
|
80
81
|
<script type="module" src="/pm/premium-board.js"></script>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</header>
|
|
42
42
|
<section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
|
|
43
43
|
<div id="iMain"><p class="empty3 plain" id="iRead">The initiative is read from its records. This page shows nothing until it has read, rather than guess.</p></div>
|
|
44
|
-
<p class="foot" id="foot">This page reads the initiative's own records, the same ones the Initiatives sheet reads. Its presses are Draft it on a core document, which starts the existing read-only run that writes a draft and sends nothing, Add a task,
|
|
44
|
+
<p class="foot" id="foot">This page reads the initiative's own records, the same ones the Initiatives sheet reads. Its presses are Draft it on a core document, which starts the existing read-only run that writes a draft and sends nothing, Add a task, Add a document, which saves a document on the initiative's record, and the bar under the stages: move it, put it on hold, cancel or archive it, each through the console's route and each with Undo. Opening a document only reads it. Issue and Drop are not built on this page.</p>
|
|
45
45
|
</main>
|
|
46
46
|
<noscript>This page needs JavaScript.</noscript>
|
|
47
47
|
<script type="module" src="/pm/premium-initiative.js"></script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-board-actions: the Board's own presses (new asks, New initiative, move, hold, cancel, archive, each with Undo) against the real server on a scratch team repo.",
|
|
3
|
+
"panels": [
|
|
4
|
+
"premium-board-actions-test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"premium-board-actions-test.js": 150
|
|
8
|
+
}
|
|
9
|
+
}
|