create-pmos 0.401.0 → 0.403.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 +25 -30
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/board-programs-test.js +227 -0
- package/workspace/board-shot.js +54 -0
- package/workspace/briefing-premium-adddoc-test.js +28 -22
- package/workspace/briefing-premium-board-test.js +107 -82
- package/workspace/briefing-premium-calendar-2-test.js +23 -10
- package/workspace/briefing-premium-calendar-3-test.js +23 -19
- package/workspace/briefing-premium-calendar-test.js +20 -15
- package/workspace/briefing-premium-initiative-test.js +25 -12
- package/workspace/briefing-premium-insights-test.js +31 -18
- package/workspace/briefing-premium-metrics-test.js +8 -8
- package/workspace/briefing-premium-sources-test.js +15 -10
- package/workspace/briefing-premium-test.js +39 -16
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-premium-facts.js +20 -3
- package/workspace/fixtures/briefing-premium-facts.js +18 -2
- package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
- package/workspace/fixtures/program-ascent.js +101 -0
- package/workspace/guide/home.md +11 -7
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/jira.md +38 -6
- package/workspace/guide/programs.md +37 -0
- package/workspace/home-rows-test.js +184 -0
- package/workspace/lib/briefing-premium-products.js +4 -4
- package/workspace/lib/briefing-premium.js +2 -2
- package/workspace/lib/calendar-layers.js +8 -4
- package/workspace/lib/initiative-layout.js +4 -3
- package/workspace/lib/jira-cli.js +17 -12
- package/workspace/lib/jira-status.js +1 -1
- package/workspace/lib/jira-tickets.js +126 -24
- package/workspace/lib/meeting-files.js +58 -0
- package/workspace/lib/meeting-learn.js +139 -0
- package/workspace/lib/meeting-material.js +12 -5
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/programs.js +129 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-brief-page.js +8 -1
- package/workspace/lib/routes-briefing-premium.js +1 -1
- package/workspace/lib/routes-calendar-views.js +24 -3
- package/workspace/lib/routes-meeting-material.js +38 -0
- package/workspace/lib/routes-meeting-points.js +23 -3
- package/workspace/lib/routes-programs.js +122 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +31 -25
- package/workspace/premium-chat-context-test.js +1 -1
- package/workspace/premium-chat-goal-view-test.js +1 -1
- package/workspace/premium-chat-viewer-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +13 -7
- package/workspace/premium-discuss-landing-test.js +83 -0
- package/workspace/premium-link-suggest-test.js +103 -0
- package/workspace/premium-report-read-test.js +86 -82
- package/workspace/premium-vw-backlog-test.js +6 -5
- package/workspace/premium-vw-cal-test.js +45 -19
- package/workspace/premium-vw-item-test.js +8 -6
- package/workspace/premium-vw-jira-test.js +3 -2
- package/workspace/premium-vw-meet-test.js +122 -66
- package/workspace/premium-vw-notes-test.js +7 -6
- package/workspace/premium-vw-rec-test.js +14 -13
- package/workspace/premium-vw-slides-test.js +11 -5
- package/workspace/program-panel-test.js +152 -0
- package/workspace/public/pm/bd-acts.js +24 -15
- package/workspace/public/pm/bd-asks.js +111 -30
- package/workspace/public/pm/bd-ini-panel.js +229 -0
- package/workspace/public/pm/bd-pop.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +436 -0
- package/workspace/public/pm/bd-prog.js +191 -0
- package/workspace/public/pm/bd-span.js +98 -15
- package/workspace/public/pm/bd-views.js +93 -29
- package/workspace/public/pm/cozy-board.css +214 -20
- package/workspace/public/pm/cozy-evui.js +4 -2
- package/workspace/public/pm/cozy-home-rows.css +54 -0
- package/workspace/public/pm/cozy-home.css +35 -0
- package/workspace/public/pm/cozy-insights.css +1 -2
- package/workspace/public/pm/cozy-mtg-present.css +160 -0
- package/workspace/public/pm/cozy-panel.css +155 -0
- package/workspace/public/pm/cozy-rec-pill.css +12 -0
- package/workspace/public/pm/cozy-rec-pill.js +46 -0
- package/workspace/public/pm/cozy-today.css +189 -0
- package/workspace/public/pm/cozy-viewer.js +307 -43
- package/workspace/public/pm/cozy-vw-mtg.css +96 -94
- package/workspace/public/pm/cozy-vw-rp.css +40 -25
- package/workspace/public/pm/cozy-vw-shell.css +127 -0
- package/workspace/public/pm/cozy-xv.css +51 -0
- package/workspace/public/pm/cozy-xv.js +34 -0
- package/workspace/public/pm/home-app.js +192 -72
- package/workspace/public/pm/home-chat.js +17 -4
- package/workspace/public/pm/home-data.js +1 -1
- package/workspace/public/pm/home-day.js +64 -0
- package/workspace/public/pm/home-ini-model.js +1 -1
- package/workspace/public/pm/home-ini.js +197 -54
- package/workspace/public/pm/home-list.js +100 -27
- package/workspace/public/pm/home-mentions.js +187 -0
- package/workspace/public/pm/home-rec-row.js +67 -0
- package/workspace/public/pm/home-review.js +20 -10
- package/workspace/public/pm/home-task.js +19 -18
- package/workspace/public/pm/home-today.js +137 -59
- package/workspace/public/pm/premium-board.js +294 -288
- package/workspace/public/pm/premium-insights.js +118 -82
- package/workspace/public/pm/premium-mtg-present.js +408 -100
- package/workspace/public/pm/premium-mtg-replay.js +70 -10
- package/workspace/public/pm/premium-report-read.js +118 -63
- package/workspace/public/pm/premium-vw-cal.js +62 -34
- package/workspace/public/pm/premium-vw-mtg.js +348 -192
- package/workspace/public/pm/program-model.js +192 -0
- package/workspace/public/pm/rec-state.js +63 -0
- package/workspace/public/pm/rp-parts.js +33 -8
- package/workspace/public/pm/tk-draft.js +107 -0
- package/workspace/public/pm/tk-model.js +134 -0
- package/workspace/public/pm/tk-send.js +124 -0
- package/workspace/public/pm/tk-tasks.css +120 -0
- package/workspace/public/premium-board.html +4 -2
- package/workspace/server.js +4 -2
- package/workspace/skills/jira-push.skill +3 -3
- package/workspace/test-lists/board-programs.json +9 -0
- package/workspace/test-lists/prd-to-jira.json +6 -0
- package/workspace/test-lists/program-hierarchy.json +11 -0
- package/workspace/test-lists/program-panel.json +9 -0
- package/workspace/test-lists/viewer-home-rows.json +9 -0
- package/workspace/test-lists/viewer-meetings.json +9 -0
- package/workspace/test-lists/viewer-shell-a.json +15 -0
- package/workspace/tk-tasks-test.js +199 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* program-panel-test.js — the program panel on the Board (initiative program-hierarchy P5, P9; canvas PgProgram, PgMilestones), re-shelled
|
|
4
|
+
* into the Viewer's shell A by the second kit (initiative viewer-shell-a, V9; canvas XvABoard). Serves the real page from the real server;
|
|
5
|
+
* GET /api/board-premium answers each product of Project Ascent (fixtures/program-ascent.js through fixtures/board-premium-facts.js
|
|
6
|
+
* programFacts), GET /api/programs its programs, and the program writes are captured, not written.
|
|
7
|
+
* P open on ?program=, the shell's header, no chat box · G goals per half, each KR's name and whether it is met · M the track and the
|
|
8
|
+
* Milestones row · W waits on you, in Home · T the initiatives per product, another product read from its board · K every task by level,
|
|
9
|
+
* and the sort card after Turn into a program · F folds kept · O the Board's program row opens it, an initiative opens the Board's
|
|
10
|
+
* initiative in the same shell · X task done and a program check · V floats at 560 px, the grip · S full screen on a phone. Per product the
|
|
11
|
+
* KRs (GET /api/boards/anchors), the Insights goals (GET /api/insights-premium) and the PMOS tasks (GET /api/boards/items) answer from
|
|
12
|
+
* fixtures/program-ascent.js. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { spawn } = require('child_process');
|
|
15
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
16
|
+
const T = require('./test-run').configure({ name: 'program-panel' });
|
|
17
|
+
const BP = require('./lib/board-premium.js');
|
|
18
|
+
const F = require('./fixtures/board-premium-facts.js');
|
|
19
|
+
const A = require('./fixtures/program-ascent.js');
|
|
20
|
+
|
|
21
|
+
const BASE = T.BASE;
|
|
22
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
23
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
24
|
+
const results = [];
|
|
25
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
26
|
+
let srv = null; let browser = null;
|
|
27
|
+
const finish = async (code) => {
|
|
28
|
+
if (browser) await browser.close().catch(() => {});
|
|
29
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
30
|
+
T.killTmux();
|
|
31
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
32
|
+
console.log(`\n${results.length - bad}/${results.length} program-panel assertions passed`);
|
|
33
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
34
|
+
};
|
|
35
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
36
|
+
|
|
37
|
+
(async () => {
|
|
38
|
+
const exe = process.env.PMOS_CHROME || findBrowser();
|
|
39
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
40
|
+
let chromium;
|
|
41
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
42
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
43
|
+
await T.waitForServer(BASE);
|
|
44
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
45
|
+
|
|
46
|
+
const open = async ({ w = 1440, h = 900, qs = '?ws=idpf&program=project-ascent', ctx = null, programs = F.programs() } = {}) => {
|
|
47
|
+
const c = ctx || await browser.newContext({ viewport: { width: w, height: h } });
|
|
48
|
+
const page = await c.newPage();
|
|
49
|
+
const errors = [], posts = [];
|
|
50
|
+
page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
|
|
51
|
+
await page.route('**/api/board-premium*', (r) => { const ws = new URL(r.request().url()).searchParams.get('ws') || 'idpf'; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.programFacts(ws)), as_of: Date.now() }) }); });
|
|
52
|
+
await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs }) }));
|
|
53
|
+
const wsOf = (r) => new URL(r.request().url()).searchParams.get('ws') || 'idpf', json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) });
|
|
54
|
+
await page.route('**/api/boards/anchors*', (r) => json(r, { ok: true, anchors: A.ANCHORS[wsOf(r)] || [] }));
|
|
55
|
+
await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, model: { goals: A.GOALS[wsOf(r)] || [] } }));
|
|
56
|
+
await page.route('**/api/boards/items*', (r) => json(r, { ok: true, items: A.ITEMS[wsOf(r)] || [] }));
|
|
57
|
+
await page.route('**/api/programs/*', (r) => { const rq = r.request(); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
|
|
58
|
+
await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: '{"ok":false,"error":"not in this check"}' }));
|
|
59
|
+
await page.addInitScript(() => { window.__bdp = 0; document.addEventListener('bd:program', () => { window.__bdp += 1; }); });
|
|
60
|
+
await page.goto(BASE + '/premium-board.html' + qs);
|
|
61
|
+
return { page, ctx: c, errors, posts };
|
|
62
|
+
};
|
|
63
|
+
const shown = (p) => until(() => p.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden && /^Viewer: Program/.test(v.getAttribute('aria-label') || '') && !!v.querySelector('.pp-vw .czs-sum'); }));
|
|
64
|
+
const fold = (p, id) => p.click(`#czViewer [data-czs-fold="${id}"]`);
|
|
65
|
+
const isOpen = (p, id) => p.evaluate((k) => { const b = document.querySelector(`#czViewer [data-czs-fold="${k}"]`); return !!b && b.getAttribute('aria-expanded') === 'true'; }, id);
|
|
66
|
+
|
|
67
|
+
/* ── desktop ── */
|
|
68
|
+
const D = await open();
|
|
69
|
+
const p = D.page;
|
|
70
|
+
ok('P ?program=<id> opens the program in the Viewer once the board and the programs are read', await shown(p));
|
|
71
|
+
await sleep(1500); // the other product's board and the program reads land after the program opened: none of them opens it again
|
|
72
|
+
ok('P ?program=<id> sends bd:program once: one path opens the program', await p.evaluate(() => window.__bdp) === 1, String(await p.evaluate(() => window.__bdp)));
|
|
73
|
+
const hd = await p.evaluate(() => { const v = document.querySelector('#czViewer'); const r = v.getBoundingClientRect(); return { t: v.querySelector('.cz-vw-title').textContent, kind: (v.querySelector('.cz-vw-kind') || {}).textContent, meta: (v.querySelector('.czs-meta') || {}).textContent, tools: [...v.querySelectorAll('.cz-vw-head [data-cz-vw], [data-cz-vw]')].filter((b) => b.closest('#czViewer') && !b.classList.contains('cz-vw-grip')).map((b) => b.getAttribute('aria-label')), input: v.querySelectorAll('.cz-vw-body input, .cz-vw-body textarea').length, tabs: v.querySelectorAll('.pp-tab, [role="tab"]').length, w: Math.round(r.width), right: Math.round(innerWidth - r.right), sel: !!document.querySelector('#ibBody [data-prow="project-ascent"].sel') }; });
|
|
74
|
+
ok('P the shell\'s header names it once ("title · goal"), with Discuss in chat, ⋯, Open wide and Close; the summary says the owner and the span; there is no chat box and no tab', hd.t === 'Project Ascent · CIAM migration' && hd.kind === 'Program' && hd.meta === 'Wawan · Sep 2026 to Jun 2028' && [...new Set(hd.tools)].join('|') === 'Discuss in chat|More|Open wide|Close the viewer' && hd.input === 0 && hd.tabs === 0, JSON.stringify(hd));
|
|
75
|
+
ok('V the program floats at 560 px over the page\'s right edge, and its band row on the Board is selected', hd.w === 560 && hd.right < 40 && hd.sel, JSON.stringify(hd));
|
|
76
|
+
const sm = await p.evaluate(() => ({ line: (document.querySelector('#czViewer .czs-line') || {}).textContent, pri: (document.querySelector('#czViewer .czs-pri') || {}).textContent || '' }));
|
|
77
|
+
ok('P the summary line is the next milestone (Waits on you counts itself in its row, said once); no primary while every task has a level', /^Next: Pilot live/.test(sm.line) && sm.pri === '', JSON.stringify(sm));
|
|
78
|
+
const g = await p.evaluate(() => ({ per: document.querySelector('#czViewer .pp-per').textContent.trim(), krs: [...document.querySelectorAll('#czViewer .pp-goal .pp-kr:not(.ghost) b')].map((b) => b.textContent) }));
|
|
79
|
+
ok('G the goals are the KRs its initiatives anchor to, once each, for the current half', g.per === 'H2 2026' && g.krs.slice().sort().join() === 'KR 1.2,KR 2.1,KR 2.3', JSON.stringify(g));
|
|
80
|
+
const gn = await until(() => p.evaluate(() => { const c = [...document.querySelectorAll('#czViewer .pp-goal .pp-kr:not(.ghost)')].map((k) => ({ kr: k.querySelector('b').textContent, text: k.textContent, dot: k.querySelector('.pp-gd') ? (k.querySelector('.pp-gd.off') ? 'off' : 'ok') : '', label: k.getAttribute('aria-label') || '' })); return c.length && c.every((x) => x.dot) ? c : null; }));
|
|
81
|
+
const kr = (id) => (gn || []).find((x) => x.kr === id) || {};
|
|
82
|
+
ok('G each KR shows its name from the OKR files and whether Insights reads it as met: 1.2 met, 2.1 on course, 2.3 behind', !!gn
|
|
83
|
+
&& /KR 2\.1Sign-in success 99\.5%$/.test(kr('KR 2.1').text) && /Retire legacy IdP$/.test(kr('KR 2.3').text) && /Microsite conversion \+8%$/.test(kr('KR 1.2').text)
|
|
84
|
+
&& kr('KR 1.2').dot === 'ok' && /, met$/.test(kr('KR 1.2').label) && kr('KR 2.1').dot === 'ok' && /on course$/.test(kr('KR 2.1').label) && kr('KR 2.3').dot === 'off' && /behind$/.test(kr('KR 2.3').label), JSON.stringify(gn));
|
|
85
|
+
const mt = await p.evaluate(() => { const t = document.querySelector('#czViewer .pp-mt'); return { caps: [...t.querySelectorAll('.pp-cap')].map((c) => c.textContent.trim()), ms: [...t.querySelectorAll('.pp-m b')].map((b) => b.textContent), next: (t.querySelector('.pp-dm.n') || {}).parentElement && t.querySelector('.pp-dm.n').parentElement.querySelector('b').textContent, rd: (t.querySelector('.pp-rd') || {}).getAttribute && t.querySelector('.pp-rd').getAttribute('aria-label') }; });
|
|
86
|
+
ok('M the track shows 3 milestones between a done cluster and an "N more" cluster; the next one is marked and counts its initiatives', mt.caps.join('|') === '1 done|4 more' && mt.ms.join('|') === 'Charter approved|Pilot live|Pilot users invited' && mt.next === 'Pilot live' && mt.rd === '0 of 2 initiatives ready', JSON.stringify(mt));
|
|
87
|
+
const rows = await until(() => p.evaluate(() => { const r = [...document.querySelectorAll('#czViewer .czs-row')].map((b) => b.querySelector('b').textContent + ':' + ((b.querySelector('.czs-n') || {}).textContent || '')); return r.length >= 7 ? r : null; }));
|
|
88
|
+
ok('P the tabs are folding rows: Waits on you, On the program, On its initiatives, On their epics, Initiatives, Milestones, Documents, each with its count', !!rows && /^Waits on you:1\|On the program:2\|On its initiatives:\d+\|On their epics:\d+\|Initiatives:3\|Milestones:8\|Documents:\d+$/.test(rows.join('|')), JSON.stringify(rows));
|
|
89
|
+
await p.click('#czViewer .pp-cap:not(.dn)');
|
|
90
|
+
const ml = await until(() => p.evaluate(() => { const l = document.querySelector('#czViewer [data-czs-id="ms"] .pp-ml'); return l && !l.closest('[hidden]') ? { groups: [...l.querySelectorAll('.pp-mg')].map((x) => x.textContent.trim()), check: [...l.querySelectorAll('.pp-mr')].filter((x) => /A program check/.test(x.textContent)).map((x) => x.querySelector('b').textContent) } : null; }));
|
|
91
|
+
ok('M "N more" opens the Milestones row: Done, Next and Later, and a milestone with no initiative is a program check', !!ml && ml.groups.join('|') === 'Done · 2|Next · 1|Later · 5' && ml.check.join() === 'Support ready,Program review', JSON.stringify(ml));
|
|
92
|
+
await p.click('#czViewer .pp-mr button.pp-dm[data-ms="support-ready"]');
|
|
93
|
+
const ck = await until(() => D.posts.find((x) => x.path === '/api/programs/check'));
|
|
94
|
+
ok('X a program check\'s diamond marks it done (POST /api/programs/check)', !!ck && ck.body.program === 'project-ascent' && ck.body.milestone === 'support-ready' && ck.body.done === true, JSON.stringify(ck));
|
|
95
|
+
const nr = await p.evaluate(() => [...document.querySelectorAll('#czViewer .pp-needs .pp-nr')].map((a) => ({ t: a.querySelector('b').textContent, href: a.getAttribute('href'), box: !!a.querySelector('.pp-ck'), sub: a.querySelector('.t span').textContent })));
|
|
96
|
+
ok('W waits on you lists your program task as a check box, and it opens in Home at that item; Dara\'s task is not yours', nr.length === 1 && nr[0].t === 'Sign the CIAM vendor order form' && nr[0].box && /^\/premium\.html\?/.test(nr[0].href) && /item=pt%3Aproject-ascent%3Apt-vendor-form/.test(nr[0].href) && /^On the program · /.test(nr[0].sub), JSON.stringify(nr));
|
|
97
|
+
const tr = await until(() => p.evaluate(() => { const t = document.querySelector('#czViewer [data-czs-id="tree"] .pp-tree[role="tree"]'); if (!t || /reading its board|not read/.test(t.textContent)) return null; return { rows: [...t.querySelectorAll('.pp-nd.ini .x, .pp-nd.prd2')].map((x) => (x.classList.contains('prd2') ? x.lastChild.textContent : x.textContent).trim()), here: [...t.querySelectorAll('button.pp-open')].map((b) => b.textContent), away: [...t.querySelectorAll('a.pp-open')].map((a) => a.getAttribute('href')) }; }));
|
|
98
|
+
ok('T Initiatives lists each product with its initiatives; the other product\'s initiative is read from its own board and links there', !!tr && tr.rows[0] === 'IDPF' && tr.rows.indexOf('Microsites') > tr.rows.indexOf('IDPF') && tr.rows.includes('Microsite sign-in on CIAM') && tr.here.length === 2 && tr.away.length === 1 && /ws=microsites&focus=microsite-signin/.test(tr.away[0]), JSON.stringify(tr));
|
|
99
|
+
const tk = await until(() => p.evaluate(() => { const one = (k) => { const s = document.querySelector(`#czViewer [data-czs-id="${k}"]`); return s ? { n: (s.querySelector('.czs-n') || {}).textContent || '', rows: [...s.querySelectorAll('a.pp-tk')].map((a) => ({ t: a.querySelector('.x').textContent, href: a.getAttribute('href') })) } : null; };
|
|
100
|
+
const i = one('itasks'), e = one('etasks'); return i && e ? { i, e, sort: !!(document.querySelector('#czViewer .czs-pri') || {}).textContent } : null; }));
|
|
101
|
+
if (tk) { await fold(p, 'itasks'); await fold(p, 'etasks'); }
|
|
102
|
+
const tk2 = await p.evaluate(() => [...document.querySelectorAll('#czViewer [data-czs-id="itasks"] a.pp-tk, #czViewer [data-czs-id="etasks"] a.pp-tk')].map((a) => ({ t: a.querySelector('.x').textContent, href: a.getAttribute('href') })));
|
|
103
|
+
ok('K every open task of its initiatives has a row by level, On its initiatives and On their epics (with On the program, 7); an initiative\'s task opens in Home; no sort primary without Turn into a program', !!tk && +tk.i.n + +tk.e.n === 5
|
|
104
|
+
&& tk2.length === 5 && tk2.some((x) => x.t === 'Pick the sign-in widget') && !tk2.some((x) => /Not in the program|Read the Descope docs/.test(x.t)) && /^\/premium\.html\?ws=idpf&ini=legacy-idp-sunset$/.test((tk2.find((x) => x.t === 'Draft the cutover plan') || {}).href) && !tk.sort, JSON.stringify({ tk, tk2 }));
|
|
105
|
+
await fold(p, 'itasks'); await fold(p, 'etasks');
|
|
106
|
+
await fold(p, 'tree');
|
|
107
|
+
ok('F a row folds', await until(() => p.evaluate(() => document.querySelector('#czViewer [data-czs-fold="tree"]').getAttribute('aria-expanded') === 'false')));
|
|
108
|
+
await p.click('#czViewer [data-cz-vw="close"]');
|
|
109
|
+
ok('P Close closes the Viewer', await until(() => p.evaluate(() => document.querySelector('#czViewer').hidden)));
|
|
110
|
+
await p.reload();
|
|
111
|
+
await shown(p);
|
|
112
|
+
ok('F the folds are kept after a reload', await until(async () => !(await isOpen(p, 'tree')) && await isOpen(p, 'ms')));
|
|
113
|
+
await fold(p, 'tasks');
|
|
114
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-pp="done"][data-key="pt-vendor-form"]')));
|
|
115
|
+
await p.click('#czViewer [data-pp="done"][data-key="pt-vendor-form"]');
|
|
116
|
+
const dn = await until(() => D.posts.find((x) => x.path === '/api/programs/task-done'));
|
|
117
|
+
ok('X a program task\'s check box marks it done (POST /api/programs/task-done)', !!dn && dn.body.key === 'pt-vendor-form' && dn.body.done === true && dn.body.program === 'project-ascent', JSON.stringify(dn));
|
|
118
|
+
await fold(p, 'tree');
|
|
119
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer button.pp-open[data-ini="descope-parity"]')));
|
|
120
|
+
await p.click('#czViewer button.pp-open[data-ini="descope-parity"]');
|
|
121
|
+
const ip = await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer'); if (!v || v.hidden || !/Initiative/.test(v.getAttribute('aria-label') || '')) return null; return { t: v.querySelector('.cz-vw-title').textContent, peek: !document.querySelector('#peek'), stg: v.querySelectorAll('.xv-stg i').length }; }));
|
|
122
|
+
ok('O an initiative in the tree opens the Board\'s initiative in the same shell, with its eight steps (XvABoard)', !!ip && ip.t === 'Descope feature parity' && ip.peek && ip.stg === 8, JSON.stringify(ip));
|
|
123
|
+
await p.keyboard.press('Escape');
|
|
124
|
+
await until(() => p.evaluate(() => document.querySelector('#czViewer').hidden));
|
|
125
|
+
await p.click('#ibBody [data-prog="project-ascent"]');
|
|
126
|
+
ok('O the Board\'s program row opens the program (bd:program)', await shown(p));
|
|
127
|
+
await p.focus('#czViewer .cz-vw-grip');
|
|
128
|
+
await p.keyboard.press('ArrowLeft');
|
|
129
|
+
const gw = await p.evaluate(() => { const r = document.querySelector('#czViewer').getBoundingClientRect(); let kept = null; try { kept = localStorage.getItem('cz-vw-w:program'); } catch { /* none */ } return { w: Math.round(r.width), kept }; });
|
|
130
|
+
ok('V the grip on the Viewer\'s edge widens it, and the width is kept for programs', gw.w === 584 && gw.kept === '584', JSON.stringify(gw));
|
|
131
|
+
await p.keyboard.press('Escape');
|
|
132
|
+
ok('P Escape closes the Viewer', await until(() => p.evaluate(() => document.querySelector('#czViewer').hidden)));
|
|
133
|
+
ok('0 no page error on desktop', D.errors.length === 0, D.errors.join(' | '));
|
|
134
|
+
await D.ctx.close();
|
|
135
|
+
|
|
136
|
+
/* ── Turn into a program: the sort card counts the tasks of the initiative it came from that have no level, and sorting starts in Home ── */
|
|
137
|
+
const U = await open({ programs: F.programs().map((x) => ({ ...x, from: 'legacy-idp-sunset' })) });
|
|
138
|
+
await shown(U.page);
|
|
139
|
+
const so = await until(() => U.page.evaluate(() => { const c = document.querySelector('#czViewer a.czs-pri'); return c ? { t: (document.querySelector('#czViewer .czs-p') || {}).textContent || '', label: c.textContent, href: c.getAttribute('href') } : null; }));
|
|
140
|
+
ok('K after Turn into a program the summary counts the tasks from before the split (not the one already on an epic), and its primary opens the sorting in Home', !!so && /^2 tasks from before the split have no level yet\./.test(so.t) && so.label === 'Review the suggested homes' && /^\/premium\.html\?ws=idpf&ask=program%3Aproject-ascent&q=/.test(so.href), JSON.stringify(so));
|
|
141
|
+
ok('0 no page error after Turn into a program', U.errors.length === 0, U.errors.join(' | '));
|
|
142
|
+
await U.ctx.close();
|
|
143
|
+
|
|
144
|
+
/* ── phone ── */
|
|
145
|
+
const S = await open({ w: 390, h: 844 });
|
|
146
|
+
ok('S on a phone the program opens', await shown(S.page));
|
|
147
|
+
const sh = await S.page.evaluate(() => { const r = document.querySelector('#czViewer').getBoundingClientRect(); const g = document.querySelector('#czViewer .cz-vw-grip'); return { l: Math.round(r.left), w: Math.round(r.width), h: Math.round(r.height), vw: innerWidth, vh: innerHeight, grip: !g || getComputedStyle(g).display === 'none', wide: document.documentElement.scrollWidth <= innerWidth + 1 }; });
|
|
148
|
+
ok('S it covers the whole screen, with no grip and no sideways scroll', sh.l === 0 && sh.w === sh.vw && sh.h === sh.vh && sh.grip && sh.wide, JSON.stringify(sh));
|
|
149
|
+
ok('0 no page error on a phone', S.errors.length === 0, S.errors.join(' | '));
|
|
150
|
+
await S.ctx.close();
|
|
151
|
+
finish();
|
|
152
|
+
})();
|
|
@@ -37,7 +37,7 @@ const dayIso = (n) => { const t = new Date(Date.now() + n * 86400000); return t.
|
|
|
37
37
|
const plural = (n, a, b) => (n === 1 ? a : b);
|
|
38
38
|
const cap = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : '');
|
|
39
39
|
|
|
40
|
-
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r), openTicket(ini, tk), askHref(r, q), pageHref(r), trail(r), docMeta(path), loadDocMeta(
|
|
40
|
+
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r), openTicket(ini, tk), askHref(r, q), pageHref(r), trail(r), docMeta(path, ws), loadDocMeta([{ path, ws }]), viewDoc(path) }
|
|
41
41
|
export function init(api) { A = api; }
|
|
42
42
|
const M = () => A.M();
|
|
43
43
|
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
@@ -59,9 +59,11 @@ const chipsRadio = (L, name) => `<div class="bd-chips" role="radiogroup" aria-la
|
|
|
59
59
|
const whyOf = (root) => { const c = root.querySelector('[data-why].on'), t = (root.querySelector('input[name="why"]') || {}).value || ''; return ((c && c.dataset.why) || 'Other') + (t.trim() ? ': ' + t.trim().replace(/\s+/g, ' ') : ''); };
|
|
60
60
|
|
|
61
61
|
/* ── a row's actions (BdActions): the ⋯ menu ────────────────────────────────────────────────────────────────────── */
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
62
|
+
/** The board an initiative belongs to: its own product's with All products picked (r.ws, r.boardId), else this board. */
|
|
63
|
+
const own = (id) => { const r = (M().rows || []).find((x) => x.id === id && x.ws); return r ? { ws: r.ws, board: r.boardId } : { ws: M().board.ws, board: M().board.id }; };
|
|
64
|
+
const life = (id, state, reason, back) => post('/api/lifecycle', { ws: own(id).ws, initiative_id: id, state, reason: reason || '', ...(back ? { back } : {}) });
|
|
65
|
+
const arch = (id, archived, reason) => post('/api/boards/archive', { ...own(id), id, archived, ...(reason ? { reason } : {}) });
|
|
66
|
+
const move = (id, to, why) => post('/api/boards/move', { ...own(id), id, to, ...(why ? { why } : {}) });
|
|
65
67
|
const prevOf = (r) => ({ life: r.acts.life, reason: r.acts.reason, backDay: r.acts.backDay || null });
|
|
66
68
|
const lifeBack = (r, p) => (p.life === 'hold' ? life(r.id, 'on-hold', p.reason, p.backDay) : p.life === 'cancelled' ? life(r.id, 'cancelled', p.reason) : life(r.id, 'active', 'undo'));
|
|
67
69
|
/** How much of the step is ready, for "Move to <next> · 2 of 4 ready": the parts or tickets counted toward its output. */
|
|
@@ -189,7 +191,10 @@ function filterHtml() {
|
|
|
189
191
|
const kinds = [...new Set(rows.map((r) => r.lane).filter(Boolean))].sort();
|
|
190
192
|
const sprints = (M().jira && M().jira.sprints) || [];
|
|
191
193
|
const chip = (k, v, label) => `<button type="button" class="bd-chip${F[k].has(v) ? ' on' : ''}" data-flt="${k}" data-v="${esc(v)}" aria-pressed="${F[k].has(v)}">${label || esc(v)}</button>`;
|
|
192
|
-
|
|
194
|
+
// the grouping (PgBoard, PgBoardProduct): programs first by default, so the toolbar shows nothing; By product shows its chip there
|
|
195
|
+
const G = A.grouping ? A.grouping() : null;
|
|
196
|
+
const grp = G && G.on ? `<p class="bd-mlbl">Group</p><div class="bd-fg" role="radiogroup" aria-label="Group">${[['program', 'Programs first'], ['product', 'By product']].map(([k, n]) => `<button type="button" class="bd-chip${(k === 'product') === G.byProduct ? ' on' : ''}" role="radio" aria-checked="${(k === 'product') === G.byProduct}" data-fgrp="${k}">${n}</button>`).join('')}</div>` : '';
|
|
197
|
+
return grp + `<p class="bd-mlbl">Owner</p><div class="bd-fg">${owners.map((o) => chip('owners', o, (o === 'No owner' ? '' : V.avatar(o, 'xs')) + esc(o))).join('')}</div>`
|
|
193
198
|
+ `<p class="bd-mlbl">Kind</p><div class="bd-fg">${kinds.map((l) => chip('lanes', l, esc(cap(l)))).join('') || '<span class="bd-amut">No kind is on record</span>'}</div>`
|
|
194
199
|
+ (sprints.length ? `<p class="bd-mlbl">Sprint</p><div class="bd-fg">${sprints.map((s) => chip('sprints', s.name, esc(s.name + (s.now ? ' · now' : '')))).join('')}${chip('sprints', 'Backlog')}</div>` : '')
|
|
195
200
|
+ `<div class="bd-arow bd-ffoot"><button type="button" class="bd-btn sm ghost" data-fclear>Clear</button><span class="bd-amut bd-push">Applies as you pick</span></div>`;
|
|
@@ -266,8 +271,8 @@ function docById(id) { return V.docRows().find((x) => V.docId(x) === id) || null
|
|
|
266
271
|
async function openDocPanel(id, from) {
|
|
267
272
|
const x = docById(id); if (!x) return;
|
|
268
273
|
docOpen = id;
|
|
269
|
-
const meta = x.path ? A.docMeta(x.path) : null, h = V.healthOf(x), d = x.d || {};
|
|
270
|
-
const eye = (x.src === 'core' ? 'Board document' : x.kind) + ' · ' + (x.src === 'core' ? M().board.name || 'Board' : x.ini.title);
|
|
274
|
+
const meta = x.path ? A.docMeta(x.path, x.ws) : null, h = V.healthOf(x), d = x.d || {};
|
|
275
|
+
const eye = (x.src === 'core' ? 'Board document' : x.kind) + ' · ' + (x.src === 'core' ? d.product || M().board.name || 'Board' : x.ini.title);
|
|
271
276
|
const sub = x.src === 'core' ? [d.by, d.cadence].filter(Boolean).join(' · ') : meta ? [meta.by, meta.changed].filter(Boolean).join(' · ') : '';
|
|
272
277
|
const home = x.src === 'ini' ? A.pageHref(x.ini) : null;
|
|
273
278
|
const tools = home ? `<a class="bd-ib" href="${esc(home)}" aria-label="Open in Home" title="Open in Home">${SV(I.ext)}</a>` : '';
|
|
@@ -276,7 +281,7 @@ async function openDocPanel(id, from) {
|
|
|
276
281
|
else box = `<div class="bd-box"><div class="bd-boxh"><b>${esc(h.text)}</b><span class="bd-amut">Health</span></div>${x.src === 'core' && d.what ? `<p class="sm">${esc(d.what)}</p>` : ''}</div>`;
|
|
277
282
|
const drift = x.drift && x.drift.length ? `<div class="bd-warn sm">The PRD changed after the tickets were pushed. ${esc(x.drift.join(', '))} may not match.</div>` : '';
|
|
278
283
|
const draft = x.src === 'core' && d.st === 'draft' && d.slot;
|
|
279
|
-
const issue = x.src === 'core' && d.path ? (draft ? `<div class="bd-issue" data-issue-bar="draft"><span>A draft. Nothing is sent: issuing marks it issued and sends nothing to anyone.</span><button type="button" class="bd-btn solid" data-act="issue" data-key="${esc(d.key)}">Issue it</button></div>` : `<div class="bd-issue done" data-issue-bar="done"><span>${esc(d.state || 'Issued')}. Nothing was sent to anyone.</span></div>`) : '';
|
|
284
|
+
const issue = x.src === 'core' && d.path ? (draft ? `<div class="bd-issue" data-issue-bar="draft"><span>A draft. Nothing is sent: issuing marks it issued and sends nothing to anyone.</span><button type="button" class="bd-btn solid" data-act="issue" data-key="${esc(d.key)}"${d.ws ? ` data-ws="${esc(d.ws)}"` : ''}>Issue it</button></div>` : `<div class="bd-issue done" data-issue-bar="done"><span>${esc(d.state || 'Issued')}. Nothing was sent to anyone.</span></div>`) : '';
|
|
280
285
|
const log = meta && meta.log && meta.log.length ? `<p class="bd-lbl">Edit log</p>${meta.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : x.path ? '<p class="bd-amut" id="dlogW">Reading the edit log…</p>' : '';
|
|
281
286
|
const cmp = x.drift && x.drift.length ? `<a class="bd-btn" href="${esc(A.askHref(x.ini, 'What changed in the PRD after ' + x.drift.join(', ') + ' ' + (x.drift.length === 1 ? 'was' : 'were') + ' pushed? Compare it with Jira.'))}">Compare with Jira</a>` : '';
|
|
282
287
|
const foot = home || cmp ? `<div class="bd-arow bd-pfoot">${home ? `<a class="bd-btn solid" href="${esc(home)}">Open in Home</a>` : ''}${cmp}</div>` : '';
|
|
@@ -284,16 +289,18 @@ async function openDocPanel(id, from) {
|
|
|
284
289
|
panel(x.title, `${issue}${msg('formM')}${box}${drift}${log}${text}${foot}`, from, { eye, sub, tools, cls: 'pk-doc' });
|
|
285
290
|
A.redraw();
|
|
286
291
|
if (x.path) {
|
|
287
|
-
if (!meta) { await A.loadDocMeta([x.path]); const m2 = A.docMeta(x.path), w = $('#dlogW'); if (w && docOpen === id) w.outerHTML = m2 && m2.log ? `<p class="bd-lbl">Edit log</p>${m2.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : '<p class="bd-amut">No edit is in the git history yet.</p>'; }
|
|
288
|
-
let t = null; try { const res = await fetch('/api/doc?ws=' + encodeURIComponent(M().board.ws || '') + '&path=' + encodeURIComponent(x.path), { credentials: 'same-origin' }); t = res.ok ? await res.text() : null; } catch { t = null; }
|
|
292
|
+
if (!meta) { await A.loadDocMeta([{ path: x.path, ws: x.ws }]); const m2 = A.docMeta(x.path, x.ws), w = $('#dlogW'); if (w && docOpen === id) w.outerHTML = m2 && m2.log ? `<p class="bd-lbl">Edit log</p>${m2.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : '<p class="bd-amut">No edit is in the git history yet.</p>'; }
|
|
293
|
+
let t = null; try { const res = await fetch('/api/doc?ws=' + encodeURIComponent(x.ws || M().board.ws || '') + '&path=' + encodeURIComponent(x.path), { credentials: 'same-origin' }); t = res.ok ? await res.text() : null; } catch { t = null; }
|
|
289
294
|
const el = $('#cdText'); if (el && docOpen === id) el.textContent = t == null ? x.path + ' could not be read.' : t;
|
|
290
295
|
}
|
|
291
296
|
}
|
|
297
|
+
/** A board document by its key; with All products, by its key and its product's workspace (two products can hold the same key). */
|
|
298
|
+
const coreDoc = (key, ws) => { const D = M().docs || {}; return (D.rows || []).find((x) => x.key === key && (!ws || x.ws === ws)) || null; };
|
|
292
299
|
async function issueDoc(key, btn) {
|
|
293
|
-
const D = M().docs || {}, d = (
|
|
294
|
-
const r = await press(btn, $('#formM'), () => post('/api/core-docs/issue', { scope: D.scope, key: d.key, slot: d.slot }));
|
|
300
|
+
const D = M().docs || {}, d = coreDoc(key, btn.dataset.ws); if (!d) return;
|
|
301
|
+
const r = await press(btn, $('#formM'), () => post('/api/core-docs/issue', { ...(d.ws ? { ws: d.ws } : {}), scope: d.scope || D.scope, key: d.key, slot: d.slot }));
|
|
295
302
|
if (!r) return;
|
|
296
|
-
A.say('Issued. Nothing was sent to anyone.'); await A.load(); openDocPanel('core
|
|
303
|
+
A.say('Issued. Nothing was sent to anyone.'); await A.load(); openDocPanel(V.docId({ src: 'core', d }), null);
|
|
297
304
|
}
|
|
298
305
|
/** Add a document: a board document written by you or drafted by PMOS, kept in PMOS or linked to a page elsewhere (POST /api/custom-docs/add).
|
|
299
306
|
* PMOS saves the title and the address on the board's record; it does not read or sync the linked page. */
|
|
@@ -301,7 +308,7 @@ const DKINDS = ['In PMOS', 'Confluence', 'Google Docs', 'Google Slides'];
|
|
|
301
308
|
const radios = (name, L, cur) => `<div class="bd-rad" role="radiogroup">${L.map(([v, l]) => `<label><input type="radio" name="${name}" value="${esc(v)}"${v === cur ? ' checked' : ''}><span>${esc(l)}</span></label>`).join('')}</div>`;
|
|
302
309
|
function openAddDoc(from) {
|
|
303
310
|
panel('Add a document', `<form class="bd-form" data-form="adddoc"><label>Title<input name="title" maxlength="80" placeholder="For example: UAT plan"></label><p class="bd-albl">Who writes it</p>${radios('writer', [['drafts', 'PMOS drafts it'], ['you', 'I write it']], 'drafts')}<label>Where it lives<select name="kind">${DKINDS.map((k) => `<option>${k}</option>`).join('')}</select></label><label>Address<input name="url" maxlength="300" placeholder="https://" disabled></label><p class="bd-amut">It is saved on the board's record. PMOS does not read or sync a linked page.</p>${msg('formM')}<div class="bd-arow"><button type="submit" class="bd-btn solid">Add</button><button type="button" class="bd-btn" data-pk="close">Not now</button></div></form>`, from, { eye: 'Documents' });
|
|
304
|
-
const f = $('#
|
|
311
|
+
const f = $('#czViewer form[data-form="adddoc"]'); if (f) f.kind.onchange = () => { f.url.disabled = f.kind.value === 'In PMOS'; };
|
|
305
312
|
}
|
|
306
313
|
|
|
307
314
|
/* ── Metrics and Notifications ─────────────────────────────────────────────────────────────────────────────────── */
|
|
@@ -347,6 +354,7 @@ document.addEventListener('click', async (e) => {
|
|
|
347
354
|
const fi = t.closest('[data-findini]'); if (fi) { const r = A.rowOf(fi.dataset.findini); Pop.close(false); if (r) A.openIni(r); return; }
|
|
348
355
|
const ft = t.closest('[data-findtk]'); if (ft) { Pop.close(false); A.openTicket(ft.dataset.ini, ft.dataset.findtk); return; }
|
|
349
356
|
const fl = t.closest('[data-flt]'); if (fl && Pop.isOpen() && Pop.el().contains(fl)) { const S = A.F[fl.dataset.flt], v = fl.dataset.v; if (S.has(v)) S.delete(v); else S.add(v); Pop.redraw(filterHtml()); A.redraw(); return; }
|
|
357
|
+
const fg = t.closest('[data-fgrp]'); if (fg && Pop.isOpen() && Pop.el().contains(fg)) { A.setGrouping(fg.dataset.fgrp === 'product'); Pop.redraw(filterHtml()); return; }
|
|
350
358
|
if (t.closest('[data-fclear]')) { A.F.owners.clear(); A.F.lanes.clear(); A.F.sprints.clear(); Pop.redraw(filterHtml()); A.redraw(); return; }
|
|
351
359
|
const sp = t.closest('[data-sprint]'); if (sp) { const S = A.F.sprints, v = sp.dataset.sprint; if (S.has(v)) S.delete(v); else { S.clear(); S.add(v); } Pop.close(false); A.say(S.has(v) ? 'Showing the initiatives with work in ' + v + '.' : 'Showing every sprint.'); A.redraw(); return; }
|
|
352
360
|
const rl = t.closest('[data-rel]'); if (rl) { Pop.close(false); openRelease(+rl.dataset.rel, $('#chSprint')); return; }
|
|
@@ -366,7 +374,8 @@ document.addEventListener('click', async (e) => {
|
|
|
366
374
|
if (k === 'issue') { issueDoc(b.dataset.key, b); return; }
|
|
367
375
|
if (k === 'draft') {
|
|
368
376
|
b.disabled = true;
|
|
369
|
-
const
|
|
377
|
+
const d = coreDoc(b.dataset.key, b.dataset.ws);
|
|
378
|
+
const r = await pmPost('/api/core-docs/draft', { ws: (d && d.ws) || M().board.ws, scope: (d && d.scope) || M().docs.scope, key: b.dataset.key }).catch(() => null);
|
|
370
379
|
if (r && r.ok) { A.say('The agent is drafting it. It lands as a draft for you to review; nothing is sent.'); await A.load(); } else { b.disabled = false; A.say(errOf(r)); }
|
|
371
380
|
}
|
|
372
381
|
});
|
|
@@ -15,10 +15,12 @@ import { $, $$, esc } from './premium-shell.js';
|
|
|
15
15
|
import * as Pop from './bd-pop.js';
|
|
16
16
|
import { avatar } from './bd-views.js';
|
|
17
17
|
|
|
18
|
-
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), rowOf(key), openIni(r), openDoc(path), anchors() }
|
|
18
|
+
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), rowOf(key), openIni(r), openDoc(path), anchors(ws, board), programs(), reloadPrograms() }
|
|
19
19
|
export function init(api) { A = api; }
|
|
20
20
|
const M = () => A.M();
|
|
21
21
|
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
22
|
+
/** The board an ask goes to: the product picked for it, else its own product's board (All products tags each ask), else this board. */
|
|
23
|
+
const boardOfAsk = (a) => { const p = picked[a.id]; return p && p.ws ? { ws: p.ws, board: p.id } : a.ws ? { ws: a.ws, board: a.boardId } : { ws: M().board.ws, board: M().board.id }; };
|
|
22
24
|
const errOf = (r) => (r && r.error) || 'Nothing was recorded. The server did not say why.';
|
|
23
25
|
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
24
26
|
const I = { x: 'M6 6l12 12M18 6L6 18', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1', file: 'M7 3h7l5 5v13H7zM14 3v5h5', up: 'M12 16V4M7 9l5-5 5 5M5 20h14', info: 'M12 8v5M12 16h.01M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18', chev: 'M7 10l5 5 5-5', next: 'M9 6l6 6-6 6' };
|
|
@@ -32,7 +34,7 @@ const asksOf = () => ((M().asks && M().asks.rows) || []);
|
|
|
32
34
|
function askCard(a, i, phone) {
|
|
33
35
|
if (phone && i > 0 && expanded !== a.id) return `<button type="button" class="bd-acard row" data-askopen="${esc(a.id)}">${avatar(a.by || a.source)}<span class="tx"><b>${esc(a.by || a.source || 'Someone')}</b> · “${esc(a.line)}”</span>${SV(I.next)}</button>`;
|
|
34
36
|
const who = `<div class="bd-awho">${avatar(a.by || a.source)}<b>${esc(a.by || a.source || 'Someone')}</b><span class="bd-amut">${esc([a.by ? a.source : '', a.at].filter(Boolean).map((x) => '· ' + x).join(' '))}</span></div>`;
|
|
35
|
-
const prod = picked[a.id] || a.product;
|
|
37
|
+
const prod = picked[a.id] || a.product || (a.forProduct ? { name: a.forProduct, why: 'it came in on the ' + a.forProduct + ' board' } : null);
|
|
36
38
|
const product = prod && prod.name ? `<div class="bd-aprod"><span class="bd-chip sm"><b>${esc(prod.name)}</b></span><span class="bd-amut">Why: ${esc(prod.why || '')}</span></div>` : '';
|
|
37
39
|
const pills = [a.draft.lane ? `<span class="bd-pill">Suggest: ${esc(cap(a.draft.lane))}</span>` : '', a.draft.anchor ? `<span class="bd-pill">${esc(krShort(a.draft.anchor))}</span>` : '', a.close ? `<span class="bd-pill w">Close to: ${esc(a.close.title)}</span>` : ''].join('');
|
|
38
40
|
const prior = (a.prior || []).length ? `<p class="bd-warn sm">Close to something you declined: “${esc(a.prior[0].title)}”.</p>` : '';
|
|
@@ -42,11 +44,11 @@ function askCard(a, i, phone) {
|
|
|
42
44
|
+ `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="decline-go" data-id="${esc(a.id)}">Decline</button><button type="button" class="bd-btn sm ghost" data-askact="back">Back</button><span class="bd-amut bd-push">The reason is kept with the ask</span></div></div>`;
|
|
43
45
|
}
|
|
44
46
|
const btns = phone
|
|
45
|
-
? `<button type="button" class="bd-btn solid wide" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage())}</button><div class="bd-arow two">${a.close ? `<button type="button" class="bd-btn" data-askact="add" data-id="${esc(a.id)}">Add to existing</button>` : ''}<button type="button" class="bd-btn ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`
|
|
46
|
-
: `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage())}</button>${a.close ? `<button type="button" class="bd-btn sm" data-askact="add" data-id="${esc(a.id)}">Add to ${esc(a.close.title)}</button>` : ''}<button type="button" class="bd-btn sm ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`;
|
|
47
|
+
? `<button type="button" class="bd-btn solid wide" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage(a))}</button><div class="bd-arow two">${a.close ? `<button type="button" class="bd-btn" data-askact="add" data-id="${esc(a.id)}">Add to existing</button>` : ''}<button type="button" class="bd-btn ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`
|
|
48
|
+
: `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage(a))}</button>${a.close ? `<button type="button" class="bd-btn sm" data-askact="add" data-id="${esc(a.id)}">Add to ${esc(a.close.title)}</button>` : ''}<button type="button" class="bd-btn sm ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`;
|
|
47
49
|
return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}${pills ? `<div class="bd-pills">${pills}</div>` : ''}${prior}${btns}<p class="bd-amsg" role="status"></p></div>`;
|
|
48
50
|
}
|
|
49
|
-
const firstStage = () => (M().board.stages || [])[0] || 'Triage';
|
|
51
|
+
const firstStage = (a) => (a && a.stages && a.stages[0]) || (M().board.stages || [])[0] || 'Triage';
|
|
50
52
|
function unsureHtml(L) {
|
|
51
53
|
if (!L.length) return '';
|
|
52
54
|
return `<div class="bd-unsure"><p class="bd-lbl">Not sure which product · ${L.length}</p>${L.map((a) => `<div class="bd-un1"><p class="sm">${esc(a.by || 'Someone')}${a.source ? ' by ' + esc(a.source.toLowerCase()) : ''}: “${esc(a.line)}”</p><p class="bd-amut">Could be ${a.products.map((p) => esc(p.name) + (p.why ? ' (' + esc(p.why) + ')' : '')).join(' or ')}.</p><div class="bd-chips">${a.products.map((p) => `<button type="button" class="bd-chip" data-pickprod="${esc(a.id)}" data-prod="${esc(p.id)}">${esc(p.name)}</button>`).join('')}</div></div>`).join('')}<p class="bd-amut bd-hr">PMOS picks the product from where the ask came from and what it talks about. When both point the same way, it shows the product with its reason. When they disagree, it asks you.</p></div>`;
|
|
@@ -57,7 +59,7 @@ function asksHtml() {
|
|
|
57
59
|
if (M().asks == null || M().asks.missing) return '<p class="bd-h3">New asks</p><p class="bd-amut">The new asks could not be read, so none is shown.</p>';
|
|
58
60
|
const sure = L.filter((a) => !(a.products || []).length || picked[a.id]), unsure = L.filter((a) => (a.products || []).length && !picked[a.id]);
|
|
59
61
|
const src = [...new Set(L.map((a) => a.source).filter(Boolean))];
|
|
60
|
-
const head = `<div class="bd-phead"><p class="bd-h3" id="hAsks">${L.length} new ${L.length === 1 ? 'ask' : 'asks'}</p>${src.length ? `<span class="bd-amut"
|
|
62
|
+
const head = `<div class="bd-phead"><p class="bd-h3" id="hAsks">${L.length} new ${L.length === 1 ? 'ask' : 'asks'}</p>${src.length ? `<span class="bd-amut">${M().board.all ? 'Across products' : 'For ' + esc(M().board.name || 'this board')} · from ${esc(src.slice(0, 3).join(', ').toLowerCase())}</span>` : ''}</div>`;
|
|
61
63
|
if (!L.length) return head + '<p class="bd-amut">No new ask waits for triage.</p>';
|
|
62
64
|
return head + `<div class="bd-acards">${sure.map((a, i) => askCard(a, i, phone)).join('')}</div>` + unsureHtml(unsure);
|
|
63
65
|
}
|
|
@@ -70,11 +72,12 @@ async function acceptAsk(a, btn) {
|
|
|
70
72
|
const d = a.draft || {};
|
|
71
73
|
if (!d.anchor) { Pop.close(false); openNew(null, a); return; } // no anchor yet: the New initiative panel asks for one
|
|
72
74
|
btn.disabled = true;
|
|
73
|
-
const
|
|
75
|
+
const B = boardOfAsk(a);
|
|
76
|
+
const r = await post('/api/boards/asks/accept', { ws: B.ws, board: B.board, ask: a.id, title: d.title, lane: d.lane || 'feature', anchor: d.anchor, intent: a.line.slice(0, 400) }).catch(() => null);
|
|
74
77
|
if (!r || !r.ok) { btn.disabled = false; const m = btn.closest('.bd-acard').querySelector('.bd-amsg'); if (m) m.textContent = errOf(r); return; }
|
|
75
78
|
Pop.close(false);
|
|
76
79
|
const id = r.initiative && r.initiative.id;
|
|
77
|
-
A.say('Accepted to ' + (r.stage || firstStage()) + ' · ' + d.title, id ? async () => { const u = await post('/api/boards/archive', { board:
|
|
80
|
+
A.say('Accepted to ' + (r.stage || firstStage(a)) + ' · ' + d.title, id ? async () => { const u = await post('/api/boards/archive', { ws: B.ws, board: B.board, id, archived: true, reason: 'Accepted by mistake: undone' }).catch(() => null); A.say(u && u.ok ? d.title + ' is undone. It is archived, and nothing else changed.' : errOf(u)); await A.load(); } : null);
|
|
78
81
|
await A.load();
|
|
79
82
|
}
|
|
80
83
|
document.addEventListener('click', async (e) => {
|
|
@@ -84,7 +87,9 @@ document.addEventListener('click', async (e) => {
|
|
|
84
87
|
const pp = e.target.closest('[data-pickprod]');
|
|
85
88
|
if (pp) {
|
|
86
89
|
const a = asksOf().find((x) => x.id === pp.dataset.pickprod), p = a && a.products.find((x) => x.id === pp.dataset.prod); if (!p) return;
|
|
87
|
-
|
|
90
|
+
const there = M().board.all ? (M().board.products || []).find((x) => x.id === p.id || x.name === p.name) : null; // All products holds every product's board
|
|
91
|
+
if (there) { picked[a.id] = { name: there.name, why: 'you chose it', ws: there.ws, id: there.id }; redrawAsks(); }
|
|
92
|
+
else if (p.name === M().board.name || p.id === M().board.id) { picked[a.id] = { name: p.name, why: 'you chose it' }; redrawAsks(); }
|
|
88
93
|
else A.say('Open the ' + p.name + ' Board to accept it there. This Board holds only ' + (M().board.name || 'its own') + ' work.');
|
|
89
94
|
return;
|
|
90
95
|
}
|
|
@@ -99,7 +104,8 @@ document.addEventListener('click', async (e) => {
|
|
|
99
104
|
if (k === 'add') why = 'Added to ' + a.close.title + ' (' + a.close.id + ')';
|
|
100
105
|
else { const c = Pop.el().querySelector('[data-whynot].on'), t = (card.querySelector('input[name="why"]') || {}).value || ''; why = ((c && c.dataset.whynot) || 'Other') + (t.trim() ? ': ' + t.trim().replace(/\s+/g, ' ') : ''); }
|
|
101
106
|
b.disabled = true;
|
|
102
|
-
const
|
|
107
|
+
const B = boardOfAsk(a);
|
|
108
|
+
const r = await post('/api/boards/asks/decline', { ws: B.ws, board: B.board, ask: a.id, why }).catch(() => null);
|
|
103
109
|
if (!r || !r.ok) { b.disabled = false; if (m) m.textContent = errOf(r); return; }
|
|
104
110
|
declining = null; Pop.close(false);
|
|
105
111
|
A.say(k === 'add' ? 'Added to ' + a.close.title + '. The ask is kept with the reason.' : 'Ask declined. The reason is kept in the board ledger.');
|
|
@@ -129,6 +135,25 @@ function closeOf(text) {
|
|
|
129
135
|
for (const r of M().initiatives.list.rows) { const have = sig(r.title), n = [...have].filter((w) => want.has(w)).length; if (have.size && (n >= 2 || (n >= 1 && n / have.size >= 0.5)) && (!best || n > best.n)) best = { n, r }; }
|
|
130
136
|
return best ? { key: best.r.key, title: best.r.title, stage: (best.r.track && best.r.track.label) || best.r.stage } : null;
|
|
131
137
|
}
|
|
138
|
+
/** The product of a new initiative: this board's, read-only; with All products (PgBoard) a choice of every product that takes new work. */
|
|
139
|
+
const products = () => (M().board.products || []).filter((p) => !p.self);
|
|
140
|
+
function productField(ask) {
|
|
141
|
+
if (!M().board.all) return `<div class="bd-field"><span class="bd-flbl">Product</span><span class="bd-inp ro">${esc(M().board.name || 'This board')}</span></div>`;
|
|
142
|
+
const P = products(), at = ask && ask.ws ? ask.ws : '';
|
|
143
|
+
return `<label class="bd-field">Product<select class="bd-inp" name="product"${ask ? ' disabled' : ''}>${P.length > 1 && !at ? '<option value="">Choose the product</option>' : ''}${P.map((p) => `<option value="${esc(p.ws)}"${p.ws === at || P.length === 1 ? ' selected' : ''}>${esc(p.name)}</option>`).join('')}</select></label>`;
|
|
144
|
+
}
|
|
145
|
+
/** The board a new initiative goes to: the product picked in the form, or this board. */
|
|
146
|
+
function boardOfForm(f) {
|
|
147
|
+
if (!M().board.all) return { ws: M().board.ws, board: M().board.id };
|
|
148
|
+
const ws = N && N.ask && N.ask.ws ? N.ask.ws : f.elements.product ? f.elements.product.value : '';
|
|
149
|
+
const p = products().find((x) => x.ws === ws); return p ? { ws: p.ws, board: p.id, stages: p.stages } : null;
|
|
150
|
+
}
|
|
151
|
+
async function fillAnchors(ws, board, want) {
|
|
152
|
+
const L = await A.anchors(ws, board), w = $('#anW'); if (!w) return;
|
|
153
|
+
w.innerHTML = L && L.length ? `<select class="bd-inp" name="anchor"><option value="">Choose a goal or a health budget</option>${L.map((x) => `<option value="${esc(x.value)}"${x.value === want ? ' selected' : ''}>${esc(x.label || x.value)}</option>`).join('')}</select>`
|
|
154
|
+
: `<input class="bd-inp" name="anchor" maxlength="120" value="${esc(want || '')}" placeholder="A KR id or health:<budget>">`;
|
|
155
|
+
}
|
|
156
|
+
document.addEventListener('change', (e) => { if (N && e.target.matches('form[data-form="new2"] select[name="product"]')) { const B = boardOfForm(e.target.form); if (B) fillAnchors(B.ws, B.board, ''); } });
|
|
132
157
|
export async function openNew(from, ask) {
|
|
133
158
|
const d = ask ? ask.draft || {} : {};
|
|
134
159
|
N = { ask: ask || null, links: [], files: [], lean: d.lane || null, prior: ask ? ask.prior || [] : [], ack: false, close: null };
|
|
@@ -140,13 +165,13 @@ export async function openNew(from, ask) {
|
|
|
140
165
|
+ `<div class="bd-linkin" id="nwLink" hidden><input class="bd-inp sm" name="link" maxlength="600" placeholder="https://" aria-label="A link"><button type="button" class="bd-btn sm" data-newact="addlink">Add</button></div><p class="bd-amut">Drop files here. PMOS reads them before it asks you anything.</p></div>`
|
|
141
166
|
+ `<div class="bd-box sm" id="nwKind">${kindBox()}</div>`
|
|
142
167
|
+ `<label class="bd-field">Counts toward<span id="anW"><select class="bd-inp" name="anchor" disabled><option>Reading the goals</option></select></span><span class="bd-amut">A goal, or a health budget for upkeep work.</span></label>`
|
|
143
|
-
+
|
|
168
|
+
+ productField(ask)
|
|
144
169
|
+ `<div id="nwHints">${hintsHtml()}</div><p class="bd-amsg" id="formM" role="status"></p>`
|
|
145
|
-
+ `<div class="bd-arow bd-pfoot"><button type="submit" class="bd-btn solid">${ask ? 'Accept and start ' : 'Create and start '}${esc(firstStage())}</button><span class="bd-amut">PMOS asks a few questions next</span></div></form>`;
|
|
170
|
+
+ `<div class="bd-arow bd-pfoot"><button type="submit" class="bd-btn solid">${ask ? 'Accept and start ' : 'Create and start '}${esc(firstStage(ask))}</button><span class="bd-amut">PMOS asks a few questions next</span></div></form>`;
|
|
146
171
|
A.panel(`<div class="pk-h"><div class="pk-ht"><h2 id="pkTitle">${ask ? 'Accept ask' : 'New initiative'}</h2></div><div class="pk-tools"><button type="button" class="bd-ib" data-pk="close" aria-label="Close" title="Close">${SV(I.x)}</button></div></div><div class="pk-b bd-pl">${body}</div>`, from, 'pk-new');
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
172
|
+
// All products: the goals of the product picked (an ask's own product, or the only one); none picked yet, the field waits for it
|
|
173
|
+
const f0 = document.querySelector('form[data-form="new2"]'), B = f0 ? boardOfForm(f0) : null;
|
|
174
|
+
if (B) await fillAnchors(B.ws, B.board, d.anchor); else { const w = $('#anW'); if (w) w.innerHTML = '<select class="bd-inp" name="anchor" disabled><option>Choose the product first</option></select>'; }
|
|
150
175
|
if (d.title) lean(d.title);
|
|
151
176
|
}
|
|
152
177
|
let leanT = null;
|
|
@@ -194,16 +219,18 @@ document.addEventListener('submit', async (e) => {
|
|
|
194
219
|
const m = $('#formM'), go = f.querySelector('[type="submit"]'), val = (n) => (f.elements[n] ? String(f.elements[n].value || '').trim() : '');
|
|
195
220
|
const title = val('title'), why = val('why').replace(/\s+/g, ' ').slice(0, 400), anchor = val('anchor'), askId = f.dataset.ask || null;
|
|
196
221
|
if (!title) { m.textContent = 'Give it a name.'; f.title.focus(); return; }
|
|
222
|
+
const B = boardOfForm(f);
|
|
223
|
+
if (!B) { m.textContent = 'Choose the product it is for.'; return; }
|
|
197
224
|
if (!anchor) { m.textContent = 'Choose what it counts toward. Unanchored work is rejected.'; return; }
|
|
198
225
|
go.disabled = true; m.textContent = '';
|
|
199
226
|
let ask = askId;
|
|
200
|
-
if (!ask) { const r0 = await post('/api/boards/asks/add', { board:
|
|
201
|
-
const res = await post('/api/boards/asks/accept', { board:
|
|
227
|
+
if (!ask) { const r0 = await post('/api/boards/asks/add', { ws: B.ws, board: B.board, line: title, source: 'New initiative, typed by you' }).catch(() => null); if (!r0 || r0.ok !== true) { go.disabled = false; m.textContent = errOf(r0); return; } ask = r0.ask && r0.ask.id; }
|
|
228
|
+
const res = await post('/api/boards/asks/accept', { ws: B.ws, board: B.board, ask, title, lane: N.lean || 'feature', anchor, ...(why ? { intent: why } : {}) }).catch(() => null);
|
|
202
229
|
if (!res || res.ok !== true) { go.disabled = false; m.textContent = errOf(res); return; }
|
|
203
|
-
const id = res.initiative && res.initiative.id, stage = res.stage || firstStage();
|
|
230
|
+
const id = res.initiative && res.initiative.id, stage = res.stage || firstStage(B);
|
|
204
231
|
if (id) {
|
|
205
|
-
await post('/api/board-grill/start', { id, why, links: N.links }).catch(() => null);
|
|
206
|
-
for (const file of N.files) { if (file.size > 4 * 1024 * 1024) continue; await post('/api/board-grill/file', { id, name: file.name, type: file.type, data: await b64(file) }).catch(() => null); }
|
|
232
|
+
await post('/api/board-grill/start', { ws: B.ws, id, why, links: N.links }).catch(() => null);
|
|
233
|
+
for (const file of N.files) { if (file.size > 4 * 1024 * 1024) continue; await post('/api/board-grill/file', { ws: B.ws, id, name: file.name, type: file.type, data: await b64(file) }).catch(() => null); }
|
|
207
234
|
}
|
|
208
235
|
N = null;
|
|
209
236
|
A.say('“' + title + '” is ' + (askId ? 'accepted' : 'created') + ' in ' + stage + ', anchored to ' + anchor + '.');
|
|
@@ -211,9 +238,48 @@ document.addEventListener('submit', async (e) => {
|
|
|
211
238
|
if (id) openGrill(id, title, stage, true); else A.close();
|
|
212
239
|
});
|
|
213
240
|
|
|
241
|
+
/* ── New program (PgBoard's "New program or initiative") ─────────────────────────────────────────────────────────── */
|
|
242
|
+
/** The menu under New (PgBoard): New initiative, or New program. A program is a PMOS record (POST /api/programs/save); its products, state
|
|
243
|
+
* and stage spread come from the initiatives that join it, so the form asks only its name, what it is for and its target. */
|
|
244
|
+
export function openNewMenu(btn) {
|
|
245
|
+
Pop.open(`<button type="button" class="bd-mi" data-newmenu="ini">${SV(I.file)}<span>New initiative</span></button><button type="button" class="bd-mi" data-newmenu="prog"><span class="bd-pti s" aria-hidden="true">${SV('M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5')}</span><span>New program</span><span class="k">spans products</span></button>`, btn, { label: 'New', width: 260, align: 'right', cls: 'bd-newm' });
|
|
246
|
+
}
|
|
247
|
+
function openNewProgram(from) {
|
|
248
|
+
const ws = M().board.all ? ((products()[0] || {}).ws || '') : M().board.ws;
|
|
249
|
+
const body = `<form class="bd-form bd-new" data-form="newprog" data-ws="${esc(ws || '')}" novalidate>`
|
|
250
|
+
+ `<label class="bd-field">Name<input class="bd-inp" name="title" maxlength="120" placeholder="For example: Project Ascent" autocomplete="off"></label>`
|
|
251
|
+
+ `<label class="bd-field">What it is for<textarea class="bd-inp ta" name="goal" rows="2" maxlength="400" placeholder="The outcome its initiatives add up to"></textarea></label>`
|
|
252
|
+
+ `<label class="bd-field">Target<input class="bd-inp" type="date" name="target"><span class="bd-amut">Optional. A program can run longer than any one initiative.</span></label>`
|
|
253
|
+
+ `<p class="bd-amsg" id="formM" role="status"></p><div class="bd-arow bd-pfoot"><button type="submit" class="bd-btn solid">Create program</button><span class="bd-amut">Then move initiatives into it from its panel</span></div></form>`;
|
|
254
|
+
A.panel(`<div class="pk-h"><div class="pk-ht"><h2 id="pkTitle">New program</h2></div><div class="pk-tools"><button type="button" class="bd-ib" data-pk="close" aria-label="Close" title="Close">${SV(I.x)}</button></div></div><div class="pk-b bd-pl">${body}</div>`, from, 'pk-new');
|
|
255
|
+
const i = document.querySelector('form[data-form="newprog"] input[name="title"]'); if (i) i.focus();
|
|
256
|
+
}
|
|
257
|
+
document.addEventListener('click', (e) => {
|
|
258
|
+
const b = e.target.closest('[data-newmenu]'); if (!b || !A || !Pop.isOpen() || !Pop.el().contains(b)) return;
|
|
259
|
+
const from = $('#newIni'); Pop.close(false);
|
|
260
|
+
if (b.dataset.newmenu === 'prog') openNewProgram(from); else openNew(from);
|
|
261
|
+
});
|
|
262
|
+
document.addEventListener('submit', async (e) => {
|
|
263
|
+
const f = e.target.closest('form[data-form="newprog"]'); if (!f || !A) return;
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
const m = $('#formM'), go = f.querySelector('[type="submit"]'), val = (n) => String(f.elements[n].value || '').trim();
|
|
266
|
+
const title = val('title'), goal = val('goal').replace(/\s+/g, ' '), target = val('target');
|
|
267
|
+
if (!title) { m.textContent = 'Give the program a name.'; f.elements.title.focus(); return; }
|
|
268
|
+
const same = (A.programs() || []).find((p) => !p.archived && String(p.title).toLowerCase() === title.toLowerCase());
|
|
269
|
+
if (same) { m.textContent = 'A program named ' + same.title + ' exists already.'; return; }
|
|
270
|
+
go.disabled = true; m.textContent = '';
|
|
271
|
+
const r = await pmPost('/api/programs/save', { ws: f.dataset.ws || null, program: { title, ...(goal ? { goal } : {}), ...(target ? { target } : {}) } }).catch(() => null);
|
|
272
|
+
if (!r || !r.ok) { go.disabled = false; m.textContent = errOf(r); return; }
|
|
273
|
+
A.close(); A.say('Program ' + title + ' is created. Move initiatives into it from its panel.');
|
|
274
|
+
await A.reloadPrograms();
|
|
275
|
+
if (r.program && r.program.id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id: r.program.id } }));
|
|
276
|
+
});
|
|
277
|
+
|
|
214
278
|
/* ── the first questions (BdGrill) ─────────────────────────────────────────────────────────────────────────────── */
|
|
215
279
|
let Q = null; // { id, title, stage, fresh, data, at }
|
|
216
|
-
|
|
280
|
+
/** The workspace an initiative belongs to: its own product's with All products picked, else this board's. */
|
|
281
|
+
const wsOf = (id) => { const r = (M().rows || []).find((x) => x.id === id && x.ws); return r ? r.ws : M().board.ws; };
|
|
282
|
+
const gget = async (id) => { try { const r = await (await fetch('/api/board-grill?ws=' + encodeURIComponent(wsOf(id) || '') + '&id=' + encodeURIComponent(id), { credentials: 'same-origin' })).json(); return r && r.ok ? r : null; } catch { return null; } };
|
|
217
283
|
function grillHtml() {
|
|
218
284
|
const g = Q.data, qs = g ? g.questions : [], cur = qs[Q.at] || null, open = qs.filter((x) => !x.answer).length;
|
|
219
285
|
const took = g && g.summary.took.length ? g.summary.took : ['Nothing yet: no Why and no material were given.'];
|
|
@@ -227,35 +293,50 @@ function grillHtml() {
|
|
|
227
293
|
+ (qs.length ? `<div class="bd-qhd"><b>${qs.length} ${qs.length === 1 ? 'question' : 'questions'} before the BRD</b><span class="bd-amut">Only what the material does not answer</span></div>${qs.map(card).join('')}` : '<p class="bd-amut">Nothing is left to ask: the BRD can start from what you gave.</p>')
|
|
228
294
|
+ `<p class="bd-amsg" id="grM" role="status"></p><div class="bd-arow bd-pfoot">${qs.length ? `<button type="button" class="bd-btn solid" data-grill="next">${last ? 'Done' : 'Next question'}</button>` : ''}<button type="button" class="bd-btn ghost" data-grill="later">Later</button><span class="bd-amut bd-push">${open ? 'Later keeps them as the next step' : 'Every question is answered'}</span></div></div>`;
|
|
229
295
|
}
|
|
296
|
+
/** The questions in the Viewer's shell (premium-board.js actsPanel): the shell's Close (×, Escape) is the same as Later. */
|
|
297
|
+
const grillPanel = (from) => A.panel(grillHtml(), from || null, 'pk-new', { onClose: () => { later(); } });
|
|
230
298
|
export async function openGrill(id, title, stage, fresh, from) {
|
|
231
299
|
Q = { id, title, stage, fresh: !!fresh, data: null, at: 0 };
|
|
232
|
-
|
|
300
|
+
grillPanel(from);
|
|
233
301
|
const g = await gget(id); if (!Q || Q.id !== id) return;
|
|
234
302
|
Q.data = g; Q.at = Math.max(0, g ? g.questions.findIndex((x) => !x.answer) : 0);
|
|
235
|
-
|
|
303
|
+
grillPanel();
|
|
236
304
|
}
|
|
237
305
|
async function saveCur() {
|
|
238
306
|
const cur = Q.data && Q.data.questions[Q.at]; if (!cur) return true;
|
|
239
|
-
const box = document.querySelector('#
|
|
307
|
+
const box = document.querySelector('#czViewer .bd-qc.on'); if (!box) return true;
|
|
240
308
|
const typed = (box.querySelector('input[name="qa"]') || {}).value || '', chip = box.querySelector('[data-qchip].on');
|
|
241
309
|
const answer = typed.trim() || (chip ? chip.dataset.qchip : '');
|
|
242
310
|
if (answer === (cur.answer || '')) return true;
|
|
243
|
-
const r = await post('/api/board-grill/answer', { id: Q.id, q: cur.key, answer }).catch(() => null);
|
|
311
|
+
const r = await post('/api/board-grill/answer', { ws: wsOf(Q.id), id: Q.id, q: cur.key, answer }).catch(() => null);
|
|
244
312
|
if (!r || !r.ok) { $('#grM').textContent = errOf(r); return false; }
|
|
245
313
|
Q.data = r; return true;
|
|
246
314
|
}
|
|
247
315
|
document.addEventListener('click', async (e) => {
|
|
248
|
-
if (!Q || !e.target.closest('#
|
|
249
|
-
const c = e.target.closest('[data-qchip]'); if (c) { $$('#
|
|
250
|
-
const go = e.target.closest('[data-qgo]'); if (go) { if (await saveCur()) { Q.at = +go.dataset.qgo;
|
|
316
|
+
if (!Q || !e.target.closest('#czViewer')) return;
|
|
317
|
+
const c = e.target.closest('[data-qchip]'); if (c) { $$('#czViewer [data-qchip]').forEach((x) => { const on = x === c && !x.classList.contains('on'); x.classList.toggle('on', on); x.setAttribute('aria-checked', String(on)); }); return; }
|
|
318
|
+
const go = e.target.closest('[data-qgo]'); if (go) { if (await saveCur()) { Q.at = +go.dataset.qgo; grillPanel(); } return; }
|
|
251
319
|
const b = e.target.closest('[data-grill]'); if (!b) return;
|
|
252
320
|
if (!(await saveCur())) return;
|
|
253
321
|
const open = Q.data ? Q.data.questions.filter((x) => !x.answer).length : 0, title = Q.title;
|
|
254
|
-
if (b.dataset.grill === 'next' && Q.at < ((Q.data && Q.data.questions.length) || 0) - 1) { Q.at++;
|
|
255
|
-
if (b.dataset.grill === 'later' && open) await post('/api/board-grill/later', { id: Q.id }).catch(() => null);
|
|
322
|
+
if (b.dataset.grill === 'next' && Q.at < ((Q.data && Q.data.questions.length) || 0) - 1) { Q.at++; grillPanel(); const i = $('#czViewer .bd-qc.on input'); if (i) i.focus(); return; }
|
|
323
|
+
if (b.dataset.grill === 'later' && open) await post('/api/board-grill/later', { ws: wsOf(Q.id), id: Q.id }).catch(() => null);
|
|
256
324
|
Q = null; A.close();
|
|
257
325
|
A.say(open ? 'Kept as the next step of ' + title + ': ' + open + ' open ' + (open === 1 ? 'question' : 'questions') + '.' : 'The answers are kept on ' + title + ' for its BRD.');
|
|
258
326
|
A.load();
|
|
259
327
|
});
|
|
328
|
+
/** The shell closed the questions while they showed: the answer typed is kept, and the open ones stay as the next step, as Later does. */
|
|
329
|
+
async function later() {
|
|
330
|
+
if (!Q) return;
|
|
331
|
+
const q = Q, cur = q.data && q.data.questions[q.at], box = document.querySelector('#czViewer .bd-qc.on');
|
|
332
|
+
const typed = box ? ((box.querySelector('input[name="qa"]') || {}).value || '').trim() || ((box.querySelector('[data-qchip].on') || {}).dataset || {}).qchip || '' : '';
|
|
333
|
+
Q = null;
|
|
334
|
+
let data = q.data;
|
|
335
|
+
if (cur && typed && typed !== (cur.answer || '')) { const r = await post('/api/board-grill/answer', { ws: wsOf(q.id), id: q.id, q: cur.key, answer: typed }).catch(() => null); if (r && r.ok) data = r; }
|
|
336
|
+
const open = data ? data.questions.filter((x) => !x.answer).length : 0;
|
|
337
|
+
if (open) await post('/api/board-grill/later', { ws: wsOf(q.id), id: q.id }).catch(() => null);
|
|
338
|
+
A.say(open ? 'Kept as the next step of ' + q.title + ': ' + open + ' open ' + (open === 1 ? 'question' : 'questions') + '.' : 'The answers are kept on ' + q.title + ' for its BRD.');
|
|
339
|
+
A.load();
|
|
340
|
+
}
|
|
260
341
|
export const grillOpen = () => !!Q;
|
|
261
342
|
export function dropGrill() { Q = null; N = null; }
|