create-pmos 0.420.0 → 0.422.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 -25
- 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/scripts/anchor-resolve.js +93 -15
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +59 -3
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/report-api/draft.json +2 -1
- package/workspace/guide/briefing-premium.md +2 -1
- package/workspace/guide/home.md +6 -2
- package/workspace/guide/programs.md +4 -3
- package/workspace/home-other-product-test.js +55 -0
- package/workspace/lib/board-premium.js +18 -4
- package/workspace/lib/briefing-premium-agent.js +8 -0
- package/workspace/lib/doc-live-root.js +37 -0
- package/workspace/lib/engine/anchor-resolve.js +93 -15
- package/workspace/lib/engine/boards.js +7 -2
- package/workspace/lib/engine/intake.js +1 -1
- package/workspace/lib/first-input.js +13 -6
- package/workspace/lib/hold-spans.js +24 -10
- package/workspace/lib/kg.js +1 -1
- package/workspace/lib/report-draft.js +3 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-premium.js +6 -0
- package/workspace/lib/routes-boards.js +48 -9
- package/workspace/lib/routes-doc-sheet.js +29 -1
- package/workspace/lib/routes-programs.js +44 -5
- package/workspace/lib/routes-task-plans.js +333 -0
- package/workspace/lib/task-cli.js +16 -9
- package/workspace/lib/task-items.js +1 -1
- package/workspace/lib/task-plans.js +232 -0
- package/workspace/lib/transcript-read.js +29 -1
- package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
- package/workspace/lib/vendor/scripts/intake.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-viewer-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +26 -3
- package/workspace/program-leave-test.js +203 -0
- package/workspace/public/pm/bd-acts.js +5 -2
- package/workspace/public/pm/bd-ini-panel.js +20 -7
- package/workspace/public/pm/bd-prog-panel.js +22 -7
- package/workspace/public/pm/bd-span.js +177 -24
- package/workspace/public/pm/cozy-board.css +80 -0
- package/workspace/public/pm/cozy-home.css +3 -0
- package/workspace/public/pm/cozy-live-pill.js +1 -1
- package/workspace/public/pm/cozy-nav.js +1 -1
- package/workspace/public/pm/cozy-steps.js +1 -1
- package/workspace/public/pm/cozy-xv.js +1 -1
- package/workspace/public/pm/doc-follow.js +36 -0
- package/workspace/public/pm/home-app.js +38 -7
- package/workspace/public/pm/home-ask.js +7 -0
- package/workspace/public/pm/home-ini.js +13 -4
- package/workspace/public/pm/home-line.js +1 -1
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-today.js +3 -1
- package/workspace/public/pm/ini-tasks.js +81 -16
- package/workspace/public/pm/ini-versions.js +343 -0
- package/workspace/public/pm/ini-view-model.js +27 -41
- package/workspace/public/pm/ini-view.css +82 -0
- package/workspace/public/pm/ini-view.js +18 -11
- package/workspace/public/pm/premium-board.js +109 -18
- package/workspace/public/pm/premium-insights.js +1 -1
- package/workspace/public/pm/premium-mtg-present.js +2 -2
- package/workspace/public/pm/premium-report-read.js +21 -2
- package/workspace/public/pm/premium-report-tab.js +1 -1
- package/workspace/public/pm/premium-shell.js +29 -4
- package/workspace/public/pm/premium-viewer.js +3 -3
- package/workspace/public/pm/premium-vw-doc.js +46 -11
- package/workspace/public/pm/premium-vw-mtg.js +1 -1
- package/workspace/public/pm/premium-vw-open.js +1 -1
- package/workspace/public/pm/premium-vw-slides.js +1 -1
- package/workspace/public/pm/prog-move.js +69 -0
- package/workspace/public/pm/prog-order.js +1 -1
- package/workspace/public/pm/task-card.css +3 -0
- package/workspace/public/pm/task-card.js +10 -3
- package/workspace/public/pm/tk-send.js +1 -1
- package/workspace/server.js +26 -2
- package/workspace/task-milestones-test.js +176 -0
- package/workspace/task-plans-test.js +175 -0
- package/workspace/task-views-test.js +2 -2
- package/workspace/test-lists/program-leave.json +6 -0
- package/workspace/test-lists/task-milestones.json +6 -0
- package/workspace/test-lists/task-plans.json +6 -0
- package/workspace/test-lists/viewer-live-file.json +9 -0
- package/workspace/timeline-holds-test.js +70 -5
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Serves the real Home from the real server (premium-agreed-design: the initiative is a layout of Home, ?ini=<id>) and opens its PRD from the
|
|
5
5
|
* initiative's Files group; the document opens as its page in the cozy Viewer (#czViewer), one item at a time, so "a tab" is now "the card". The /api/doc-sheet routes are answered by a
|
|
6
6
|
* small stateful stand-in, so each press can be read off the request the page sent. The routes' own behaviour is in briefing-premium-doc-edit.test.js.
|
|
7
|
-
* D1 the page · D2 edit in place · D3 Markdown · D4 an agent's edit · D5 Undo all · D6 ask · D7 the sheet reads again · D8 floors
|
|
7
|
+
* D1 the page · D2 edit in place · D3 Markdown · D4 an agent's edit · D5 Undo all · D6 ask · D7 the sheet reads again · D8 floors
|
|
8
|
+
* D10 the page follows the file: a chat's edit shows with no refresh, from the initiative's worktree, and an unsaved edit is never replaced */
|
|
8
9
|
const path = require('path');
|
|
9
10
|
const { spawn } = require('child_process');
|
|
10
11
|
const { findBrowser } = require('./lib/find-browser');
|
|
@@ -47,10 +48,10 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
|
|
|
47
48
|
await T.waitForServer(BASE);
|
|
48
49
|
browser = await chromium.launch({ executablePath: exe });
|
|
49
50
|
|
|
50
|
-
const open = async ({ w = 1280, h = 900, theme = 'light', props = [], post = null } = {}) => {
|
|
51
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', props = [], post = null, live = false } = {}) => {
|
|
51
52
|
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
52
53
|
const page = await ctx.newPage();
|
|
53
|
-
const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }], props, ask: null, errors: [], posts: [], gets: [], links: [] };
|
|
54
|
+
const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z', after_hash: 'h1' }], hash: 'h1', ws: 'w1', props, ask: null, errors: [], posts: [], gets: [], links: [] };
|
|
54
55
|
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
55
56
|
await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(F.facts()), as_of: F.NOW }) }));
|
|
56
57
|
await page.route('**/api/doc-health/check', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, health: { passed: 1, total: 1, checks: [{ id: 'fresh', pass: true, reason: 'ok' }] } }) }));
|
|
@@ -66,6 +67,7 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
|
|
|
66
67
|
if (route === 'at') return send({ ok: true, path: PATH, rev: S.revs.length, text: S.text });
|
|
67
68
|
if (route === 'proposals') return send({ ok: true, path: PATH, proposals: S.props });
|
|
68
69
|
if (route === 'ask') return send(S.ask || { ok: true, id: 'ask-1', state: 'working' });
|
|
70
|
+
if (route === 'stamp' && live) return send({ ok: true, path: PATH, ws: S.ws, hash: S.hash });
|
|
69
71
|
return send({ ok: false, error: 'not in this test' }, 404);
|
|
70
72
|
}
|
|
71
73
|
const body = JSON.parse(rq.postData() || '{}'); S.posts.push({ route, query: u.search, body });
|
|
@@ -198,6 +200,27 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
|
|
|
198
200
|
ok('0 no page error', C.S.errors.length === 0, C.S.errors.join(' | '));
|
|
199
201
|
await C.ctx.close();
|
|
200
202
|
}
|
|
203
|
+
/* D10 the page follows the file (feedback batch 11 item 1): the stand-in's stamp is the file's hash; a chat's write is a new hash and a new revision */
|
|
204
|
+
{
|
|
205
|
+
const L = await open({ live: true }); const q = L.page;
|
|
206
|
+
const write = (text, hash, ws) => { L.S.text = text; L.S.hash = hash; if (ws) L.S.ws = ws; L.S.revs.push({ rev: L.S.revs.length + 1, why: 'changed outside the sheet', by: 'baseline', via: 'outside', at: '2026-10-26T08:00:00Z', after_hash: hash }); };
|
|
207
|
+
await until(() => L.S.gets.some((g) => g.route === 'stamp'));
|
|
208
|
+
const st = L.S.gets.find((g) => g.route === 'stamp');
|
|
209
|
+
ok('D10 the page asks which copy is live with its workspace and its initiative', /ws=w1/.test(st.query) && /ini=self-serve-v2/.test(st.query), st.query);
|
|
210
|
+
write(TEXT.replace('A partner waits for a person.', 'A partner waits for a person. The chat wrote this line.'), 'h2', 'w2');
|
|
211
|
+
ok('D10 a chat\'s edit shows within a few seconds, with no refresh and no commit', !!(await until(() => q.evaluate((v) => /The chat wrote this line/.test((document.querySelector(v + ' .cfb') || {}).textContent || ''), V), 8000)));
|
|
212
|
+
ok('D10 the copy in the initiative\'s worktree is read there: the page reads with the workspace the stamp named', L.S.gets.some((g) => g.route === 'at' && /ws=w2/.test(g.query)) && L.S.gets.filter((g) => g.route === 'stamp').every((g) => /ws=w1/.test(g.query)));
|
|
213
|
+
await q.click(V + ' [data-vd="mode:edit"]');
|
|
214
|
+
await until(() => q.evaluate((v) => !!document.querySelector(v + ' .cfb[contenteditable="true"]'), V));
|
|
215
|
+
await q.evaluate((v) => { const b = document.querySelector(v + ' .cfb'); const pp = [...b.querySelectorAll('p')].find((x) => /The chat wrote this line/.test(x.textContent)); pp.textContent = pp.textContent + ' I typed this.'; }, V);
|
|
216
|
+
const nAt = L.S.gets.filter((g) => g.route === 'at').length;
|
|
217
|
+
write(TEXT.replace('A partner waits for a person.', 'A second chat edit.'), 'h3');
|
|
218
|
+
ok('D10 while you edit, a change says the file changed and keeps what you typed', !!(await until(() => q.evaluate((v) => /The chat changed this file while you were editing/.test((document.querySelector(v + ' #vwErr') || {}).textContent || ''), V), 8000)) && /I typed this/.test(await txt(q, V + ' .cfb')) && L.S.gets.filter((g) => g.route === 'at').length === nAt);
|
|
219
|
+
await q.click(V + ' [data-vd="cancel"]');
|
|
220
|
+
ok('D10 Cancel shows the new text', !!(await until(() => q.evaluate((v) => /A second chat edit/.test((document.querySelector(v + ' .cfb') || {}).textContent || ''), V), 8000)));
|
|
221
|
+
ok('0 no page error', L.S.errors.length === 0, L.S.errors.join(' | '));
|
|
222
|
+
await L.ctx.close();
|
|
223
|
+
}
|
|
201
224
|
/* D8 floors */
|
|
202
225
|
for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
|
|
203
226
|
const R = await open({ w, h, theme, props: [prop()] });
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* program-leave-test.js — move an initiative out of its program, or to another, on the Board and on Home (feedback batch 11 item 2, option A
|
|
4
|
+
* agreed 2026-10-26; canvas LpA1More, LpA2Other, LpA3Done, LpA4Phone, LpA5PhoneDone). Serves the real pages from the real server. The program
|
|
5
|
+
* routes are answered here by lib/routes-programs.js itself, over two temp workspaces seeded with Project Ascent's ledgers
|
|
6
|
+
* (fixtures/program-ascent.js) and a second program, Partner identity, so a reload reads back what the press wrote.
|
|
7
|
+
* B Board: ⋯ of an initiative in the program holds Move out of it and Move to another program (no Turn into a program); Move out is one press,
|
|
8
|
+
* the toast says where it went and the milestone it left, with Undo; the row shows under its product, still selected; Undo puts it back in
|
|
9
|
+
* its place; Move to another program lists the other program with its count; a phone's ⋯ holds the same items
|
|
10
|
+
* H Home: the initiative page's ⋯ holds the same two items; an initiative in no program keeps Turn into a program and has neither */
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const os = require('os');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { Readable } = require('stream');
|
|
15
|
+
const { spawn } = require('child_process');
|
|
16
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
17
|
+
const T = require('./test-run').configure({ name: 'program-leave' });
|
|
18
|
+
const BP = require('./lib/board-premium.js');
|
|
19
|
+
const F = require('./fixtures/board-premium-facts.js');
|
|
20
|
+
const B = require('./lib/briefing-premium.js');
|
|
21
|
+
const HF = require('./fixtures/briefing-premium-facts.js');
|
|
22
|
+
const A = require('./fixtures/program-ascent.js');
|
|
23
|
+
const IP = require('./lib/initiative-premium.js');
|
|
24
|
+
const IF = require('./fixtures/initiative-premium-facts.js');
|
|
25
|
+
const R = require('./lib/routes-programs.js');
|
|
26
|
+
const P = require('./lib/programs.js');
|
|
27
|
+
|
|
28
|
+
const BASE = T.BASE;
|
|
29
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
30
|
+
const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
31
|
+
const results = [];
|
|
32
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
33
|
+
let srv = null; let browser = null; let root = null;
|
|
34
|
+
const finish = async (code) => {
|
|
35
|
+
if (browser) await browser.close().catch(() => {});
|
|
36
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
37
|
+
T.killTmux();
|
|
38
|
+
if (root) fs.rmSync(root, { recursive: true, force: true });
|
|
39
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
40
|
+
console.log(`\n${results.length - bad}/${results.length} program-leave assertions passed`);
|
|
41
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
42
|
+
};
|
|
43
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
44
|
+
|
|
45
|
+
/* the program routes, over temp workspaces: seed() writes the fixture's ledgers again before each page */
|
|
46
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'program-leave-'));
|
|
47
|
+
const W = { idpf: { id: 'idpf', root: path.join(root, 'idpf') }, microsites: { id: 'microsites', root: path.join(root, 'microsites') } };
|
|
48
|
+
const stateOf = (w) => { const d = path.join(w.root, 'pmos', 'state'); fs.mkdirSync(d, { recursive: true }); return d; };
|
|
49
|
+
const rctx = { getWs: (id) => (id == null ? W.idpf : W[id] || null), workspaceList: () => Object.values(W), stateDirFor: (w) => stateOf(w),
|
|
50
|
+
json: (res, obj, code) => { res.code = code || 200; res.body = obj; },
|
|
51
|
+
readJson: async (req) => { try { return { ok: true, body: JSON.parse(req.raw || '{}') }; } catch { return { ok: false }; } } };
|
|
52
|
+
function seed() {
|
|
53
|
+
for (const { ws, lines } of A.ledgers()) {
|
|
54
|
+
const extra = ws === 'idpf' ? [P.validProgram({ title: 'Partner identity' }), { kind: 'member', program: 'partner-identity', initiative: 'usage-billing' }] : [];
|
|
55
|
+
fs.writeFileSync(path.join(stateOf(W[ws]), 'programs.jsonl'), [...lines, ...extra].map((l) => JSON.stringify(l)).join('\n') + '\n');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const posts = [];
|
|
59
|
+
const routePrograms = async (page) => {
|
|
60
|
+
await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs: R.all(rctx) }) }));
|
|
61
|
+
await page.route('**/api/programs/*', async (r) => {
|
|
62
|
+
const url = new URL(r.request().url()), raw = r.request().postData() || '';
|
|
63
|
+
posts.push({ path: url.pathname, body: JSON.parse(raw || '{}') });
|
|
64
|
+
const req = Object.assign(Readable.from([]), { method: 'POST', headers: { origin: 'http://127.0.0.1:1', host: '127.0.0.1:1' }, raw });
|
|
65
|
+
const res = {};
|
|
66
|
+
await R.handle(req, res, new URL('http://127.0.0.1:1' + url.pathname), rctx);
|
|
67
|
+
r.fulfill({ status: res.code || 200, contentType: 'application/json', body: JSON.stringify(res.body) });
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const members = () => (R.all(rctx).find((p) => p.id === 'project-ascent') || { members: [] }).members.map((m) => m.initiative);
|
|
71
|
+
const waitsOf = (id) => ((R.all(rctx).find((p) => p.id === 'project-ascent') || { milestones: [] }).milestones.find((m) => m.id === id) || {}).waits || [];
|
|
72
|
+
|
|
73
|
+
(async () => {
|
|
74
|
+
const exe = findBrowser();
|
|
75
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
76
|
+
let chromium;
|
|
77
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
78
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
79
|
+
await T.waitForServer(BASE);
|
|
80
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
81
|
+
|
|
82
|
+
const board = async (o = {}) => {
|
|
83
|
+
seed();
|
|
84
|
+
const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 } });
|
|
85
|
+
const page = await ctx.newPage();
|
|
86
|
+
const errors = [];
|
|
87
|
+
page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
|
|
88
|
+
await page.clock.setFixedTime(new Date(F.NOW));
|
|
89
|
+
await page.route('**/api/board-premium*', (r) => { const q = new URL(r.request().url()).searchParams; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.programFacts(q.get('ws') || 'idpf')), as_of: Date.now() }) }); });
|
|
90
|
+
await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
|
|
91
|
+
await routePrograms(page);
|
|
92
|
+
await page.addInitScript(() => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); localStorage.setItem('pmos.board.view', 'track'); localStorage.setItem('pmos.board.pview', 'track'); localStorage.setItem('pmos.board.grouping', 'program'); } } catch { /* none */ } });
|
|
93
|
+
await page.goto(BASE + '/premium-board.html?ws=idpf&board=idpf');
|
|
94
|
+
await page.waitForSelector('#ibBody [data-key]', { timeout: 15000 });
|
|
95
|
+
await page.waitForTimeout(700);
|
|
96
|
+
return { ctx, page, errors };
|
|
97
|
+
};
|
|
98
|
+
const menu = async (p) => { await p.click('#czViewer [data-cz-vw="more"]'); await p.waitForTimeout(80); return p.evaluate(() => [...document.querySelectorAll('.cz-vw-menu [role="menuitem"]')].map((b) => b.textContent.trim())); };
|
|
99
|
+
const kids = (p) => p.evaluate(() => [...document.querySelectorAll('#ibBody [data-po-list] [data-po-id]')].map((r) => r.dataset.poId));
|
|
100
|
+
const toast = (p) => p.evaluate(() => { const t = document.querySelector('#bdToast'); return t && !t.hidden ? t.textContent : ''; });
|
|
101
|
+
|
|
102
|
+
/* B — the Board's initiative panel */
|
|
103
|
+
{
|
|
104
|
+
const { ctx, page: p, errors } = await board();
|
|
105
|
+
await p.click('#ibBody .bt-kid .bt-nm >> text=Legacy IdP sunset');
|
|
106
|
+
await p.waitForSelector('#czViewer:not([hidden])');
|
|
107
|
+
const m = await menu(p);
|
|
108
|
+
ok('B ⋯ of an initiative in a program: Move out of it and Move to another program, after the plan dates; no Turn into a program',
|
|
109
|
+
m.includes('Move out of Project Ascent') && m.some((x) => /^Move to another program/.test(x)) && !m.includes('Turn into a program') && m.indexOf('Move out of Project Ascent') > m.indexOf('Change the plan dates'), JSON.stringify(m));
|
|
110
|
+
ok('B the two items carry their icons', await p.evaluate(() => [...document.querySelectorAll('.cz-vw-menu [role="menuitem"]')].filter((b) => /^Move (out|to another)/.test(b.textContent.trim())).every((b) => !!b.querySelector('svg'))));
|
|
111
|
+
if (process.env.SHOTS) await p.screenshot({ path: process.env.SHOTS + '/board-more.png' });
|
|
112
|
+
const n0 = posts.length;
|
|
113
|
+
await p.click('.cz-vw-menu [role="menuitem"] >> text=Move out of Project Ascent');
|
|
114
|
+
await until(async () => !(await kids(p)).includes('legacy-idp-sunset'));
|
|
115
|
+
const t = await toast(p);
|
|
116
|
+
ok('B Move out is one press: one leave, no confirm; the toast says where it went and the milestone it left, with Undo',
|
|
117
|
+
posts.length === n0 + 1 && posts[n0].body.leave === true && /Moved out of Project Ascent · now under IDPF · off 1 milestone/.test(t) && /Undo/.test(t), JSON.stringify({ t, posts: posts.slice(n0) }));
|
|
118
|
+
ok('B the program no longer has it, and Legacy IdP off no longer waits on it', !members().includes('legacy-idp-sunset') && !waitsOf('legacy-idp-off').includes('legacy-idp-sunset'), JSON.stringify({ m: members(), w: waitsOf('legacy-idp-off') }));
|
|
119
|
+
const after = await until(() => p.evaluate(() => { const r = [...document.querySelectorAll('#ibBody [data-key]')].find((x) => /Legacy IdP sunset/.test(x.textContent) && !x.closest('[data-po-list]')); const v = document.querySelector('#czViewer'); return r ? { sel: r.classList.contains('sel') || !!r.querySelector('.sel'), open: !!v && !v.hidden && /Legacy IdP sunset/.test(v.textContent) } : null; }));
|
|
120
|
+
ok('B the row shows under its product, and the panel stays on it', !!after && after.open, JSON.stringify(after));
|
|
121
|
+
if (process.env.SHOTS) await p.screenshot({ path: process.env.SHOTS + '/board-done.png' });
|
|
122
|
+
await p.click('#bdToast .bd-undo');
|
|
123
|
+
await until(async () => (await kids(p)).includes('legacy-idp-sunset'));
|
|
124
|
+
ok('B Undo rejoins it with the milestone back, in its old place', members().includes('legacy-idp-sunset') && waitsOf('legacy-idp-off').includes('legacy-idp-sunset') && (await kids(p)).includes('legacy-idp-sunset') && posts[posts.length - 1].body.back.length === 1, JSON.stringify({ k: await kids(p), last: posts[posts.length - 1] }));
|
|
125
|
+
// Move to another program
|
|
126
|
+
await p.click('#ibBody .bt-kid .bt-nm >> text=Legacy IdP sunset');
|
|
127
|
+
await p.waitForSelector('#czViewer:not([hidden])');
|
|
128
|
+
await menu(p);
|
|
129
|
+
await p.click('.cz-vw-menu [role="menuitem"] >> text=Move to another program');
|
|
130
|
+
const list = await until(() => p.evaluate(() => { const h = document.querySelector('#bdPop'); return h && !h.hidden ? [...h.querySelectorAll('[data-pm-to]')].map((b) => b.textContent.trim()) : null; }));
|
|
131
|
+
ok('B Move to another program lists the other open program, with its count', !!list && list.length === 1 && /Partner identity/.test(list[0]) && /1 initiative/.test(list[0]), JSON.stringify(list));
|
|
132
|
+
if (process.env.SHOTS) await p.screenshot({ path: process.env.SHOTS + '/board-other.png' });
|
|
133
|
+
await p.click('#bdPop [data-pm-to="0"]');
|
|
134
|
+
await until(async () => !(await kids(p)).includes('legacy-idp-sunset'));
|
|
135
|
+
ok('B the move lands in Partner identity; the toast says so with Undo', /Moved to Partner identity · off 1 milestone/.test(await toast(p)) && (R.all(rctx).find((x) => x.id === 'partner-identity').members.some((m) => m.initiative === 'legacy-idp-sunset')), await toast(p));
|
|
136
|
+
await p.click('#bdToast .bd-undo');
|
|
137
|
+
await until(() => members().includes('legacy-idp-sunset'));
|
|
138
|
+
ok('B Undo of a move to another program brings it back to Project Ascent', members().includes('legacy-idp-sunset') && !R.all(rctx).find((x) => x.id === 'partner-identity').members.some((m) => m.initiative === 'legacy-idp-sunset'));
|
|
139
|
+
ok('B no page error', !errors.length, errors.join(' | '));
|
|
140
|
+
await ctx.close();
|
|
141
|
+
}
|
|
142
|
+
{
|
|
143
|
+
const { ctx, page: p, errors } = await board({ w: 390, h: 844 });
|
|
144
|
+
const row = p.locator('#ibBody .bt-nm >> text=Legacy IdP sunset').first();
|
|
145
|
+
await row.click();
|
|
146
|
+
await p.waitForSelector('#czViewer:not([hidden])');
|
|
147
|
+
const m = await menu(p);
|
|
148
|
+
ok('B phone: the ⋯ sheet holds the same two items', m.includes('Move out of Project Ascent') && m.some((x) => /^Move to another program/.test(x)), JSON.stringify(m));
|
|
149
|
+
await p.click('.cz-vw-menu [role="menuitem"] >> text=Move out of Project Ascent');
|
|
150
|
+
const t = await until(() => toast(p));
|
|
151
|
+
ok('B phone: the toast is short: where it is now and the milestone it left', /^Now under IDPF · off 1 milestone/.test(t), t);
|
|
152
|
+
if (process.env.SHOTS) await p.screenshot({ path: process.env.SHOTS + '/board-phone-done.png' });
|
|
153
|
+
ok('B phone: no page error', !errors.length, errors.join(' | '));
|
|
154
|
+
await ctx.close();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* H — Home's initiative page */
|
|
158
|
+
const home = async () => {
|
|
159
|
+
seed();
|
|
160
|
+
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
|
161
|
+
const page = await ctx.newPage();
|
|
162
|
+
const errors = [];
|
|
163
|
+
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
164
|
+
const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
|
|
165
|
+
await page.route(/\/api\/briefing-premium(\?.*)?$/, json({ ok: true, state: 'ready', model: B.build(HF.facts()), as_of: Date.now() }));
|
|
166
|
+
await page.route('**/api/briefing-premium/thread**', json({ ok: true, turns: [], working: false }));
|
|
167
|
+
await page.route('**/api/board-premium*', (r) => { const q = new URL(r.request().url()).searchParams; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.programFacts(q.get('ws') || 'idpf')), as_of: Date.now() }) }); });
|
|
168
|
+
await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
|
|
169
|
+
// the initiative's own read (its page's ⋯ needs it): the fixture's model, named after the initiative asked for
|
|
170
|
+
await page.route('**/api/initiative-premium*', (r) => { const id = new URL(r.request().url()).searchParams.get('id') || ''; const m = IP.build(IF.facts()); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: { ...m, id, title: id }, as_of: Date.now() }) }); });
|
|
171
|
+
await routePrograms(page);
|
|
172
|
+
const am = new Date(); am.setHours(10, 0, 0, 0); await page.clock.setFixedTime(am);
|
|
173
|
+
await page.goto(BASE + '/premium.html?theme=light');
|
|
174
|
+
await until(() => page.evaluate(() => !!document.querySelector('#hmList .hv-g.prg [data-po-id]')), 20000);
|
|
175
|
+
return { ctx, page, errors };
|
|
176
|
+
};
|
|
177
|
+
{
|
|
178
|
+
const { ctx, page: p, errors } = await home();
|
|
179
|
+
const goPage = async (id) => {
|
|
180
|
+
await p.goto(BASE + '/premium.html?theme=light&ini=' + id);
|
|
181
|
+
return until(() => p.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden && !!v.querySelector('[data-cz-vw="more"]'); }), 15000);
|
|
182
|
+
};
|
|
183
|
+
ok('H the initiative page opens', await goPage('legacy-idp-sunset'));
|
|
184
|
+
const m = await menu(p);
|
|
185
|
+
ok('H the page\'s ⋯ holds Move out of Project Ascent and Move to another program; no Turn into a program', m.includes('Move out of Project Ascent') && m.some((x) => /^Move to another program/.test(x)) && !m.includes('Turn into a program'), JSON.stringify(m));
|
|
186
|
+
if (process.env.SHOTS) await p.screenshot({ path: process.env.SHOTS + '/home-more.png' });
|
|
187
|
+
await p.click('.cz-vw-menu [role="menuitem"] >> text=Move to another program');
|
|
188
|
+
const list = await until(() => p.evaluate(() => { const h = document.querySelector('.hi-pop.menu'); return h ? [...h.querySelectorAll('[data-hi-mi]')].map((b) => b.textContent.trim()) : null; }));
|
|
189
|
+
ok('H Move to another program lists Partner identity', !!list && list.length === 1 && /Partner identity/.test(list[0]), JSON.stringify(list));
|
|
190
|
+
await p.keyboard.press('Escape');
|
|
191
|
+
await menu(p);
|
|
192
|
+
await p.click('.cz-vw-menu [role="menuitem"] >> text=Move out of Project Ascent');
|
|
193
|
+
const t = await until(() => p.evaluate(() => { const el = document.querySelector('#toast'); return el && el.classList.contains('on') ? el.textContent : ''; }));
|
|
194
|
+
ok('H Move out: the toast says where it went, with Undo; the program lets it go', /Moved out of Project Ascent · now under .+ · off 1 milestone/.test(t) && /Undo/.test(t) && !members().includes('legacy-idp-sunset'), t);
|
|
195
|
+
await p.click('#toast .undo');
|
|
196
|
+
await until(() => members().includes('legacy-idp-sunset'));
|
|
197
|
+
ok('H Undo puts it back, with the milestone', members().includes('legacy-idp-sunset') && waitsOf('legacy-idp-off').includes('legacy-idp-sunset'));
|
|
198
|
+
ok('H an initiative in no program keeps Turn into a program and has no Move items', await goPage('eshop-inline-login') && await (async () => { const m2 = await menu(p); return m2.includes('Turn into a program') && !m2.some((x) => /^Move (out|to another)/.test(x)); })());
|
|
199
|
+
ok('H no page error', !errors.length, errors.join(' | '));
|
|
200
|
+
await ctx.close();
|
|
201
|
+
}
|
|
202
|
+
finish();
|
|
203
|
+
})();
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* and its text (GET /api/doc). Add a document POST /api/custom-docs/add; Draft it POST /api/core-docs/draft.
|
|
17
17
|
* Metrics, Notifications the board's measures (GET /api/board-metrics-premium) and what waits on you here
|
|
18
18
|
* Nothing here invents a value: what a record does not hold is not drawn. */
|
|
19
|
+
import { followDoc } from './doc-follow.js';
|
|
19
20
|
import { pmPost } from './http.js';
|
|
20
21
|
import { $, $$, esc } from './premium-shell.js';
|
|
21
22
|
import * as Pop from './bd-pop.js';
|
|
@@ -297,8 +298,10 @@ async function openDocPanel(id, from) {
|
|
|
297
298
|
A.redraw();
|
|
298
299
|
if (x.path) {
|
|
299
300
|
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>'; }
|
|
300
|
-
|
|
301
|
-
const el = $('#cdText');
|
|
301
|
+
// the text follows the file: a chat's edit shows within a few seconds, uncommitted, from the initiative's worktree (pm/doc-follow.js)
|
|
302
|
+
const shown = () => { const el = $('#cdText'); return !!el && el.isConnected && docOpen === id; };
|
|
303
|
+
followDoc({ ws: x.ws || M().board.ws || '', ini: x.src === 'ini' && x.ini ? x.ini.id : '', path: x.path, alive: shown,
|
|
304
|
+
onText: (t) => { const el = $('#cdText'); if (el && docOpen === id) el.textContent = t == null ? x.path + ' could not be read.' : t; } });
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
/** A board document by its key; with All products, by its key and its product's workspace (two products can hold the same key). */
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* questions, usual(track) the usual days in the step, rowOf(key), pageHref(r), askHref(r, q), refreshJira(), send(r) the
|
|
6
6
|
* Send to Jira sheet, acts(r, btn) the row actions popover, grillOpen(r, btn), onShow(key, from) / onHide() so the page
|
|
7
7
|
* marks the row the item came from, programOf(r) the program it is in or null, openProgram(id, btn), turnProgram(r)
|
|
8
|
-
* "Turn into a program", setTask(r, uid, state) a task's state, setDates(r, uid, { start?, due? }) its days (the Tasks
|
|
8
|
+
* "Turn into a program", moveItems(r) Move out of its program and Move to another (pm/prog-move.js), setTask(r, uid, state) a task's state, setDates(r, uid, { start?, due? }) its days (the Tasks
|
|
9
9
|
* views' quick changes, batch 9 item 5b), addTask(r, title) a new task (POST /api/boards/tasks/add),
|
|
10
|
-
* openTask(r, task) the task's own editor, viewDoc(path)
|
|
10
|
+
* openTask(r, task) the task's own editor, viewDoc(path), reload() a new read of the Board and toast(text, undo?) (planned
|
|
11
|
+
* versus actual, pm/ini-versions.js) }
|
|
11
12
|
* openIni(r, from) the initiative: the ONE view (pm/ini-view.js from pm/ini-view-model.js, feedback batch 6 item 1; canvas OvIniA), the
|
|
12
13
|
* same as Home's initiative page: the summary card, the stage card with its dates line (it replaced the Plan card, item 3),
|
|
13
14
|
* Tasks as the WBS, then Documents and Linked. What the Board adds under them: drafted tickets and the PRD drift.
|
|
@@ -20,6 +21,7 @@ import * as VW from './cozy-viewer.js';
|
|
|
20
21
|
import { esc } from './premium-shell.js';
|
|
21
22
|
import { lr, copyText } from './cozy-xv.js';
|
|
22
23
|
import { iniView } from './ini-view-model.js';
|
|
24
|
+
import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
|
|
23
25
|
import { viewHtml, wireView } from './ini-view.js';
|
|
24
26
|
import * as TV from './tk-view.js';
|
|
25
27
|
|
|
@@ -27,6 +29,7 @@ let O = null;
|
|
|
27
29
|
let cur = null; // { key, tk } the initiative shown, and its ticket while the drill-in is shown
|
|
28
30
|
let adding = null; // the key of the initiative whose inline Add a task is open
|
|
29
31
|
let addTo = ''; // the stage a task added there finishes (the Board's Next cell: "Add what finishes <stage>")
|
|
32
|
+
let addDates = null; // the start and due a task added there takes (a gap's + on the timeline, batch 11 item 13)
|
|
30
33
|
const TI = (r) => (r && r.trail) || null;
|
|
31
34
|
const tkState = (k) => (k.blocked ? 'Blocked' + (k.reason ? ' by ' + k.reason.replace(/^Waiting on /i, '') : '') : k.status || 'To do');
|
|
32
35
|
const jiraAt = () => { const J = (O.M() && O.M().jira) || {}; return J.readAt ? 'Jira · ' + O.ago(J.readAt) : ''; };
|
|
@@ -35,7 +38,7 @@ const jiraAt = () => { const J = (O.M() && O.M().jira) || {}; return J.readAt ?
|
|
|
35
38
|
/** The view's model for a row: the same function Home's page calls, with what only the Board's model holds (its eight steps, its day). */
|
|
36
39
|
export function viewOf(r) {
|
|
37
40
|
const M = O.M() || {}, p = O.programOf ? O.programOf(r) : null, u = O.usual ? O.usual(r.track || {}) : null;
|
|
38
|
-
return iniView(r, { steps: M.steps || [], today: M.today, usual: u, grill: r.id ? O.grill(r.id) : null, program: p ? { id: p.id, title: p.title } : null, jiraAt: jiraAt() });
|
|
41
|
+
return iniView(rowFor(r), { steps: M.steps || [], today: M.today, usual: u, grill: r.id ? O.grill(r.id) : null, program: p ? { id: p.id, title: p.title } : null, jiraAt: jiraAt() });
|
|
39
42
|
}
|
|
40
43
|
function draftedHtml(d, g) {
|
|
41
44
|
return d.slice(0, 8).map((x) => lr({ mk: x.waiting ? 'you' : '', title: (x.id ? `<em>${esc(x.id)}</em> ` : '') + esc(x.summary || ''), sub: 'not in Jira' })).join('')
|
|
@@ -61,6 +64,9 @@ function iniMore(r) {
|
|
|
61
64
|
if (r.id) more.push({ label: 'Change the plan dates', on: () => location.assign(O.askHref(r, 'Propose new start and end dates for ' + r.title)) });
|
|
62
65
|
// P7 (program-hierarchy PRD): an initiative in no program can become one; the chat cannot, because every program write is a page press
|
|
63
66
|
if (r.id && O.turnProgram && !(O.programOf && O.programOf(r))) more.push({ label: 'Turn into a program', on: () => O.turnProgram(r) });
|
|
67
|
+
// an initiative in a program can move out of it, or to another one (feedback batch 11 item 2, canvas LpA1More, LpA2Other; pm/prog-move.js)
|
|
68
|
+
const mv = r.id && O.moveItems ? O.moveItems(r) : [];
|
|
69
|
+
if (mv.length) more.push({ sep: true }, ...mv);
|
|
64
70
|
if ((O.M() || {}).jira) more.push({ sep: true }, { label: 'Read Jira again', on: () => O.refreshJira() });
|
|
65
71
|
more.push({ sep: true });
|
|
66
72
|
if (r.id) more.push({ label: 'Copy link', on: () => copyText(new URL(O.pageHref(r), location.href).href, 'Link copied.') });
|
|
@@ -77,22 +83,29 @@ function iniText(r) {
|
|
|
77
83
|
return lines.join('\n');
|
|
78
84
|
}
|
|
79
85
|
function iniBody(r) {
|
|
80
|
-
|
|
86
|
+
const md = (v) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+v.slice(5, 7) - 1] + ' ' + +v.slice(8, 10);
|
|
87
|
+
return viewHtml(viewOf(r), { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), tail: VW.czSections(boardSections(r), { key: 'board' }) });
|
|
81
88
|
}
|
|
82
89
|
/** Presses inside the shown item: the view's own (pm/ini-view.js), a ticket's drill-in, the PRD-change question. A [data-doc] goes to the page's handler. */
|
|
83
90
|
function wire(body, key) {
|
|
84
91
|
const redraw = () => { const r = O.rowOf(key); if (!r || (cur && cur.tk)) return; const top = body.scrollTop; body.innerHTML = iniBody(r); body.scrollTop = top; };
|
|
85
92
|
wireView(body, {
|
|
93
|
+
// planned versus actual (batch 11 item 8, pm/ini-versions.js): where a draft's writes go, the read after Make live, the toast with Undo
|
|
94
|
+
where: () => { const r = O.rowOf(key), M = O.M() || {}; return { ws: (r && r.ws) || (M.board && M.board.ws), board: (r && r.boardId) || (M.board && M.board.id) }; },
|
|
95
|
+
reload: () => (O.reload ? O.reload() : null),
|
|
96
|
+
toast: (m, undo) => (O.toast ? O.toast(m, undo) : null),
|
|
86
97
|
check: (uid, b) => { const r = O.rowOf(key), k = r && (r.tasks || []).find((x) => x.uid === uid); if (r && O.setTask) O.setTask(r, uid, k && k.status === 'Done' ? 'To do' : 'Done'); },
|
|
87
98
|
// the quick changes (batch 9 item 5b): the status caret, the date press and a Timeline or Kanban drag, each with Undo in the toast
|
|
88
99
|
status: (uid, state) => { const r = O.rowOf(key); if (r && O.setTask) O.setTask(r, uid, state); },
|
|
89
100
|
dates: (uid, patch) => { const r = O.rowOf(key); if (r && O.setDates) O.setDates(r, uid, patch); },
|
|
101
|
+
// the ◇ in the status picker (batch 11 item 3): a task made a milestone, or made a plain task again, with Undo
|
|
102
|
+
milestone: (uid, on) => { const r = O.rowOf(key); if (r && O.setDates) O.setDates(r, uid, { milestone: !!on }); },
|
|
90
103
|
openTicket: (tk) => { const r = O.rowOf(key), k = r && ((r.track && r.track.tickets) || []).find((x) => x.key === tk); if (k) openTicket(r, k); },
|
|
91
104
|
// a task's title opens the one task editor (task-card.js) as a drill-in: ← comes back to the initiative (batch 9 item 5a)
|
|
92
105
|
openTask: (uid) => { const r = O.rowOf(key), k = r && (r.tasks || []).find((x) => x.uid === uid); if (k && O.openTask) { VW.drill(); O.openTask(r, k); } },
|
|
93
106
|
add: () => { adding = key; redraw(); const f = body.querySelector('#ivAddTask'); if (f) f.focus(); },
|
|
94
|
-
addCancel: () => { adding = null; addTo = ''; redraw(); },
|
|
95
|
-
addTask: async (title, inp) => { const r = O.rowOf(key); if (!r || !O.addTask) return; inp.disabled = true; const ok = await O.addTask(r, title, addTo); inp.disabled = false; if (ok) { inp.value = ''; inp.focus(); } },
|
|
107
|
+
addCancel: () => { adding = null; addTo = ''; addDates = null; redraw(); },
|
|
108
|
+
addTask: async (title, inp) => { const r = O.rowOf(key); if (!r || !O.addTask) return; inp.disabled = true; const ok = await O.addTask(r, title, addTo, addDates); inp.disabled = false; if (ok) { inp.value = ''; inp.focus(); } },
|
|
96
109
|
primary: (act, b) => {
|
|
97
110
|
const r = O.rowOf(key); if (!r) return;
|
|
98
111
|
if (act === 'grill') O.grillOpen(r, b);
|
|
@@ -117,7 +130,7 @@ function wire(body, key) {
|
|
|
117
130
|
export const vidOf = (r) => (r.id ? String(r.id) : 'bd:' + r.key);
|
|
118
131
|
export function openIni(r, from, o = {}) {
|
|
119
132
|
if (!O || !r || !r.track) return;
|
|
120
|
-
adding = o.addTo != null ? r.key : null; addTo = o.addTo || '';
|
|
133
|
+
adding = o.addTo != null ? r.key : null; addTo = o.addTo || ''; addDates = o.addDates || null;
|
|
121
134
|
// a row with no record id has no chat of its own: its question goes to the board's chat
|
|
122
135
|
VW.open({ kind: 'Initiative', title: r.title, icon: 'flag', id: vidOf(r), url: r.id ? O.pageHref(r) : '', full: true,
|
|
123
136
|
discuss: r.id ? true : () => location.assign(O.askHref(r, '')), more: iniMore(r), rename: O.rename ? O.rename(r) : null,
|
|
@@ -71,12 +71,17 @@ function rowsOf(ws) {
|
|
|
71
71
|
return a && a !== 'reading' ? { name: a.name, rows: shape(a.rows) } : null;
|
|
72
72
|
}
|
|
73
73
|
/** Reads the board of each product of the program that is not this one, once per page load; the panel draws again when one arrives. */
|
|
74
|
+
const TRIES = new Map(); // ws → reads tried this page load
|
|
74
75
|
function readAway(p) {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
// the program's own product too: its initiatives are the ones Move an initiative in offers (moreOf)
|
|
77
|
+
const wss = [...new Set([p && p.home, ...((p && p.members) || []).map((m) => m.ws)])];
|
|
78
|
+
for (const ws of wss) {
|
|
79
|
+
if (!ws || !board().ws || ws === board().ws || AWAY.has(ws)) continue;
|
|
77
80
|
AWAY.set(ws, 'reading');
|
|
78
81
|
fetch('/api/board-premium?ws=' + encodeURIComponent(ws), { credentials: 'same-origin' }).then((r) => r.json()).catch(() => null).then((r) => {
|
|
79
|
-
|
|
82
|
+
// still reading (a cold board answers before its model is ready), or refused: ask again a few times, then the next open asks again,
|
|
83
|
+
// so a member does not stay "not read" until the panel is opened again
|
|
84
|
+
if (!r || !r.ok || !r.model) { AWAY.delete(ws); const n = (TRIES.get(ws) || 0) + 1; TRIES.set(ws, n); if (n < 4 && cur && cur.id === p.id) setTimeout(() => { if (cur && cur.id === p.id) { readAway(p); draw(); } }, 1500 * n); return; }
|
|
80
85
|
AWAY.set(ws, { name: (r.model.board && (r.model.board.product || r.model.board.name)) || ws, board: (r.model.board && r.model.board.id) || ws, rows: r.model.rows || [] });
|
|
81
86
|
if (cur && cur.id === p.id) draw();
|
|
82
87
|
});
|
|
@@ -366,12 +371,22 @@ function draw(keepFocus) {
|
|
|
366
371
|
}
|
|
367
372
|
/** ⋯ in the shell's order: change it (add, move in), look back (the charter), copy, then archive in red, last. */
|
|
368
373
|
function moreOf(p) {
|
|
369
|
-
|
|
374
|
+
// the initiatives that can move in, grouped by product with the PROGRAM's own product first (batch 11 item 11: a pmos-microsites program
|
|
375
|
+
// on Home listed only pmos-idpf initiatives, with no product named). A program spans products, so the others stay, each under its name.
|
|
376
|
+
const M = O.M(), hw = p.home || board().ws || '';
|
|
377
|
+
const taken = new Set(((O.programs()) || []).flatMap((x) => (x.members || []).map((m) => (m.ws || hw) + '|' + m.initiative)));
|
|
370
378
|
// only the open initiatives: a cancelled or archived one moved in would not show in the program
|
|
371
379
|
const gone = new Set(Object.values((M && M.initiatives && M.initiatives.gone) || {}).flat().map((r) => r.key));
|
|
372
|
-
const
|
|
380
|
+
const here = board().ws || '', groups = new Map(); // ws → { name, rows }
|
|
381
|
+
const add = (ws, name, rows) => { const g = groups.get(ws) || { name, rows: [] }; g.rows.push(...rows.filter((r) => r.id && r.track && !gone.has(r.key) && !taken.has(ws + '|' + r.id))); groups.set(ws, g); };
|
|
382
|
+
if (hw && here && hw !== here) { const a = AWAY.get(hw); add(hw, a && a !== 'reading' ? a.name : '', a && a !== 'reading' ? a.rows : []); }
|
|
383
|
+
if (here) add(here, board().product || board().name || '', (M && M.rows) || []);
|
|
384
|
+
else for (const r of (M && M.rows) || []) add(r.ws || '', r.product || r.ws || '', [r]); // All products: each row keeps its own product
|
|
385
|
+
const order = [...groups.keys()].sort((x, y) => (y === hw) - (x === hw));
|
|
386
|
+
const named = order.filter((w) => groups.get(w).rows.length).length > 1;
|
|
387
|
+
const free = order.flatMap((w) => groups.get(w).rows.slice(0, 8).map((r, i) => ({ r, ws: w, head: named && i === 0 ? groups.get(w).name || w : '' })));
|
|
373
388
|
const more = [{ label: 'Add a new initiative', on: () => { VW.close(); const n = document.getElementById('newIni'); if (n) n.click(); } }];
|
|
374
|
-
if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((
|
|
389
|
+
if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((x) => (x.head ? `<p class="bd-mlbl">${esc(x.head)}</p>` : '') + `<button type="button" class="bd-mi" role="menuitem" data-ppjoin="${esc(x.r.id)}" data-ppws="${esc(x.ws)}">${esc(x.r.title)}</button>`).join('')}`, b, { label: 'Move an initiative in', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' }) });
|
|
375
390
|
more.push({ label: 'Add a task to the program', on: () => { adding = true; try { localStorage.setItem('cz-vw-fold:program:tasks', '1'); } catch { /* a private window */ } draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); } });
|
|
376
391
|
more.push({ sep: true }, { label: 'Copy link', on: () => copyText(new URL('/premium-board.html?' + (p.home ? 'ws=' + encodeURIComponent(p.home) + '&' : '') + 'program=' + encodeURIComponent(p.id), location.href).href, 'Link copied.') },
|
|
377
392
|
{ label: 'Copy as text', on: () => copyText(textOf(p), 'Copied as text.') });
|
|
@@ -476,7 +491,7 @@ async function popPress(e) {
|
|
|
476
491
|
const j = e.target.closest('[data-ppjoin]'), x = e.target.closest('[data-pparch]'); if (!j && !x) return;
|
|
477
492
|
const p = cur && progOf(cur.id); Pop.close(true); if (!p) return;
|
|
478
493
|
if (j) {
|
|
479
|
-
const r = await pmPost('/api/programs/member', { ws: board().ws || null, program: p.id, initiative: j.dataset.ppjoin });
|
|
494
|
+
const r = await pmPost('/api/programs/member', { ws: j.dataset.ppws || board().ws || null, program: p.id, initiative: j.dataset.ppjoin });
|
|
480
495
|
if (!r || !r.ok) { O.say((r && r.error) || 'It did not move in. The server did not say why.'); return; }
|
|
481
496
|
O.say('Moved into ' + p.title + '.'); O.reload();
|
|
482
497
|
} else if (x.dataset.pparch === '1') {
|