create-pmos 0.827.0 → 0.829.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 (103) hide show
  1. package/package.json +217 -45
  2. package/payload/KIT-VERSION +1 -1
  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/workspace/bin/pmos.js +19 -9
  7. package/workspace/board-deliveries-test.js +2 -2
  8. package/workspace/changelog.json +216 -12
  9. package/workspace/guide/cli.md +62 -0
  10. package/workspace/guide/home.md +1 -0
  11. package/workspace/guide/settings-and-switches.md +1 -0
  12. package/workspace/lib/board-cli.js +5 -1
  13. package/workspace/lib/board-premium.js +1 -0
  14. package/workspace/lib/critical-needs.js +162 -0
  15. package/workspace/lib/deps-cli.js +102 -0
  16. package/workspace/lib/engine/boards.js +13 -2
  17. package/workspace/lib/features.json +5 -0
  18. package/workspace/lib/five-action-cap.js +84 -0
  19. package/workspace/lib/needs-providers.js +1 -0
  20. package/workspace/lib/page-one-answer.js +86 -0
  21. package/workspace/lib/pages-cli.js +6 -2
  22. package/workspace/lib/people-cli.js +43 -2
  23. package/workspace/lib/pmos-verbs.js +15 -1
  24. package/workspace/lib/portfolio-cli.js +64 -0
  25. package/workspace/lib/portfolio.js +168 -0
  26. package/workspace/lib/prototype-cli.js +86 -0
  27. package/workspace/lib/report-cli.js +12 -2
  28. package/workspace/lib/report-readers.js +5 -3
  29. package/workspace/lib/review-pack.js +348 -0
  30. package/workspace/lib/review-reasons.js +357 -0
  31. package/workspace/lib/route-modules.js +6 -0
  32. package/workspace/lib/routes-boards.js +25 -2
  33. package/workspace/lib/routes-portfolio.js +50 -0
  34. package/workspace/lib/routes-review-pack.js +42 -0
  35. package/workspace/lib/routes-roadmap-ops.js +53 -1
  36. package/workspace/lib/routes-sim-users.js +66 -0
  37. package/workspace/lib/routes-stakeholders.js +42 -0
  38. package/workspace/lib/routes-strategy-card.js +29 -1
  39. package/workspace/lib/routes-team-waits.js +24 -0
  40. package/workspace/lib/routes-use-log.js +6 -1
  41. package/workspace/lib/sim-users.js +329 -0
  42. package/workspace/lib/stakeholder-map.js +232 -0
  43. package/workspace/lib/task-store.js +1 -1
  44. package/workspace/lib/team-waits.js +167 -0
  45. package/workspace/lib/tradeoff-cards.js +258 -0
  46. package/workspace/lib/tradeoff-cli.js +83 -0
  47. package/workspace/lib/voice-cli.js +7 -0
  48. package/workspace/package-lock.json +2 -2
  49. package/workspace/package.json +1 -1
  50. package/workspace/premium-vw-jira-test.js +6 -2
  51. package/workspace/public/pm/bd-backlog.js +44 -6
  52. package/workspace/public/pm/bd-principles.js +12 -1
  53. package/workspace/public/pm/cozy-library.css +5 -0
  54. package/workspace/public/pm/cozy-pick.css +1 -0
  55. package/workspace/public/pm/cozy-pop-work.js +8 -2
  56. package/workspace/public/pm/cozy-proto.css +5 -0
  57. package/workspace/public/pm/cozy-proto.js +11 -3
  58. package/workspace/public/pm/cozy-today-app.js +53 -3
  59. package/workspace/public/pm/cozy-today-view.js +12 -4
  60. package/workspace/public/pm/day-time.js +8 -0
  61. package/workspace/public/pm/five-action-cap.js +104 -0
  62. package/workspace/public/pm/home-ini.js +3 -2
  63. package/workspace/public/pm/ini-links.js +2 -1
  64. package/workspace/public/pm/ini-tasks.js +5 -2
  65. package/workspace/public/pm/ini-view-model.js +14 -6
  66. package/workspace/public/pm/ini-view.js +12 -2
  67. package/workspace/public/pm/library-model.js +1 -1
  68. package/workspace/public/pm/page-one-answer.css +18 -0
  69. package/workspace/public/pm/page-one-answer.js +134 -0
  70. package/workspace/public/pm/pop-work-model.js +8 -6
  71. package/workspace/public/pm/portfolio.js +67 -0
  72. package/workspace/public/pm/premium-board.js +19 -6
  73. package/workspace/public/pm/premium-library.js +27 -3
  74. package/workspace/public/pm/product-switcher.js +7 -1
  75. package/workspace/public/pm/range-pick.css +12 -0
  76. package/workspace/public/pm/range-pick.js +30 -6
  77. package/workspace/public/pm/review-pack.js +47 -0
  78. package/workspace/public/pm/review-reasons.js +75 -0
  79. package/workspace/public/pm/sim-users.js +34 -0
  80. package/workspace/public/pm/sort-order.js +3 -0
  81. package/workspace/public/pm/stakeholder-map.js +125 -0
  82. package/workspace/public/pm/task-card.js +10 -7
  83. package/workspace/public/pm/team-waits.js +56 -0
  84. package/workspace/public/pm/tradeoff-cards.css +27 -0
  85. package/workspace/public/pm/tradeoff-cards.js +183 -0
  86. package/workspace/public/premium-board.html +1 -0
  87. package/workspace/public/premium-portfolio.html +48 -0
  88. package/workspace/public/today.html +1 -0
  89. package/workspace/run-tests.js +9 -1
  90. package/workspace/server.js +1 -1
  91. package/workspace/stage-card-tasks-test.js +11 -5
  92. package/workspace/test-lists/critical-needs.json +9 -0
  93. package/workspace/test-lists/five-action-cap.json +9 -0
  94. package/workspace/test-lists/page-one-answer.json +9 -0
  95. package/workspace/test-lists/portfolio.json +9 -0
  96. package/workspace/test-lists/review-pack.json +9 -0
  97. package/workspace/test-lists/review-reasons.json +9 -0
  98. package/workspace/test-lists/sim-users.json +9 -0
  99. package/workspace/test-lists/stakeholder-map.json +9 -0
  100. package/workspace/test-lists/task-time-optional.json +9 -0
  101. package/workspace/test-lists/team-waits.json +9 -0
  102. package/workspace/test-lists/tradeoff-cards.json +9 -0
  103. package/workspace/test-timings.json +25 -0
@@ -0,0 +1,134 @@
1
+ /* pm/page-one-answer.js — every page opens with one answer (initiative page-one-answer, job #1889, idea A308; board BatchPagesDS panel 1,
2
+ * agreed 2026-11-25). The top of Today, Work, Board and each initiative:
3
+ * 1. one sentence answers the page's question: it counts what needs you, then the rest ("2 things need you; the other 9 are moving.");
4
+ * 2. under it, only what needs you (pm-li rows, a press opens the item);
5
+ * 3. the rest folds into one line, closed by default ("9 moving · 2 waiting on others");
6
+ * 4. zero is silence: nothing needs you → "All moving." and no list.
7
+ * The block holds no primary button: it never adds a call to act to a first view (firstViewCalls counts them for `pmos pages calls`).
8
+ * Pure but firstViewCalls and reportCalls: Node imports it (page-one-answer.test.js).
9
+ *
10
+ * answerOf({ needs, moving, waiting, scope, day }) → { said, needs, moving, waiting, rest, scope, day }
11
+ * boardAnswer(rows, { stateOf, grill, scope, day }) → the Work and Board answer, from the initiative rows on screen
12
+ * iniAnswer(rows, { wait, scope, day }) → an initiative's answer, from its task rows (ini-view-model rowOf) and what waits on you
13
+ * todayAnswer(L, { day }) → Today's answer, from the log's model (Your move is its list)
14
+ * answerHtml(A, { open, list, page }) → the block; '' with no answer
15
+ * firstViewCalls(root, win) → { n, labels } the calls to act above the fold
16
+ * reportCalls(page, post) → logs [page-one-answer] once per page load; posts only a count over one (or the fix of one) */
17
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
18
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
19
+ export const ALL_MOVING = 'All moving.';
20
+ export const SHOW = 5; // the Needs you rows shown before "N more"
21
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
22
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
23
+ /** "Wed 25 Nov" */
24
+ export function dayWord(now = Date.now()) { const d = new Date(now); return `${WD[d.getDay()]} ${d.getDate()} ${MON[d.getMonth()]}`; }
25
+ const dayKey = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
26
+
27
+ /** The sentence and its parts. needs: [{ key, title, sub }]; moving and waiting: counts. */
28
+ export function answerOf({ needs = [], moving = 0, waiting = 0, scope = '', day = '' } = {}) {
29
+ const N = (needs || []).filter((x) => x && x.title), m = Math.max(0, moving | 0), w = Math.max(0, waiting | 0), rest = m + w;
30
+ const said = !N.length ? ALL_MOVING
31
+ : `${plural(N.length, 'thing needs', 'things need')} you` + (rest ? `; the other ${rest} ${rest === 1 ? 'is' : 'are'} moving.` : '.');
32
+ return { said, needs: N, moving: m, waiting: w, rest, scope: String(scope || ''), day: String(day || '') };
33
+ }
34
+
35
+ /** Work and Board. rows: the initiative rows on screen. stateOf(r) → { state: 'done'|'late'|'risk'|'wait'|'none'|'on', why } (bd-work.js
36
+ * rowState). grill(id) → { open, later } the first questions still open. A closed row is not counted. */
37
+ export function boardAnswer(rows, { stateOf, grill = () => null, scope = '', day = '' } = {}) {
38
+ const needs = [], restRows = [];
39
+ let moving = 0, waiting = 0;
40
+ for (const r of rows || []) {
41
+ if (!r) continue;
42
+ const s = (stateOf && stateOf(r)) || { state: 'on', why: '' };
43
+ if (s.state === 'done') continue;
44
+ const g = grill(r.id || r.key) || null, q = g && g.open > 0 && !g.later ? g.open : 0;
45
+ if (s.state === 'late' || s.state === 'risk' || q) {
46
+ const why = s.state === 'late' ? (s.why || 'Late') : s.state === 'risk' ? (s.why || 'Due soon') : plural(q, 'first question open', 'first questions open');
47
+ needs.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: why, rank: s.state === 'late' ? 0 : s.state === 'risk' ? 1 : 2 });
48
+ } else if (s.state === 'wait') { waiting += 1; restRows.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: 'Waiting on others' }); }
49
+ else { moving += 1; restRows.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: '' }); }
50
+ }
51
+ needs.sort((a, b) => a.rank - b.rank);
52
+ return { ...answerOf({ needs, moving, waiting, scope, day }), restRows };
53
+ }
54
+
55
+ /** An initiative. rows: its task rows (ini-view-model rowOf: { uid, title, closed, late, owner: 'You' | name, end, due }). wait: what waits on
56
+ * you there ({ title, sub }) or null. Yours, open, and late or due today need you; another's late task waits on others; the rest moves. */
57
+ export function iniAnswer(rows, { wait = null, scope = '', day = '', today = new Date() } = {}) {
58
+ const t = dayKey(today), needs = [], restRows = [];
59
+ let moving = 0, waiting = 0;
60
+ if (wait && wait.title) needs.push({ key: '', title: wait.title, sub: wait.sub || '', act: 'summary' });
61
+ for (const x of rows || []) {
62
+ if (!x || x.closed) continue;
63
+ const mine = x.owner === 'You', dueNow = !!x.end && String(x.end).slice(0, 10) <= t;
64
+ if (mine && (x.late || dueNow)) needs.push({ key: x.uid || '', title: x.title, sub: x.late ? x.lateText || 'Late' : 'Due today', act: 'task' });
65
+ else if (!mine && x.owner && x.late) { waiting += 1; restRows.push({ key: x.uid || '', title: x.title, sub: x.owner + ' · ' + (x.lateText || 'late'), act: 'task' }); }
66
+ else { moving += 1; restRows.push({ key: x.uid || '', title: x.title, sub: x.owner && x.owner !== 'You' ? x.owner : '', act: 'task' }); }
67
+ }
68
+ return { ...answerOf({ needs, moving, waiting, scope, day }), restRows };
69
+ }
70
+
71
+ /** Today: Your move is its Needs you list (cozy-today-model.js yourMove); the day's other rows and Later are the rest. */
72
+ export function todayAnswer(L, { day = '' } = {}) {
73
+ const needs = ((L && (L.move || L.first)) || []).map((r) => ({ key: r.key, title: r.title, sub: r.why || '' }));
74
+ const moving = ((L && L.todayRows) || []).length + ((L && L.wait) || []).length;
75
+ return answerOf({ needs, moving, waiting: 0, scope: '', day }); // the page's own head says the day: said once
76
+ }
77
+
78
+ const CHEV = '<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M7 10l5 5 5-5"/></svg>';
79
+ const row = (x, page) => `<div class="pm-li poa-r" data-poa-key="${esc(x.key)}"><span class="poa-dot" aria-hidden="true"></span><span class="txt">`
80
+ + `<button type="button" class="t poa-t" data-poa="open" data-poa-key="${esc(x.key)}"${x.act ? ` data-poa-act="${esc(x.act)}"` : ''} aria-label="${esc('Open ' + x.title)}">${esc(x.title)}</button>`
81
+ + `${x.sub ? `<span class="w pm-meta">${esc(x.sub)}</span>` : ''}</span></div>`;
82
+
83
+ /** The block. o.list === false: the page draws its own Needs you list under the sentence (Today's Your move). o.open: the fold is open. */
84
+ export function answerHtml(A, o = {}) {
85
+ if (!A || !A.said) return '';
86
+ const page = o.page || '';
87
+ const meta = [A.scope, A.day].filter(Boolean).join(' · ');
88
+ let h = `<section class="poa pm-block" aria-label="What needs you" data-poa-page="${esc(page)}"><div class="poa-said"><p class="poa-line">${esc(A.said)}</p>${meta ? `<span class="pm-meta">${esc(meta)}</span>` : ''}</div>`;
89
+ // zero is silence: no Needs you list, no count of zero
90
+ if (A.needs.length && o.list !== false) {
91
+ const shown = o.more ? A.needs : A.needs.slice(0, SHOW), more = A.needs.length - shown.length;
92
+ h += `<div class="poa-needs"><h2 class="pm-h-sm">Needs you</h2><div class="rows">${shown.map((x) => row(x, page)).join('')}</div>`
93
+ + (more > 0 ? `<button type="button" class="pm-fold poa-more" data-poa="more" aria-expanded="false">${esc(more + ' more')}${CHEV}</button>` : '') + '</div>';
94
+ }
95
+ const parts = [A.moving ? A.moving + ' moving' : '', A.waiting ? A.waiting + ' waiting on others' : ''].filter(Boolean);
96
+ if (parts.length && o.list !== false) {
97
+ h += `<button type="button" class="pm-fold poa-fold" data-poa="fold" aria-expanded="${!!o.open}">${CHEV}<span>${esc(parts.join(' · '))}</span></button>`;
98
+ if (o.open && (A.restRows || []).length) h += `<div class="rows poa-rest">${A.restRows.map((x) => row(x, page)).join('')}</div>`;
99
+ }
100
+ return h + '</section>';
101
+ }
102
+
103
+ /* ── the one-call check ── */
104
+ export const CALL_SEL = '.pm-btn.primary, [data-call]';
105
+ /** The calls to act that show in the first view: a primary button or a [data-call] whose box starts above the fold and is drawn. */
106
+ export function firstViewCalls(root, win) {
107
+ const W = win || (typeof window !== 'undefined' ? window : null);
108
+ if (!root || !W) return { n: 0, labels: [] };
109
+ const fold = W.innerHeight || 0, labels = [];
110
+ for (const el of root.querySelectorAll(CALL_SEL)) {
111
+ const b = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
112
+ if (!b || b.width === 0 || b.height === 0 || b.top >= fold || b.bottom <= 0) continue;
113
+ labels.push(String(el.getAttribute('aria-label') || el.textContent || '').trim().slice(0, 60));
114
+ }
115
+ return { n: labels.length, labels };
116
+ }
117
+ const REPORTED = new Set();
118
+ /** Once per page load: counts the first view's calls and says it in the console. It posts to the local record (lib/page-one-answer.js) only a count over one, or the next count of a page it flagged. */
119
+ export function reportCalls(page, post, root) {
120
+ if (!page || REPORTED.has(page) || typeof document === 'undefined') return null;
121
+ REPORTED.add(page);
122
+ const C = firstViewCalls(root || document.body);
123
+ console.info(`[page-one-answer] page=${page} calls=${C.n}`);
124
+ if (C.n > 1) console.warn(`[page-one-answer] ${page}: the first view has ${C.n} calls to act (${C.labels.join(', ')}); one is the most it should have`);
125
+ // Nothing is written on a plain load: post only a page with more than one call, or one that this browser posted as flagged before
126
+ // (so `pmos pages calls` clears it once it is fixed).
127
+ const key = 'pmos.poa.flagged.' + page;
128
+ let was = false; try { was = localStorage.getItem(key) === '1'; } catch { /* no storage */ }
129
+ if (typeof post === 'function' && (C.n > 1 || was)) {
130
+ try { if (C.n > 1) localStorage.setItem(key, '1'); else localStorage.removeItem(key); } catch { /* no storage */ }
131
+ Promise.resolve().then(() => post('/api/page-calls', { page, calls: C.n, labels: C.labels })).catch(() => {});
132
+ }
133
+ return C;
134
+ }
@@ -29,6 +29,7 @@
29
29
  * 5 Artefacts: one table: Artefact, Kind, Updated. A core document a gate needs that is not written is a grey row that says which gate. */
30
30
 
31
31
  import { gapsOf } from './cozy-bar.js';
32
+ import { withTime } from './day-time.js'; // a task's optional time on its start and due (task-time-optional)
32
33
  import { provenStatus, NO_SIGNAL } from './status-proof.js';
33
34
  import * as WT from './work-tree.js'; // subtasks: nesting and the roll-up (initiative work-subtasks)
34
35
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -51,10 +52,10 @@ export function dayText(v, today) {
51
52
  return d.getDate() + ' ' + MON[d.getMonth()] + (d.getFullYear() !== t.getFullYear() ? ' ' + d.getFullYear() : '');
52
53
  }
53
54
  /** A date and, when it has passed and the thing is open, how late: "4 Nov · 14 days late". */
54
- export function dateLate(v, today, open = true) {
55
- const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: dayText(v, t), late: false };
55
+ export function dateLate(v, today, open = true, time = '') {
56
+ const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: withTime(dayText(v, t), time), late: false };
56
57
  const late = open && d < t;
57
- return { text: dayText(v, t) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
58
+ return { text: withTime(dayText(v, t), time) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
58
59
  }
59
60
 
60
61
  /* ── the timeline ── */
@@ -324,8 +325,8 @@ export function goalName(list, anchor) {
324
325
  }
325
326
 
326
327
  /* ── the work breakdown ── */
327
- function taskRow(x, t) {
328
- const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
328
+ export function taskRow(x, t) {
329
+ const dl = x.end ? dateLate(x.end, t, !x.closed, x.due_time) : { text: x.start ? 'from ' + withTime(dayText(x.start, t), x.start_time) : '', late: false };
329
330
  const st = taskStatus(x);
330
331
  return { kind: 'task', uid: x.uid, title: x.title, who: x.owner || '', status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
331
332
  // a Jira ticket's own status name and a move PMOS asked that Jira has not answered (jira-row-edit): the status press moves it in Jira
@@ -333,7 +334,8 @@ function taskRow(x, t) {
333
334
  prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do",
334
335
  // subtasks and Jira (initiative work-subtasks): the parent, the chip's key and link, the epic as read, the assignee, a Jira sub-task
335
336
  parent: x.parent || '', ckey: x.ckey || x.jkey || '', jurl: x.jurl || '', ...(x.jepic !== undefined ? { jepic: x.jepic, jepicName: x.jepicName || '' } : {}), jassignee: x.jassignee || '', jtype: x.jtype || '',
336
- ...(x.jsub ? { jsub: true } : {}), ...(x.jsubOf ? { jsubOf: x.jsubOf } : {}), ...(x.priority ? { priority: x.priority } : {}) };
337
+ ...(x.jsub ? { jsub: true } : {}), ...(x.jsubOf ? { jsubOf: x.jsubOf } : {}), ...(x.priority ? { priority: x.priority } : {}),
338
+ ...(x.start_time ? { start_time: x.start_time } : {}), ...(x.due_time ? { due_time: x.due_time } : {}) }; // the optional times (task-time-optional)
337
339
  }
338
340
  /** The tasks of every stage, nested (initiative work-subtasks): the read Jira sub-tasks join as rows under their ticket, and a task that names
339
341
  * a sub-task's key with no parent of its own sits under its ticket's row. → { T: Map uid → node, isChild(x), rx(x) (a parent with its roll-up) } */
@@ -0,0 +1,67 @@
1
+ /* pm/portfolio.js — the Portfolio page (initiative portfolio, bet A56, board BatchPlanDS panel 7; done test planning/done-tests/portfolio.md).
2
+ *
3
+ * One Table block: Product, Bets, Odds, Spend, Outcome, one row per product (GET /api/product-portfolio, lib/portfolio.js). An empty cell is a number
4
+ * PMOS does not know yet (zero is silence). Under the table, at most one ✦ line: PMOS's recommendation with its reason, then two icon buttons,
5
+ * Keep and Not now (POST /api/product-portfolio/decide), each with Undo in the toast. A press on a row (or Enter on it) shows that product alone and
6
+ * opens it in Work. Nothing here edits a product. With fewer than two products the page says so in one line and shows nothing else.
7
+ *
8
+ * pageHtml(v, o) PURE. The page body for the read v ({ show, rows, rec }); o.name(ws, fallback) gives the shown product name */
9
+ import { pmGet, pmPost } from './http.js';
10
+ import { mountNav } from './cozy-nav.js';
11
+ import { savePick } from './cozy-pick.js';
12
+ import { productName, whenNames } from './scope-chip.js';
13
+
14
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
+ const svg = (d, n = 18) => `<svg class="pm-ic" viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
16
+ const I = { keep: 'M5 12.5l4.5 4.5L19 7.5', later: 'M6 6l12 12M18 6L6 18', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', spark: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z' };
17
+ const money = (n) => (n == null ? '' : '$' + (n >= 1000 ? (Math.round(n / 100) / 10) + 'k' : n >= 10 ? Math.round(n) : n.toFixed(2)));
18
+
19
+ export function pageHtml(v, o = {}) {
20
+ const name = o.name || ((ws, f) => f);
21
+ if (!v || !v.show) return '<p class="pm-meta">The Portfolio compares two or more products. This workspace has one.</p>';
22
+ const rows = v.rows.map((r) => {
23
+ const nm = name(r.ws, r.name);
24
+ return `<tr data-pf-row="${esc(r.ws)}" tabindex="0" aria-label="Open ${esc(nm)} in Work"><td>${esc(nm)}</td><td class="n">${r.bets || ''}</td>`
25
+ + `<td class="n">${r.odds == null ? '' : r.odds + ' %'}</td><td class="n">${esc(money(r.spend))}</td><td>${esc(r.outcome || '')}</td></tr>`;
26
+ }).join('');
27
+ const table = `<table class="pm-table" aria-label="Products"><thead><tr><th>Product</th><th class="n">Bets</th><th class="n">Odds</th><th class="n" title="Agent runs, last 30 days">Spend</th><th>Outcome</th></tr></thead><tbody>${rows}</tbody></table>`;
28
+ const rec = v.rec ? `<div class="pm-said" data-pf-rec="${esc(v.rec.key)}"><span class="pf-mark" aria-hidden="true">✦</span><span>${esc(v.rec.text)}: ${esc(v.rec.why)}</span><span class="sp"></span>`
29
+ + `<button type="button" class="pm-btn" data-pf-keep aria-label="Keep" title="Keep">${svg(I.keep)}</button>`
30
+ + `<button type="button" class="pm-btn" data-pf-later aria-label="Not now" title="Not now">${svg(I.later)}</button></div>` : '';
31
+ return `<section class="pm-block" aria-label="Portfolio">${table}${rec}</section>`;
32
+ }
33
+
34
+ const $ = (id) => document.getElementById(id);
35
+ let V = null;
36
+ function toast(text, undo) {
37
+ const el = $('pfToast'); if (!el) return;
38
+ const w = document.createElement('span'); w.textContent = text;
39
+ el.replaceChildren(w);
40
+ if (undo) { const b = document.createElement('button'); b.type = 'button'; b.className = 'pm-btn'; b.setAttribute('aria-label', 'Undo'); b.title = 'Undo'; b.innerHTML = svg(I.undo, 16); b.onclick = () => { el.classList.remove('on'); undo(); }; el.append(b); }
41
+ el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), undo ? 10000 : 4200);
42
+ }
43
+ function draw() { const b = $('pfBody'); if (b) b.innerHTML = pageHtml(V, { name: productName }); }
44
+ async function load() {
45
+ const r = await pmGet('/api/product-portfolio');
46
+ if (!(r && r.ok)) { const b = $('pfBody'); if (b) b.innerHTML = '<p class="pm-meta">The products could not be read. Open the page again in a minute.</p>'; return; }
47
+ V = r; draw();
48
+ }
49
+ async function answer(kind) {
50
+ const key = V && V.rec && V.rec.key; if (!key) return;
51
+ const r = await pmPost('/api/product-portfolio/decide', { key, kind });
52
+ if (!(r && r.ok)) { toast((r && r.error) || 'Not saved.'); return; }
53
+ await load();
54
+ toast(kind === 'keep' ? 'Kept.' : 'Not now: hidden for 7 days.', async () => { await pmPost('/api/product-portfolio/decide', { key, kind: 'undo' }); await load(); });
55
+ }
56
+ async function open(ws) { const r = await savePick([ws]); if (r && r.ok === false) { toast(r.error); return; } location.href = '/premium-board.html'; }
57
+
58
+ if (typeof document !== 'undefined' && document.getElementById('pfBody')) {
59
+ mountNav('portfolio', document, {});
60
+ document.addEventListener('click', (e) => {
61
+ const t = e.target.closest('[data-pf-keep],[data-pf-later],[data-pf-row]'); if (!t) return;
62
+ if (t.hasAttribute('data-pf-keep')) answer('keep'); else if (t.hasAttribute('data-pf-later')) answer('not-now'); else open(t.getAttribute('data-pf-row'));
63
+ });
64
+ document.addEventListener('keydown', (e) => { const t = e.target.closest && e.target.closest('[data-pf-row]'); if (t && e.key === 'Enter') open(t.getAttribute('data-pf-row')); });
65
+ load();
66
+ try { whenNames().then(draw).catch(() => {}); } catch { /* names come with the page */ }
67
+ }
@@ -65,6 +65,7 @@ import * as CM from './changed-mark.js'; // bet A456: the ✦ and Undo on a ro
65
65
  import { setSay } from './cozy-xv.js';
66
66
  import { narrowForm } from './pn-narrow.js';
67
67
  import * as BP2 from './bd-pane.js';
68
+ import * as PA from './page-one-answer.js'; // page-one-answer (A308): Work and Board open with one sentence, what needs you, the rest folded
68
69
  import * as WV from './bd-work.js'; // Work, one view on a desk (slice 4 of the six-place navigation, initiative work-one-view)
69
70
  import * as BK from './bd-backlog.js';
70
71
  import * as PL from './bd-phone-line.js'; // a phone offers List and By stage, no Gantt (board PhIniB)
@@ -92,6 +93,7 @@ let readTimer = null;
92
93
  const SKEL = $('#ibBody').innerHTML; // the grey rows the page opens with (premium-board.html), put back if a failure line replaced them
93
94
  LS.slowLine($('#ibBody'), () => M);
94
95
  let readTries = 0; // reads that answered "reading" in a row: the next ask waits longer each time
96
+ const POA = { open: false, more: false }; // page-one-answer: the answer's fold (closed by default) and its "N more"
95
97
  let foldOpen = false; // the Monitor and Evaluate rows under the table
96
98
  let sprintSet = false; // "This sprint" starts on, once, when the board has a sprint
97
99
  const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints: new Set() }; // the chip filters, Find and Filter (the workflow is pm/bd-wf.js picked())
@@ -968,7 +970,9 @@ function drawInit() {
968
970
  if (v === 'time') TL.hold(); else TL.forget();
969
971
  // a row with the focus keeps it when the rows are drawn again (the page panel changes form as a Viewer opens or closes beside it)
970
972
  const fe = document.activeElement, fk = fe && body.contains(fe) && fe.matches('[data-key]') ? fe.dataset.key : null;
971
- body.innerHTML = html + phx;
973
+ // page-one-answer (A308): one sentence first, then only what needs you, the rest in one fold (a published copy shows none: it is the PM's own)
974
+ const ans = window.PMOS_READONLY ? '' : PA.answerHtml(PA.boardAnswer(L, { stateOf: (r) => WV.rowState(r), grill: (id) => GR[id], day: PA.dayWord() }), { open: POA.open, more: POA.more, page: v === 'work' ? 'work' : 'board' });
975
+ body.innerHTML = ans + html + phx;
972
976
  LB.sizeBars(body);
973
977
  if (fk) { const n = $$('#ibBody [data-key]').find((x) => x.dataset.key === fk); if (n) n.focus({ preventScroll: true }); }
974
978
  if (v === 'time') TL.mount(body);
@@ -980,6 +984,7 @@ function drawInit() {
980
984
  document.body.dataset.bdView = v;
981
985
  $('#stage').dataset.bdDesk = view; // what fit() measures: the desktop's view, so the narrow form never flips it back and forth
982
986
  markOpen();
987
+ if (M && !window.PMOS_READONLY) PA.reportCalls(v === 'work' ? 'work' : 'board', pmPost, $('#stage'));
983
988
  }
984
989
  PHONE.addEventListener('change', () => { if (M) { drawChips(); drawInit(); } });
985
990
  /** The grouping (PgBoard, PgBoardProduct): programs first (the default) or By product, in the tune sheet (#bdFilter) since UI grill U2.
@@ -1000,6 +1005,13 @@ $('#bdShowing').addEventListener('click', (e) => {
1000
1005
  });
1001
1006
  function setSpan(s) { span = s; store.set(SPAN_KEY, span); drawChips(); drawInit(); }
1002
1007
  $('#ibBody').addEventListener('click', (e) => {
1008
+ // page-one-answer: a Needs you row opens its initiative; the fold and "N more" open in place
1009
+ const pa = e.target.closest('[data-poa]');
1010
+ if (pa) {
1011
+ if (pa.dataset.poa === 'open') { const r = rowOf(pa.dataset.poaKey); if (r) openIni(r, pa); return; }
1012
+ if (pa.dataset.poa === 'fold') POA.open = !POA.open; else if (pa.dataset.poa === 'more') POA.more = true;
1013
+ drawInit(); const n = $('#ibBody [data-poa="fold"]'); if (n && pa.dataset.poa === 'fold') n.focus(); return;
1014
+ }
1003
1015
  if (curView() === 'work') {
1004
1016
  const op = e.target.closest('[data-wkopen]'); if (op) { e.preventDefault(); openIni(rowOf(op.dataset.wkopen), op); return; }
1005
1017
  const sg = e.target.closest('[data-wksug]'); if (sg) { sugPress(sg); return; }
@@ -1201,7 +1213,7 @@ function msPop(anchor, r, ids, sheet) {
1201
1213
  el.className = 'tg-msp' + (sheet ? ' sh' : ''); el.setAttribute('role', 'menu'); el.setAttribute('aria-label', (sheet ? '' : 'Milestones of ') + r.title); el.dataset.escLayer = '';
1202
1214
  el.innerHTML = (sheet ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(r.title)}</b>` : '') + items.map((x) => x.html).join('');
1203
1215
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1204
- if (!sheet) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
1216
+ if (!sheet) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; const h = el.offsetHeight; el.style.top = Math.max(8, b.bottom + 8 + h > innerHeight - 8 ? b.top - h - 8 : b.bottom + 8) + 'px'; }
1205
1217
  el.onclick = (e) => {
1206
1218
  const o = e.target.closest('[data-ms-open]'); if (!o) return;
1207
1219
  const id = o.dataset.msOpen, m = L.find((x) => x.id === id); msClose();
@@ -1225,7 +1237,7 @@ function lanePop(anchor, data, title) {
1225
1237
  el.innerHTML = (title ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(title)}</b>` : '')
1226
1238
  + L.map((m) => `<button type="button" role="menuitem" class="o" data-ms-ini="${esc(m.k)}"><i class="tg-tm-i${m.s ? ' ' + m.s : ''}" aria-hidden="true"></i><span>${esc(m.n)}<small>${esc(m.t)}</small></span><span class="k${m.s === 'late' ? ' late' : ''}">${esc(md(m.d))}</span></button>`).join('');
1227
1239
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1228
- if (!title) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
1240
+ if (!title) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; const h = el.offsetHeight; el.style.top = Math.max(8, b.bottom + 8 + h > innerHeight - 8 ? b.top - h - 8 : b.bottom + 8) + 'px'; }
1229
1241
  el.onclick = (e) => { const o = e.target.closest('[data-ms-ini]'); if (!o) return; msClose(); openIni(rowOf(o.dataset.msIni), anchor); };
1230
1242
  const f = el.querySelector('button'); if (f) f.focus({ preventScroll: true });
1231
1243
  }
@@ -1244,7 +1256,8 @@ function gapPop(anchor, r) {
1244
1256
  el.innerHTML = `<div class="w">${lines.map((t, i) => `<p class="${i ? 's' : ''}">${esc(t)}</p>`).join('')}${sk.map((k) => `<p class="s">${esc(skipWords(k.items))}</p>`).join('')}</div>`
1245
1257
  + (anchor.dataset.ahead ? `<button type="button" class="gp-add" aria-label="${esc('New task, ' + md(d(start)) + ' to ' + md(d(due)))}" title="New task">${'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>'}</button>` : '');
1246
1258
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1247
- const bx = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(bx.left + bx.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = bx.bottom + 6 + 'px';
1259
+ const bx = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(bx.left + bx.width / 2 - w / 2, innerWidth - w - 8)) + 'px';
1260
+ const h = el.offsetHeight; el.style.top = Math.max(8, bx.bottom + 6 + h > innerHeight - 8 ? bx.top - h - 6 : bx.bottom + 6) + 'px'; // flips above a row low on the screen
1248
1261
  const add = el.querySelector('.gp-add');
1249
1262
  if (add) { add.onclick = () => { msClose(); BI.openIni(r, anchor, { addTo: '', addDates: { start, due } }); }; add.focus({ preventScroll: true }); }
1250
1263
  }
@@ -1552,8 +1565,8 @@ async function setDates(r, uid, patch) {
1552
1565
  const res = await pmPost('/api/boards/tasks/edit', { ...body, ...patch }).catch(() => null);
1553
1566
  if (!res || res.ok === false) { say(LE.notSaved(res), () => setDates(r, uid, patch), 'Try again'); return; }
1554
1567
  const ms = 'milestone' in patch;
1555
- const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
1556
- const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : 'Dates saved';
1568
+ const back = {}; for (const f of Object.keys(patch)) back[f] = /_time$/.test(f) ? (res.from && res.from[f]) || '' : f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
1569
+ const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : Object.keys(patch).every((f) => /_time$/.test(f)) ? 'Time saved' : 'Dates saved'; // a time alone (task-time-optional)
1557
1570
  const jd = !k && !ms && res.from && ('start' in res.from || 'due' in res.from); // a Jira ticket's days, kept in PMOS (batch 11 item 23)
1558
1571
  say(words + (k ? ': ' + k.title : jd ? ': ' + uid + ', kept in PMOS' : '') + '.', k || ms || jd ? async () => { const u = await pmPost('/api/boards/tasks/edit', { ...body, ...back }).catch(() => null); say(u && u.ok !== false ? (ms ? 'Put back.' : 'Dates put back.') : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
1559
1572
  load();
@@ -29,6 +29,8 @@ import { FAMILIES, GROUPS, STATES, view, counts, passes, matches, aboutText, sta
29
29
  import { openItem } from './library-open.js';
30
30
  import { bindSlash, bindEnterOpen, pressStep } from './library-keys.js'; // D1 and D6: the keys and presses, tested by pressing them (A437)
31
31
  import { STEP, nextShown, moreHtml, totalOf, logMore } from './list-cap.js'; // lists stay short (A455): one step for every long list
32
+ import * as RP from './review-pack.js'; // the monthly review pack (review-pack, job #1910): its parts in the preview, and the share (Issue) press
33
+ import { noteUse } from './use-log.js';
32
34
 
33
35
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
34
36
  const svg = (d, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -315,18 +317,23 @@ async function drawPreview() {
315
317
  if (!x || !wide()) { pv.hidden = true; pv.innerHTML = ''; document.body.classList.remove('lb-pv-on'); return; }
316
318
  pv.hidden = false; document.body.classList.add('lb-pv-on');
317
319
  const older = (S.items || []).filter((o) => o.ed && o.ed === x.ed && o.id !== x.id).sort((a, b) => (b.v || 0) - (a.v || 0) || String(when(b)).localeCompare(String(when(a))));
318
- const p = x.open && x.open.doc ? S.peek.get(x.id) : null;
320
+ const p = x.open && x.open.doc && !x.pack ? S.peek.get(x.id) : null;
319
321
  const lines = x.kind === 'meeting' ? x.gist || [] : p && p.head ? p.head : [];
322
+ const pack = x.pack ? RP.packHtml(x) : '';
323
+ if (pack && S.packSeen !== x.id) { S.packSeen = x.id; noteUse('rpOpen'); console.info('[review-pack] preview ' + x.id); }
320
324
  pv.innerHTML = `<div class="head"><span class="lb-mi">${svg(ICON[x.kind] || ICON.doc)}</span><h2 class="pm-h">${esc(x.name)}</h2>`
321
325
  + `<button type="button" class="pm-btn" data-lb-pv-open aria-label="Open ${esc(x.name)}, with the chat about it" title="Open, with the chat about it">${svg(OPEN)}</button>`
326
+ + (x.pack ? RP.shareHtml(x) : '')
322
327
  + `<button type="button" class="pm-btn" data-lb-pv-close aria-label="Close the record" title="Close">${svg(X)}</button></div>`
323
328
  + `<p class="pm-meta lb-pvh">Press again or Enter to open it as the full popup</p>`
324
329
  + `<dl class="pm-field">${field('Kind', x.kindText)}${field('Product', x.product)}${field('About', aboutText(x) || (x.about && x.about.title))}${field('By', x.by)}${stateText({ x, older }) ? `<dt>State</dt><dd><span class="pm-badge${x.state === 'Issued' ? ' blue' : ''}">${esc(stateText({ x, older }))}</span></dd>` : ''}`
325
330
  + `${field(x.kind === 'meeting' ? 'Held' : 'Updated', dayText(when(x)))}${field('Came out of it', x.came)}${field('Title', x.sub)}${field('File', x.path)}</dl>`
326
- + (lines.length ? `<h3 class="pm-meta lb-pvk">First lines</h3><div class="lb-pvl">${lines.map((l) => `<p>${esc(l)}</p>`).join('')}</div>` : x.open && x.open.doc && !p ? '<p class="pm-meta">Reading the first lines…</p>' : '')
331
+ + pack
332
+ + (S.shareMsg && S.shareMsg.id === x.id ? `<p class="pm-meta" role="status">${esc(S.shareMsg.text)}</p>` : '')
333
+ + (pack ? '' : lines.length ? `<h3 class="pm-meta lb-pvk">First lines</h3><div class="lb-pvl">${lines.map((l) => `<p>${esc(l)}</p>`).join('')}</div>` : x.open && x.open.doc && !p ? '<p class="pm-meta">Reading the first lines…</p>' : '')
327
334
  + (p && p.from && p.from.length ? `<h3 class="pm-meta lb-pvk">Linked from</h3><ul>${p.from.map((f) => `<li>${esc(f.title)}</li>`).join('')}</ul>` : '')
328
335
  + (older.length ? `<h3 class="pm-meta lb-pvk">Editions</h3><ul>${older.map((o) => `<li><button type="button" class="lb-nb" data-lb-pv-ed="${esc(o.id)}">${esc(o.name)}${o.v ? ' · v' + o.v : ''}</button> <span class="pm-meta">${esc(dayText(when(o)))}</span></li>`).join('')}</ul>` : '');
329
- if (x.open && x.open.doc && !p) {
336
+ if (x.open && x.open.doc && !p && !x.pack) {
330
337
  const r = await pmGet('/api/library-items/peek?ws=' + encodeURIComponent(x.open.doc.ws) + '&path=' + encodeURIComponent(x.open.doc.path)).catch(() => null);
331
338
  S.peek.set(x.id, r && r.ok ? r : { head: [], from: [] });
332
339
  if (S.pick === x.id) drawPreview();
@@ -381,6 +388,13 @@ async function load() {
381
388
  S.at = Date.now(); S.P = P || S.P;
382
389
  if (r && r.ok) { S.items = r.items || []; nameProducts(S.items); S.programs = r.programs || []; S.error = ''; } else { S.items = S.items || []; S.error = (r && r.error) || 'the server did not answer'; }
383
390
  draw();
391
+ // the monthly review packs (Library › Reports): PMOS drafts a product's pack in the month's last week when it has none, then they join the list
392
+ pmPost('/api/review-packs/due', {}).catch(() => pmGet('/api/review-packs').catch(() => null)).then((k) => {
393
+ if (!k || !k.ok || !Array.isArray(k.items) || !k.items.length) return;
394
+ const have = new Set((S.items || []).map((x) => x.id));
395
+ S.items = [...k.items.filter((x) => !have.has(x.id)), ...(S.items || [])];
396
+ nameProducts(S.items); draw();
397
+ });
384
398
  whenNames().then(() => { nameProducts(S.items); drawFilters(); draw(); }).catch(() => {});
385
399
  }
386
400
 
@@ -459,6 +473,16 @@ pv.onclick = (e) => {
459
473
  let b;
460
474
  if (e.target.closest('[data-lb-pv-close]')) { S.pick = null; draw(); drawPreview(); return; }
461
475
  if (e.target.closest('[data-lb-pv-open]') && x) { openItem(x, { from: 'Library' }); return; }
476
+ if (e.target.closest('[data-rp-share]') && x && x.pack) {
477
+ // Share is the PM's Issue press (POST /api/report/issue): the pack is frozen as it is now. PMOS never shares a pack by itself.
478
+ noteUse('rpShare');
479
+ RP.share(x, pmPost).then((r) => {
480
+ S.shareMsg = { id: x.id, text: r && r.ok ? 'Shared. The pack is issued and frozen as it is now.' : 'Not shared: ' + ((r && r.error) || 'the server did not answer') };
481
+ if (r && r.ok) { x.pack.issued = true; x.state = 'Issued'; }
482
+ drawPreview();
483
+ });
484
+ return;
485
+ }
462
486
  if ((b = e.target.closest('[data-lb-pv-ed]'))) { const o = (S.items || []).find((i) => i.id === b.dataset.lbPvEd); if (o) openItem(o, { from: 'Library' }); }
463
487
  };
464
488
  qBox.addEventListener('input', () => { S.q = qBox.value.trim(); draw(); findByMeaning(); });
@@ -7,6 +7,9 @@
7
7
  * pressOf(P, ws) PURE. The pick a press saves: that product alone, or every product when it is already shown alone
8
8
  * press(P, ws) saves pressOf with savePick, so every page follows (pp:changed) → savePick's answer
9
9
  *
10
+ * The row ends with one icon link to the Portfolio (initiative portfolio, bet A56): every product side by side. Like the row, it shows only
11
+ * with two or more products.
12
+ *
10
13
  * Each tile is a button with data-psw, so the local use log (pm/use-log.js, A466) counts the presses: the outcome check reads them with
11
14
  * node workspace/lib/product-dots.js count. Tiles, letters and tints are the product chip's own (cozy-pick.js). */
12
15
  import { pmGet } from './http.js';
@@ -21,6 +24,9 @@ export async function readDots() { const r = await pmGet('/api/briefing-premium/
21
24
  /** The one product shown alone, or null when two or more are shown. */
22
25
  const aloneOf = (P) => { const on = P.products.filter((p) => p.on); return on.length === 1 ? on[0].ws : null; };
23
26
 
27
+ const PORTFOLIO = '<a class="psw-b psw-pf" data-psw-pf href="/premium-portfolio.html" aria-label="Portfolio: every product side by side" title="Portfolio">'
28
+ + '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M4 20V11M10 20V5M16 20v-6M21 20H3"/></svg></a>';
29
+
24
30
  export function switcherHtml(P, o = {}) {
25
31
  if (!P || !Array.isArray(P.products) || P.products.length < 2) return '';
26
32
  const T = o.tones || tonesOf(P.products), alone = aloneOf(P);
@@ -30,7 +36,7 @@ export function switcherHtml(P, o = {}) {
30
36
  return `<button type="button" class="psw-b" data-psw="${esc(p.ws)}" aria-pressed="${p.ws === alone}" aria-label="${esc(words)}" title="${esc(words)}">`
31
37
  + `<i class="ppk-t t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</i>${n > 0 ? '<i class="psw-dot" aria-hidden="true"></i>' : ''}</button>`;
32
38
  }).join('');
33
- return `<div class="psw${o.cls ? ' ' + esc(o.cls) : ''}" role="group" aria-label="Switch product">${tiles}</div>`;
39
+ return `<div class="psw${o.cls ? ' ' + esc(o.cls) : ''}" role="group" aria-label="Switch product">${tiles}${PORTFOLIO}</div>`;
34
40
  }
35
41
 
36
42
  export function pressOf(P, ws) {
@@ -49,3 +49,15 @@
49
49
  .rp .rp-nav { width: 44px; height: 44px; }
50
50
  .rp .rp-clear { min-height: 44px; }
51
51
  }
52
+ /* the optional time (task-time-optional): a clock press at the foot's end, and a row of time fields above the foot */
53
+ .rp .rp-clock { margin-left: auto; display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--cz-ink2); cursor: pointer; }
54
+ .rp .rp-clock[aria-expanded="true"] { background: var(--cz-bluebg); color: var(--cz-blue); }
55
+ .rp-tm { display: flex; gap: var(--space-8); }
56
+ .rp .rp-tf { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; height: 52px; padding: 6px 10px; border-radius: var(--radius-md); background: var(--cz-well); box-sizing: border-box; }
57
+ .rp .rp-tf small { font-size: var(--fs-badge); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: var(--lh-badge); }
58
+ .rp .rp-ti { width: 100%; min-width: 0; border: 0; padding: 0; background: none; font: inherit; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); line-height: var(--lh-body); outline: 0; font-variant-numeric: tabular-nums; }
59
+ .rp .rp-ti:disabled { color: var(--cz-ink3); }
60
+ .rp .rp-tf:focus-within { box-shadow: inset 0 0 0 2px var(--cz-blue); }
61
+ @media (hover: hover) { .rp .rp-clock:hover { background: var(--cz-well); color: var(--cz-ink); } }
62
+ @media (pointer: coarse), (max-width: 640px) { .rp .rp-clock { width: 44px; height: 44px; } .rp .rp-tf { height: 60px; } }
63
+ .rp .rp-ti::-webkit-calendar-picker-indicator { display: none; } /* the clock press is the one clock; the field takes typed digits */
@@ -9,15 +9,21 @@
9
9
  * Words work as well (bet A488): "friday", "+2w", "in 3 days", "end of month", "end of sprint" (o.sprintEnd). While the PM types, the
10
10
  * message line says the day it read ("Reads as Friday 27 Nov 2026 · Enter saves") before anything is saved; a word form taken logs dateWords.
11
11
  * Keyboard: arrows move a day or a week, Page Up/Down a month, Home/End the week's ends, Enter or Space picks.
12
+ * A time is optional (Wawan 2026-11-25, initiative task-time-optional): where the host offers it (o.time), a clock press beside No date
13
+ * opens a time row, Start time and Due time (a milestone one Time), each saved on its own change as { start_time | due_time: 'HH:MM' or
14
+ * '' }. A set time opens the row by itself. The days never carry the time, so a task with no time picks, saves and reads as before.
12
15
  *
13
- * rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus }
16
+ * rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus,
17
+ * time (the host offers a time), timeOpen, start_time, due_time }
14
18
  * o: { today, head (html drawn first), coarse (a phone: the fields do not open the keyboard) }
15
19
  * rangeTap(s, iso) → { patch, field, done } pure: what one tap (or a typed day, or '' for "No date") writes, and what comes next
16
20
  * mountRange(el, o) → { state } draws into el and wires it. o: { start, due, one, field, today, head, sprintEnd (an ISO day, or a function that gives one),
21
+ * time (true: offer the optional time), start_time, due_time,
17
22
  * onPick(patch, done, state) — after each tap; done: the range is complete, the host closes;
18
23
  * onState(state) — after each draw, so a host that redraws can open it where it was }
19
24
  * Its own presses stop at el, so a popup's click handler around it sees only the host's own buttons (a sheet's ✕). */
20
25
  import { dayText, dayLong, parseDay, wordsOnly, localToday } from './cozy-day-pick.js';
26
+ import { isTime } from './day-time.js';
21
27
 
22
28
  const CSS = new URL('./range-pick.css', import.meta.url).href;
23
29
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l); }
@@ -30,7 +36,7 @@ const iso = (n) => new Date(n).toISOString().slice(0, 10);
30
36
  const addDays = (v, n) => iso(ms(v) + n * 864e5);
31
37
  const addMonths = (ym, n) => { const [y, m] = ym.split('-').map(Number); return iso(Date.UTC(y, m - 1 + n, 1)).slice(0, 7); };
32
38
  const svg = (d, s = 16) => `<svg aria-hidden="true" width="${s}" height="${s}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
33
- const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' }, DIA = 'M12 4l8 8-8 8-8-8z';
39
+ const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' }, DIA = 'M12 4l8 8-8 8-8-8z', CLOCK = 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0zM12 7v5l3 2';
34
40
 
35
41
  /** The month shown: the one asked for, else the end being picked, else the start, else today's. */
36
42
  const monthOf = (s, today) => (s.month && /^\d{4}-\d{2}$/.test(s.month) ? s.month : String((isDay(s[fieldOf(s)]) && s[fieldOf(s)]) || (isDay(s.start) && s.start) || (isDay(s.due) && s.due) || today).slice(0, 7));
@@ -72,18 +78,24 @@ export function rangeHtml(s, o = {}) {
72
78
  const ends = s.one ? `<div class="rp-ends one">${inp('due', 'Date', svg(DIA, 12))}</div>` : `<div class="rp-ends">${inp('start', 'Start')}${svg(ARR.next, 14)}${inp('due', 'Due')}</div>`;
73
79
  const tom = addDays(today, 1), dow = new Date(ms(today)).getUTCDay(), fri = addDays(today, ((5 - dow + 7) % 7) || 7);
74
80
  const quick = `<div class="rp-qk"><button type="button" data-rp-day="${today}">Today</button><button type="button" data-rp-day="${tom}">Tomorrow</button><button type="button" data-rp-day="${fri}">Fri</button></div>`;
81
+ // the optional time (task-time-optional): a clock press beside No date; the row shows when pressed or when a time is set
82
+ const tOpen = !!s.time && (!!s.timeOpen || isTime(s.start_time) || isTime(s.due_time));
83
+ const tin = (k, label, day) => `<label class="rp-tf"><small>${label}</small><input class="rp-ti" data-rp-tm="${k}" type="time" value="${isTime(s[k]) ? s[k] : ''}" aria-label="${esc(label + (day ? '' : ', pick a day first'))}"${day ? '' : ' disabled'}></label>`;
84
+ const times = tOpen ? `<div class="rp-tm">${s.one ? tin('due_time', 'Time', b) : tin('start_time', 'Start time', a) + tin('due_time', 'Due time', b)}</div>` : '';
85
+ const clock = s.time ? `<button type="button" class="rp-clock" data-rp-time aria-expanded="${tOpen}" aria-label="${tOpen ? 'Time' : 'Add a time'}" title="${tOpen ? 'Time' : 'Add a time'}">${svg(CLOCK, 16)}</button>` : '';
75
86
  return `<div class="rp${s.one ? ' one' : ''}" data-rp>${o.head || ''}${ends}${quick}`
76
87
  + `<div class="rp-mh"><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, -1)}" aria-label="Previous month">${svg(ARR.prev)}</button><b aria-live="polite">${FULL[m - 1]} ${y}</b><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, 1)}" aria-label="Next month">${svg(ARR.next)}</button></div>`
77
88
  + `<div class="rp-g" role="grid" aria-label="${esc(FULL[m - 1] + ' ' + y)}"><div class="rp-row rp-wk" aria-hidden="true"><i>M</i><i>T</i><i>W</i><i>T</i><i>F</i><i>S</i><i>S</i></div>${weeks.join('')}</div>`
78
89
  + `<p class="rp-msg" role="status"${o.msg ? '' : ' hidden'}>${esc(o.msg || '')}</p>`
79
- + `<div class="rp-ft"><button type="button" class="rp-clear" data-rp-clear>No date</button></div></div>`;
90
+ + times + `<div class="rp-ft"><button type="button" class="rp-clear" data-rp-clear>No date</button>${clock}</div></div>`;
80
91
  }
81
92
 
82
93
  const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
83
94
 
84
95
  export function mountRange(el, o = {}) {
85
96
  const today = o.today || localToday();
86
- const s = { start: isDay(o.start) && !o.one ? o.start : '', due: isDay(o.due) ? o.due : '', one: !!o.one, field: o.one ? 'due' : o.field === 'due' ? 'due' : 'start', month: o.month || '', focus: '' };
97
+ const s = { start: isDay(o.start) && !o.one ? o.start : '', due: isDay(o.due) ? o.due : '', one: !!o.one, field: o.one ? 'due' : o.field === 'due' ? 'due' : 'start', month: o.month || '', focus: '',
98
+ time: !!o.time, timeOpen: !!o.timeOpen, start_time: isTime(o.start_time) && !o.one ? o.start_time : '', due_time: isTime(o.due_time) ? o.due_time : '' };
87
99
  let msg = '', drawing = false;
88
100
  const draw = (focusDay) => {
89
101
  if (focusDay) { s.focus = focusDay; s.month = focusDay.slice(0, 7); }
@@ -95,6 +107,8 @@ export function mountRange(el, o = {}) {
95
107
  const tap = (v, from) => {
96
108
  const r = rangeTap(s, v);
97
109
  Object.assign(s, r.patch); s.field = r.field; msg = '';
110
+ if (r.patch.start === '') s.start_time = ''; // a day taken out takes its time with it (the server does the same)
111
+ if (r.patch.due === '') s.due_time = '';
98
112
  draw(from === 'grid' && v ? v : null);
99
113
  if (from === 'type' && !r.done) el.querySelector(`[data-rp-end="${s.field}"] .rp-in`)?.focus({ preventScroll: true });
100
114
  if (o.onPick) o.onPick(r.patch, r.done, { ...s });
@@ -109,8 +123,9 @@ export function mountRange(el, o = {}) {
109
123
  el.onclick = (e) => {
110
124
  const b = e.target.closest('button'); if (!b || !el.contains(b) || !b.closest('[data-rp]')) return;
111
125
  const d = b.dataset;
112
- if (d.rpDay == null && d.rpMonth == null && !('rpClear' in d)) return; // the host's own button (a sheet's ✕)
126
+ if (d.rpDay == null && d.rpMonth == null && !('rpClear' in d) && !('rpTime' in d)) return; // the host's own button (a sheet's ✕)
113
127
  e.stopPropagation();
128
+ if ('rpTime' in d) { s.timeOpen = !s.timeOpen; draw(); (el.querySelector('.rp-ti:not([disabled])') || el.querySelector('[data-rp-time]'))?.focus({ preventScroll: true }); return; }
114
129
  if (d.rpMonth) { const next = b.getAttribute('aria-label') === 'Next month'; s.month = d.rpMonth; s.focus = ''; draw(); el.querySelector(next ? '.rp-mh .rp-nav:last-child' : '.rp-mh .rp-nav')?.focus({ preventScroll: true }); return; }
115
130
  if ('rpClear' in d) { tap('', 'clear'); return; }
116
131
  tap(d.rpDay, b.closest('.rp-g') ? 'grid' : 'quick');
@@ -166,7 +181,16 @@ export function mountRange(el, o = {}) {
166
181
  if (btn) { el.querySelectorAll('.rp-g [tabindex="0"]').forEach((x) => x.setAttribute('tabindex', '-1')); btn.setAttribute('tabindex', '0'); btn.focus({ preventScroll: true }); }
167
182
  else draw(to);
168
183
  });
169
- el.addEventListener('change', (e) => { const inp = e.target.closest && e.target.closest('.rp-in'); if (inp) take(inp); });
184
+ el.addEventListener('change', (e) => {
185
+ const inp = e.target.closest && e.target.closest('.rp-in'); if (inp) { take(inp); return; }
186
+ // a time field: saved on its own change, "HH:MM" or '' when it is cleared; the picker stays open
187
+ const ti = e.target.closest && e.target.closest('.rp-ti'); if (!ti || drawing || !ti.isConnected) return;
188
+ const k = ti.dataset.rpTm, v = ti.value ? String(ti.value).slice(0, 5) : '';
189
+ if ((v && !isTime(v)) || v === s[k]) return;
190
+ s[k] = v; s.timeOpen = true;
191
+ if (o.onState) o.onState({ ...s });
192
+ if (o.onPick) o.onPick({ [k]: v }, false, { ...s });
193
+ });
170
194
  draw();
171
195
  return { state: s, focus() { (el.querySelector('.rp-g [tabindex="0"]') || el.querySelector('.rp-in'))?.focus({ preventScroll: true }); } };
172
196
  }