create-pmos 0.401.0 → 0.403.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +227 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-adddoc-test.js +28 -22
  10. package/workspace/briefing-premium-board-test.js +107 -82
  11. package/workspace/briefing-premium-calendar-2-test.js +23 -10
  12. package/workspace/briefing-premium-calendar-3-test.js +23 -19
  13. package/workspace/briefing-premium-calendar-test.js +20 -15
  14. package/workspace/briefing-premium-initiative-test.js +25 -12
  15. package/workspace/briefing-premium-insights-test.js +31 -18
  16. package/workspace/briefing-premium-metrics-test.js +8 -8
  17. package/workspace/briefing-premium-sources-test.js +15 -10
  18. package/workspace/briefing-premium-test.js +39 -16
  19. package/workspace/changelog.json +24 -0
  20. package/workspace/fixtures/board-premium-facts.js +20 -3
  21. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  22. package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
  23. package/workspace/fixtures/program-ascent.js +101 -0
  24. package/workspace/guide/home.md +11 -7
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/guide/jira.md +38 -6
  27. package/workspace/guide/programs.md +37 -0
  28. package/workspace/home-rows-test.js +184 -0
  29. package/workspace/lib/briefing-premium-products.js +4 -4
  30. package/workspace/lib/briefing-premium.js +2 -2
  31. package/workspace/lib/calendar-layers.js +8 -4
  32. package/workspace/lib/initiative-layout.js +4 -3
  33. package/workspace/lib/jira-cli.js +17 -12
  34. package/workspace/lib/jira-status.js +1 -1
  35. package/workspace/lib/jira-tickets.js +126 -24
  36. package/workspace/lib/meeting-files.js +58 -0
  37. package/workspace/lib/meeting-learn.js +139 -0
  38. package/workspace/lib/meeting-material.js +12 -5
  39. package/workspace/lib/notes.js +3 -0
  40. package/workspace/lib/programs.js +129 -0
  41. package/workspace/lib/route-modules.js +1 -0
  42. package/workspace/lib/routes-brief-page.js +8 -1
  43. package/workspace/lib/routes-briefing-premium.js +1 -1
  44. package/workspace/lib/routes-calendar-views.js +24 -3
  45. package/workspace/lib/routes-meeting-material.js +38 -0
  46. package/workspace/lib/routes-meeting-points.js +23 -3
  47. package/workspace/lib/routes-programs.js +122 -0
  48. package/workspace/package-lock.json +2 -2
  49. package/workspace/package.json +1 -1
  50. package/workspace/premium-board-actions-test.js +31 -25
  51. package/workspace/premium-chat-context-test.js +1 -1
  52. package/workspace/premium-chat-goal-view-test.js +1 -1
  53. package/workspace/premium-chat-viewer-test.js +1 -1
  54. package/workspace/premium-core-doc-issue-test.js +13 -7
  55. package/workspace/premium-discuss-landing-test.js +83 -0
  56. package/workspace/premium-link-suggest-test.js +103 -0
  57. package/workspace/premium-report-read-test.js +86 -82
  58. package/workspace/premium-vw-backlog-test.js +6 -5
  59. package/workspace/premium-vw-cal-test.js +45 -19
  60. package/workspace/premium-vw-item-test.js +8 -6
  61. package/workspace/premium-vw-jira-test.js +3 -2
  62. package/workspace/premium-vw-meet-test.js +122 -66
  63. package/workspace/premium-vw-notes-test.js +7 -6
  64. package/workspace/premium-vw-rec-test.js +14 -13
  65. package/workspace/premium-vw-slides-test.js +11 -5
  66. package/workspace/program-panel-test.js +152 -0
  67. package/workspace/public/pm/bd-acts.js +24 -15
  68. package/workspace/public/pm/bd-asks.js +111 -30
  69. package/workspace/public/pm/bd-ini-panel.js +229 -0
  70. package/workspace/public/pm/bd-pop.js +2 -2
  71. package/workspace/public/pm/bd-prog-panel.js +436 -0
  72. package/workspace/public/pm/bd-prog.js +191 -0
  73. package/workspace/public/pm/bd-span.js +98 -15
  74. package/workspace/public/pm/bd-views.js +93 -29
  75. package/workspace/public/pm/cozy-board.css +214 -20
  76. package/workspace/public/pm/cozy-evui.js +4 -2
  77. package/workspace/public/pm/cozy-home-rows.css +54 -0
  78. package/workspace/public/pm/cozy-home.css +35 -0
  79. package/workspace/public/pm/cozy-insights.css +1 -2
  80. package/workspace/public/pm/cozy-mtg-present.css +160 -0
  81. package/workspace/public/pm/cozy-panel.css +155 -0
  82. package/workspace/public/pm/cozy-rec-pill.css +12 -0
  83. package/workspace/public/pm/cozy-rec-pill.js +46 -0
  84. package/workspace/public/pm/cozy-today.css +189 -0
  85. package/workspace/public/pm/cozy-viewer.js +307 -43
  86. package/workspace/public/pm/cozy-vw-mtg.css +96 -94
  87. package/workspace/public/pm/cozy-vw-rp.css +40 -25
  88. package/workspace/public/pm/cozy-vw-shell.css +127 -0
  89. package/workspace/public/pm/cozy-xv.css +51 -0
  90. package/workspace/public/pm/cozy-xv.js +34 -0
  91. package/workspace/public/pm/home-app.js +192 -72
  92. package/workspace/public/pm/home-chat.js +17 -4
  93. package/workspace/public/pm/home-data.js +1 -1
  94. package/workspace/public/pm/home-day.js +64 -0
  95. package/workspace/public/pm/home-ini-model.js +1 -1
  96. package/workspace/public/pm/home-ini.js +197 -54
  97. package/workspace/public/pm/home-list.js +100 -27
  98. package/workspace/public/pm/home-mentions.js +187 -0
  99. package/workspace/public/pm/home-rec-row.js +67 -0
  100. package/workspace/public/pm/home-review.js +20 -10
  101. package/workspace/public/pm/home-task.js +19 -18
  102. package/workspace/public/pm/home-today.js +137 -59
  103. package/workspace/public/pm/premium-board.js +294 -288
  104. package/workspace/public/pm/premium-insights.js +118 -82
  105. package/workspace/public/pm/premium-mtg-present.js +408 -100
  106. package/workspace/public/pm/premium-mtg-replay.js +70 -10
  107. package/workspace/public/pm/premium-report-read.js +118 -63
  108. package/workspace/public/pm/premium-vw-cal.js +62 -34
  109. package/workspace/public/pm/premium-vw-mtg.js +348 -192
  110. package/workspace/public/pm/program-model.js +192 -0
  111. package/workspace/public/pm/rec-state.js +63 -0
  112. package/workspace/public/pm/rp-parts.js +33 -8
  113. package/workspace/public/pm/tk-draft.js +107 -0
  114. package/workspace/public/pm/tk-model.js +134 -0
  115. package/workspace/public/pm/tk-send.js +124 -0
  116. package/workspace/public/pm/tk-tasks.css +120 -0
  117. package/workspace/public/premium-board.html +4 -2
  118. package/workspace/server.js +4 -2
  119. package/workspace/skills/jira-push.skill +3 -3
  120. package/workspace/test-lists/board-programs.json +9 -0
  121. package/workspace/test-lists/prd-to-jira.json +6 -0
  122. package/workspace/test-lists/program-hierarchy.json +11 -0
  123. package/workspace/test-lists/program-panel.json +9 -0
  124. package/workspace/test-lists/viewer-home-rows.json +9 -0
  125. package/workspace/test-lists/viewer-meetings.json +9 -0
  126. package/workspace/test-lists/viewer-shell-a.json +15 -0
  127. package/workspace/tk-tasks-test.js +199 -0
@@ -25,6 +25,7 @@ import { $, $$, esc, toast, wireRail, setPageGaps } from './premium-shell.js';
25
25
  import { pmPost } from './http.js';
26
26
  import { openReport } from './premium-report-read.js';
27
27
  import { mountNav } from './cozy-nav.js';
28
+ import { mountRecPill } from './cozy-rec-pill.js';
28
29
 
29
30
  let M = null; // the model
30
31
  let BM = null, bmErr = ''; // the Board measures (Delivery trends)
@@ -38,6 +39,7 @@ let loadedAt = 0;
38
39
  let selecting = false; let picked = []; // New dashboard: the goals picked in the table, in order
39
40
  wireRail('rep');
40
41
  mountNav('insights');
42
+ mountRecPill();
41
43
 
42
44
  const SV = (d, sw) => `<svg viewBox="0 0 24 24" aria-hidden="true"${sw ? ` stroke-width="${sw}"` : ''}><path d="${d}"/></svg>`;
43
45
  const I = {
@@ -67,8 +69,7 @@ function viewer(o) {
67
69
  }
68
70
  const isPhone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
69
71
  const closeViewer = () => { if (window.czViewer && typeof window.czViewer.close === 'function') window.czViewer.close(); else closeSide(); };
70
- // The floating Viewer covers the right of the page on a desktop, so the page makes room for it while it is open.
71
- document.addEventListener('cz-viewer', (e) => document.body.classList.toggle('ins-vwon', !!(e.detail && e.detail.open)));
72
+ // The Viewer floats over the page (XvAInsight); the page does not move for it.
72
73
 
73
74
  /* ── small menus: one open at a time, Escape and an outside press close it ─────────────────────────────────────────────────────── */
74
75
  const MENUS = [['#prodPick', '#prodMenu'], ['#viewChip', '#viewMenu'], ['#perChip', '#perMenu'], ['#filtB', '#filtMenu'], ['#newB', '#newMenu'], ['#moreB', '#moreMenu']];
@@ -497,95 +498,128 @@ function detailSvg(g, c, W = 490, H = 150) {
497
498
  const emptyTrend = (g, add) => `<div class="ins-box ins-etr"><span>${g.readings ? 'A trend needs 2 readings.' : 'No reading yet. A trend needs 2 readings.'} ${esc(nextReading(g))}</span>${add ? '<button type="button" class="ins-btn sm" data-gx="add">Add a reading</button>' : ''}</div>`;
498
499
  const dashSwitches = (g) => savedDash().map((D) => { const on = D.charts.includes(g.id); return `<div class="ins-trow"><span>${esc(D.name)}</span><button type="button" class="ins-tog${on ? ' on' : ''}" role="switch" aria-checked="${on}" aria-label="On ${esc(D.name)}" data-gx="dash" data-d="${esc(D.id)}"></button></div>`; }).join('')
499
500
  || '<p class="note">No dashboard is saved yet. New dashboard makes one.</p>';
500
- function goalDetailHtml(g, o) {
501
- const c = g.key ? byKey(g.key) : null, phone = isPhone(), steps = g.type === 'Done or not' && g.steps && g.steps.length;
502
- const tabs = [['read', 'Readings'], ['moved', 'Moved by']].concat(phone && o.own ? [['dash', 'Dashboards']] : []);
503
- const bar = `<div class="ins-vbar" role="tablist" aria-label="${esc(g.title)}">${tabs.map(([k, l]) => `<button type="button" role="tab" class="ins-vtab${o.tab === k ? ' on' : ''}" aria-selected="${o.tab === k}" data-gt="${k}">${l}</button>`).join('')}`
504
- + (o.own && M.goals.some((x) => x.id === g.id) ? `<button type="button" class="cz-ib sm ins-vedit" data-gx="chart" aria-label="Edit chart" title="Edit chart">${SV(I.pen)}</button>` : '') + '</div>';
505
- const sub = [g.nowTxt ? g.nowTxt + ' now' : 'No reading yet', g.targetTxt ? g.targetTxt + (g.byAt ? ' by ' + md(day(g.byAt)) : '') : 'no target', g.source ? 'from ' + srcOf(g).toLowerCase() : ''].filter(Boolean).join(' · ');
501
+ /* ── a goal in the Viewer's shell A (initiative viewer-shell-a, V9; canvas XvAInsight): the summary card with its one primary (Add a
502
+ * reading), the chart, then the folding rows Readings, Moved by and On your dashboards. The tabs Readings | Moved by are gone; on a phone
503
+ * it is the same shell, full screen. ⋯ holds Edit chart, then Copy link and Copy as text. Discuss in chat takes the goal to Home. ── */
504
+ const vwOpen = (o) => { const V = window.czViewer; return V && typeof V.open === 'function' && typeof V.czSummary === 'function' ? V.open(o) : null; };
505
+ /** The change since the reading before: "Up 3 since Oct 6." in the goal's unit; '' with fewer than 2 readings. */
506
+ function sinceOf(g) {
507
+ const S = g.series || []; if (S.length < 2) return '';
508
+ const a = S[S.length - 2], b = S[S.length - 1], d = Math.round((b.v - a.v) * 100) / 100;
509
+ return (d === 0 ? 'No change' : (d > 0 ? 'Up ' : 'Down ') + unitV(g, Math.abs(d))) + ' since ' + md(day(a.at)) + '.';
510
+ }
511
+ function goalSummary(g, own) {
512
+ const steps = g.type === 'Done or not' && g.steps && g.steps.length;
513
+ const line = [g.nowTxt ? g.nowTxt + ' now' : 'No reading yet', g.targetTxt ? 'target ' + g.targetTxt + (g.byAt ? ' by ' + md(day(g.byAt)) : '') : 'no target'].join(' · ');
506
514
  const pace = g.pace ? (g.pace.head !== '—' ? g.pace.head + (g.pace.sub ? ', ' + g.pace.sub : '') : g.pace.sub) : '';
507
- const sub2 = [PF ? g.prod : '', g.dirTxt, pace, g.owner ? 'owner ' + g.owner : '', g.guardrail].filter(Boolean).join(' · ');
508
- const head = `<div class="ins-gh"><p class="ins-gsub">${esc(sub)}</p>${sub2 ? `<p class="note">${esc(sub2)}</p>` : ''}</div>`;
509
- const chart = steps ? stepsHtml(g) : c ? detailSvg(g, c, phone ? 358 : 490, phone ? 120 : 150) : emptyTrend(g, !o.adding);
510
- let body = '';
511
- if (o.tab === 'moved') {
512
- body = g.moves.length ? `<div class="ins-mvl">${g.moves.map((r) => initRow(r)).join('')}</div>` : `<p class="note">${M.initiativesRead ? 'No initiative anchors to it yet. An initiative moves it once its anchor names it.' : 'The initiatives are not read yet.'}</p>`;
513
- } else if (o.tab === 'dash') {
514
- body = '<p class="ins-lbl">On your dashboards</p>' + dashSwitches(g);
515
- } else {
516
- const R = g.series.slice().reverse(), shown = o.more ? R : R.slice(0, 3);
517
- body = (R.length ? `<div class="ins-th2"><span>Reading</span><span>Value</span><span>Source</span></div>` + shown.map((r) => `<div class="ins-trow ins-rd3"><span>${esc(md(day(r.at)) + ' ' + r.at.slice(0, 4))}</span><b>${esc(unitV(g, r.v))}</b><span class="note">${esc(srcOf(g))}</span></div>`).join('')
518
- + (R.length > shown.length ? `<button type="button" class="ins-btn sm ghost" data-gx="all">All ${R.length} readings</button>` : '') : '')
519
- + (steps ? `<form class="ins-mf" data-stf><p class="ins-lbl">Steps</p>${g.steps.map((x, i) => `<label class="ins-ck2"><input type="checkbox" name="s${i}"${x.done ? ' checked' : ''}> ${esc(x.text)}</label>`).join('')}<div class="ins-mact"><button type="submit" class="ins-btn sm dark">Save steps</button><span class="note" data-msg role="status"></span></div></form>` : '')
520
- + (!steps && o.adding ? `<form class="ins-mf ins-box" data-rdf><div class="ins-2"><label class="ins-fl">Date<input class="ins-inp" type="date" name="at" value="${esc(M.today || '')}"></label><label class="ins-fl">Value${g.unit ? ' (' + esc(g.unit) + ')' : ''}<input class="ins-inp" name="v" inputmode="decimal" maxlength="16"></label></div><div class="ins-mact"><button type="submit" class="ins-btn sm dark">Add reading</button><button type="button" class="ins-btn sm ghost" data-gx="cancel">Cancel</button><span class="note" data-msg role="status"></span></div></form>` : '')
521
- + `<div class="ins-acts">${!steps && !o.adding && (c || !phone) ? `<button type="button" class="ins-btn sm${phone ? ' wide' : ''}" data-gx="add">Add a reading</button>` : ''}${g.moves.length && !phone ? `<button type="button" class="ins-btn sm ghost ins-clip" data-gx="moved">Moved by: ${esc(g.moves.map((m) => m.title).join(', '))}</button>` : ''}</div>`
522
- + (o.own && !phone ? '<p class="ins-lbl">On your dashboards</p>' + dashSwitches(g) : '');
523
- }
524
- return `<div class="ins-gd${phone ? ' ph' : ''}">${phone ? head + chart + bar : bar + head + (o.tab === 'read' ? chart : '')}<div class="ins-gb" role="tabpanel">${body}</div><p class="note ins-gmsg" data-gmsg role="status"></p></div>`;
515
+ const ship = shipsOf(g).sort((x, y) => y.t - x.t)[0];
516
+ const text = [sinceOf(g), pace ? pace.charAt(0).toUpperCase() + pace.slice(1) + '.' : '', ship ? ship.label + ' on ' + md(ship.t) + '.' : ''].filter(Boolean).join(' ');
517
+ const meta = [PF ? g.prod : '', g.source ? 'From ' + srcOf(g).toLowerCase() : '', g.owner, g.dirTxt, g.guardrail].filter(Boolean).join(' · ');
518
+ const tone = g.pace && g.pace.tone === 'late' ? 'warn' : '';
519
+ return { line, tone, text, meta, primary: !steps && own ? { label: 'Add a reading', act: 'add' } : null };
520
+ }
521
+ function readingsHtml(g, o) {
522
+ const steps = g.type === 'Done or not' && g.steps && g.steps.length, R = g.series.slice().reverse(), shown = o.more ? R : R.slice(0, 3);
523
+ return (R.length ? `<div class="ins-th2"><span>Reading</span><span>Value</span><span>Source</span></div>` + shown.map((r) => `<div class="ins-trow ins-rd3"><span>${esc(md(day(r.at)) + ' ' + r.at.slice(0, 4))}</span><b>${esc(unitV(g, r.v))}</b><span class="note">${esc(srcOf(g))}</span></div>`).join('')
524
+ + (R.length > shown.length ? `<div><button type="button" class="ins-btn sm ghost" data-gx="all">All ${R.length} readings</button></div>` : '') : `<p class="note">${esc(nextReading(g))}</p>`)
525
+ + (steps ? `<form class="ins-mf" data-stf><p class="ins-lbl">Steps</p>${g.steps.map((x, i) => `<label class="ins-ck2"><input type="checkbox" name="s${i}"${x.done ? ' checked' : ''}> ${esc(x.text)}</label>`).join('')}<div class="ins-mact"><button type="submit" class="ins-btn sm dark">Save steps</button><span class="note" data-msg role="status"></span></div></form>` : '');
526
+ }
527
+ const movedHtml = (g) => (g.moves.length ? `<div class="ins-mvl">${g.moves.map((r) => initRow(r)).join('')}</div>` : `<p class="note">${M.initiativesRead ? 'No initiative anchors to it yet. An initiative moves it once its anchor names it.' : 'The initiatives are not read yet.'}</p>`);
528
+ function goalBodyHtml(g, o) {
529
+ const V = window.czViewer, c = g.key ? byKey(g.key) : null, phone = isPhone(), steps = g.type === 'Done or not' && g.steps && g.steps.length;
530
+ const chart = steps ? stepsHtml(g) : c ? detailSvg(g, c, phone ? 358 : 490, phone ? 120 : 150) : emptyTrend(g, false);
531
+ const form = !steps && o.adding ? `<form class="ins-mf ins-box" data-rdf><div class="ins-2"><label class="ins-fl">Date<input class="ins-inp" type="date" name="at" value="${esc(M.today || '')}"></label><label class="ins-fl">Value${g.unit ? ' (' + esc(g.unit) + ')' : ''}<input class="ins-inp" name="v" inputmode="decimal" maxlength="16"></label></div><div class="ins-mact"><button type="submit" class="ins-btn sm dark">Add reading</button><button type="button" class="ins-btn sm ghost" data-gx="cancel">Cancel</button><span class="note" data-msg role="status"></span></div></form>` : '';
532
+ const onDash = savedDash().filter((D) => D.charts.includes(g.id)).length;
533
+ const rows = [
534
+ { id: 'read', title: 'Readings', count: g.series.length, open: o.open === 'read', render: () => readingsHtml(g, o) },
535
+ { id: 'moved', title: 'Moved by', count: g.moves.length, open: o.open === 'moved', render: () => movedHtml(g) },
536
+ o.own ? { id: 'dash', title: 'On your dashboards', count: onDash, render: () => dashSwitches(g) } : null,
537
+ ];
538
+ return V.czSummary(goalSummary(g, o.own && !o.adding)) + chart + form + V.czSections(rows, { key: 'goal' }) + '<p class="note ins-gmsg" data-gmsg role="status"></p>';
539
+ }
540
+ /** The goal as plain text, for Copy as text. */
541
+ function goalText(g) {
542
+ const s = goalSummary(g, false), kr = krId(g);
543
+ return [(kr ? kr + ' · ' : '') + g.title, s.line, s.text, s.meta].filter(Boolean).join('\n') + (g.moves.length ? '\nMoved by: ' + g.moves.map((m) => m.title).join(', ') : '');
525
544
  }
526
- function openGoalDetail(id, tab0) {
545
+ const goalLink = (g) => new URL(setQ({ goal: g.id, tab: null }), location.href).href;
546
+ function copyText(text, said) { try { navigator.clipboard.writeText(text).then(() => toast(said), () => toast('This browser did not allow the copy.')); } catch { toast('This browser did not allow the copy.'); } }
547
+ function openGoalDetail(id, open0) {
527
548
  let g = goalById(id); if (!g) return;
528
- const own = goalWs(g) === M.board.ws, st = { tab: tab0 || 'read', more: false, adding: false, own };
549
+ const own = goalWs(g) === M.board.ws, st = { open: open0 || '', more: false, adding: false, own };
529
550
  const kr = krId(g);
530
- viewer({ kind: 'Goal' + (kr ? ' · ' + kr : ''), title: g.title, icon: 'goal', id: 'goal:' + id, render: (el) => {
531
- const draw = () => { el.innerHTML = goalDetailHtml(g, st); };
532
- const fresh = async (said) => { toast(said); await load(); if (PF) await openPortfolio(); g = goalById(id); if (g) draw(); };
533
- draw();
534
- el.addEventListener('click', async (e) => {
535
- const t = e.target.closest('[data-gt]'); if (t) { st.tab = t.dataset.gt; draw(); return; }
536
- const x = e.target.closest('[data-gx]'); if (!x || x.disabled) return;
537
- const k = x.dataset.gx, msg = el.querySelector('[data-gmsg]');
538
- if (k === 'chart') openChartEdit(g.id);
539
- else if (k === 'all') { st.more = true; draw(); }
540
- else if (k === 'add') { st.adding = true; st.tab = 'read'; draw(); const f = el.querySelector('[data-rdf] [name="v"]'); if (f) f.focus(); }
541
- else if (k === 'cancel') { st.adding = false; draw(); }
542
- else if (k === 'moved') { st.tab = 'moved'; draw(); }
543
- else if (k === 'dash') {
544
- const D = savedDash().find((d) => d.id === x.dataset.d); if (!D) return;
545
- const on = D.charts.includes(g.id); x.disabled = true; msg.textContent = 'Saving.';
546
- const res = await saveDash({ id: D.id, name: D.name, purpose: D.purpose, charts: on ? D.charts.filter((c) => c !== g.id) : D.charts.concat(g.id), main: D.main });
547
- if (!res || res.ok !== true) { x.disabled = false; msg.textContent = (res && res.error) || 'The dashboard could not be saved. Nothing changed.'; return; }
548
- await fresh((on ? 'Took it off ' : 'Added it to ') + D.name + '.');
549
- }
550
- });
551
- el.addEventListener('submit', async (e) => {
552
- const f = e.target; e.preventDefault(); const m = f.querySelector('[data-msg]');
553
- if (f.matches('[data-rdf]')) {
554
- const v = f.v.value.trim(), at = f.at.value;
555
- if (!/^\d{4}-\d{2}-\d{2}$/.test(at) || v === '' || !Number.isFinite(Number(v))) { m.textContent = 'Pick a date and type a number.'; return; }
556
- m.textContent = 'Saving.';
557
- const res = await pmPost('/api/records/kr-metrics/reading', { ws: goalWs(g), rid: goalRid(g), at, value: Number(v), why: 'Reading from Insights' });
558
- if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'It could not be saved. Nothing changed.'; return; }
559
- st.adding = false; await fresh('Added the reading.');
560
- } else if (f.matches('[data-stf]')) {
561
- m.textContent = 'Saving.';
562
- const res = await pmPost('/api/insights-records/steps', { ws: goalWs(g), rid: goalRid(g), done: g.steps.map((_, i) => f['s' + i].checked) });
563
- if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'It could not be saved. Nothing changed.'; return; }
564
- await fresh('Saved the steps.');
565
- }
566
- });
567
- } });
551
+ const more = [];
552
+ if (own && M.goals.some((x) => x.id === g.id)) more.push({ label: 'Edit chart', on: () => openChartEdit(g.id) }, { sep: true });
553
+ more.push({ label: 'Copy link', on: () => copyText(goalLink(g), 'Link copied.') }, { label: 'Copy as text', on: () => copyText(goalText(g), 'Copied as text.') });
554
+ const body = vwOpen({ kind: 'Goal', title: (kr ? kr + ' · ' : '') + g.title, icon: 'goal', id: 'goal:' + id, more,
555
+ discuss: true,
556
+ render: (el) => {
557
+ el.classList.add('ins-vbody', 'ins-xv');
558
+ const draw = () => { const top = el.scrollTop; el.innerHTML = goalBodyHtml(g, st); el.scrollTop = top; };
559
+ const fresh = async (said) => { toast(said); await load(); if (PF) await openPortfolio(); g = goalById(id); if (g) draw(); };
560
+ draw();
561
+ el.onclick = async (e) => {
562
+ const x = e.target.closest('[data-gx], [data-czs-act]'); if (!x || x.disabled) return;
563
+ const k = x.dataset.gx || x.dataset.czsAct, msg = el.querySelector('[data-gmsg]');
564
+ if (k === 'all') { st.more = true; st.open = 'read'; draw(); }
565
+ else if (k === 'add') { st.adding = true; draw(); const f = el.querySelector('[data-rdf] [name="v"]'); if (f) f.focus(); }
566
+ else if (k === 'cancel') { st.adding = false; draw(); }
567
+ else if (k === 'dash') {
568
+ const D = savedDash().find((d) => d.id === x.dataset.d); if (!D) return;
569
+ const on = D.charts.includes(g.id); x.disabled = true; msg.textContent = 'Saving.';
570
+ const res = await saveDash({ id: D.id, name: D.name, purpose: D.purpose, charts: on ? D.charts.filter((c) => c !== g.id) : D.charts.concat(g.id), main: D.main });
571
+ if (!res || res.ok !== true) { x.disabled = false; msg.textContent = (res && res.error) || 'The dashboard could not be saved. Nothing changed.'; return; }
572
+ await fresh((on ? 'Took it off ' : 'Added it to ') + D.name + '.');
573
+ }
574
+ };
575
+ el.onsubmit = async (e) => {
576
+ const f = e.target; if (!f.matches('[data-rdf], [data-stf]')) return;
577
+ e.preventDefault(); const m = f.querySelector('[data-msg]');
578
+ if (f.matches('[data-rdf]')) {
579
+ const v = f.v.value.trim(), at = f.at.value;
580
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(at) || v === '' || !Number.isFinite(Number(v))) { m.textContent = 'Pick a date and type a number.'; return; }
581
+ m.textContent = 'Saving.';
582
+ const res = await pmPost('/api/records/kr-metrics/reading', { ws: goalWs(g), rid: goalRid(g), at, value: Number(v), why: 'Reading from Insights' });
583
+ if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'It could not be saved. Nothing changed.'; return; }
584
+ st.adding = false; await fresh('Added the reading.');
585
+ } else {
586
+ m.textContent = 'Saving.';
587
+ const res = await pmPost('/api/insights-records/steps', { ws: goalWs(g), rid: goalRid(g), done: g.steps.map((_, i) => f['s' + i].checked) });
588
+ if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'It could not be saved. Nothing changed.'; return; }
589
+ await fresh('Saved the steps.');
590
+ }
591
+ };
592
+ } });
593
+ if (!body) openGoalSide(g, st); // no shell A on this page: the page's own side panel
568
594
  }
569
- /* a health budget in the same frame: its reading is its share of the board's open initiatives against its cap; what moves it is the work anchored to it */
595
+ /** The fallback with no Viewer: the goal's summary and rows in the page's side panel. */
596
+ function openGoalSide(g, st) {
597
+ openSide({ kind: 'view', eye: 'Goal', title: g.title, body: '', note: '', go: null });
598
+ const sum = goalSummary(g, false);
599
+ $('#sideBody').innerHTML = `<div class="ins-gd"><div class="ins-gh"><p class="ins-gsub">${esc(sum.line)}</p>${sum.text ? `<p class="note">${esc(sum.text)}</p>` : ''}</div>${readingsHtml(g, st)}${movedHtml(g)}</div>`;
600
+ }
601
+ /* a health budget in the same shell: its reading is its share of the board's open initiatives against its cap; what moves it is the work anchored to it */
570
602
  function openBudget(id) {
571
603
  const b = (M.budgets || []).find((x) => x.id === id); if (!b) return;
572
- let tab = 'read';
573
- viewer({ kind: 'Health budget · ' + b.anchor, title: b.title, icon: 'goal', id: 'budget:' + id, render: (el) => {
574
- const draw = () => {
575
- const R = b.reading, has = R && R.share !== null;
576
- const sub = [has ? pct(R.share) + ' now' : 'No reading yet', b.cap !== null ? 'cap ' + pct(b.cap) + ' of a quarter’s initiatives' : 'no cap declared', 'always on'].join(' · ');
577
- const bar = `<div class="ins-vbar" role="tablist" aria-label="${esc(b.title)}">${[['read', 'Readings'], ['moved', 'Moved by']].map(([k, l]) => `<button type="button" role="tab" class="ins-vtab${tab === k ? ' on' : ''}" aria-selected="${tab === k}" data-bt="${k}">${l}</button>`).join('')}</div>`;
604
+ const R = b.reading, has = R && R.share !== null;
605
+ const sum = { line: [has ? pct(R.share) + ' now' : 'No reading yet', b.cap !== null ? 'cap ' + pct(b.cap) + ' of a quarter’s initiatives' : 'no cap declared'].join(' · '), tone: has && R.over ? 'warn' : '',
606
+ text: has ? (R.over ? 'Over its cap.' : 'Within its cap.') + ' ' + R.n + ' of ' + R.total + ' open on the Board.' : 'It has no reading: ' + (b.declared ? 'no open initiative to share.' : 'it is not in the budget registry.'),
607
+ meta: [b.anchor, 'always on', 'judged every week'].join(' · ') };
608
+ const text = [b.title, sum.line, sum.text].join('\n');
609
+ vwOpen({ kind: 'Health budget', title: b.title, icon: 'goal', id: 'budget:' + id, more: [{ label: 'Copy as text', on: () => copyText(text, 'Copied as text.') }],
610
+ discuss: true,
611
+ render: (el) => {
612
+ el.classList.add('ins-vbody', 'ins-xv');
613
+ const V = window.czViewer;
578
614
  const meter = has && b.cap !== null ? bandSvg([{ at: M.today || iso(today()), v: R.share * 100 }], b.cap * 100, true, R.over ? 'late' : 'ok', b.title + ': ' + pct(R.share) + ' of open initiatives, the green band is inside its ' + pct(b.cap) + ' cap', isPhone() ? 358 : 490, 60) : '';
579
- const body = tab === 'moved' ? (b.moves.length ? `<div class="ins-mvl">${b.moves.map((r) => initRow(r)).join('')}</div>` : '<p class="note">No initiative anchors to it.</p>')
580
- : (has ? `<div class="ins-th2"><span>Reading</span><span>Value</span><span>Source</span></div><div class="ins-trow ins-rd3"><span>${esc(md(today()) + ' ' + iso(today()).slice(0, 4))}</span><b>${esc(pct(R.share))}</b><span class="note">${esc(R.n + ' of ' + R.total + ' open on the Board')}</span></div>` : '<div class="ins-box">It has no reading: ' + esc(b.declared ? 'no open initiative to share.' : 'it is not in the budget registry.') + '</div>')
581
- + `<div class="ins-box note">${esc(b.covers ? 'Covers ' + b.covers + '. ' : 'What it covers is not declared. ')}It is read each time the Board is read. The PM edits the budgets in planning/okrs/health-budgets.md.</div>`;
582
- el.innerHTML = `<div class="ins-gd">${bar}<div class="ins-gh"><p class="ins-gsub">${esc(sub)}</p><p class="note">${esc(has ? (R.over ? 'Over its cap' : 'Within its cap') : '')}</p></div>${tab === 'read' ? meter : ''}<div class="ins-gb" role="tabpanel">${body}</div></div>`;
583
- };
584
- draw();
585
- el.addEventListener('click', (e) => { const t = e.target.closest('[data-bt]'); if (t) { tab = t.dataset.bt; draw(); } });
586
- } });
615
+ const rows = [
616
+ { id: 'bread', title: 'Readings', count: has ? 1 : 0, render: () => (has ? `<div class="ins-th2"><span>Reading</span><span>Value</span><span>Source</span></div><div class="ins-trow ins-rd3"><span>${esc(md(today()) + ' ' + iso(today()).slice(0, 4))}</span><b>${esc(pct(R.share))}</b><span class="note">${esc(R.n + ' of ' + R.total + ' open on the Board')}</span></div>` : '')
617
+ + `<p class="note">${esc(b.covers ? 'Covers ' + b.covers + '. ' : 'What it covers is not declared. ')}It is read each time the Board is read. The PM edits the budgets in planning/okrs/health-budgets.md.</p>` },
618
+ { id: 'bmoved', title: 'Moved by', count: b.moves.length, render: () => (b.moves.length ? `<div class="ins-mvl">${b.moves.map((r) => initRow(r)).join('')}</div>` : '<p class="note">No initiative anchors to it.</p>') },
619
+ ];
620
+ el.innerHTML = V.czSummary(sum) + meter + V.czSections(rows, { key: 'budget' });
621
+ } });
587
622
  }
588
-
589
623
  /* the phone (AgInsPhone): one card per goal, its status at the top right, its value, its so-far, its bar and the first initiative that moves it */
590
624
  function cardPill(g) {
591
625
  const t = g.pace && g.pace.tone !== 'q' ? g.pace.tone : g.tone;
@@ -1293,6 +1327,8 @@ async function load() {
1293
1327
  return;
1294
1328
  }
1295
1329
  const first = !M; M = r.model; loadedAt = Date.now(); draw(); if (first || !BM) bmLoad();
1330
+ // A shared goal link (?goal=<id>, from "Copy link" in the goal's ⋯) opens that goal once, after the first read.
1331
+ if (first) { const gid = new URLSearchParams(location.search).get('goal'); if (gid && allGoals().some((g) => g.id === gid)) openGoalDetail(gid); }
1296
1332
  }
1297
1333
  { const t = new URLSearchParams(location.search).get('tab'); setTab(t === 'outcomes' || t === 'library' ? t : 'goals'); }
1298
1334
  load();