create-pmos 0.428.0 → 0.429.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-board-test.js +2 -2
- package/workspace/briefing-premium-insights-test.js +81 -60
- package/workspace/briefing-premium-metrics-test.js +5 -3
- package/workspace/briefing-premium-sources-test.js +5 -5
- package/workspace/briefing-premium-test.js +5 -4
- package/workspace/changelog.json +12 -0
- package/workspace/ev-everywhere-test.js +2 -2
- package/workspace/guide/home.md +2 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/metric-drafts.md +48 -0
- package/workspace/intel-report-ui-test.js +189 -0
- package/workspace/lib/board-metrics-premium.js +1 -1
- package/workspace/lib/headless.js +15 -2
- package/workspace/lib/insights-premium.js +5 -1
- package/workspace/lib/insights-records.js +14 -5
- package/workspace/lib/intel-report.js +419 -0
- package/workspace/lib/metric-draft-runs.js +193 -0
- package/workspace/lib/metric-drafts.js +231 -0
- package/workspace/lib/metrics-cli.js +104 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-setups.js +29 -13
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-insights-premium.js +2 -2
- package/workspace/lib/routes-insights-records.js +13 -5
- package/workspace/lib/routes-metric-drafts.js +141 -0
- package/workspace/lib/routes-phone-day.js +13 -2
- package/workspace/lib/routes-report-setups.js +92 -3
- package/workspace/lib/routes-viewer.js +5 -2
- package/workspace/metric-drafts-ui-test.js +209 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-phone-card-test.js +8 -5
- package/workspace/public/pm/bd-acts.js +3 -3
- package/workspace/public/pm/bd-pin-card.css +4 -4
- package/workspace/public/pm/bd-prog-panel.js +9 -4
- package/workspace/public/pm/cozy-aud.css +1 -1
- package/workspace/public/pm/cozy-board.css +256 -256
- package/workspace/public/pm/cozy-ev.css +45 -45
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-home-rows.css +23 -23
- package/workspace/public/pm/cozy-home.css +207 -207
- package/workspace/public/pm/cozy-insights.css +207 -108
- package/workspace/public/pm/cozy-live-pill.css +5 -5
- package/workspace/public/pm/cozy-mtg-present.css +23 -23
- package/workspace/public/pm/cozy-nav.js +1 -1
- package/workspace/public/pm/cozy-news.js +2 -2
- package/workspace/public/pm/cozy-panel.css +29 -29
- package/workspace/public/pm/cozy-pick.css +5 -5
- package/workspace/public/pm/cozy-rec-now.css +20 -20
- package/workspace/public/pm/cozy-rec-present.css +11 -11
- package/workspace/public/pm/cozy-rec-tab.css +13 -13
- package/workspace/public/pm/cozy-settings.js +1 -1
- package/workspace/public/pm/cozy-steps.css +9 -9
- package/workspace/public/pm/cozy-today.css +107 -71
- package/workspace/public/pm/cozy-viewer.css +7 -7
- package/workspace/public/pm/cozy-viewer.js +1 -1
- package/workspace/public/pm/cozy-vw-mtg.css +81 -81
- package/workspace/public/pm/cozy-vw-rp.css +53 -53
- package/workspace/public/pm/cozy-vw-shell.css +23 -23
- package/workspace/public/pm/cozy-vw.css +117 -117
- package/workspace/public/pm/cozy-xv.css +11 -11
- package/workspace/public/pm/cozy.css +18 -15
- package/workspace/public/pm/hi-pop.css +19 -19
- package/workspace/public/pm/home-app.js +28 -2
- package/workspace/public/pm/home-day.js +131 -26
- package/workspace/public/pm/home-ini.css +32 -32
- package/workspace/public/pm/home-line.css +7 -7
- package/workspace/public/pm/home-list.js +12 -1
- package/workspace/public/pm/home-phone-card.js +18 -15
- package/workspace/public/pm/ini-view.css +102 -102
- package/workspace/public/pm/ini-view.js +9 -3
- package/workspace/public/pm/loose-props.css +13 -13
- package/workspace/public/pm/metric-drafts.css +82 -0
- package/workspace/public/pm/metric-drafts.js +165 -0
- package/workspace/public/pm/ms-suggest.css +8 -8
- package/workspace/public/pm/ov-view.css +12 -12
- package/workspace/public/pm/premium-chart-tab.js +6 -6
- package/workspace/public/pm/premium-insights.js +298 -107
- package/workspace/public/pm/premium-report-intel.css +56 -0
- package/workspace/public/pm/premium-report-intel.js +232 -0
- package/workspace/public/pm/premium-shell.js +2 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium.css +127 -128
- package/workspace/public/pm/prog-order.css +6 -6
- package/workspace/public/pm/program-charter.css +23 -23
- package/workspace/public/pm/rp-parts.js +2 -2
- package/workspace/public/pm/sort-order.css +1 -1
- package/workspace/public/pm/split-merge.css +15 -15
- package/workspace/public/pm/task-card.css +21 -21
- package/workspace/public/pm/tk-tasks.css +37 -37
- package/workspace/public/pm/tk-view.css +6 -6
- package/workspace/public/pm/wf-page.css +28 -28
- package/workspace/public/premium-intelligence.html +82 -0
- package/workspace/server.js +38 -3
- package/workspace/skills/metric-draft.skill +47 -0
- package/workspace/test-lists/intel-report-ui.json +5 -0
- package/workspace/test-lists/intel-report.json +9 -0
- package/workspace/test-lists/metric-drafts-ui.json +5 -0
- package/workspace/test-lists/metric-drafts.json +9 -0
- package/workspace/test-run.js +3 -0
- package/workspace/public/premium-insights.html +0 -81
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* pm/premium-report-intel.css — a report made from Intelligence (batch 15 item 4, design A+: RfA1Entry, RfA2Draft, RfA6Phone).
|
|
2
|
+
* The header's report menu, and the draft in the side panel: the chips, The answer, The story with its switches, the five checks. Type scale only. */
|
|
3
|
+
.ins-menu.ins-rpmenu { min-width: 280px; }
|
|
4
|
+
.ins-menu#repMenu [role="menuitem"] { flex-direction: row; align-items: center; gap: 10px; }
|
|
5
|
+
.ins-menu#repMenu [role="menuitem"] > span { flex: 1; min-width: 0; }
|
|
6
|
+
.ins-menu#repMenu [role="menuitem"] small { display: block; font-size: var(--fs-1); font-weight: 600; color: var(--cz-ink3); }
|
|
7
|
+
.ins-menu#repMenu .ins-rpback { color: var(--cz-ink2); }
|
|
8
|
+
|
|
9
|
+
.ins-rpd { display: flex; flex-direction: column; gap: 14px; }
|
|
10
|
+
.ins-rps { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--cz-bluebg); }
|
|
11
|
+
.ins-rps.ok { background: var(--cz-okbg); }
|
|
12
|
+
.ins-rps .sp { display: inline-flex; color: var(--cz-blueink); }
|
|
13
|
+
.ins-rps.ok .sp { color: var(--cz-ok); }
|
|
14
|
+
.ins-rps .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-2); color: var(--cz-ink2); }
|
|
15
|
+
.ins-rps .t b { font-size: var(--fs-3); color: var(--cz-ink); }
|
|
16
|
+
|
|
17
|
+
.ins-rpc { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
18
|
+
.ins-rpchip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px; background: var(--cz-well); font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink); }
|
|
19
|
+
.ins-rpchip svg[aria-hidden="true"] { width: 14px; height: 14px; }
|
|
20
|
+
.ins-rpchip select, .ins-rpchip input { border: 0; background: none; font: inherit; font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink); outline: 0; padding: 0; min-width: 0; }
|
|
21
|
+
.ins-rpchip input::placeholder { color: var(--cz-ink3); font-weight: 600; }
|
|
22
|
+
.ins-rpchip:focus-within { box-shadow: 0 0 0 2px var(--cz-blue); }
|
|
23
|
+
.ins-rpchip.gh { background: none; color: var(--cz-ink3); font-weight: 600; }
|
|
24
|
+
|
|
25
|
+
.ins-rpb { display: flex; flex-direction: column; gap: 6px; }
|
|
26
|
+
.ins-rpl { font-size: var(--fs-1); font-weight: 800; color: var(--cz-ink3); }
|
|
27
|
+
.ins-rpl span { font-weight: 600; margin-left: 6px; }
|
|
28
|
+
.ins-rpa { width: 100%; box-sizing: border-box; resize: vertical; border: 1px solid var(--cz-hair); border-radius: 12px; padding: 10px 12px; background: var(--cz-card); font: inherit; font-size: var(--fs-3); font-weight: 800; line-height: 1.35; color: var(--cz-ink); }
|
|
29
|
+
.ins-rpa:focus { outline: 0; box-shadow: 0 0 0 2px var(--cz-blue); }
|
|
30
|
+
.ins-rpbox { border: 1px solid var(--cz-hair); border-radius: 14px; padding: 2px 14px; background: var(--cz-card); }
|
|
31
|
+
.ins-rpst { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--cz-hair); font-size: var(--fs-3); }
|
|
32
|
+
.ins-rpst:last-child { border-bottom: 0; }
|
|
33
|
+
.ins-rpst .n { font-size: var(--fs-1); font-weight: 800; color: var(--cz-ink3); }
|
|
34
|
+
.ins-rpst b { display: block; font-weight: 800; line-height: 1.3; }
|
|
35
|
+
.ins-rpst small { display: block; font-size: var(--fs-1); color: var(--cz-ink3); margin-top: 1px; }
|
|
36
|
+
.ins-rpst.off .w { opacity: .55; }
|
|
37
|
+
.ins-rplive { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-1); font-weight: 700; color: var(--cz-ok); }
|
|
38
|
+
.ins-rplive i { width: 6px; height: 6px; border-radius: 50%; background: var(--cz-dot-ok); }
|
|
39
|
+
.ins-rptog { position: relative; width: 34px; height: 20px; border-radius: 999px; border: 0; background: var(--cz-well2); cursor: pointer; padding: 0; flex: none; }
|
|
40
|
+
.ins-rptog::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--cz-card); transition: transform .15s ease; }
|
|
41
|
+
.ins-rptog.on { background: var(--cz-blueink); }
|
|
42
|
+
.ins-rptog.on::after { transform: translateX(14px); }
|
|
43
|
+
.ins-rptog:disabled { opacity: .5; cursor: default; }
|
|
44
|
+
.ins-rptog:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
45
|
+
.ins-rpask { grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 120px 140px; gap: 6px; }
|
|
46
|
+
.ins-rpask input { min-width: 0; height: 32px; border: 1px solid var(--cz-hair); border-radius: 8px; padding: 0 8px; background: var(--cz-card); font: inherit; font-size: var(--fs-2); color: var(--cz-ink); }
|
|
47
|
+
.ins-rpck { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
|
|
48
|
+
.ins-rpck .ck { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-2); color: var(--cz-ink2); padding: 4px 0; line-height: 1.35; }
|
|
49
|
+
.ins-rpck .m { width: 18px; height: 18px; border-radius: 50%; background: var(--cz-okbg); color: var(--cz-ok); display: inline-flex; align-items: center; justify-content: center; flex: none; }
|
|
50
|
+
.ins-rpck .m svg[aria-hidden="true"] { width: 12px; height: 12px; }
|
|
51
|
+
.ins-rpck .ck.w .m { background: var(--cz-latebg); color: var(--cz-late); }
|
|
52
|
+
@media (prefers-reduced-motion: reduce) { .ins-rptog::after { transition: none; } }
|
|
53
|
+
@media (max-width: 720px) {
|
|
54
|
+
.ins-rpck { grid-template-columns: minmax(0, 1fr); }
|
|
55
|
+
.ins-rpask { grid-template-columns: minmax(0, 1fr); }
|
|
56
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/* pm/premium-report-intel.js — a report made from Intelligence (batch 15 item 4, design A+: RfA1Entry, RfA2Draft, RfA6Phone; RfA3–A5 are the
|
|
2
|
+
* documents lib/intel-report.js writes and the report reader shows).
|
|
3
|
+
*
|
|
4
|
+
* The report icon in the Intelligence header, between Filter and +, opens a menu: This whole view, A dashboard, One key result or outcome.
|
|
5
|
+
* A key result's Viewer carries the same icon (pressRep, a press of the Viewer header).
|
|
6
|
+
* The ✦ strip gets one more kind of item: a report Claude proposes on its own (stripItems), with See the draft, Not now and ✓ Set it up.
|
|
7
|
+
* The draft opens in the Intelligence side panel (the Viewer card; the page's own side panel without it): who reads it, how often and the
|
|
8
|
+
* format (from history, with its ⓘ), The answer (the title of the report), The story (numbered finding titles, each a switch; Appendix off),
|
|
9
|
+
* and the five Checks before it goes out. One ✓ sets it up; Undo in the panel and the toast takes it back (the setup and its first draft).
|
|
10
|
+
*
|
|
11
|
+
* READS GET /api/report-setups/storyline?ws&board&scope&story (the draft, its defaults, its five checks, the strip's proposals).
|
|
12
|
+
* WRITES, each a press: POST /api/report-setups/setup { source: 'intelligence', scope, … }; /strip-dismiss (Not now); Undo is /remove then
|
|
13
|
+
* /api/report-documents/discard of the draft it made. Nothing is sent outward: the PM sends the report from their own mail.
|
|
14
|
+
*
|
|
15
|
+
* mount(P) — P is the page: { model(), scope(), viewer(o), close(), reload(), openFile(setupId, path), toast, esc }. */
|
|
16
|
+
import { pmGet, pmPost } from './http.js';
|
|
17
|
+
|
|
18
|
+
const SVG = (d, sw) => `<svg viewBox="0 0 24 24" aria-hidden="true"${sw ? ` stroke-width="${sw}"` : ''}><path d="${d}"/></svg>`;
|
|
19
|
+
export const REPORT_ICON = 'M6 3h9l4 4v14H6zM14 3v5h5M9 18v-3M12 18v-6M15 18v-4';
|
|
20
|
+
const I = { rep: REPORT_ICON, chk: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', eye: 'M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6',
|
|
21
|
+
info: 'M12 8h.01M11 12h1v5h1M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18', rep2: 'M17 2l4 4-4 4M3 11V9a3 3 0 0 1 3-3h15M7 22l-4-4 4-4M21 13v2a3 3 0 0 1-3 3H3', user: 'M12 12a4 4 0 1 0 0-8a4 4 0 1 0 0 8M4 21a8 8 0 0 1 16 0',
|
|
22
|
+
file: 'M6 3h9l4 4v14H6zM14 3v5h5', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', open: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5', next: 'M9 6l6 6-6 6' };
|
|
23
|
+
const DAYS = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
24
|
+
const OUTPUTS = [['pdf', 'One page + appendix'], ['google-slides', 'Slides'], ['google-doc', 'A document']];
|
|
25
|
+
const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
26
|
+
const schedSay = (s) => !s ? 'Weekly · Mon 09:00' : s.cadence === 'weekly' ? 'Weekly · ' + (s.day || 'Mon') + ' ' + (s.time || '09:00') : s.cadence === 'bi-weekly' ? 'Every two weeks · ' + (s.day || 'Mon') + ' ' + (s.time || '09:00')
|
|
27
|
+
: s.cadence === 'monthly' ? 'Monthly · day ' + (s.dayOfMonth || 1) + ' ' + (s.time || '09:00') : s.cadence === 'daily' ? 'Daily · ' + (s.time || '09:00') : 'Weekly · Mon 09:00';
|
|
28
|
+
const schedKey = (s) => JSON.stringify(s || {});
|
|
29
|
+
|
|
30
|
+
let P = null;
|
|
31
|
+
let D = null; // the draft on screen: { scope, data, story: { answer, ask, items }, audience, schedule, output, set, busy, msg, tm }
|
|
32
|
+
|
|
33
|
+
export function mount(page) {
|
|
34
|
+
P = page;
|
|
35
|
+
const b = document.getElementById('repB'), m = document.getElementById('repMenu');
|
|
36
|
+
if (!b || !m) return;
|
|
37
|
+
b.addEventListener('click', (e) => { e.stopPropagation(); const open = m.hidden; P.close(m); m.hidden = !open; b.setAttribute('aria-expanded', String(open)); if (open) drawMenu(); });
|
|
38
|
+
m.addEventListener('click', (e) => {
|
|
39
|
+
e.stopPropagation(); // a step redraws the menu, so the press's target leaves the page before the outside-press check could read it
|
|
40
|
+
const x = e.target.closest('[data-rs]'); if (!x) return;
|
|
41
|
+
if (x.dataset.rs === 'dash' || x.dataset.rs === 'one') { drawMenu(x.dataset.rs); return; }
|
|
42
|
+
if (x.dataset.rs === 'back') { drawMenu(); return; }
|
|
43
|
+
m.hidden = true; b.setAttribute('aria-expanded', 'false');
|
|
44
|
+
openDraft(x.dataset.rs);
|
|
45
|
+
});
|
|
46
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !m.hidden) { m.hidden = true; b.setAttribute('aria-expanded', 'false'); b.focus(); } });
|
|
47
|
+
document.addEventListener('click', (e) => { if (!m.hidden && !e.target.closest('#repMenu, #repB')) { m.hidden = true; b.setAttribute('aria-expanded', 'false'); } });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The menu (RfA1): the view on screen first, then a dashboard or one key result or outcome, each a list one step in. */
|
|
51
|
+
function drawMenu(step) {
|
|
52
|
+
const M = P.model(), m = document.getElementById('repMenu'), esc = P.esc;
|
|
53
|
+
if (!M) { m.innerHTML = ''; return; }
|
|
54
|
+
const row = (rs, icon, label, sub) => `<button type="button" role="menuitem" data-rs="${esc(rs)}">${SVG(icon)}<span>${esc(label)}${sub ? `<small>${esc(sub)}</small>` : ''}</span></button>`;
|
|
55
|
+
if (step === 'dash') {
|
|
56
|
+
const L = (M.dashboards || []).filter((d) => d.saved);
|
|
57
|
+
m.innerHTML = `<button type="button" role="menuitem" data-rs="back" class="ins-rpback">${SVG('M15 6l-6 6 6 6')}<span>A dashboard</span></button>` + (L.length ? L.map((d) => row('dashboard:' + d.id, I.rep, d.name, d.charts.length + (d.charts.length === 1 ? ' goal' : ' goals'))).join('') : '<p class="ins-mh">No saved dashboard yet</p>');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (step === 'one') {
|
|
61
|
+
const G = (M.goals || []).filter((g) => !g.program && !g.initiative), O = (M.outcomes || []).filter((o) => o.verdict || o.group === 'verdict');
|
|
62
|
+
m.innerHTML = `<button type="button" role="menuitem" data-rs="back" class="ins-rpback">${SVG('M15 6l-6 6 6 6')}<span>One key result or outcome</span></button>`
|
|
63
|
+
+ G.slice(0, 12).map((g) => row('goal:' + g.id, I.rep, g.title, g.nowTxt ? g.nowTxt + (g.targetTxt ? ' of ' + g.targetTxt : '') : 'no reading yet')).join('')
|
|
64
|
+
+ O.slice(0, 6).map((o) => row('outcome:' + o.id, I.rep, o.title, 'Did it work?')).join('');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const sc = P.scope();
|
|
68
|
+
m.innerHTML = '<p class="ins-mh">Make a report from</p>' + row(sc, I.rep, 'This whole view', sc === 'view' ? 'every goal and budget on screen' : 'the dashboard on screen')
|
|
69
|
+
+ `<button type="button" role="menuitem" data-rs="dash" aria-haspopup="menu">${SVG(I.rep)}<span>A dashboard</span>${SVG(I.next)}</button>`
|
|
70
|
+
+ `<button type="button" role="menuitem" data-rs="one" aria-haspopup="menu">${SVG(I.rep)}<span>One key result or outcome</span>${SVG(I.next)}</button>`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ── the ✦ strip (RfA1, RfA6) ───────────────────────────────────────────────────────────────────────────────────────────────────
|
|
74
|
+
let PROPS = [];
|
|
75
|
+
let propsFor = null;
|
|
76
|
+
/** The reports Claude proposes, for this workspace. Read once per load; the page's stripList adds them after the findings. */
|
|
77
|
+
export async function loadProposals(ws, board) {
|
|
78
|
+
propsFor = ws || null; PROPS = [];
|
|
79
|
+
if (!ws) return PROPS;
|
|
80
|
+
const r = await Promise.resolve(pmGet('/api/report-setups/storyline?' + q({ ws, board, scope: 'view' }))).catch(() => null);
|
|
81
|
+
if (propsFor !== (ws || null)) return PROPS;
|
|
82
|
+
PROPS = r && r.ok && Array.isArray(r.proposals) ? r.proposals : [];
|
|
83
|
+
return PROPS;
|
|
84
|
+
}
|
|
85
|
+
export const stripItems = () => PROPS.map((p) => ({ text: p.text, why: p.why || '', report: p }));
|
|
86
|
+
/** The presses of a proposal on the strip: See the draft, Not now, ✓ Set it up. */
|
|
87
|
+
export function stripActs(p) {
|
|
88
|
+
const esc = P.esc;
|
|
89
|
+
return `<button type="button" class="cz-ib sm" data-rp="see" data-rpid="${esc(p.id)}" aria-label="See the draft" title="See the draft">${SVG(I.eye)}</button>`
|
|
90
|
+
+ `<button type="button" class="cz-ib sm" data-rp="no" data-rpid="${esc(p.id)}" aria-label="Not now" title="Not now">${SVG(I.x)}</button>`
|
|
91
|
+
+ `<button type="button" class="cz-ib sm solid" data-rp="set" data-rpid="${esc(p.id)}" aria-label="${esc('Set it up' + (p.defaults && p.defaults.audience ? ' for ' + p.defaults.audience : ''))}" title="Set it up"${p.defaults && p.defaults.audience ? '' : ' disabled'}>${SVG(I.chk, 2.4)}</button>`;
|
|
92
|
+
}
|
|
93
|
+
/** A press on the strip; true when it was one of these. */
|
|
94
|
+
export async function stripPress(e) {
|
|
95
|
+
const x = e.target.closest('[data-rp]'); if (!x) return false;
|
|
96
|
+
const p = PROPS.find((y) => y.id === x.dataset.rpid); if (!p) return true;
|
|
97
|
+
const M = P.model();
|
|
98
|
+
if (x.dataset.rp === 'see') { openDraft(p.scope, p); return true; }
|
|
99
|
+
if (x.dataset.rp === 'no') {
|
|
100
|
+
x.disabled = true;
|
|
101
|
+
const r = await pmPost('/api/report-setups/strip-dismiss', { ws: M.board.ws, id: p.id });
|
|
102
|
+
if (!r || r.ok !== true) { x.disabled = false; P.toast((r && r.error) || 'It could not be put off. Nothing changed.'); return true; }
|
|
103
|
+
PROPS = PROPS.filter((y) => y.id !== p.id); P.redrawStrip(); P.toast('Not now. I will not propose it again.');
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (x.dataset.rp === 'set') {
|
|
107
|
+
x.disabled = true;
|
|
108
|
+
const got = await Promise.resolve(pmGet('/api/report-setups/storyline?' + q({ ws: M.board.ws, board: M.board.id, scope: p.scope }))).catch(() => null);
|
|
109
|
+
if (!got || !got.ok) { x.disabled = false; P.toast((got && got.error) || 'The draft could not be read. Nothing was set up.'); return true; }
|
|
110
|
+
D = draftState(p.scope, got, p);
|
|
111
|
+
await setUp();
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ── the draft (RfA2) ───────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
118
|
+
function draftState(scope, data, prop) {
|
|
119
|
+
const d = (prop && prop.defaults) || data.defaults || {};
|
|
120
|
+
return { scope, data, story: { items: data.storyline.items.map((x) => ({ id: x.id, on: x.on })), ask: null, answer: '' }, audience: d.audience || '', schedule: d.schedule || { cadence: 'weekly', day: 'Mon', time: '09:00' },
|
|
121
|
+
output: d.output || 'pdf', from: d.from || null, finding: d.finding || null, name: prop && prop.name ? prop.name : d.name || data.storyline.name, set: null, busy: false, msg: '', el: null, tm: null };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function openDraft(scope, prop) {
|
|
125
|
+
const M = P.model(); if (!M || !M.board.ws) { P.toast('Pick one product first: a report is made for one product.'); return; }
|
|
126
|
+
const got = await Promise.resolve(pmGet('/api/report-setups/storyline?' + q({ ws: M.board.ws, board: M.board.id, scope }))).catch(() => null);
|
|
127
|
+
if (!got || !got.ok) { P.toast((got && got.error) || 'The draft could not be read.'); return; }
|
|
128
|
+
D = draftState(scope, got, prop);
|
|
129
|
+
const me = D;
|
|
130
|
+
P.viewer({ kind: 'Report' + (D.audience ? ' · ' + D.audience : ''), title: D.name, icon: I.rep, id: 'report-draft:' + scope, onClose: () => { if (D === me) D = null; },
|
|
131
|
+
render: (el) => { me.el = el; el.classList.add('ins-rpd'); draw(); el.addEventListener('click', onClick); el.addEventListener('change', onChange); el.addEventListener('input', onInput); } });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const storyOn = (id) => { const x = D.story.items.find((y) => y.id === id); return x ? x.on : false; };
|
|
135
|
+
function draw() {
|
|
136
|
+
if (!D || !D.el) return;
|
|
137
|
+
const esc = P.esc, S = D.data.storyline, C = D.data.checks || [], nOn = S.items.filter((x) => storyOn(x.id)).length;
|
|
138
|
+
const sets = [D.schedule, { cadence: 'weekly', day: 'Mon', time: '09:00' }, { cadence: 'bi-weekly', day: 'Mon', time: '09:00' }, { cadence: 'monthly', dayOfMonth: 1, time: '09:00' }].filter((s, i, a) => a.findIndex((t) => schedKey(t) === schedKey(s)) === i);
|
|
139
|
+
const top = D.set
|
|
140
|
+
? `<div class="ins-rps ok"><span class="sp">${SVG(I.chk, 2.4)}</span><div class="t"><b>Set up</b><span>${esc('Issue 1 is drafted. ' + (D.audience || 'Your reader') + ' gets it ' + schedSay(D.schedule).toLowerCase().replace(' · ', ' at ').replace(/^weekly at (\w+)/, (m0, d) => (DAYS[d] || d) + 's at').replace(/^every two weeks at (\w+)/, (m0, d) => 'every other ' + (DAYS[d] || d) + ' at') + ', from your mail.')}</span></div>`
|
|
141
|
+
+ (D.set.drafted && D.set.drafted.path ? `<button type="button" class="cz-ib" data-rd="open" aria-label="Open issue 1" title="Open issue 1">${SVG(I.open)}</button>` : '')
|
|
142
|
+
+ `<button type="button" class="cz-ib" data-rd="undo" aria-label="Undo" title="Undo"${D.busy ? ' disabled' : ''}>${SVG(I.undo)}</button></div>`
|
|
143
|
+
: `<div class="ins-rps"><span class="sp">${SVG(I.spark)}</span><div class="t"><b>I drafted the story from Intelligence</b><span>Nothing goes out until you check it.</span></div>`
|
|
144
|
+
+ `<button type="button" class="cz-ib solid" data-rd="set" aria-label="Set it up" title="${esc(D.audience ? 'Set it up' : 'Say who reads it first')}"${D.busy || !D.audience.trim() ? ' disabled' : ''}>${SVG(I.chk, 2.4)}</button></div>`;
|
|
145
|
+
const chips = `<div class="ins-rpc">`
|
|
146
|
+
+ `<label class="ins-rpchip">${SVG(I.rep2)}<span class="vh">How often</span><select data-rf="sched" aria-label="How often">${sets.map((s, i) => `<option value="${i}"${schedKey(s) === schedKey(D.schedule) ? ' selected' : ''}>${esc(schedSay(s))}</option>`).join('')}</select></label>`
|
|
147
|
+
+ `<label class="ins-rpchip">${SVG(I.user)}<span class="vh">Who reads it</span><input data-rf="aud" value="${esc(D.audience)}" maxlength="120" placeholder="Who reads it?" aria-label="Who reads it" size="${Math.max(10, D.audience.length + 1)}"></label>`
|
|
148
|
+
+ `<label class="ins-rpchip">${SVG(I.file)}<span class="vh">Format</span><select data-rf="out" aria-label="Format">${OUTPUTS.map(([v, l]) => `<option value="${v}"${v === D.output ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select></label>`
|
|
149
|
+
+ (D.from ? `<span class="ins-rpchip gh" title="${esc(D.from.why || '')}" tabindex="0" aria-label="${esc('Why these: ' + D.from.text)}">${SVG(I.info)}${esc(D.from.text)}</span>` : '')
|
|
150
|
+
+ '</div>';
|
|
151
|
+
const answer = `<div class="ins-rpb"><p class="ins-rpl">The answer <span>the title of the report</span></p><textarea class="ins-rpa" data-rf="answer" rows="2" maxlength="200" aria-label="The answer, the title of the report"${D.set ? ' disabled' : ''}>${esc(D.story.answer || S.answer)}</textarea></div>`;
|
|
152
|
+
const ask = D.story.ask || { text: '', who: '', by: '' };
|
|
153
|
+
const rows = S.items.map((it, i) => {
|
|
154
|
+
const on = storyOn(it.id);
|
|
155
|
+
const extra = it.kind === 'ask' && on ? `<div class="ins-rpask"><input data-rf="askt" value="${esc(ask.text)}" maxlength="200" placeholder="The decision you need" aria-label="The decision you need"><input data-rf="askw" value="${esc(ask.who)}" maxlength="80" placeholder="Who decides" aria-label="Who decides"><input type="date" data-rf="askb" value="${esc(ask.by)}" aria-label="By when"></div>` : '';
|
|
156
|
+
const title = it.kind === 'ask' && ask.text ? 'Your decision: ' + ask.text : it.title;
|
|
157
|
+
const sub = it.kind === 'ask' ? (ask.text ? 'the ask · ' + (ask.who || 'who?') + ' · by ' + (ask.by || 'when?') : 'none asked yet') : it.sub;
|
|
158
|
+
return `<div class="ins-rpst${on ? '' : ' off'}"><span class="n">${i + 1}</span><span class="w"><b>${esc(title)}</b><small>${esc(sub)}</small></span>`
|
|
159
|
+
+ (on && it.kind !== 'ask' && it.kind !== 'appendix' ? '<span class="ins-rplive"><i></i>live</span>' : '<span></span>')
|
|
160
|
+
+ `<button type="button" class="ins-rptog${on ? ' on' : ''}" role="switch" aria-checked="${on}" aria-label="${esc('Include ' + title)}" data-rd="tog" data-id="${esc(it.id)}"${D.set ? ' disabled' : ''}></button>${extra}</div>`;
|
|
161
|
+
}).join('');
|
|
162
|
+
const story = `<div class="ins-rpb"><p class="ins-rpl">The story <span>each title is a finding · ${nOn} of ${S.items.length}</span></p><div class="ins-rpbox">${rows}</div></div>`;
|
|
163
|
+
const passed = C.filter((c) => c.ok).length;
|
|
164
|
+
const checks = C.length ? `<div class="ins-rpb"><p class="ins-rpl">Checks before it goes out <span>${passed} of ${C.length}</span></p><div class="ins-rpck">${C.map((c) => `<div class="ck${c.ok ? '' : ' w'}"><span class="m">${SVG(c.ok ? I.chk : I.info, 2.4)}</span><span>${esc(c.text)}</span></div>`).join('')}</div></div>` : '';
|
|
165
|
+
D.el.innerHTML = top + chips + answer + story + checks + `<p class="note" role="status" data-rmsg>${esc(D.msg || '')}</p>`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function refresh() {
|
|
169
|
+
const M = P.model(), me = D; if (!M || !me) return;
|
|
170
|
+
const story = { items: me.story.items, ...(me.story.answer ? { answer: me.story.answer } : {}), ...(me.story.ask && me.story.ask.text ? { ask: me.story.ask } : {}) };
|
|
171
|
+
const got = await Promise.resolve(pmGet('/api/report-setups/storyline?' + q({ ws: M.board.ws, board: M.board.id, scope: me.scope, story: JSON.stringify(story) }))).catch(() => null);
|
|
172
|
+
if (D !== me) return;
|
|
173
|
+
if (got && got.ok) { me.data = Object.assign({}, me.data, { storyline: got.storyline, checks: got.checks }); me.msg = ''; } else me.msg = (got && got.error) || 'The checks could not be read.';
|
|
174
|
+
draw();
|
|
175
|
+
}
|
|
176
|
+
const later = () => { clearTimeout(D.tm); D.tm = setTimeout(refresh, 350); };
|
|
177
|
+
|
|
178
|
+
function onClick(e) {
|
|
179
|
+
const x = e.target.closest('[data-rd]'); if (!x || x.disabled || !D) return;
|
|
180
|
+
if (x.dataset.rd === 'tog') {
|
|
181
|
+
const it = D.story.items.find((y) => y.id === x.dataset.id); if (!it) return;
|
|
182
|
+
it.on = !it.on;
|
|
183
|
+
if (it.id === 'ask' && it.on && !D.story.ask) D.story.ask = { text: '', who: D.audience || '', by: '' };
|
|
184
|
+
if (it.id === 'ask' && !it.on) D.story.ask = null;
|
|
185
|
+
draw(); later(); return;
|
|
186
|
+
}
|
|
187
|
+
if (x.dataset.rd === 'set') { setUp(); return; }
|
|
188
|
+
if (x.dataset.rd === 'undo') { undo(); return; }
|
|
189
|
+
if (x.dataset.rd === 'open' && D.set && D.set.drafted) P.openFile(D.set.setup, D.set.drafted.path);
|
|
190
|
+
}
|
|
191
|
+
function onChange(e) {
|
|
192
|
+
const f = e.target.dataset.rf; if (!f || !D) return;
|
|
193
|
+
if (f === 'sched') { const sets = [D.schedule, { cadence: 'weekly', day: 'Mon', time: '09:00' }, { cadence: 'bi-weekly', day: 'Mon', time: '09:00' }, { cadence: 'monthly', dayOfMonth: 1, time: '09:00' }].filter((s, i, a) => a.findIndex((t) => schedKey(t) === schedKey(s)) === i); D.schedule = sets[+e.target.value] || D.schedule; D.from = null; draw(); }
|
|
194
|
+
if (f === 'out') { D.output = e.target.value; D.from = null; draw(); }
|
|
195
|
+
}
|
|
196
|
+
function onInput(e) {
|
|
197
|
+
const f = e.target.dataset.rf; if (!f || !D) return;
|
|
198
|
+
if (f === 'aud') { D.audience = e.target.value; const b = D.el.querySelector('[data-rd="set"]'); if (b) b.disabled = !D.audience.trim() || D.busy; return; }
|
|
199
|
+
if (f === 'answer') { D.story.answer = e.target.value.replace(/[\r\n]+/g, ' ').trim(); later(); return; }
|
|
200
|
+
if (f === 'askt' || f === 'askw' || f === 'askb') { D.story.ask = D.story.ask || { text: '', who: '', by: '' }; D.story.ask[{ askt: 'text', askw: 'who', askb: 'by' }[f]] = e.target.value; later(); }
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function setUp() {
|
|
204
|
+
const M = P.model(), me = D; if (!M || !me || me.busy) return;
|
|
205
|
+
if (!me.audience.trim()) { me.msg = 'Say who reads it, then set it up.'; draw(); return; }
|
|
206
|
+
me.busy = true; draw();
|
|
207
|
+
const storyline = { items: me.story.items, ...(me.story.answer ? { answer: me.story.answer } : {}), ...(me.story.ask && me.story.ask.text ? { ask: me.story.ask } : {}) };
|
|
208
|
+
const r = await pmPost('/api/report-setups/setup', { ws: M.board.ws, board: M.board.id, source: 'intelligence', scope: me.scope, name: me.name, audience: me.audience.trim(), output: me.output, schedule: me.schedule, storyline, finding: me.finding || undefined });
|
|
209
|
+
me.busy = false;
|
|
210
|
+
if (!r || r.ok !== true) { me.msg = (r && r.error) || 'It could not be set up. Nothing changed.'; draw(); P.toast(me.msg); return; }
|
|
211
|
+
me.set = { setup: r.setup.id, drafted: r.drafted && r.drafted.ok ? r.drafted : null };
|
|
212
|
+
me.msg = r.drafted && r.drafted.ok ? '' : 'Set up, but issue 1 was not drafted: ' + ((r.drafted && r.drafted.error) || 'no reason given') + '. Draft it now from Reports and dashboards.';
|
|
213
|
+
draw();
|
|
214
|
+
PROPS = PROPS.filter((p) => !(p.defaults && p.defaults.finding && p.defaults.finding === me.finding));
|
|
215
|
+
P.toast('Set up. ' + me.audience.trim() + ' gets it ' + schedSay(me.schedule).toLowerCase().replace(' · ', ' at ') + ' from your mail.', { label: 'Undo', fn: () => { if (D === me) undo(); else undoOf(me); } });
|
|
216
|
+
P.reload();
|
|
217
|
+
}
|
|
218
|
+
async function undoOf(me) {
|
|
219
|
+
const M = P.model(); if (!M || !me.set) return false;
|
|
220
|
+
me.busy = true; if (D === me) draw();
|
|
221
|
+
const r = await pmPost('/api/report-setups/remove', { ws: M.board.ws, id: me.set.setup });
|
|
222
|
+
if (r && r.ok === true && me.set.drafted && me.set.drafted.path) await pmPost('/api/report-documents/discard', { ws: M.board.ws, path: me.set.drafted.path });
|
|
223
|
+
me.busy = false;
|
|
224
|
+
if (!r || r.ok !== true) { P.toast((r && r.error) || 'It could not be undone.'); if (D === me) draw(); return false; }
|
|
225
|
+
me.set = null; if (D === me) draw();
|
|
226
|
+
P.toast('Undone. Nothing was set up.'); P.reload();
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
const undo = () => undoOf(D);
|
|
230
|
+
|
|
231
|
+
/** The KR or outcome Viewer's report press (RfA1: the side panel has the icon too). */
|
|
232
|
+
export const viewerPress = (scope) => ({ act: 'report', label: 'Make a report from this', icon: REPORT_ICON, run: () => openDraft(scope) });
|
|
@@ -63,7 +63,7 @@ export function flip() {
|
|
|
63
63
|
const MORE = '<svg class="i" viewBox="0 0 24 24"><circle cx="6" cy="12" r="1.3"/><circle cx="12" cy="12" r="1.3"/><circle cx="18" cy="12" r="1.3"/></svg>';
|
|
64
64
|
const TH = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
|
|
65
65
|
/** The ⋯ menu's items that open a placeholder: [id, label, icon]. Insights adds what its own design names. Pure, for a unit test. */
|
|
66
|
-
export const moreItems = (path = location.pathname) => (/premium-insights/.test(path)
|
|
66
|
+
export const moreItems = (path = location.pathname) => (/premium-(insights|intelligence)/.test(path)
|
|
67
67
|
? [['srcItem', 'Sources', 'source'], ['tbExport', 'Export', 'export'], ['tbAbout', 'About these numbers', 'info']]
|
|
68
68
|
: [['srcItem', 'Sources', 'source']]);
|
|
69
69
|
function tbMount() {
|
|
@@ -913,7 +913,7 @@ export function openAddDoc(o) {
|
|
|
913
913
|
const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
|
|
914
914
|
const IC = (d) => `<svg class="i" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
915
915
|
const GL = { place: IC('M4 5h16v14H4zM4 10h16'), ini: IC('M12 3l9 9-9 9-9-9z'), doc: IC('M6 3h9l4 4v14H6zM14 3v5h5'), ses: IC('M5 4l14 8-14 8z'), need: IC('M12 4v10M12 18v2') };
|
|
916
|
-
const PLACES = [['Home', '/premium.html'], ['Board', '/premium-board.html'], ['
|
|
916
|
+
const PLACES = [['Home', '/premium.html'], ['Board', '/premium-board.html'], ['Intelligence', '/premium-intelligence.html']];
|
|
917
917
|
const PV_WS = new URLSearchParams(location.search).get('ws');
|
|
918
918
|
const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
|
|
919
919
|
async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
|
|
@@ -64,9 +64,9 @@ export function pageSrc(f, print = false) {
|
|
|
64
64
|
body = `<h1>${esc(title)}</h1>` + bodyHtml([sd.pre, ...sd.sections.map((x, n) => (n === 0 && h.h1 ? x.body : x.head + '\n' + x.body))].join('\n')).html;
|
|
65
65
|
} else body = `<h1>${esc(title)}</h1><pre>${esc(f.text)}</pre>`;
|
|
66
66
|
// a plain document: the browser's own heading sizes and black on white, no app colours (the frame cannot load the app's stylesheets)
|
|
67
|
-
const css = ':root{color-scheme:light}body{font:
|
|
67
|
+
const css = ':root{color-scheme:light}body{font:16px/1.6 -apple-system,"Segoe UI",system-ui,sans-serif;max-width:720px;margin:32px auto;padding:0 24px}'
|
|
68
68
|
+ 'table{border-collapse:collapse;width:100%}th,td{border:1px solid;padding:5px 9px;text-align:left;vertical-align:top}'
|
|
69
|
-
+ 'pre,code{font:
|
|
69
|
+
+ 'pre,code{font:14px ui-monospace,Menlo,monospace;white-space:pre-wrap}img{max-width:100%}@page{margin:18mm}';
|
|
70
70
|
return framedSrc(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(String(title || 'Document').replace(/\.[A-Za-z0-9]+$/, ''))}</title><style>${css}</style></head><body>${body}${go}</body></html>`);
|
|
71
71
|
}
|
|
72
72
|
/** The page a PDF is printed from, as the srcdoc of a sandboxed frame. Pure. */
|