create-pmos 0.829.0 → 0.831.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 +149 -49
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/changelog.json +148 -22
- package/workspace/guide/agent-capabilities.md +1 -1
- package/workspace/guide/backlog.md +12 -1
- package/workspace/guide/cli.md +20 -1
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/layout.md +3 -0
- package/workspace/lib/anchor-id.js +226 -0
- package/workspace/lib/artefacts-cli.js +25 -1
- package/workspace/lib/code-map.js +8 -2
- package/workspace/lib/factory-floor.js +16 -8
- package/workspace/lib/features.json +14 -13
- package/workspace/lib/initiative-cli.js +67 -2
- package/workspace/lib/lessons-draft.js +242 -0
- package/workspace/lib/people-cli.js +9 -1
- package/workspace/lib/people-prep.js +140 -0
- package/workspace/lib/pmos-verbs.js +2 -0
- package/workspace/lib/prefs-sync.js +1 -1
- package/workspace/lib/print-cli.js +49 -0
- package/workspace/lib/print-pdf.js +96 -0
- package/workspace/lib/review-reasons.js +121 -9
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-c3-strategy.js +2 -1
- package/workspace/lib/routes-proposals.js +2 -2
- package/workspace/lib/routes-report-design.js +3 -1
- package/workspace/lib/routes-skill-map.js +39 -0
- package/workspace/lib/routes-strategy-card.js +13 -6
- package/workspace/lib/skill-map.js +199 -0
- package/workspace/lib/team-cli.js +20 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-keys.js +1 -0
- package/workspace/public/pm/ask-here-ctx.js +25 -1
- package/workspace/public/pm/ask-here.css +7 -0
- package/workspace/public/pm/ask-here.js +15 -2
- package/workspace/public/pm/bd-backlog.css +61 -0
- package/workspace/public/pm/bd-backlog.js +62 -8
- package/workspace/public/pm/bd-work.js +12 -1
- package/workspace/public/pm/card-fold.js +123 -0
- package/workspace/public/pm/code-map.js +15 -4
- package/workspace/public/pm/cozy-board.css +5 -1
- package/workspace/public/pm/cozy-ev.css +7 -0
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-pop-work.js +2 -0
- package/workspace/public/pm/cozy-search.js +2 -2
- package/workspace/public/pm/factory.js +199 -0
- package/workspace/public/pm/pop-cap.js +5 -3
- package/workspace/public/pm/premium-board.js +4 -0
- package/workspace/public/pm/premium-report-read.js +11 -2
- package/workspace/public/pm/print-pdf.js +191 -0
- package/workspace/public/pm/readonly.js +2 -0
- package/workspace/public/pm/review-reasons.js +19 -5
- package/workspace/public/pm/skill-map.js +57 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/anchor-id.json +9 -0
- package/workspace/test-lists/card-fold.json +9 -0
- package/workspace/test-lists/factory-page-ui.json +9 -0
- package/workspace/test-lists/lessons-on-close.json +9 -0
- package/workspace/test-lists/people-prep.json +9 -0
- package/workspace/test-lists/print-pdf.json +9 -0
- package/workspace/test-lists/skill-map.json +9 -0
- package/workspace/test-lists/surface-ask-card.json +9 -0
- package/workspace/test-lists/voice-files.json +9 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/* pm/factory.js — Work › Factory: the stations, and the work they make (initiative factory-page-ui, slice C of the Factory page; boards
|
|
2
|
+
* FxFloor and FxStation on the main canvas; brief /mnt/project-files/factory-page/BRIEF.md, agreed by the PM 2026-11-25).
|
|
3
|
+
* Pure: Node imports it (factory-page-ui.test.js). The page reads only the saved snapshot (GET /api/factory, lib/factory-floor.js), so it
|
|
4
|
+
* opens in 200 ms or less.
|
|
5
|
+
*
|
|
6
|
+
* THE MODEL (keep the two apart): the work is what gets made (goals → initiatives at a stage of their own workflow); the factory is who makes
|
|
7
|
+
* it. PMOS's stations in flow order: Intake, Shape, Plan, Track, Evaluate; then Check (PMOS checking its own work) and You (only what no
|
|
8
|
+
* record can decide).
|
|
9
|
+
*
|
|
10
|
+
* floorModel(products, { now }) → { none, at, lastRun, made, stations: [5 working], you, check, held: { signoffs, drafts, inis }, stale }
|
|
11
|
+
* statusLine(M, { now }) → { alert, text, sub } red only while something is held, and it names who must act
|
|
12
|
+
* goalsModel(rows) → { stages: [names], goals: [{ name, n, segs: [{ stage, n, c }] }] } | null rows: { goal, stage, stages }
|
|
13
|
+
* floorHtml(M, { goals, now }) → the page: status line, five tiles, the You tile, the Check tile, What the factory is making
|
|
14
|
+
* stationHtml(st, { undone }) → the popup body: Waiting (what each item waits on), Made this week (Undo), Cost this week
|
|
15
|
+
* minutesText(n) → "14 min" · "1 h 5 min"
|
|
16
|
+
*
|
|
17
|
+
* The words say PMOS. Every button shows an icon only and carries its aria-label. Zero is silence: a number row of 0 is not drawn, and a
|
|
18
|
+
* station with nothing waiting and nothing made stays grey and silent. Text from records goes through esc(). */
|
|
19
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
20
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
21
|
+
const SV = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
|
|
22
|
+
const IC = {
|
|
23
|
+
intake: 'M4 4h16v6H4zM8 14h8M10 18h4', shape: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5', plan: 'M4 5h16M4 12h10M4 19h6',
|
|
24
|
+
track: 'M3 12h4l3-8 4 16 3-8h4', evaluate: 'M4 20V10M10 20V4M16 20v-7M22 20H2', check: 'M5 12.5l4.5 4.5L19 7', you: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0',
|
|
25
|
+
open: 'M9 6l6 6-6 6', go: 'M5 12h14M13 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', more: 'M7 10l5 5 5-5',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const FLOW = Object.freeze(['intake', 'shape', 'plan', 'track', 'evaluate']);
|
|
29
|
+
export const NAMES = Object.freeze({ intake: 'Intake', shape: 'Shape', plan: 'Plan', track: 'Track', evaluate: 'Evaluate', check: 'Check', you: 'You' });
|
|
30
|
+
export const DOES = Object.freeze({
|
|
31
|
+
intake: 'Asks → initiatives', shape: 'Problem, evidence, PRD', plan: 'Milestones, tasks, owners, dates', track: 'Tracker, follow-ups, slips',
|
|
32
|
+
evaluate: 'Outcome reading, lessons', check: 'PMOS checking its own work', you: 'Sign-offs and calls only a person can make',
|
|
33
|
+
});
|
|
34
|
+
const STALE_MS = 36 * 3600000; // a snapshot older than a day and a half says when it is from
|
|
35
|
+
|
|
36
|
+
export function minutesText(n) {
|
|
37
|
+
const m = Math.max(0, Math.round(Number(n) || 0));
|
|
38
|
+
if (m < 60) return m + ' min';
|
|
39
|
+
return Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '');
|
|
40
|
+
}
|
|
41
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
42
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
43
|
+
const dayOf = (d) => d.getDate() + ' ' + MON[d.getMonth()];
|
|
44
|
+
/** "at 00:09" today, "on 24 Nov at 00:09" another day (the computer's own time). */
|
|
45
|
+
export function whenText(iso, now = Date.now()) {
|
|
46
|
+
const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return '';
|
|
47
|
+
const d = new Date(t), n = new Date(now), hm = pad(d.getHours()) + ':' + pad(d.getMinutes());
|
|
48
|
+
return d.toDateString() === n.toDateString() ? 'at ' + hm : 'on ' + dayOf(d) + ' at ' + hm;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One model over the picked products: numbers add up, items keep their product (ws). */
|
|
52
|
+
export function floorModel(products, { now = Date.now() } = {}) {
|
|
53
|
+
const snaps = (Array.isArray(products) ? products : []).filter((p) => p && p.snapshot && Array.isArray(p.snapshot.stations));
|
|
54
|
+
const st = new Map([...FLOW, 'check', 'you'].map((k) => [k, { key: k, name: NAMES[k], waiting: 0, made: 0, undone: 0, minutes: 0, runs: 0, items: [], madeItems: [] }]));
|
|
55
|
+
let at = null, lastRun = null;
|
|
56
|
+
for (const p of snaps) {
|
|
57
|
+
const s = p.snapshot;
|
|
58
|
+
if (s.at && (!at || s.at > at)) at = s.at;
|
|
59
|
+
if (s.lastRun && (!lastRun || s.lastRun > lastRun)) lastRun = s.lastRun;
|
|
60
|
+
for (const x of s.stations) {
|
|
61
|
+
const m = st.get(x.key); if (!m) continue;
|
|
62
|
+
for (const k of ['waiting', 'made', 'undone', 'minutes', 'runs']) m[k] += Number(x[k]) || 0;
|
|
63
|
+
m.items.push(...(x.items || []).map((i) => ({ ...i, ws: p.ws })));
|
|
64
|
+
m.madeItems.push(...(x.madeItems || []).map((i) => ({ ...i, ws: p.ws })));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const m of st.values()) m.madeItems.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
|
|
68
|
+
const stations = FLOW.map((k) => st.get(k));
|
|
69
|
+
// the red edge: the station that holds the most (the first in flow order on a tie); none while nothing waits
|
|
70
|
+
const top = stations.reduce((b, s) => (s.waiting > (b ? b.waiting : 0) ? s : b), null);
|
|
71
|
+
for (const s of stations) { s.quiet = !s.waiting && !s.made; s.con = !!top && s === top; }
|
|
72
|
+
const you = st.get('you');
|
|
73
|
+
const signoffs = you.items.filter((i) => i.kind === 'signoff');
|
|
74
|
+
const drafts = you.items.filter((i) => i.code === 'pm-open');
|
|
75
|
+
const inis = new Set([...signoffs.map((i) => i.ini && i.ws + '|' + i.ini), ...drafts.filter((i) => i.kind === 'initiative').map((i) => i.ws + '|' + i.id)].filter(Boolean));
|
|
76
|
+
// the snapshot counts open sign-offs past the item cap too: the You station's waiting is the whole number
|
|
77
|
+
const nSign = Math.max(signoffs.length, you.waiting - drafts.length);
|
|
78
|
+
return {
|
|
79
|
+
none: !snaps.length, at, lastRun, stations, you, check: st.get('check'),
|
|
80
|
+
made: stations.reduce((n, s) => n + s.made, 0),
|
|
81
|
+
held: { signoffs: nSign, drafts: drafts.length, inis: inis.size, any: you.waiting > 0 },
|
|
82
|
+
stale: !!at && now - Date.parse(at) > STALE_MS,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The status line: red only while something is held, and then it names who must act (the PM, on Today). */
|
|
87
|
+
export function statusLine(M, { now = Date.now() } = {}) {
|
|
88
|
+
if (!M || M.none) return { alert: false, text: 'The factory has not run here yet. Its numbers show after its first run.', sub: '' };
|
|
89
|
+
const when = whenText(M.lastRun, now);
|
|
90
|
+
const lead = when ? `The factory ran ${when}` : 'The factory did not run this week';
|
|
91
|
+
let text = M.made ? `${lead} and made ${plural(M.made, 'thing', 'things')} this week.` : `${lead}. It made nothing this week.`;
|
|
92
|
+
const H = M.held;
|
|
93
|
+
if (H.any) {
|
|
94
|
+
const parts = [H.signoffs ? plural(H.signoffs, 'sign-off', 'sign-offs') : '', H.drafts ? plural(H.drafts, 'draft', 'drafts') : ''].filter(Boolean).join(' and ');
|
|
95
|
+
const n = H.signoffs + H.drafts;
|
|
96
|
+
text += ` It is waiting on you: ${parts}${H.inis ? ` ${n === 1 ? 'holds' : 'hold'} ${plural(H.inis, 'initiative', 'initiatives')}` : ''}.`;
|
|
97
|
+
}
|
|
98
|
+
const t = Date.parse(M.at || '');
|
|
99
|
+
const sub = M.stale && Number.isFinite(t) ? `These numbers are from ${dayOf(new Date(t))}. The next run brings new ones.` : '';
|
|
100
|
+
return { alert: !!H.any, text, sub };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Initiatives by goal, coloured by stage. Stage order: where each stage stands in its own workflow (the first seen on a tie). */
|
|
104
|
+
export function goalsModel(rows) {
|
|
105
|
+
const R = (Array.isArray(rows) ? rows : []).filter((r) => r && r.stage);
|
|
106
|
+
if (!R.length) return null;
|
|
107
|
+
const pos = new Map();
|
|
108
|
+
for (const r of R) {
|
|
109
|
+
const list = Array.isArray(r.stages) && r.stages.length ? r.stages : [r.stage];
|
|
110
|
+
list.forEach((n, i) => { const p = pos.get(n); if (!p) pos.set(n, { i, first: pos.size }); else if (i < p.i) p.i = i; });
|
|
111
|
+
}
|
|
112
|
+
const stages = [...pos.entries()].sort((a, b) => a[1].i - b[1].i || a[1].first - b[1].first).map(([n]) => n)
|
|
113
|
+
.filter((n) => R.some((r) => r.stage === n));
|
|
114
|
+
const by = new Map();
|
|
115
|
+
for (const r of R) { const g = r.goal || ''; if (!by.has(g)) by.set(g, []); by.get(g).push(r); }
|
|
116
|
+
const goals = [...by.entries()].sort((a, b) => (a[0] ? 0 : 1) - (b[0] ? 0 : 1) || b[1].length - a[1].length || a[0].localeCompare(b[0]))
|
|
117
|
+
.map(([g, list]) => ({ name: g || 'No goal', n: list.length,
|
|
118
|
+
segs: stages.map((s, c) => ({ stage: s, n: list.filter((r) => r.stage === s).length, c })).filter((x) => x.n) }));
|
|
119
|
+
return { stages, goals };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const kv = (label, v) => `<div class="ff-kv"><span>${esc(label)}</span><b>${esc(v)}</b></div>`;
|
|
123
|
+
function tileHtml(s) {
|
|
124
|
+
const rows = s.quiet ? '' : [s.waiting ? kv('Waiting', s.waiting) : '', s.made ? kv('Made this week', s.made) : '',
|
|
125
|
+
s.minutes ? kv('PMOS time', minutesText(s.minutes)) : '', s.undone ? kv('You undid', s.undone) : ''].join('');
|
|
126
|
+
return `<section class="ff-st${s.quiet ? ' quiet' : ''}${s.con ? ' con' : ''}" data-fx-tile="${s.key}" aria-label="${esc(s.name)}">`
|
|
127
|
+
+ `<header><span class="ff-ic">${SV(IC[s.key])}</span><b>${esc(s.name)}</b>`
|
|
128
|
+
+ `<button type="button" class="ff-open" data-fx-st="${s.key}" aria-label="Open ${esc(s.name)}" title="Open ${esc(s.name)}">${SV(IC.open)}</button></header>`
|
|
129
|
+
+ `<p class="ff-does">${esc(DOES[s.key])}</p>${rows}</section>`;
|
|
130
|
+
}
|
|
131
|
+
function youHtml(M) {
|
|
132
|
+
const Y = M.you, H = M.held;
|
|
133
|
+
const line = Y.waiting
|
|
134
|
+
? `${plural(Y.waiting, 'thing waits', 'things wait')} on you.${H.inis ? ` ${Y.waiting === 1 ? 'It holds' : 'They hold'} ${plural(H.inis, 'initiative', 'initiatives')}.` : ''}`
|
|
135
|
+
: 'Nothing waits on you.';
|
|
136
|
+
const done = Y.made ? ` You answered ${Y.made} this week.` : '';
|
|
137
|
+
return `<section class="ff-side ff-you${Y.waiting ? ' con' : ' quiet'}" aria-label="You">`
|
|
138
|
+
+ `<header><span class="ff-ic">${SV(IC.you)}</span><b>You</b>`
|
|
139
|
+
+ `<a class="ff-open ff-go" href="/today.html" aria-label="Answer them on Today" title="Answer them on Today">${SV(IC.go)}</a></header>`
|
|
140
|
+
+ `<p class="ff-does">${esc(DOES.you)}</p><p class="ff-line">${esc(line + done)}</p></section>`;
|
|
141
|
+
}
|
|
142
|
+
function checkHtml(M) {
|
|
143
|
+
const C = M.check, undone = M.stations.reduce((n, s) => n + s.undone, 0);
|
|
144
|
+
const parts = [C.made ? `${C.made} checked this week` : '', C.waiting ? `${C.waiting} wait for a check` : '', undone ? `${undone} undone this week` : ''].filter(Boolean);
|
|
145
|
+
return `<section class="ff-side ff-check${parts.length ? '' : ' quiet'}" aria-label="Check">`
|
|
146
|
+
+ `<header><span class="ff-ic">${SV(IC.check)}</span><b>Check</b>`
|
|
147
|
+
+ `<button type="button" class="ff-open" data-fx-st="check" aria-label="Open Check" title="Open Check">${SV(IC.open)}</button></header>`
|
|
148
|
+
+ `<p class="ff-does">${esc(DOES.check)}</p><p class="ff-line">${esc(parts.length ? parts.join(' · ') : 'Nothing to check this week.')}</p></section>`;
|
|
149
|
+
}
|
|
150
|
+
function goalsHtml(G) {
|
|
151
|
+
if (!G || !G.goals.length) return '';
|
|
152
|
+
const row = (g) => `<li class="ff-goal"><span class="ff-gn">${esc(g.name)}</span><span class="ff-gc">${plural(g.n, 'initiative', 'initiatives')}</span>`
|
|
153
|
+
+ `<span class="ff-seg" role="img" aria-label="${esc(g.segs.map((x) => `${x.stage}: ${x.n}`).join(', '))}">`
|
|
154
|
+
// one equal mark per initiative, so a stage's width is its count (no inline style)
|
|
155
|
+
+ g.segs.map((x) => Array.from({ length: x.n }, () => `<i class="c${x.c % 6}" title="${esc(x.stage)}: ${x.n}"></i>`).join('')).join('') + '</span></li>';
|
|
156
|
+
const legend = G.stages.map((s, c) => `<span><i class="c${c % 6}"></i>${esc(s)}</span>`).join('');
|
|
157
|
+
return `<section class="ff-goals" aria-label="What the factory is making"><h3>What the factory is making <small>initiatives by goal, coloured by stage</small></h3>`
|
|
158
|
+
+ `<ul>${G.goals.map(row).join('')}</ul><p class="ff-legend">${legend}</p>`
|
|
159
|
+
+ `<p class="ff-note">Each initiative’s stage, tasks and milestones open from Work › Initiatives.</p></section>`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The page. o.goals: goalsModel(…) or null (no section). */
|
|
163
|
+
export function floorHtml(M, { goals = null, now = Date.now() } = {}) {
|
|
164
|
+
const S = statusLine(M, { now });
|
|
165
|
+
const andon = `<p class="bd-andon ff-andon${S.alert ? ' alert' : ''}" role="status"><span class="bd-lamp" aria-hidden="true"></span><span>${esc(S.text)}`
|
|
166
|
+
+ `${S.sub ? `<small>${esc(S.sub)}</small>` : ''}</span></p>`;
|
|
167
|
+
if (M.none) return `<div class="ff">${andon}${goalsHtml(goals)}</div>`;
|
|
168
|
+
const flow = M.stations.map(tileHtml).join('<span class="ff-arr" aria-hidden="true">›</span>');
|
|
169
|
+
return `<div class="ff">${andon}<div class="ff-flow" aria-label="Stations in flow order">${flow}</div>`
|
|
170
|
+
+ `<div class="ff-sides">${youHtml(M)}${checkHtml(M)}</div>${goalsHtml(goals)}</div>`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const STATE = { applied: 'applied by PMOS', kept: 'kept', undone: 'undone', proposed: 'drafted', dropped: 'dropped', expired: 'not answered', sent: 'sent' };
|
|
174
|
+
const FIRST = 5;
|
|
175
|
+
/** The station popup's body. o.undone: Set of '<ws>|<ref>' the PM undid on this page (the snapshot shows it at the next run). */
|
|
176
|
+
export function stationHtml(st, { undone = new Set() } = {}) {
|
|
177
|
+
if (!st) return '';
|
|
178
|
+
const wait = st.items.length
|
|
179
|
+
? `<section class="fx-sec"><h4>Waiting <span>${st.waiting}</span></h4><ul>${st.items.map((i) => `<li><b>${esc(i.title || i.id)}</b><span>${esc(i.text || '')}</span></li>`).join('')}</ul>`
|
|
180
|
+
+ (st.waiting > st.items.length ? `<p class="fx-more">${st.waiting - st.items.length} more are not listed.</p>` : '') + '</section>'
|
|
181
|
+
: '';
|
|
182
|
+
const made = (i) => {
|
|
183
|
+
const gone = undone.has((i.ws || '') + '|' + i.ref);
|
|
184
|
+
const btn = i.undo && i.ref && !gone
|
|
185
|
+
? `<button type="button" class="ff-undo" data-fx-undo="${esc(i.ref)}" data-fx-ws="${esc(i.ws || '')}" aria-label="Undo ${esc(i.title)}" title="Undo">${SV(IC.undo)}</button>` : '';
|
|
186
|
+
return `<li><b>${esc(i.title)}</b><span>${esc(gone ? 'undone' : STATE[i.state] || i.state || '')}</span>${btn}</li>`;
|
|
187
|
+
};
|
|
188
|
+
const M = st.madeItems || [];
|
|
189
|
+
const madeSec = M.length
|
|
190
|
+
? `<section class="fx-sec"><h4>Made this week <span>${st.made}</span></h4><ul>${M.slice(0, FIRST).map(made).join('')}</ul>`
|
|
191
|
+
+ (M.length > FIRST ? `<details class="fx-fold"><summary>${M.length - FIRST} more</summary><ul>${M.slice(FIRST).map(made).join('')}</ul></details>` : '')
|
|
192
|
+
+ '</section>'
|
|
193
|
+
: st.made ? `<section class="fx-sec"><h4>Made this week <span>${st.made}</span></h4><p class="fx-more">Background runs; nothing here to undo.</p></section>` : '';
|
|
194
|
+
const cost = [st.minutes ? `${minutesText(st.minutes)} of PMOS time over ${plural(st.runs, 'run', 'runs')}` : '',
|
|
195
|
+
st.made ? `you undid ${st.undone} of ${st.made}` : '', 'tokens not recorded yet'].filter(Boolean).join(' · ');
|
|
196
|
+
const costSec = `<section class="fx-sec"><h4>Cost this week</h4><p>${esc(cost.charAt(0).toUpperCase() + cost.slice(1))}</p></section>`;
|
|
197
|
+
const none = !wait && !madeSec ? '<p class="fx-more">Nothing waited here and nothing was made this week.</p>' : '';
|
|
198
|
+
return `<div class="fx-sheet">${none}${wait}${madeSec}${costSec}</div>`;
|
|
199
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* due(saved, now) → true when the four are worked out again: none saved, or saved a week or more ago
|
|
10
10
|
* toolbarHtml(ids, o) → the toolbar: the four icon buttons (data-pw-act). o: { picked, jiraPicked }
|
|
11
11
|
* pickLineHtml(act, n) → the line while picking: "Pick the tasks to change · Esc to stop", then "Who for 2 tasks" with its button
|
|
12
|
-
* moreGroups(o) → [{ group, items: [{ act, label, icon }] }] for ⋯. Plan and Jira only while rows are picked (Move the
|
|
12
|
+
* moreGroups(o) → [{ group, items: [{ act, label, icon }] }] for ⋯. Print (Print or PDF) always, last. Plan and Jira only while rows are picked (Move the
|
|
13
13
|
* dates always: with nothing picked it moves every open task); View always. o: { bar, picked, one, oneJira,
|
|
14
14
|
* allJira, oneOpen, view, src, tl }. An action that does not apply is not there. bar (the toolbar's ids,
|
|
15
15
|
* default DEFAULT): Who, Set the date or Stage left off it go in a first group, Change, while rows are
|
|
@@ -33,7 +33,7 @@ export const IC = {
|
|
|
33
33
|
stage: 'M5 7h14M5 12h10M5 17h6', shift: 'M4 12h14M14 8l4 4-4 4', epic: 'M13 3L5 14h6l-1 7 8-11h-6z',
|
|
34
34
|
sprint: 'M4 12h11M11 8l4 4-4 4M19 6v12', flag: 'M6 21V4M6 4h11l-2 4 2 4H6', gantt: 'M4 6h9M8 12h10M6 18h7', cols: 'M4 5h16v14H4zM9 5v14M15 5v14',
|
|
35
35
|
span: 'M4 12h16M4 8v8M20 8v8', parts: 'M5 7h14M5 12h14M5 17h14', jira: 'M12 3l9 9-9 9-9-9zM12 8l4 4-4 4-4-4z', full: 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5',
|
|
36
|
-
tree: 'M6 5v14M6 12h8M6 19h8', done: 'M5 12.5l4.5 4.5L19 7.5', src: 'M4 6h16l-6 7v5l-4 2v-7z',
|
|
36
|
+
tree: 'M6 5v14M6 12h8M6 19h8', print: 'M7 9V4h10v5M7 17H5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-2M7 14h10v6H7z', done: 'M5 12.5l4.5 4.5L19 7.5', src: 'M4 6h16l-6 7v5l-4 2v-7z',
|
|
37
37
|
};
|
|
38
38
|
/** The toolbar's candidates, in the order the default and a tie keep. `pick: true` acts on picked rows (with none picked it starts picking). */
|
|
39
39
|
export const ACTIONS = Object.freeze({
|
|
@@ -99,7 +99,9 @@ export function moreGroups(o = {}) {
|
|
|
99
99
|
if (o.src) view.push(it('src', 'Source', IC.src));
|
|
100
100
|
view.push(it('parts', 'Every part', IC.parts));
|
|
101
101
|
const jira = o.picked && o.one && o.oneJira ? [it('jira', 'Status in Jira', IC.jira)] : [];
|
|
102
|
-
|
|
102
|
+
// Print or PDF (job #1911, A379): always, on a desk and a phone; it prints the popup in the one print layout (pm/print-pdf.js)
|
|
103
|
+
const print = [it('print', 'Print or PDF', IC.print)];
|
|
104
|
+
return [{ group: 'Change', items: change }, { group: 'Plan', items: plan }, { group: 'View', items: view }, { group: 'Jira', items: jira }, { group: 'Print', items: print }].filter((g) => g.items.length);
|
|
103
105
|
}
|
|
104
106
|
export const iconOf = (d, w = 14) => SV(d, w);
|
|
105
107
|
|
|
@@ -73,6 +73,7 @@ import * as ST from './bd-stands.js'; // Where it stands, its Suggestion and t
|
|
|
73
73
|
import * as LS from './load-shapes.js'; // the skeleton and the slow-case line while the board is read (page-open-speed, SpD) // the Board as the first panel: fit(), the rows that open beside, the open row's mark
|
|
74
74
|
import * as STRAT from './bd-strategy.js'; // the product's strategy in five lines above the initiatives (bet A458)
|
|
75
75
|
import * as PRIN from './bd-principles.js'; // the product's principles drafted from its decisions, below the strategy (bet A352)
|
|
76
|
+
import * as SKM from './skill-map.js'; // the team skill map below the principles (bet A208)
|
|
76
77
|
import * as CMAP from './code-map.js'; // the product's code map, one box per main part (idea A176)
|
|
77
78
|
import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
|
|
78
79
|
import { pressHold } from './state-glyph.js';
|
|
@@ -1525,6 +1526,7 @@ async function load() {
|
|
|
1525
1526
|
LE.loaded({ since, stale: !!r.stale }); // a change still saving stays on the new read; open views (the big Work breakdown) follow it
|
|
1526
1527
|
STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
|
|
1527
1528
|
PRIN.refresh($('#cPrin'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1529
|
+
SKM.refresh($('#cSkills'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1528
1530
|
CMAP.mount($('#cCode'), { ws: M.board.ws || null, single: !ALL });
|
|
1529
1531
|
focusOnce(); taskOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
|
|
1530
1532
|
if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
|
|
@@ -1598,6 +1600,8 @@ const bkApi = () => ({
|
|
|
1598
1600
|
scope: () => (M.board.all ? (M.board.products || []).map((p) => ({ ws: p.ws, board: p.id || '', name: p.name })) : [{ ws: M.board.ws || '', board: M.board.id || '', name: M.board.product || M.board.name || '' }]),
|
|
1599
1601
|
// CLASSIC (lib/classic-board.js) is the test seam of the four Board views: Work and its Backlog switch are not there
|
|
1600
1602
|
post: pmPost, say, reload: () => load(), readonly: !!window.PMOS_READONLY || CLASSIC,
|
|
1603
|
+
// Work › Factory (factory-page-ui): What the factory is making, the live initiatives by goal and by the stage of their own workflow
|
|
1604
|
+
work: () => (M && M.initiatives ? M.initiatives.list.rows : []).filter((r) => r.track && r.acts).map((r) => ({ id: r.id, goal: wkGoalOf(r), stage: r.acts.stage || '', stages: r.acts.stages || [] })),
|
|
1601
1605
|
// the Line tab (quiet-rows slice B): a row opens its initiative, as a row of Initiatives does
|
|
1602
1606
|
openIni: (id, ws) => { const r = (M.rows || []).find((x) => x.id === id && x.track && (!ws || (x.ws || M.board.ws) === ws)); if (r) openIni(r); else say('Open ' + id + ' from Initiatives.'); },
|
|
1603
1607
|
// the sprint band (pm/bd-sprint.js): Read Jira again is the Board's own; "Make a home" opens New initiative with the theme's name
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
* (Read again: a redraft that keeps the notes; Start the next cycle without a template), /api/report-setups/draft (Start the next cycle),
|
|
52
52
|
* /api/report-design/revert (Go back to it). */
|
|
53
53
|
import { pmGet, pmPost } from './http.js';
|
|
54
|
+
import * as PR from './print-pdf.js'; // Print or PDF and Send a copy: the one print layout (job #1911, A379)
|
|
54
55
|
import { open as vOpen, current as vCur, czSections } from './cozy-viewer.js';
|
|
55
56
|
import * as MP from './premium-mtg-present.js'; // the one presenter window for every kind (canvas note xvPresent)
|
|
56
57
|
import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, the recording tab presents it (rule 10)
|
|
@@ -263,7 +264,7 @@ function dlPop() {
|
|
|
263
264
|
const fmt = (k, l) => (k === 'pdf' || k === 'md' ? `<button type="button" class="vz-fmt" data-r="${k}">${l}</button>` : `<a class="vz-fmt" data-r="dl|${k}" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: k }))}" download>${l}</a>`);
|
|
264
265
|
return `<div class="vz-pop vz-pop-dl" data-esc-layer="1" role="menu" aria-label="Download"><p class="vz-lab">Download</p>`
|
|
265
266
|
+ `<div class="vz-fmts">${fmt('pptx', 'PPTX')}${fmt('docx', 'DOCX')}${fmt('pdf', 'PDF')}${fmt('xlsx', 'XLSX')}${fmt('csv', 'CSV')}${fmt('md', 'MD')}</div>`
|
|
266
|
-
+ `<p class="vz-note vz-padmi">Slides as PowerPoint, words as Word or Markdown, tables as Excel or CSV. PDF keeps the look.</p><hr>${mi('print', 'print', 'Print')}</div>`;
|
|
267
|
+
+ `<p class="vz-note vz-padmi">Slides as PowerPoint, words as Word or Markdown, tables as Excel or CSV. PDF keeps the look.</p><hr>${mi('print', 'print', 'Print or PDF')}</div>`;
|
|
267
268
|
}
|
|
268
269
|
function schedPop() {
|
|
269
270
|
const k = R.sch, opts = [['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month, on the 1st'], ['else', 'Something else: say it in the chat']];
|
|
@@ -340,6 +341,7 @@ function sharePop() {
|
|
|
340
341
|
return `<div class="vz-pop vz-pop-share" data-esc-layer="1" role="dialog" aria-label="Share">${seg}${body}${foot}</div>`;
|
|
341
342
|
}
|
|
342
343
|
function canSend() {
|
|
344
|
+
PR.brandNow(R.ws); // the brand is read before Send a copy is pressed (a share sheet cannot wait)
|
|
343
345
|
try { return typeof navigator !== 'undefined' && !!navigator.share && !!navigator.canShare && navigator.canShare({ files: [new File([R.text || ''], fileName(), { type: 'text/markdown' })] }); } catch { return false; }
|
|
344
346
|
}
|
|
345
347
|
const fileName = () => String(R.row.path).split('/').slice(-2).join('-') || 'report.md';
|
|
@@ -956,7 +958,7 @@ async function shareAct(k, v) {
|
|
|
956
958
|
S.off = null; if (r && r.ok) { S.list = S.list.filter((x) => x.id !== v); R.shares = sharesOf(S.list, R.row.path); } else S.err = (r && r.error) || 'The link could not be turned off.';
|
|
957
959
|
return draw();
|
|
958
960
|
}
|
|
959
|
-
if (k === 'shsend') { try { await navigator.share({ files: [new File([R.text || ''], fileName(), { type: 'text/markdown' })], title: R.name }); R.pop = null; draw(); } catch { /* the PM closed the share sheet */ } return; }
|
|
961
|
+
if (k === 'shsend') { try { await navigator.share({ files: [new File([R.W ? docPage() : R.text || ''], R.W ? fileName().replace(/\.md$/i, '') + '.html' : fileName(), { type: R.W ? 'text/html' : 'text/markdown' })], title: R.name }); R.pop = null; draw(); } catch { /* the PM closed the share sheet */ } return; }
|
|
960
962
|
if (k === 'shmake') {
|
|
961
963
|
if (S.pw && String(S.pass || '').trim().length < 8) { S.err = 'The password needs at least 8 characters.'; return draw(); }
|
|
962
964
|
S.busy = true; S.err = ''; draw();
|
|
@@ -1041,7 +1043,14 @@ function printHtml() {
|
|
|
1041
1043
|
: `<h1>${esc(w.title)}</h1>` + w.sections.map((x) => `<h2>${esc(x.h)}</h2>${slideHtml(x.lines)}`).join('');
|
|
1042
1044
|
return frameDoc('', inner, R.view === 'deck' ? 'pmos-print pmos-print-deck' : 'pmos-print pmos-print-doc').replace('<head>', '<head><title>' + t + '</title>').replace('</head>', css + '</head>');
|
|
1043
1045
|
}
|
|
1046
|
+
/** The document view's sections for the one print layout (pm/print-pdf.js, job #1911): Print or PDF and Send a copy use the same page. */
|
|
1047
|
+
function docPrint() {
|
|
1048
|
+
const w = R.W || { title: R.name, sections: [] };
|
|
1049
|
+
return { title: R.name + (R.row.slot ? ' ' + R.row.slot : ''), sections: w.sections.map((x) => ({ h: x.h, html: slideHtml(x.lines) })) };
|
|
1050
|
+
}
|
|
1051
|
+
const docPage = () => { const d = docPrint(); return PR.layoutHtml({ ...d, brand: PR.brandNow(R.ws) }); };
|
|
1044
1052
|
function printIt() {
|
|
1053
|
+
if (!R.cyc && R.view !== 'deck' && R.W) { const d = docPrint(); PR.printPage('', { title: d.title, ws: R.ws, sections: d.sections }); return; } // Print or PDF (job #1911)
|
|
1045
1054
|
const w = window.open('', '_blank');
|
|
1046
1055
|
if (!w) return say('The browser blocked the print window. Allow pop-ups for this page, then press Print again.', 'bad');
|
|
1047
1056
|
w.document.open(); w.document.write(printHtml()); w.document.close();
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* pm/print-pdf.js — Print or PDF: one clean print layout for every report, roadmap and initiative page (initiative print-pdf, job #1911,
|
|
2
|
+
* idea A379; board BatchMoreADS panel 26, agreed by Wawan 2026-11-25). Many stakeholders still read a PDF in email; this is the page they get.
|
|
3
|
+
*
|
|
4
|
+
* layoutHtml({ title, date, brand, sections, html }) PURE → the whole print document. sections: [{ h, html }] (each a section that does
|
|
5
|
+
* not split across pages), or html: one body. Every printed page carries the title (top left), the brand when one is set
|
|
6
|
+
* (top right), the date (bottom left) and "page N of M" (bottom right), through the page's margin boxes; page 1 also
|
|
7
|
+
* opens with the title and the date. Black on white, no shadows, no colour-only marks.
|
|
8
|
+
* cleanHtml(html) PURE → the same markup with no buttons, fields, menus, nav, aside, chat, scripts, styles, frames, comments or on…
|
|
9
|
+
* handlers. A button with words keeps its words as plain text (a task's or stage's name is often a button); an
|
|
10
|
+
* icon-only button goes. Anything marked data-print="skip" goes. A state glyph or a state dot becomes its word
|
|
11
|
+
* (pm/state-glyph.js STATES: On track, At risk, Late …); a dot whose next words already say it is dropped (say it once).
|
|
12
|
+
* dateLine(d) PURE → "25 Nov 2026"
|
|
13
|
+
* brandNow(ws) the brand already read ('' until it is; starts the read), for a press that cannot wait
|
|
14
|
+
* printPage(root, { title, ws, date, sections }) the browser part: cleans root's markup, asks GET /api/print for the product's brand, and prints the
|
|
15
|
+
* layout from a hidden frame that runs no script (sandbox without allow-scripts). The browser's print window offers
|
|
16
|
+
* Save as PDF. Notes the use `print-pdf` (the kill reads it).
|
|
17
|
+
* lib/print-pdf.js loads this module in Node for `pmos print`, so the terminal and the page print the same layout. The UI says PMOS. */
|
|
18
|
+
import { STATES, stateKey } from './state-glyph.js';
|
|
19
|
+
|
|
20
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
21
|
+
// a CSS string: no quote, backslash or line break can end it early
|
|
22
|
+
const cssStr = (s) => '"' + String(s == null ? '' : s).replace(/[\\"]/g, (c) => '\\' + c).replace(/[\r\n\u2028\u2029]+/g, ' ').slice(0, 160) + '"';
|
|
23
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
24
|
+
|
|
25
|
+
export function dateLine(d = new Date()) {
|
|
26
|
+
const t = d instanceof Date ? d : new Date(d);
|
|
27
|
+
if (isNaN(t)) return '';
|
|
28
|
+
return `${t.getDate()} ${MONTHS[t.getMonth()]} ${t.getFullYear()}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ── the layout ── */
|
|
32
|
+
// The frame cannot load the app's stylesheets, so the page is the browser's own black on white (as pm/premium-vw-file.js prints a file):
|
|
33
|
+
// no colour at all, a quieter line by opacity, sizes in the font shorthand.
|
|
34
|
+
export const PRINT_CSS = `
|
|
35
|
+
.pp, .pp * { box-shadow: none !important; text-shadow: none !important; animation: none !important; transition: none !important; }
|
|
36
|
+
:root { color-scheme: light; }
|
|
37
|
+
body.pp { margin: 0; font: 11pt/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
38
|
+
.pp-head { margin: 0 0 18pt; }
|
|
39
|
+
.pp-head h1 { margin: 0; font: 700 20pt/1.2 system-ui, sans-serif; }
|
|
40
|
+
.pp-date { margin: 4pt 0 0; opacity: .7; }
|
|
41
|
+
.pp-sec { margin: 0 0 14pt; }
|
|
42
|
+
.pp-sec, .pm-block, section, table, tr, li, figure, blockquote, pre { break-inside: avoid; page-break-inside: avoid; }
|
|
43
|
+
h1, h2, h3, h4, h5 { break-after: avoid; page-break-after: avoid; }
|
|
44
|
+
h2 { font: 700 14pt/1.3 system-ui, sans-serif; margin: 0 0 6pt; } h3 { font: 700 12pt/1.3 system-ui, sans-serif; margin: 10pt 0 4pt; }
|
|
45
|
+
p { orphans: 3; widows: 3; }
|
|
46
|
+
table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 3pt 8pt 3pt 0; border-bottom: 0.5pt solid; vertical-align: top; }
|
|
47
|
+
a { color: inherit; text-decoration: none; }
|
|
48
|
+
img, svg, canvas { max-width: 100%; height: auto; }
|
|
49
|
+
.pp-st { font-weight: 600; }
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
/** The page's margin boxes: title, brand, date and "page N of M" on every printed page. */
|
|
53
|
+
function pageCss(title, date, brand) {
|
|
54
|
+
return `@page { size: A4; margin: 18mm 16mm 20mm;
|
|
55
|
+
@top-left { content: ${cssStr(title)}; font: 9pt system-ui, sans-serif; }
|
|
56
|
+
${brand ? `@top-right { content: ${cssStr(brand)}; font: 600 9pt system-ui, sans-serif; }` : ''}
|
|
57
|
+
@bottom-left { content: ${cssStr(date)}; font: 9pt system-ui, sans-serif; }
|
|
58
|
+
@bottom-right { content: "page " counter(page) " of " counter(pages); font: 9pt system-ui, sans-serif; }
|
|
59
|
+
}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function layoutHtml({ title = '', date = '', brand = '', sections = null, html = '' } = {}) {
|
|
63
|
+
const t = String(title || 'PMOS').trim(), d = String(date || dateLine()).trim(), b = String(brand || '').trim();
|
|
64
|
+
const body = Array.isArray(sections) && sections.length
|
|
65
|
+
? sections.map((s) => `<section class="pp-sec">${s.h ? `<h2>${esc(s.h)}</h2>` : ''}${cleanHtml(s.html || '')}</section>`).join('\n')
|
|
66
|
+
: `<div class="pp-sec pp-one">${cleanHtml(html || '')}</div>`;
|
|
67
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(t)}</title>`
|
|
68
|
+
+ `<style>${pageCss(t, d, b)}${PRINT_CSS}</style></head>`
|
|
69
|
+
+ `<body class="pp"><header class="pp-head"><h1>${esc(t)}</h1><p class="pp-date">${esc(d)}${b ? ' · ' + esc(b) : ''}</p></header>\n<main>${body}</main></body></html>`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── the clean-up ── */
|
|
73
|
+
const VOID = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
|
|
74
|
+
const DROP = new Set(['input', 'select', 'textarea', 'nav', 'aside', 'script', 'style', 'noscript', 'iframe', 'object', 'embed', 'template', 'dialog', 'link', 'meta', 'base', 'audio', 'video']);
|
|
75
|
+
const DROP_ROLE = /^(menu|menubar|toolbar|tablist|search|dialog|alertdialog|tooltip|status)$/i;
|
|
76
|
+
const DROP_CLASS = /(^|\s)(cz-pop[\w-]*|cz-fab|cz-chat[\w-]*|chat[\w-]*|pm-toast[\w-]*|pm-menu|vz-tb|vz-pop[\w-]*|hi-pop[\w-]*|tr-card)(\s|$)/;
|
|
77
|
+
|
|
78
|
+
const attr = (a, n) => { const m = new RegExp('(?:^|\\s)' + n + '\\s*=\\s*("([^"]*)"|\'([^\']*)\'|([^\\s>]+))', 'i').exec(a || ''); return m ? (m[2] ?? m[3] ?? m[4] ?? '') : null; };
|
|
79
|
+
const has = (a, n) => new RegExp('(?:^|\\s)' + n + '(?:\\s*=|\\s|$)', 'i').test(a || '');
|
|
80
|
+
const BLOCK_END = /<\/?(?:p|li|td|th|tr|div|section|h[1-6]|ul|ol|table|br|hr|header|footer|article)\b/i;
|
|
81
|
+
const textOf = (h) => String(h || '').replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/\s+/g, ' ').trim();
|
|
82
|
+
|
|
83
|
+
/** The word a state glyph or dot prints as, or null when the element is not one. */
|
|
84
|
+
function stateWord(tag, a) {
|
|
85
|
+
const cls = attr(a, 'class') || '';
|
|
86
|
+
if (/(^|\s)pm-glyph(\s|$)/.test(cls)) {
|
|
87
|
+
const k = stateKey(attr(a, 'data-state') || '') || stateKey(attr(a, 'aria-label') || '');
|
|
88
|
+
return k ? STATES[k].word : (attr(a, 'aria-label') || '');
|
|
89
|
+
}
|
|
90
|
+
if (/(^|\s)cz-dot(\s|$)/.test(cls)) {
|
|
91
|
+
for (const c of cls.split(/\s+/)) { const k = c !== 'cz-dot' && stateKey(c); if (k) return STATES[k].word; }
|
|
92
|
+
return attr(a, 'aria-label') || attr(a, 'title') || '';
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Strip on… handlers, style-less risky attributes and script links from a kept tag. */
|
|
98
|
+
function safeAttrs(a) {
|
|
99
|
+
return String(a || '')
|
|
100
|
+
.replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '')
|
|
101
|
+
.replace(/\s+(href|src|xlink:href|action|formaction)\s*=\s*("\s*(javascript|vbscript|data:text\/html)[^"]*"|'\s*(javascript|vbscript|data:text\/html)[^']*'|(javascript|vbscript)[^\s>]*)/gi, '')
|
|
102
|
+
.replace(/\s+(contenteditable|tabindex|draggable|autofocus)(\s*=\s*("[^"]*"|'[^']*'|[^\s>]+))?/gi, '');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const TAG_SRC = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<!doctype[^>]*>|<\/?([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^'">])*)>/gi;
|
|
106
|
+
|
|
107
|
+
/** Where the element opened at `from` (just after its open tag) ends: the index after its close tag (or the end). */
|
|
108
|
+
function closeOf(html, name, from) {
|
|
109
|
+
const re = new RegExp('<(/?)' + name + '\\b(?:"[^"]*"|\'[^\']*\'|[^\'">])*>', 'gi');
|
|
110
|
+
re.lastIndex = from;
|
|
111
|
+
let depth = 1, m;
|
|
112
|
+
while ((m = re.exec(html))) {
|
|
113
|
+
if (/\/>$/.test(m[0]) && !m[1]) continue;
|
|
114
|
+
depth += m[1] ? -1 : 1;
|
|
115
|
+
if (!depth) return { inner: html.slice(from, m.index), end: re.lastIndex };
|
|
116
|
+
}
|
|
117
|
+
return { inner: html.slice(from), end: html.length };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function cleanHtml(html) {
|
|
121
|
+
const s = String(html || '');
|
|
122
|
+
const TAG = new RegExp(TAG_SRC.source, 'gi'); // one per call: a nested call must not move this one
|
|
123
|
+
let out = '', i = 0, m;
|
|
124
|
+
while ((m = TAG.exec(s))) {
|
|
125
|
+
out += s.slice(i, m.index); i = TAG.lastIndex;
|
|
126
|
+
if (!m[1]) continue; // a comment, CDATA or doctype
|
|
127
|
+
const name = m[1].toLowerCase(), a = m[2] || '', closing = m[0][1] === '/';
|
|
128
|
+
if (closing) { if (!DROP.has(name) && name !== 'button') out += `</${name}>`; continue; }
|
|
129
|
+
const self = VOID.has(name) || /\/\s*$/.test(a);
|
|
130
|
+
const skipAll = () => { if (!self) { const c = closeOf(s, name, i); i = c.end; TAG.lastIndex = c.end; return c.inner; } return ''; };
|
|
131
|
+
const word = stateWord(name, a);
|
|
132
|
+
if (word !== null) {
|
|
133
|
+
skipAll();
|
|
134
|
+
const next = textOf(s.slice(i, i + 400).split(BLOCK_END)[0]).slice(0, 80).toLowerCase(); // the words up to the end of this line
|
|
135
|
+
if (word && !next.includes(word.toLowerCase())) out += `<span class="pp-st">${esc(word)}</span> `;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const role = attr(a, 'role') || '', cls = attr(a, 'class') || '';
|
|
139
|
+
if (DROP.has(name) || attr(a, 'data-print') === 'skip' || has(a, 'hidden') || attr(a, 'aria-hidden') === 'true' && name !== 'svg'
|
|
140
|
+
|| DROP_ROLE.test(role) || DROP_CLASS.test(cls) || has(a, 'data-chat')) { skipAll(); continue; }
|
|
141
|
+
if (name === 'button' || role === 'button' || role === 'menuitem') {
|
|
142
|
+
// a button with words keeps its words (a task's name); an icon-only or action button goes
|
|
143
|
+
const inner = skipAll(), words = textOf(cleanHtml(inner));
|
|
144
|
+
if (words && !/(^|\s)pm-btn(\s|$)/.test(cls)) out += `<span>${cleanHtml(inner)}</span>`;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (name === 'svg' && attr(a, 'aria-hidden') === 'true') { skipAll(); continue; } // an icon
|
|
148
|
+
out += `<${name}${safeAttrs(a)}>`;
|
|
149
|
+
}
|
|
150
|
+
out += s.slice(i);
|
|
151
|
+
return out.replace(/<\/(button|script|style|textarea|select|nav|aside|iframe)>/gi, '').replace(/[ \t]+\n/g, '\n');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* ── the browser part ── */
|
|
155
|
+
let brandCache = null;
|
|
156
|
+
async function brandFor(ws) {
|
|
157
|
+
const k = String(ws || '');
|
|
158
|
+
if (brandCache && brandCache.k === k) return brandCache.v;
|
|
159
|
+
let v = '';
|
|
160
|
+
try { const { pmGet } = await import('./http.js'); const r = await pmGet('/api/print' + (k ? '?ws=' + encodeURIComponent(k) : '')); v = (r && r.ok && r.brand) || ''; } catch { v = ''; }
|
|
161
|
+
brandCache = { k, v };
|
|
162
|
+
return v;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The brand already read for ws ('' until GET /api/print answers; the call starts the read). For a press that must not wait: a share sheet. */
|
|
166
|
+
export function brandNow(ws) {
|
|
167
|
+
const k = String(ws || '');
|
|
168
|
+
if (brandCache && brandCache.k === k) return brandCache.v;
|
|
169
|
+
if (typeof document !== 'undefined') brandFor(k).catch(() => {});
|
|
170
|
+
return '';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Print root (an element, or markup) in the layout. Returns the frame, or null outside a browser. */
|
|
174
|
+
export async function printPage(root, { title = '', ws = '', date = '', sections = null } = {}) {
|
|
175
|
+
if (typeof document === 'undefined') return null;
|
|
176
|
+
try { const { noteUse } = await import('./use-log.js'); noteUse('print-pdf'); } catch { /* the use log is optional */ }
|
|
177
|
+
const html = typeof root === 'string' ? root : root && root.innerHTML ? root.innerHTML : '';
|
|
178
|
+
const brand = await brandFor(ws);
|
|
179
|
+
const doc = layoutHtml({ title, date: date || dateLine(), brand, sections, html });
|
|
180
|
+
document.querySelectorAll('iframe.pp-frame').forEach((x) => x.remove());
|
|
181
|
+
const fr = document.createElement('iframe');
|
|
182
|
+
fr.className = 'pp-frame';
|
|
183
|
+
fr.setAttribute('sandbox', 'allow-same-origin allow-modals'); // no allow-scripts: the page prints, nothing in it runs
|
|
184
|
+
fr.setAttribute('aria-hidden', 'true'); fr.tabIndex = -1;
|
|
185
|
+
fr.width = '0'; fr.height = '0'; fr.setAttribute('frameborder', '0'); // out of sight; a hidden frame does not print in every browser
|
|
186
|
+
fr.addEventListener('load', () => { try { fr.contentWindow.focus(); fr.contentWindow.print(); } catch { /* the browser refused: the PM prints again */ } }, { once: true });
|
|
187
|
+
fr.srcdoc = doc;
|
|
188
|
+
document.body.append(fr);
|
|
189
|
+
setTimeout(() => fr.remove(), 120000);
|
|
190
|
+
return fr;
|
|
191
|
+
}
|
|
@@ -17,6 +17,8 @@ export const RO = !!PACK;
|
|
|
17
17
|
|
|
18
18
|
/** What a reader can do. Each is a selector; a press inside a match is let through. */
|
|
19
19
|
export const VIEW_CONTROLS = [
|
|
20
|
+
// the big cards' fold (pm/card-fold.js): Strategy, Where it stands and North Star fold to their head line, and the ✦ count opens one
|
|
21
|
+
'[data-card-fold]', '[data-card-fold-sug]',
|
|
20
22
|
// the Timeline: the span, the legend behind (i), a column's sort, back to today, the edge tab that scrolls to a bar off the view, the Deliveries lane, the folds, an initiative's name (opens its viewer)
|
|
21
23
|
'#bdLgdBtn', '.tg-chd', '.tg-tback', '.tg-edge', '.dl-fb', '.dl-dn', '.dl-e[aria-label*="press to open"]', '.bd-fold', '.bd-prdb', 'label.tg-n', 'button.tg-n.ini2',
|
|
22
24
|
// the stage track: the switch between it and the Timeline (the two views a publisher shares), an initiative's name, the Monitor and Evaluate fold
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
* mount(host, { ws, single, say }) → draws the block into `host`; a Board that shows several products at once shows none
|
|
5
5
|
*
|
|
6
6
|
* Built only from Komorebi parts: a Detail block (pm-block, its head), pm-table for the reasons, pm-said for the one ✦, pm-meta for the
|
|
7
|
-
* score line, pm-badge alert for a growing complaint, icon-only pm-btn with a label. No inline style (conformance R28-1). It reads GET /api/voice and writes POST /api/voice/file and /api/voice/
|
|
7
|
+
* score line, pm-badge alert for a growing complaint, icon-only pm-btn with a label. No inline style (conformance R28-1). It reads GET /api/voice and writes POST /api/voice/file, /api/voice/undo and /api/voice/unread
|
|
8
8
|
* (lib/routes-strategy-card.js over lib/review-reasons.js, the ledger `pmos voice` writes too) and nothing else.
|
|
9
9
|
* · Rows sort by growth over 30 days; the chevron on a row opens its comments.
|
|
10
10
|
* · One ✦ for the fastest-growing complaint; accepting it files a triage item and the Board's toast offers Undo.
|
|
11
11
|
* · The score stays as one line under the reasons. Comments with no reason yet: one quiet count.
|
|
12
12
|
* · No comments: no block (zero is silence).
|
|
13
|
-
*
|
|
13
|
+
* · An export in the product's files (review-reasons-files) shows by itself: one line names the file PMOS read, with an icon-only Undo.
|
|
14
|
+
* Each ✦ press notes voiceFile and each Undo voiceUndo in the local use log (the bet's kill line); a shown read line notes voiceRead
|
|
15
|
+
* and its Undo voiceUnread. */
|
|
14
16
|
import { pmGet, pmPost } from './http.js';
|
|
15
17
|
import { noteUse } from './use-log.js';
|
|
16
18
|
|
|
@@ -21,7 +23,8 @@ const btn = (name, value, icon, label, kind = '') => `<button type="button" clas
|
|
|
21
23
|
const when = (iso) => { const d = new Date(iso); return Number.isNaN(d.getTime()) ? '' : d.toISOString().slice(0, 10); };
|
|
22
24
|
const scoreOf = (c) => (c.score == null ? '' : `${c.score} of ${c.scale}`);
|
|
23
25
|
|
|
24
|
-
/** The block's markup. state = { rows, unsorted, score, suggest, open }. Pure, so the test reads it. '' when there is nothing to show.
|
|
26
|
+
/** The block's markup. state = { rows, unsorted, score, suggest, reads, open }. Pure, so the test reads it. '' when there is nothing to show.
|
|
27
|
+
* reads: the exports PMOS read by itself from the product's files in the last 7 days, one line each with an icon-only Undo. */
|
|
25
28
|
export function blockHtml(state) {
|
|
26
29
|
const rows = Array.isArray(state && state.rows) ? state.rows : [];
|
|
27
30
|
const unsorted = (state && state.unsorted) || 0;
|
|
@@ -41,9 +44,12 @@ export function blockHtml(state) {
|
|
|
41
44
|
const table = rows.length ? `<table class="pm-table"><thead><tr><th>Reason</th><th>Comments</th><th>30 days</th><th><span class="vh">Open</span></th></tr></thead><tbody>${rows.map(row).join('')}</tbody></table>` : '';
|
|
42
45
|
const s = state && state.suggest;
|
|
43
46
|
const said = s ? `<p class="pm-said">${SV(I.spark, 'pm-ic pm-star')}<span>${esc(s.line)}</span>${btn('voiceFile', s.reason, I.spark, 'Make it a work item: PMOS files it in triage', 'primary')}</p>` : '';
|
|
47
|
+
const reads = Array.isArray(state && state.reads) ? state.reads : [];
|
|
48
|
+
const readLines = reads.map((x) => `<p class="pm-meta" data-voice-read="${esc(x.file)}"><span>Read ${x.n} ${x.n === 1 ? 'comment' : 'comments'} from ${esc(x.file)}</span>`
|
|
49
|
+
+ `${btn('voiceUnread', x.file, I.undo, 'Undo: take back the comments PMOS read from ' + x.file, 'ghost')}</p>`).join('');
|
|
44
50
|
const foot = [state && state.score, unsorted ? `${unsorted} ${unsorted === 1 ? 'comment has' : 'comments have'} no reason yet` : ''].filter(Boolean).join(' · ');
|
|
45
51
|
return `<section class="pm-block" aria-label="Customer voice"><div class="head">${SV(I.voice)}<h3 class="pm-h-sm">Customer voice</h3><span class="sp"></span></div>`
|
|
46
|
-
+ table + said + (foot ? `<p class="pm-meta">${esc(foot)}</p>` : '') + '</section>';
|
|
52
|
+
+ table + said + (foot ? `<p class="pm-meta">${esc(foot)}</p>` : '') + readLines + '</section>';
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
/** Draw the block into `host` and wire its presses. */
|
|
@@ -56,8 +62,16 @@ export async function mount(host, opts = {}) {
|
|
|
56
62
|
const state = { ...r, open: host._voiceOpen || [] };
|
|
57
63
|
const html = blockHtml(state);
|
|
58
64
|
host.hidden = !html; host.innerHTML = html;
|
|
65
|
+
if (html && (r.reads || []).length && !host._voiceReadNoted) { host._voiceReadNoted = true; noteUse('voiceRead'); } // once per page
|
|
59
66
|
host.onclick = async (e) => {
|
|
60
|
-
const b = e.target.closest('button[name="voiceOpen"], button[name="voiceFile"]'); if (!b) return;
|
|
67
|
+
const b = e.target.closest('button[name="voiceOpen"], button[name="voiceFile"], button[name="voiceUnread"]'); if (!b) return;
|
|
68
|
+
if (b.name === 'voiceUnread') {
|
|
69
|
+
noteUse('voiceUnread'); b.disabled = true;
|
|
70
|
+
const res = await pmPost('/api/voice/unread', { ws, file: b.value }).catch(() => null);
|
|
71
|
+
if (!res || !res.ok) { b.disabled = false; if (say) say((res && res.error) || 'Not taken back.'); return; }
|
|
72
|
+
if (say) say('Taken back. PMOS reads that file again when it changes.');
|
|
73
|
+
mount(host, opts); return;
|
|
74
|
+
}
|
|
61
75
|
if (b.name === 'voiceOpen') {
|
|
62
76
|
const set = new Set(host._voiceOpen || []); if (set.has(b.value)) set.delete(b.value); else set.add(b.value);
|
|
63
77
|
host._voiceOpen = [...set]; host.innerHTML = blockHtml({ ...r, open: host._voiceOpen }); return;
|