create-pmos 0.416.0 → 0.418.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 (37) hide show
  1. package/package.json +25 -25
  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/board-programs-test.js +68 -1
  7. package/workspace/briefing-premium-board-test.js +21 -19
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/guide/workflows.md +3 -2
  10. package/workspace/lib/engine/boards.js +7 -2
  11. package/workspace/lib/initiative-chat.js +1 -1
  12. package/workspace/lib/initiative-premium.js +7 -4
  13. package/workspace/lib/routes-boards.js +73 -4
  14. package/workspace/lib/task-cli.js +27 -3
  15. package/workspace/lib/task-items.js +5 -1
  16. package/workspace/lib/workflow-cli.js +9 -3
  17. package/workspace/package-lock.json +2 -2
  18. package/workspace/package.json +1 -1
  19. package/workspace/premium-board-actions-test.js +9 -5
  20. package/workspace/public/pm/bd-acts.js +3 -2
  21. package/workspace/public/pm/bd-scroll.js +164 -0
  22. package/workspace/public/pm/bd-span.js +151 -188
  23. package/workspace/public/pm/bd-stages.js +3 -25
  24. package/workspace/public/pm/cozy-board.css +92 -71
  25. package/workspace/public/pm/home-app.js +2 -0
  26. package/workspace/public/pm/home-data.js +17 -4
  27. package/workspace/public/pm/home-ini-model.js +5 -1
  28. package/workspace/public/pm/home-ini.js +4 -2
  29. package/workspace/public/pm/home-list.js +3 -3
  30. package/workspace/public/pm/home-task.js +4 -1
  31. package/workspace/public/pm/ini-view-model.js +4 -2
  32. package/workspace/public/pm/premium-board.js +49 -38
  33. package/workspace/public/pm/premium-vw-item.js +5 -2
  34. package/workspace/public/pm/task-card.js +12 -0
  35. package/workspace/public/premium-board.html +3 -2
  36. package/workspace/server.js +3 -0
  37. package/workspace/task-card-test.js +7 -0
@@ -1,71 +1,73 @@
1
- /* pm/bd-span.js — the premium Board's timeline (initiative premium-agreed-design, B2; the AgBoardTimeline, AgBoardTimelinePhone, AgBoardTlYear
2
- * and AgBoardTl5y frames). PMOS plan dates against the Jira forecast:
3
- * · Quarter: one row per initiative over seven weeks (three on a phone), the plan bar with its done part, the days over, the Jira forecast,
4
- * the sprint band, the today line and the release line, with their labels under the axis. Monitor and Evaluate are hidden here.
5
- * · Year: themes, with their initiatives as bars inside, coloured by theme.
6
- * · 5 yr: themes only, as one phase each from the dates on record; past 18 months is directional.
1
+ /* pm/bd-span.js — the premium Board's timeline (initiative premium-agreed-design, B2; the AgBoardTimeline frames; feedback batch 7, timeline
2
+ * spans C: TsCOpen, TsCDesk, TsCPhone, TsCPhoneSpan, TsCPhoneBack, TsAllSpans, TsSprintFilter, TsCEdges, TsCGrill). PMOS plan dates against
3
+ * the Jira forecast.
4
+ * · Quarter, Half, Year, 2 yr and 5 yr draw the same rows: programs first, then products, one row per initiative, the plan bar with its done
5
+ * part, the days over, the Jira forecast and the ◇ Deliver or Evaluate date. Only the scale changes: weeks (Quarter), months (Half and
6
+ * Year), quarters (2 yr) and years (5 yr). On 2 yr and 5 yr a date reads "Nov ’26". Monitor and Evaluate are hidden, as on Quarter.
7
+ * · From Quarter on the timeline is wider than the screen and scrolls sideways (pm/bd-scroll.js wires it): it runs from one column before the
8
+ * first date on record to one column after the last, with the ends shaded. A screen shows seven weeks, six months, twelve months, eight
9
+ * quarters or five years (a phone three, three, four, four and two).
10
+ * · Each row carries its edge tabs, hidden until pm/bd-scroll.js shows them: unfinished or late work behind the view, work that starts ahead,
11
+ * and a program's next milestone ahead. Done work leaves none.
7
12
  * · Sprint (BdSpans, initiative premium-uncovered-features): the sprint's working days, each initiative with its tickets in the sprint as rows,
8
- * who has each one, the release sign-off and "Push tickets" as ◆, and the backlog row. Half is the Year view over six months; 2 yr is the
9
- * 5 yr view over two years (themes as phases).
10
- * Themes come from GET /api/board-trail (lib/board-trail.js): one per objective, named by the PRD's theme: key, else the objective's title. The Group
11
- * control groups the long spans by theme, lane or owner. Milestones: a release's sign-off (◆ with its name), "Push tickets" where drafted tickets
12
- * wait on the Commit, and "after <initiative>" where a dependency is not done. A bar is drawn only from dates a record holds. Pure: rows and the
13
- * model in, markup out. */
13
+ * who has each one, the release sign-off and "Push tickets" as ◆, and the backlog row. Sprint does not scroll; the sprint picker changes it.
14
+ * A phone draws the sprint's two weeks in the rows of the other spans.
15
+ * Milestones: a release's sign-off (◆ with its name), "Push tickets" where drafted tickets wait on the Commit, and "after <initiative>" where a
16
+ * dependency is not done. Program milestones closer than about 120 px merge into one counted diamond. A bar is drawn only from dates a record
17
+ * holds. Pure: rows and the model in, markup out. */
14
18
  import { esc } from './premium-shell.js';
15
19
  import { mergeClose } from './program-model.js';
16
20
 
17
21
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18
22
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
19
23
  export const md = (d) => MON[d.getMonth()] + ' ' + d.getDate();
24
+ /** A month and the short year: "Nov ’26" (2 yr, 5 yr and the edge tabs). */
25
+ export const my = (d) => MON[d.getMonth()] + ' ’' + String(d.getFullYear()).slice(2);
20
26
  const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
21
27
  const addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1);
22
28
  export const SPANS = [['sprint', 'Sprint'], ['quarter', 'Quarter'], ['half', 'Half'], ['year', 'Year'], ['y2', '2 yr'], ['y5', '5 yr']];
23
29
  /** The spans a design draws: every one since the uncovered-features build. */
24
30
  export const DRAWN = new Set(SPANS.map(([k]) => k));
25
- /** The trail's theme tones (lib/board-trail.js TONES), in THEME_TONES order. */
26
- const TONE_KEYS = ['grey', 'blue', 'green', 'amber', 'violet', 'teal'];
27
- export const GROUPS = [['theme', 'Theme'], ['lane', 'Lane'], ['owner', 'Owner']];
28
- /** Theme colours, in the order the Agreed design's themes take them (grey, blue, green, amber, then two more). */
29
- export const THEME_TONES = ['var(--cz-c-8c929b)', 'var(--cz-c-4894ea)', 'var(--cz-c-5e9c6a)', 'var(--cz-c-d4a13a)', 'var(--cz-c-b07cc6)', 'var(--cz-c-d9773f)'];
30
31
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
31
32
  const FLAG = 'M5 21V4M5 4h11l-2 4 2 4H5';
32
33
  const LINK = 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1';
34
+ const CHL = 'M15 6l-6 6 6 6', CHR = 'M9 6l6 6-6 6';
33
35
 
34
- /** The window and the ticks of a span, around `now`. Quarter: from the Monday of last week, seven weeks (a phone: this week's Monday, three). */
35
- export function windowOf(span, now, phone, sprint) {
36
+ /** The scale of each span from Quarter on (TsAllSpans): its column, and how many columns one screen shows on a desktop and on a phone. */
37
+ export const SCALE = { quarter: { unit: 'w', cols: 7, ph: 3 }, half: { unit: 'm', cols: 6, ph: 3 }, year: { unit: 'm', cols: 12, ph: 4 }, y2: { unit: 'q', cols: 8, ph: 4 }, y5: { unit: 'y', cols: 5, ph: 2 } };
38
+ const COL_DAYS = { w: 7, m: 30.44, q: 91.31, y: 365.25 };
39
+ const colStart = (u, d) => (u === 'w' ? addDays(d, -((d.getDay() + 6) % 7)) : u === 'm' ? new Date(d.getFullYear(), d.getMonth(), 1) : u === 'q' ? new Date(d.getFullYear(), d.getMonth() - (d.getMonth() % 3), 1) : new Date(d.getFullYear(), 0, 1));
40
+ const colAdd = (u, d, n) => (u === 'w' ? addDays(d, 7 * n) : u === 'm' ? addMonths(d, n) : u === 'q' ? addMonths(d, 3 * n) : new Date(d.getFullYear() + n, 0, 1));
41
+ /** A column's head: its label, the part under it that carries no year, and its year (the first column on screen shows it, bd-scroll.js). */
42
+ function tickOf(u, d) {
43
+ const y = d.getFullYear(), q = Math.floor(d.getMonth() / 3) + 1, yy = '’' + String(y).slice(2);
44
+ if (u === 'w') return { at: d, label: md(d), sub: d.getMonth() === 0 && d.getDate() <= 7 ? String(y) : '', base: '', y };
45
+ if (u === 'm') { const qs = d.getMonth() % 3 === 0 ? 'Q' + q : ''; return { at: d, label: MON[d.getMonth()], sub: qs ? qs + (q === 1 ? ' ' + yy : '') : '', base: qs, y }; }
46
+ if (u === 'q') return { at: d, label: 'Q' + q, sub: q === 1 ? yy : '', base: '', y };
47
+ return { at: d, label: String(y), sub: 'H1 · H2', base: 'H1 · H2', y, plain: true };
48
+ }
49
+
50
+ /** The window and the ticks of a span, around `now`. Sprint: the sprint the Jira reading holds, else two weeks from this Monday. From Quarter
51
+ * on: `dates` are the dates on record; the window runs from one column before the first to one column after the last (TsCEdges 3), at least
52
+ * one screen wide, and always holds today. */
53
+ export function windowOf(span, now, phone, sprint, dates) {
36
54
  const t = new Date(now.getFullYear(), now.getMonth(), now.getDate());
37
55
  const mon = addDays(t, -((t.getDay() + 6) % 7));
38
56
  if (span === 'sprint') {
39
- // the sprint the Jira reading holds; with none, two weeks from this Monday
40
57
  const a = sprint && day(sprint.start), b = sprint && day(sprint.end);
41
58
  const from = a && b && b > a ? a : mon, to = a && b && b > a ? addDays(b, 1) : addDays(mon, 14);
42
59
  const n = Math.round((to - from) / 86400000), step = phone ? Math.max(2, Math.ceil(n / 4)) : n > 16 ? 2 : 1;
43
- const ticks = []; for (let i = 0; i < n; i += step) { const d = addDays(from, i); ticks.push({ at: d, label: md(d) }); }
44
- return { from, to, ticks };
45
- }
46
- if (span === 'half') {
47
- const from = addMonths(t, -1), to = addMonths(from, 6);
48
- const ticks = []; for (let i = 0; i < 6; i++) { const d = addMonths(from, i); ticks.push({ at: d, label: MON[d.getMonth()], sub: d.getMonth() % 3 === 0 ? 'Q' + (d.getMonth() / 3 + 1) : '' }); }
49
- return { from, to, ticks };
50
- }
51
- if (span === 'y2') {
52
- const q0 = new Date(t.getFullYear(), t.getMonth() - (t.getMonth() % 3), 1), from = addMonths(q0, -3), to = addMonths(from, 24);
53
- const ticks = []; for (let i = 0; i < 24; i += 3) { const d = addMonths(from, i); ticks.push({ at: d, label: 'Q' + (d.getMonth() / 3 + 1), sub: '’' + String(d.getFullYear()).slice(2) }); }
54
- return { from, to, ticks };
60
+ const ticks = []; for (let i = 0; i < n; i += step) { const d = addDays(from, i); ticks.push({ at: d, label: md(d), sub: '', base: '', y: d.getFullYear() }); }
61
+ return { from, to, ticks, cols: ticks.length, fixed: true };
55
62
  }
56
- if (span === 'quarter') {
57
- const from = phone ? mon : addDays(mon, -7), n = phone ? 3 : 7, to = addDays(from, 7 * n);
58
- const ticks = []; for (let i = 0; i < n; i++) { const d = addDays(from, 7 * i); ticks.push({ at: d, label: md(d) }); }
59
- return { from, to, ticks };
60
- }
61
- if (span === 'year') {
62
- const from = addMonths(t, -6), to = addMonths(from, 12);
63
- const ticks = []; for (let i = 0; i < 12; i++) { const d = addMonths(from, i); ticks.push({ at: d, label: MON[d.getMonth()], sub: d.getMonth() % 3 === 0 ? 'Q' + (d.getMonth() / 3 + 1) + (d.getFullYear() !== t.getFullYear() ? ' ’' + String(d.getFullYear()).slice(2) : '') : '' }); }
64
- return { from, to, ticks };
65
- }
66
- const from = new Date(t.getFullYear() - 1, 0, 1), to = new Date(t.getFullYear() + 5, 0, 1);
67
- const ticks = []; for (let y = from.getFullYear(); y < to.getFullYear(); y++) ticks.push({ at: new Date(y, 0, 1), label: String(y), sub: 'H1 · H2' });
68
- return { from, to, ticks };
63
+ const S = SCALE[span] || SCALE.quarter, u = S.unit, cols = phone ? S.ph : S.cols;
64
+ const ds = (dates || []).filter(Boolean).concat([t]), lo = new Date(Math.min(...ds)), hi = new Date(Math.max(...ds));
65
+ const from = colAdd(u, colStart(u, lo), -1);
66
+ let to = colAdd(u, colStart(u, hi), 2), n = 0;
67
+ for (let d = from; d < to; d = colAdd(u, d, 1)) n++;
68
+ while (n < cols) { to = colAdd(u, to, 1); n++; }
69
+ const ticks = []; for (let d = from; d < to; d = colAdd(u, d, 1)) ticks.push(tickOf(u, d));
70
+ return { from, to, ticks, cols, unit: u, first: lo, last: hi };
69
71
  }
70
72
 
71
73
  const pctOf = (W) => (d) => Math.max(0, Math.min(100, ((d - W.from) / (W.to - W.from)) * 100));
@@ -74,24 +76,32 @@ const doneOf = (r) => { const p = r.track && r.track.prog; return p ? Math.max(0
74
76
  const toneOf = (r) => (r.late ? 'late' : r.status === 'at risk' ? 'risk' : r.track && r.track.you ? 'you' : r.status === 'on track' ? 'ok' : 'q');
75
77
  const dated = (r) => day(r.start) || day(r.end) || (r.track && day(r.track.forecast));
76
78
  const hidden = (r) => r.track && (r.track.key === 'monitor' || r.track.key === 'evaluate');
79
+ /** Done work leaves no edge tab (TsCGrill 5): the initiative is past Deliver, or every part it counts is done. */
80
+ const isDone = (r) => !!(r.track && (r.track.k >= 6 || (r.track.prog && r.track.prog.total > 0 && r.track.prog.done >= r.track.prog.total)));
81
+ /** The first and last mark of a row: the plan, the forecast, and today while it is over. */
82
+ function extentOf(r, now) {
83
+ const s = day(r.start), e = day(r.end), fc = r.track && day(r.track.forecast), ds = [s, e, fc].filter(Boolean);
84
+ if (r.over && e && now > e) ds.push(now);
85
+ return ds.length ? { a: new Date(Math.min(...ds)), b: new Date(Math.max(...ds)) } : null;
86
+ }
77
87
 
78
- /** One initiative's marks on the quarter: the plan with its done part, the days over, the forecast past the plan, and one label after the furthest mark. */
79
- function qBar(r, X, now, phone) {
88
+ /** One initiative's marks: the plan with its done part, the days over, the forecast past the plan, and one label after the furthest mark. A
89
+ * date reads by the span's scale (o.fmt). */
90
+ function qBar(r, X, now, phone, fmt) {
80
91
  const s = day(r.start), e = day(r.end), fc = r.track && day(r.track.forecast), tone = toneOf(r);
81
92
  let out = marks(r, X, now, phone);
82
93
  if (s && e) {
83
- const l = X(s), w = Math.max(0.8, X(e) - l);
84
- out += `<span class="tg-bar t-${tone}" style="left:${P(l)};width:${P(w)}" title="PMOS plan ${esc(md(s))} to ${esc(md(e))}"><b style="width:${doneOf(r).toFixed(1)}%"></b></span>`;
94
+ const l = X(s), w = Math.max(0.15, X(e) - l);
95
+ out += `<span class="tg-bar t-${tone}" data-key="${esc(r.key)}" style="left:${P(l)};width:${P(w)}" title="PMOS plan ${esc(md(s))} to ${esc(md(e))}"><b style="width:${doneOf(r).toFixed(1)}%"></b></span>`;
85
96
  const over = r.over && now > e, late = fc && fc > e, words = [];
86
- if (over) { out += `<span class="tg-over" style="left:${P(X(e))};width:${P(Math.max(0.5, X(now) - X(e)))}"></span>`; words.push(r.overDays + ' ' + (r.overDays === 1 ? 'day' : 'days') + ' over'); }
87
- if (late) { out += `<span class="tg-fc" style="left:${P(X(e))};width:${P(X(fc) - X(e))}" title="Jira forecast ${esc(md(fc))}"></span>`; words.push('Jira forecast ' + md(fc)); }
97
+ if (over) { out += `<span class="tg-over" style="left:${P(X(e))};width:${P(Math.max(0.1, X(now) - X(e)))}"></span>`; words.push(r.overDays + ' ' + (r.overDays === 1 ? 'day' : 'days') + ' over'); }
98
+ if (late) { out += `<span class="tg-fc" style="left:${P(X(e))};width:${P(X(fc) - X(e))}" title="Jira forecast ${esc(md(fc))}"></span>`; words.push('Jira forecast ' + fmt(fc)); }
88
99
  // the committed end is the Deliver or Evaluate ◇ (PgTimeline), with its date right of it; filled while the initiative is at that milestone
89
- const inW = X(e) > 0 && X(e) < 100;
90
- if (inW) out += `<i class="tg-end${r.track && r.track.ms ? ' ms' : ''}${over ? ' late' : ''}" style="left:${P(X(e))}" title="${esc((r.track && r.track.k >= 6 ? 'Committed evaluation date ' : 'Committed delivery date ') + md(e))}"></i>`;
91
- if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc((inW ? md(e) + ' · ' : '') + words.join(' · '))}</span>`;
92
- else if (inW && !phone) out += `<span class="tg-endl${X(e) > 94 ? ' l' : ''}" style="left:${P(X(e))}">${esc(md(e))}</span>`;
100
+ out += `<i class="tg-end${r.track && r.track.ms ? ' ms' : ''}${over ? ' late' : ''}" style="left:${P(X(e))}" title="${esc((r.track && r.track.k >= 6 ? 'Committed evaluation date ' : 'Committed delivery date ') + md(e))}"></i>`;
101
+ if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc((over ? '' : fmt(e) + ' · ') + words.join(' · '))}</span>`;
102
+ else if (!phone) out += `<span class="tg-endl" style="left:${P(X(e))}">${esc(fmt(e))}</span>`;
93
103
  } else if (fc) {
94
- out += `<span class="tg-fc solo" style="left:${P(Math.max(0, X(fc) - 3))};width:3%" title="Jira forecast ${esc(md(fc))}"></span>${phone ? '' : `<span class="tg-lab fc" style="left:${P(X(fc))}">Jira forecast ${esc(md(fc))}</span>`}`;
104
+ out += `<span class="tg-fc solo" style="left:${P(X(fc))};width:12px;margin-left:-12px" title="Jira forecast ${esc(md(fc))}"></span>${phone ? '' : `<span class="tg-lab fc" style="left:${P(X(fc))}">Jira forecast ${esc(fmt(fc))}</span>`}`;
95
105
  } else {
96
106
  const d = s || e; out += `<i class="tg-dm" style="left:${P(X(d))}" title="${s ? 'Starts' : 'Ends'} ${esc(md(d))}"></i>`;
97
107
  }
@@ -110,59 +120,100 @@ function marks(r, X, now, phone) {
110
120
  return out.join('');
111
121
  }
112
122
 
113
- /** The overlay of a quarter row: week lines, the sprint band, the release line and the today line. */
123
+ /** The overlay of a row: the column lines, the shaded ends (before the first date and after the last), the sprint band, the release line and
124
+ * the today line. */
114
125
  function overlay(W, X, now, sprint, rel) {
115
126
  const tl = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('');
127
+ const ends = W.first ? `<i class="tg-out" style="left:0;width:${P(X(W.first))}"></i><i class="tg-out" style="left:${P(X(W.last))};right:0"></i>` : '';
116
128
  const sa = sprint && day(sprint.start), sb = sprint && day(sprint.end);
117
129
  const band = sa && sb && sb > W.from && sa < W.to ? `<i class="tg-sb" style="left:${P(X(sa))};width:${P(X(sb) - X(sa))}"></i>` : '';
118
130
  const ra = rel && day(rel.iso), rl = ra && ra > W.from && ra < W.to ? `<i class="tg-rl" style="left:${P(X(ra))}"></i>` : '';
119
131
  const tn = now > W.from && now < W.to ? `<u class="tg-td" style="left:${P(X(now))}"></u>` : '';
120
- return tl + band + rl + tn;
132
+ return ends + tl + band + rl + tn;
121
133
  }
122
134
 
123
- /** The legend (PgTimeline), in the chip row at Quarter: done, planned, the Jira forecast, a program milestone where a program is
124
- * drawn, Deliver or Evaluate, today. */
135
+ /** A row's edge tabs (TsCDesk, TsCEdges 1): hidden here; pm/bd-scroll.js shows one when the row's marks are all off screen. Behind the view:
136
+ * unfinished work names its due date ("‹ Nov ’26"), late work its days over ("‹ 26 days over", the late colour). Ahead: the start date
137
+ * ("Jul ’27 ›"). Done work leaves none. A phone keeps only the late tab. */
138
+ function edgeTabs(r, X, now, phone) {
139
+ const x = extentOf(r, now); if (!x) return '';
140
+ const a = X(x.a).toFixed(3), b = X(x.b).toFixed(3), e = day(r.end) || x.b, late = r.over && day(r.end) && now > day(r.end);
141
+ const lw = late ? r.overDays + ' ' + (r.overDays === 1 ? 'day' : 'days') + ' over' : my(e), rw = my(x.a);
142
+ const tab = (side, words, cls) => `<button type="button" class="tg-edge ${side}${cls}" data-edge="${side}" data-a="${a}" data-b="${b}" tabindex="-1" hidden aria-label="${esc(r.title + ': ' + words + '. Scroll to it')}">${side === 'l' ? SV(CHL) : ''}<span>${esc(words)}</span>${side === 'r' ? SV(CHR) : ''}</button>`;
143
+ if (phone) return late ? tab('l', lw, ' late') : '';
144
+ return (isDone(r) ? '' : tab('l', lw, late ? ' late' : '')) + (isDone(r) ? '' : tab('r', rw, ''));
145
+ }
146
+
147
+ /** The legend (PgTimeline), in the chip row on every span from Quarter on: done, planned, the Jira forecast, a program milestone where a
148
+ * program is drawn, Deliver or Evaluate, today. */
125
149
  export const legendHtml = (prog) => `<span class="tg-lgd" role="group" aria-label="Legend"><span><i class="k dn"></i>Done in Jira</span><span><i class="k pl"></i>Planned</span><span><i class="k fc"></i>Jira forecast</span>${prog ? '<span><i class="k pdm"></i>Program milestone</span>' : ''}<span><i class="k dlv"></i>Deliver or Evaluate</span><span><i class="k td"></i>Today</span></span>`;
126
150
 
127
- /** The quarter's markup. o: { now, phone, sel, status(r) → { tone, text }, hiddenCount, askHref } */
128
- function quarter(rows, M, o) {
129
- const now = o.now, sprint = M.jira && M.jira.sprint, rel = M.jira && M.jira.release;
130
- const W = windowOf(o.span === 'sprint' ? 'sprint' : 'quarter', now, o.phone, sprint), X = pctOf(W);
151
+ /** The dates on record a window must hold: every shown row's plan and forecast, the programs' spans and milestones, the release. */
152
+ function datesOf(list, M, o) {
153
+ const ds = list.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast)]);
154
+ for (const { g, st } of progGroups(o)) { const sp = progSpan(g); if (sp) ds.push(sp.lo, sp.hi); for (const m of st.milestones || []) ds.push(day(m.date)); }
155
+ const rel = M.jira && M.jira.release; if (rel) ds.push(day(rel.iso));
156
+ return ds.filter(Boolean);
157
+ }
158
+
159
+ /** Every span from Quarter on, and Sprint on a phone. o: { now, phone, sel, status(r) → { tone, text }, hiddenCount, askHref, trackPx } */
160
+ function scaled(rows, M, o) {
161
+ const now = o.now, sprint = M.jira && M.jira.sprint, rel = M.jira && M.jira.release, sp = o.span === 'sprint' ? 'sprint' : SCALE[o.span] ? o.span : 'quarter';
131
162
  const shown = rows.filter((r) => !hidden(r)), list = shown.filter(dated), none = shown.filter((r) => !dated(r));
163
+ const W = windowOf(sp, now, o.phone, sprint, datesOf(list, M, o)), X = pctOf(W);
164
+ const long = W.unit === 'q' || W.unit === 'y', fmt = long ? my : md;
165
+ // one screen shows W.cols columns; the track is as many screens wide as the window holds (pm/bd-scroll.js measures it again on screen)
166
+ const days = (W.to - W.from) / 86400000, viewDays = W.fixed ? days : W.cols * COL_DAYS[W.unit];
167
+ const ratio = days / viewDays, tpx = Math.max(200, o.trackPx || (o.phone ? 340 : 1100)), pxDay = tpx / viewDays;
168
+ const reach = Math.max(W.fixed ? 1 : 2, Math.round(120 / pxDay)); // program milestones closer than ~120 px merge (TsCGrill 9)
132
169
  const ov = overlay(W, X, now, sprint, rel);
133
170
  const ra = rel && day(rel.iso), sa = sprint && day(sprint.start), sb = sprint && day(sprint.end);
134
171
  const askBtn = none.length ? `<a class="bd-chip tg-ask" id="askDates" href="${esc(o.askHref(none))}">${SV('M4 5h16v11h-9l-5 4v-4H4z')}Ask to propose dates</a>` : '';
172
+ const ticks = W.ticks.map((k) => `<span style="left:${P(X(k.at))}" data-y="${k.y}" data-base="${esc(k.base)}"${k.plain ? ' data-plain' : ''}><b>${esc(k.label)}</b><small>${esc(k.sub)}</small></span>`).join('');
173
+ const tn = now > W.from && now < W.to ? X(now) : null;
174
+ const pill = tn != null ? `<span class="tg-tpill" style="left:${P(tn)}">Today</span>` : '';
175
+ const back = `<button type="button" class="tg-tback" data-today hidden aria-label="Back to today">${SV(CHL)}<span>Today</span>${SV(CHR)}</button>`;
176
+ const attrs = `data-span="${sp}" data-from="${+W.from}" data-to="${+W.to}" data-ratio="${W.fixed ? 1 : ratio.toFixed(5)}" data-now="${+now}"${W.fixed ? ' data-fixed' : ''}`;
177
+ const style = `--tw:${Math.round(tpx * (W.fixed ? 1 : ratio))}px`;
178
+ const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.map((x) => ({ ...x, rows: x.rows.filter((r) => list.includes(r)) })).filter((x) => x.rows.length), rows: g.rows.filter((r) => list.includes(r)) } : { ...g, rows: g.rows.filter((r) => list.includes(r)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
179
+ const empty = '<p class="tg-empty">No initiative on screen has a date on record.</p>';
180
+ const ext = (r) => { const x = extentOf(r, now); return x ? ` data-a="${X(x.a).toFixed(3)}" data-b="${X(x.b).toFixed(3)}"` : ''; };
135
181
  if (o.phone) {
136
- const head = `<div class="tgp-h">${W.ticks.map((k) => `<span>${esc(k.label)}</span>`).join('')}</div>`;
137
- const body = list.map((r) => { const s = o.status(r); return `<button type="button" class="tgp-r${o.sel === r.key ? ' sel' : ''}" data-key="${esc(r.key)}"><span class="tgp-t"><b>${esc(r.title)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span></span><span class="tgp-p">${ov}${qBar(r, X, now, true)}</span></button>`; }).join('');
138
- const foot = `<div class="tgp-f"><span>Today ${esc(md(now))}</span>${ra ? `<span class="tg-rel">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}</div>`;
139
- const below = `${none.length ? `<div class="tg-none"><span>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates</span>${askBtn}</div>` : ''}<p class="tg-note">Grey bars are PMOS plan dates. The dark part is points done in Jira.</p>`;
140
- return { html: `<div class="tgp" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tgp-b">${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${foot}</div>${below}`, none };
182
+ // TsCPhone: each row carries its name above its bar; the name stays at the left while you swipe
183
+ const one = (r) => `<div class="tgq-r${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tgq-n ini2" data-key="${esc(r.key)}" aria-label="${esc(r.title + ', ' + o.status(r).text)}"><i class="cz-dot ${toneOf(r)}" aria-hidden="true"></i><b>${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${qBar(r, X, now, true, fmt)}${edgeTabs(r, X, now, true)}</div></div>`;
184
+ const body = G ? G.map((g) => {
185
+ if (g.kind !== 'program') return o.prodHtml(g) + (o.folded(g.key) ? '' : g.rows.map(one).join(''));
186
+ const st = o.progState(g.program), s2 = progSpan(g);
187
+ const br = s2 ? `<span class="tg-span" style="left:${P(X(s2.lo))};width:${P(Math.max(0.3, X(s2.hi) - X(s2.lo)))}"></span>` : '';
188
+ return `<div class="tgq-r tg-pg" data-prow="${esc(g.program.id)}"><div class="tgq-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${ov}${br}${progMarks(g, st, X, W, reach, long ? my : null, true)}</div></div>` + (o.folded(g.key) ? '' : g.products.map((x) => x.rows.map(one).join('')).join(''));
189
+ }).join('') : list.map(one).join('');
190
+ const head = `<div class="tgq-h"><div class="tg-p">${ticks}${pill}</div></div>`;
191
+ const below = none.length ? `<div class="tg-none"><span>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates</span>${askBtn}</div>` : '';
192
+ return { html: `<div class="tg tg-s tgq" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${head}<div class="tg-body">${body || empty}</div></div></div>${back}<i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div></div>${below}`, none };
141
193
  }
142
- const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>Initiative</b></button><div class="tg-p">${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b></span>`).join('')}</div></div>`;
194
+ const head = `<div class="tg-r tg-h"><div class="tg-n"><b>Initiative</b>${back}</div><div class="tg-p">${ticks}${pill}</div></div>`;
143
195
  // one line per initiative (PgTimeline): its status dot and its name; the owner and the step stay in the row's title for a pointer and a reader
144
196
  const one = (r, cls) => { const s = o.status(r), sub = [r.owner, r.track ? r.track.label : r.stage, s.text].filter(Boolean).join(' · ');
145
- return `<div class="tg-r${cls || ''}${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}" title="${esc(sub)}" aria-label="${esc(r.title + ', ' + sub)}"><i class="cz-dot ${toneOf(r)}${toneOf(r) === 'you' ? ' m-info' : toneOf(r) === 'late' || toneOf(r) === 'risk' ? ' m-warn' : ''}" aria-hidden="true"></i><b>${r.inProgram && o.memberIcon ? o.memberIcon(r.inProgram) : ''}${esc(r.title)}</b></button><div class="tg-p">${ov}${qBar(r, X, now, false)}</div></div>`; };
197
+ return `<div class="tg-r${cls || ''}${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}" title="${esc(sub)}" aria-label="${esc(r.title + ', ' + sub)}"><i class="cz-dot ${toneOf(r)}${toneOf(r) === 'you' ? ' m-info' : toneOf(r) === 'late' || toneOf(r) === 'risk' ? ' m-warn' : ''}" aria-hidden="true"></i><b>${r.inProgram && o.memberIcon ? o.memberIcon(r.inProgram) : ''}${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${qBar(r, X, now, false, fmt)}${edgeTabs(r, X, now, false)}</div></div>`; };
146
198
  // programs first, then the product (PgTimeline): the program's row brackets its initiatives' bars and draws its milestones as diamonds
147
- const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.map((x) => ({ ...x, rows: x.rows.filter((r) => list.includes(r)) })).filter((x) => x.rows.length), rows: g.rows.filter((r) => list.includes(r)) } : { ...g, rows: g.rows.filter((r) => list.includes(r)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
148
199
  const body = G ? G.map((g) => {
149
200
  if (g.kind !== 'program') return o.prodHtml(g) + (o.folded(g.key) ? '' : g.rows.map((r) => one(r, ' tg-gr')).join(''));
150
201
  const last = g.rows[g.rows.length - 1];
151
- return progRow(g, o.progState(g.program), X, W, ov, o) + (o.folded(g.key) ? '' : g.products.map((x) => (g.products.length > 1 ? o.subHtml(x.name) : '') + x.rows.map((r) => one(r, ' tg-kid' + (r === last ? ' last' : ''))).join('')).join(''));
202
+ return progRow(g, o.progState(g.program), X, W, ov, o, reach, long ? my : null, (tpx * (W.fixed ? 1 : ratio)) / 100) + (o.folded(g.key) ? '' : g.products.map((x) => (g.products.length > 1 ? o.subHtml(x.name) : '') + x.rows.map((r) => one(r, ' tg-kid' + (r === last ? ' last' : ''))).join('')).join(''));
152
203
  }).join('') : list.map((r) => one(r)).join('');
153
- const axis = `<div class="tg-ax"><span></span><div class="tg-p">${now > W.from && now < W.to ? `<span class="tg-axl td" style="left:${P(X(now))}">Today</span>` : ''}${sa && sb && sb > W.from && sa < W.to ? `<span class="tg-axl sb" style="left:${P(X(sa))}">Jira ${esc(sprint.name.toLowerCase())} · ${esc(md(sa))} – ${esc(md(sb))}</span>` : ''}${ra && ra > W.from && ra < W.to ? `<span class="tg-axl rl" style="left:${P(X(ra))}">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}</div></div>`;
154
- const foot = `<div class="tg-ft">${none.length ? `<span class="tg-none"><b>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(none.slice(0, 4).map((r) => r.title).join(', '))}${none.length > 4 ? ' and ' + (none.length - 4) + ' more' : ''}</span>${askBtn}</span>` : '<span></span>'}${o.hiddenCount ? `<span class="tg-hid">Monitor and Evaluate hidden · ${o.hiddenCount}</span>` : ''}</div>`;
155
- return { html: `<div class="tg tg-q" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tg-body">${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${axis}${foot}</div>`, none };
204
+ // the sprint band and the release keep their labels under the axis on Quarter, where a week is wide enough to read them
205
+ const axl = sp === 'quarter' ? `${sa && sb && sb > W.from && sa < W.to ? `<span class="tg-axl sb" style="left:${P(X(sa))}">Jira ${esc(sprint.name.toLowerCase())} · ${esc(md(sa))} – ${esc(md(sb))}</span>` : ''}${ra && ra > W.from && ra < W.to ? `<span class="tg-axl rl" style="left:${P(X(ra))}">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}` : '';
206
+ const axis = axl ? `<div class="tg-ax"><span class="tg-n"></span><div class="tg-p">${axl}</div></div>` : '';
207
+ const foot = none.length || o.hiddenCount ? `<div class="tg-ft">${none.length ? `<span class="tg-none"><b>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(none.slice(0, 4).map((r) => r.title).join(', '))}${none.length > 4 ? ' and ' + (none.length - 4) + ' more' : ''}</span>${askBtn}</span>` : '<span></span>'}${o.hiddenCount ? `<span class="tg-hid">Monitor and Evaluate hidden · ${o.hiddenCount}</span>` : ''}</div>` : '';
208
+ return { html: `<div class="tg tg-q tg-s" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${head}<div class="tg-body">${body || empty}</div>${axis}</div></div><i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div>${foot}</div>`, none };
156
209
  }
157
210
 
158
- /** A program's row on the quarter (PgTimeline .r.pg): its tile, title and products; a thin span from the first start to the last end of its
159
- * initiatives' dates on record; its milestones in the window as diamonds (filled once done, open while ahead, amber when late), the ones
160
- * within a week of each other merged into one counted diamond (pm/program-model.js mergeClose) whose label reads "Pilot live +2 · Nov 18–21".
161
- * The title opens the program (bd:program); a counted diamond names its milestones in its label and its title. */
162
- function progRow(g, st, X, W, ov, o) {
211
+ /** A program's row (PgTimeline .r.pg): its tile, title and products; a thin span from the first start to the last end of its initiatives' dates
212
+ * on record; its milestones as diamonds, the close ones merged into one counted diamond; the next milestone ahead waits at the right edge. */
213
+ function progRow(g, st, X, W, ov, o, reach, fmt, pxPct) {
163
214
  const p = g.program, sp = progSpan(g);
164
- const br = sp && sp.hi > W.from && sp.lo < W.to ? `<span class="tg-span" style="left:${P(X(sp.lo))};width:${P(Math.max(0.8, X(sp.hi) - X(sp.lo)))}"></span>` : '';
165
- return `<div class="tg-r tg-pg" data-prow="${esc(p.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${ov}${br}${progMarks(g, st, X, W, 7)}</div></div>`;
215
+ const br = sp && sp.hi > W.from && sp.lo < W.to ? `<span class="tg-span" style="left:${P(X(sp.lo))};width:${P(Math.max(0.3, X(sp.hi) - X(sp.lo)))}"></span>` : '';
216
+ return `<div class="tg-r tg-pg" data-prow="${esc(p.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${ov}${br}${progMarks(g, st, X, W, reach, fmt, false, pxPct)}</div></div>`;
166
217
  }
167
218
  /** The first start and the last end of a program's initiatives' dates on record (its own start and target where the charter holds them). */
168
219
  function progSpan(g, own) {
@@ -171,19 +222,26 @@ function progSpan(g, own) {
171
222
  return ds.length ? { lo: new Date(Math.min(...ds)), hi: new Date(Math.max(...ds)) } : null;
172
223
  }
173
224
  /** A program's milestones in the window as diamonds (filled once done, open while ahead, amber when late); the ones within `days` of each
174
- * other merge into one counted diamond (pm/program-model.js mergeClose) whose label reads "Pilot live +2 · Nov 18–21". A counted diamond
175
- * opens the program and names its milestones in its label and its title. The long spans merge over a longer reach: a week is a hair there. */
176
- function progMarks(g, st, X, W, days) {
177
- // the reach: about a label's width (160 of ~1100 px) in the window's days, at least a week (the quarter's rule, PgTimeline)
178
- if (days == null) days = Math.max(7, Math.round(((W.to - W.from) / 86400000) * 0.145));
225
+ * other merge into one counted diamond (pm/program-model.js mergeClose) whose label reads "Pilot live +2 · Nov 18–21" ("Nov ’26" on 2 yr and
226
+ * 5 yr, `fmt`). A counted diamond opens the program and names its milestones in its label and its title. The milestones not done also wait as
227
+ * one edge tab on the right, which pm/bd-scroll.js names after the first one past the view (TsCOpen: "Okta off · Sep ’27 ›"). */
228
+ function progMarks(g, st, X, W, days, fmt, phone, pxPct) {
179
229
  const p = g.program, inW = (m) => { const d = day(m.date); return d && d >= W.from && d <= W.to; };
180
- return mergeClose((st.milestones || []).filter(inW), days).map((c) => {
230
+ const C = mergeClose((st.milestones || []).filter(inW), days);
231
+ const range = (c) => (fmt ? fmt(day(c.date)) : c.range);
232
+ // a label never runs into the next diamond: it is cut at the gap to its neighbours (it is centred on its own diamond)
233
+ const xs = C.map((c) => X(day(c.date))), room = (i) => (pxPct ? Math.min(i ? xs[i] - xs[i - 1] : 1e3, i < xs.length - 1 ? xs[i + 1] - xs[i] : 1e3) * pxPct - 16 : 0);
234
+ const out = C.map((c, i) => {
181
235
  const x = P(X(day(c.date))), tone = c.late ? ' late' : c.done ? '' : ' o', names = c.items.map((m) => m.name + (m.day ? ' ' + m.day : '')).join(' · ');
182
236
  const mark = c.n > 1
183
237
  ? `<button type="button" class="tg-clu${c.late ? ' late' : ''}" data-prog="${esc(p.id)}" style="left:${x}" aria-label="${esc(c.n + ' program milestones from ' + c.range.replace('–', ' to ') + ': ' + c.items.map((m) => m.name).join(', ') + '. Open the program')}" title="${esc(names)}"><b aria-hidden="true">${c.n}</b></button>`
184
238
  : `<span class="tg-pdm${tone}" style="left:${x}" title="${esc(names + (c.first.titles && c.first.titles.length ? ' · waits on ' + c.first.titles.join(', ') : ''))}"></span>`;
185
- return mark + `<span class="tg-pdl${c.late ? ' late' : ''}" style="left:${x}">${esc(c.label)}${c.n > 1 ? ' · ' + esc(c.range) : ' ' + esc(c.range)}</span>`;
239
+ const mw = room(i) > 0 && room(i) < 600 ? `;max-width:${Math.max(24, Math.round(room(i)))}px` : '';
240
+ return mark + (phone ? '' : `<span class="tg-pdl${c.late ? ' late' : ''}" style="left:${x}${mw}" title="${esc(c.label + ' · ' + range(c))}">${esc(c.label)} · ${esc(range(c))}</span>`);
186
241
  }).join('');
242
+ if (phone || W.fixed) return out;
243
+ const ahead = (st.milestones || []).filter((m) => !m.done && day(m.date)).map((m) => [+X(day(m.date)).toFixed(3), m.name + ' · ' + my(day(m.date))]).sort((a, b) => a[0] - b[0]);
244
+ return out + (ahead.length ? `<button type="button" class="tg-edge r pg" data-edge="m" data-ms="${esc(JSON.stringify(ahead))}" tabindex="-1" hidden><span></span>${SV(CHR)}</button>` : '');
187
245
  }
188
246
  /** A program's name cell: the tile, the title and its products (or its state), the fold; the title opens the program (bd:program). */
189
247
  function progName(g, st, o) {
@@ -228,7 +286,7 @@ function sprintSpan(rows, M, o) {
228
286
  const groups = G ? G.map((g) => {
229
287
  const kids = g.kind === 'program' ? g.products.map((x) => { const h = x.rows.map(one).join(''); return h && g.products.length > 1 && o.subHtml ? o.subHtml(x.name) + h : h; }).join('') : g.rows.map(one).join('');
230
288
  if (g.kind !== 'program') return kids ? o.prodHtml(g) + (o.folded(g.key) ? '' : kids) : '';
231
- const st = o.progState ? o.progState(g.program) : { milestones: [], state: '' }, ms = progMarks(g, st, X, W, 2);
289
+ const st = o.progState ? o.progState(g.program) : { milestones: [], state: '' }, ms = progMarks(g, st, X, W, 2, null);
232
290
  if (!kids && !ms) return '';
233
291
  return `<div class="sp-r sp-pg" data-prow="${esc(g.program.id)}"><div class="sp-n tg-pgn">${progName(g, st, o)}</div><div class="sp-g sp-t" style="--n:${n}">${ms}</div></div>` + (o.folded(g.key) ? '' : kids);
234
292
  }).join('') : rows.map(one).join('');
@@ -239,105 +297,10 @@ function sprintSpan(rows, M, o) {
239
297
  return { html: `<p class="sp-cap"><span>${cap}</span><span class="bd-sp"></span><span>Group: Initiative</span></p><div class="sp" data-span="sprint">${head}<div class="sp-body">${groups || empty}</div>${back}</div><p class="tg-note">Jira holds no dates for each ticket, so a bar runs from the sprint's first day to today.</p>`, none: [] };
240
298
  }
241
299
 
242
- /** The groups of the long spans. By theme (default): the trail's themes (one per objective; the PRD's theme: names it, theme_note: says what it
243
- * is for, theme_color: picks its colour), in the trail's order; a row the trail has not reached yet takes its anchor's objective. By lane or by owner. */
244
- const cap = (x) => x.charAt(0).toUpperCase() + x.slice(1);
245
- function themesOf(rows, o = {}) {
246
- const g = o.group || 'theme', T = o.themes || [], byKey = new Map(T.map((t) => [t.key, t]));
247
- const groups = new Map();
248
- for (const r of rows) {
249
- let k, base;
250
- if (g === 'lane') { k = r.lane || 'none'; base = { key: k, label: r.lane ? cap(r.lane) : 'No lane', what: 'Lane', kind: 'lane' }; }
251
- else if (g === 'owner') { k = r.owner || 'none'; base = { key: k, label: r.owner || 'No owner', what: 'Owner', kind: 'owner' }; }
252
- else {
253
- const th = r.trail && byKey.get(r.trail.theme);
254
- if (th) { k = th.key; base = { key: k, label: th.name, what: th.note || (th.key === 'health' ? 'Upkeep anchored to a health budget' : [th.period ? th.period + ' objective' : 'Objective', th.from ? '' : 'name it with theme: in the PRD'].filter(Boolean).join(' · ')), kind: th.key === 'health' ? 'health' : 'kr', tone: th.tone }; }
255
- else { const t = r.theme || { key: 'none', label: 'No anchor', kind: 'none', period: '' }; k = 'a:' + t.key; base = { key: k, label: t.label, what: t.kind === 'kr' ? t.period + ' objective' : t.kind === 'health' ? 'Health budgets' : 'No theme', kind: t.kind }; }
256
- }
257
- if (!groups.has(k)) groups.set(k, { ...base, rows: [] });
258
- groups.get(k).rows.push(r);
259
- }
260
- const list = [...groups.values()];
261
- if (g === 'theme' && T.length) list.sort((a, b) => { const ia = T.findIndex((t) => t.key === a.key), ib = T.findIndex((t) => t.key === b.key); return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib); });
262
- return list.map((t, i) => ({ ...t, tone: THEME_TONES[t.tone && TONE_KEYS.includes(t.tone) ? TONE_KEYS.indexOf(t.tone) : i % THEME_TONES.length] }));
263
- }
264
- /** A group's left cell: its colour and name, what it is for, and its counts. */
265
- function themeCell(t, wide) {
266
- const late = t.rows.filter((r) => r.late).length, risk = t.rows.filter((r) => r.status === 'at risk').length;
267
- const anchor = t.kind === 'health' ? 'health budget' : t.kind === 'kr' || t.kind === 'other' ? t.rows.map((r) => r.kr).filter(Boolean)[0] || '' : '';
268
- return `<div class="tg-n tg-tn"><b><i class="tg-sw" style="background:${t.tone}"></i>${esc(t.label)}</b><small>${esc(t.what)}</small><em>${t.rows.length} ${t.rows.length === 1 ? 'initiative' : 'initiatives'}${anchor ? ' · ' + esc(anchor) : ''}${!wide && late ? ' · ' + late + ' late' : ''}${!wide && risk ? ' · ' + risk + ' at risk' : ''}</em></div>`;
269
- }
270
- /** The releases the rows ride on, as milestones of the long spans: name and date, once each. */
271
- function releasesOf(rows) {
272
- const seen = new Map();
273
- for (const r of rows) { const d = r.release && day(r.release.iso); if (d && !seen.has(r.release.name)) seen.set(r.release.name, { name: r.release.name, at: d }); }
274
- return [...seen.values()];
275
- }
276
-
277
- /** Year: themes with their initiatives as bars inside. */
278
- function year(rows, o) {
279
- const sp = o.span === 'half' ? 'half' : 'year';
280
- // programs first (PgTimeline's rule on every span): each program is a row that brackets its initiatives' bars, with its milestones; the
281
- // rest group by theme, lane or owner as before
282
- const PG = progGroups(o), inPg = new Set(PG.flatMap((x) => x.g.rows));
283
- const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows.filter((r) => !inPg.has(r)), o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
284
- const tn = now > W.from && now < W.to ? X(now) : null;
285
- const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>${T.length} ${T.length === 1 ? G.toLowerCase() : G.toLowerCase() + 's'} · ${rows.length} ${rows.length === 1 ? 'initiative' : 'initiatives'}</small></button><div class="tg-p">${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b>${k.sub ? `<small>${esc(k.sub)}</small>` : ''}</span>`).join('')}</div></div>`;
286
- // AgBoardTlYear draws no release line or flag: a release shows as the ◆ at the end of a bar that rides on it
287
- const grid = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('') + (tn != null ? `<u class="tg-td" style="left:${P(tn)}"></u>` : '');
288
- const line = (r, tone) => {
289
- const s = day(r.start) || day(r.end) || day(r.track && r.track.forecast), e = day(r.end) || s, l = X(s), w = Math.max(1.2, X(e) - l), st = o.status(r);
290
- return `<button type="button" class="tg-line" data-key="${esc(r.key)}" aria-label="${esc(r.title)}"><span class="tg-yb${r.track && r.track.ms ? ' ms' : ''}" style="left:${P(l)};width:${P(w)};--tone:${tone}"><b style="width:${doneOf(r).toFixed(1)}%"></b><em><i class="cz-dot ${toneOf(r)}"></i><strong>${esc(r.title)}</strong> ${esc([r.track ? r.track.label : '', st.tone === 'late' || st.tone === 'risk' ? st.text.toLowerCase() : ''].filter(Boolean).join(' · '))}</em></span></button>`;
291
- };
292
- const progs = PG.map(({ g, st }) => {
293
- const sp2 = progSpan(g), br = sp2 && sp2.hi > W.from && sp2.lo < W.to ? `<span class="tg-span tg-ybr" style="left:${P(X(sp2.lo))};width:${P(Math.max(0.8, X(sp2.hi) - X(sp2.lo)))}"></span>` : '';
294
- const lines = o.folded(g.key) ? '' : g.rows.filter(dated).map((r) => line(r, 'var(--bd-prog)')).join('');
295
- return `<div class="tg-r tg-th tg-pg" data-prow="${esc(g.program.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p tg-stack">${grid}<div class="tg-pms">${br}${progMarks(g, st, X, W)}</div>${lines}</div></div>`;
296
- }).join('');
297
- const body = progs + T.map((t) => {
298
- const lines = t.rows.filter(dated).map((r) => line(r, t.tone)).join('');
299
- return `<div class="tg-r tg-th">${themeCell(t, false)}<div class="tg-p tg-stack">${grid}${lines || '<span class="tg-nod">No dates on record</span>'}</div></div>`;
300
- }).join('');
301
- const pill = tn != null ? `<span class="tg-today" style="left:calc(230px + (100% - 230px) * ${(tn / 100).toFixed(4)})">Today · ${esc(md(now))}</span>` : '';
302
- return { html: `<div class="tg tg-y" data-span="${sp}">${head}<div class="tg-body">${pill}${body || '<p class="tg-empty">No initiative is on screen.</p>'}</div><div class="tg-ft"><span>Bars show initiatives inside their ${G.toLowerCase()}. The darker part is done. <i class="cz-ms" aria-hidden="true"></i> is a milestone.</span><button type="button" class="tg-go" data-span-go="quarter">Switch to Quarter to see one row per initiative</button></div></div>`, none: [] };
303
- }
304
-
305
- /** 5 yr: themes only, as one phase each from the earliest date on record to the latest; past 18 months is directional (dashed). */
306
- function fiveYear(rows, o) {
307
- const sp = o.span === 'y2' ? 'y2' : 'y5';
308
- const PG = progGroups(o), inPg = new Set(PG.flatMap((x) => x.g.rows)); // programs first, as one phase each; the rest by theme
309
- const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows.filter((r) => !inPg.has(r)), o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
310
- const far = addMonths(now, 18), fx = X(far), tn = now > W.from && now < W.to ? X(now) : null;
311
- const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>what each ${G.toLowerCase()} is for</small></button><div class="tg-p">${fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : ''}${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b><small>${esc(k.sub)}</small></span>`).join('')}</div></div>`;
312
- const grid = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('') + (fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : '') + (tn != null ? `<u class="tg-td" style="left:${P(tn)}"></u>` : '');
313
- // a program's phase runs over its own span where the charter holds one (a program can run for years), else over its initiatives' dates
314
- const progs = PG.map(({ g, st }) => {
315
- const sp2 = progSpan(g, true), n = g.rows.length;
316
- const words = n + ' ' + (n === 1 ? 'initiative' : 'initiatives') + (o.productsOf && o.productsOf(g.program) > 1 ? ' · ' + o.productsOf(g.program) + ' products' : '');
317
- const ph = sp2 ? `<button type="button" class="tg-phase pg${sp2.lo > far ? ' dir' : ''}" data-prog="${esc(g.program.id)}" style="left:${P(X(sp2.lo))};width:${P(Math.max(2, X(sp2.hi) - X(sp2.lo)))};--tone:var(--bd-prog)" aria-haspopup="dialog" aria-label="${esc(g.program.title + ', ' + words + '. Open the program')}"><b>${esc(g.program.title)}</b><small>${esc(words)}</small></button>` : '<span class="tg-nod">No dates on record</span>';
318
- return `<div class="tg-r tg-th tg-5 tg-pg" data-prow="${esc(g.program.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${grid}${ph}<div class="tg-pms">${progMarks(g, st, X, W)}</div></div></div>`;
319
- }).join('');
320
- const body = progs + T.map((t) => {
321
- const ds = t.rows.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast)]).filter(Boolean).sort((a, b) => a - b);
322
- const shipped = t.rows.filter((r) => r.track && r.track.k >= 6).length, planned = t.rows.filter((r) => !r.track || r.track.k < 4).length, active = t.rows.length - shipped - planned;
323
- const a = ds[0], b = ds[ds.length - 1];
324
- const words = [active ? active + ' active' : '', planned ? planned + ' planned' : '', shipped ? shipped + ' shipped' : ''].filter(Boolean).join(' · ');
325
- // a milestone sits under the phase, in the theme's colour, with its name right of the ◆ (AgBoardTl5y)
326
- const ms = releasesOf(t.rows).filter((m) => X(m.at) > 0 && X(m.at) < 100).map((m) => `<i class="tg-msd" style="left:${P(X(m.at))};--tone:${t.tone}" title="${esc(m.name)} · ${esc(md(m.at))}"></i><span class="tg-msl" style="left:${P(X(m.at))}">${esc(m.name)}</span>`).join('');
327
- const ph = ds.length ? `<button type="button" class="tg-phase${a > far ? ' dir' : ''}" data-tgtheme="${esc(t.key)}" style="left:${P(X(a))};width:${P(Math.max(2, X(b) - X(a)))};--tone:${t.tone}"><b>${esc(t.label)}</b><small>${esc(words)}${a > far ? ' · directional' : ''}</small></button>${ms}` : '<span class="tg-nod">No dates on record</span>';
328
- return `<div class="tg-r tg-th tg-5">${themeCell(t, true)}<div class="tg-p">${grid}${ph}</div></div>`;
329
- }).join('');
330
- const lab = (x) => `calc(230px + (100% - 230px) * ${(x / 100).toFixed(4)})`; // the 230 px theme column
331
- const marks = (tn != null ? `<span class="tg-today" style="left:${lab(tn)}">Today</span>` : '') + (fx < 100 ? `<span class="tg-far" style="left:${lab(fx)}">Beyond 18 months · directional</span>` : '');
332
- return { html: `<div class="tg tg-5y" data-span="${sp}">${head}<div class="tg-body">${marks}${body || '<p class="tg-empty">No initiative is on screen.</p>'}</div><div class="tg-ft"><span>Only themes and their phases at this span. Dashed means directional, not committed.</span><span class="tg-go2">Open a phase to see its initiatives</span></div></div>`, none: [] };
333
- }
334
-
335
300
  /** The timeline's markup for the rows on screen. → { html, none: [rows with no dates] } */
336
301
  export function timelineHtml(rows, M, span, o = {}) {
337
- const opt = { now: new Date(), phone: false, sel: null, status: () => ({ tone: 'q', text: '' }), hiddenCount: 0, askHref: () => '#', ...o };
302
+ const opt = { now: new Date(), phone: false, sel: null, status: () => ({ tone: 'q', text: '' }), hiddenCount: 0, askHref: () => '#', prodHtml: () => '', subHtml: () => '', folded: () => false, progState: () => ({ milestones: [], state: '' }), ...o };
338
303
  opt.span = span;
339
- if (span === 'year' || span === 'half') return year(rows, opt);
340
- if (span === 'y5' || span === 'y2') return fiveYear(rows, opt);
341
304
  if (span === 'sprint' && !opt.phone) return sprintSpan(rows, M, opt);
342
- return quarter(rows, M, opt);
305
+ return scaled(rows, M, opt);
343
306
  }
@@ -1,5 +1,6 @@
1
- /* pm/bd-stages.js — the Board's two help frames (initiative premium-agreed-design, B1 B2): "What finishes each step" (AgBoardStages) and
2
- * "The longer the span, the higher the grouping" (AgBoardTlRules), as two separate popovers. Pure markup; no reads. */
1
+ /* pm/bd-stages.js — the Board's help frame (initiative premium-agreed-design, B1): "What finishes each step" (AgBoardStages), a popover.
2
+ * The timeline's spans help (AgBoardTlRules) went with the theme grouping: every span from Quarter on draws the same rows (feedback batch 7,
3
+ * timeline spans C). Pure markup; no reads. */
3
4
  import { esc } from './premium-shell.js';
4
5
 
5
6
  export const STEP_HELP = [
@@ -12,19 +13,6 @@ export const STEP_HELP = [
12
13
  ['Monitor', false, 'Outcome report', 'Days of data against the target, then the report', 'Metrics sources'],
13
14
  ['Evaluate', true, 'Keep, iterate or stop', 'The report reviewed, the evaluation, your verdict', 'PMOS'],
14
15
  ];
15
- export const SPAN_HELP = [
16
- ['Sprint', '2 weeks', 'Jira tickets inside each initiative', 'Tickets, assignees, blockers'],
17
- ['Quarter', '3 months', 'One row per initiative', 'Stage, output progress, plan against the Jira forecast'],
18
- ['Half · Year', '6–12 months', 'Themes, with their initiatives as bars inside', 'Which initiatives carry each theme, milestones'],
19
- ['2 yr · 5 yr', '2–5 years', 'Themes only, as phases', 'Where each theme is heading, what is committed and what is directional'],
20
- ];
21
- export const THEME_HELP = [
22
- ['Foundation', 'var(--cz-c-8c929b)', 'Make PMOS reliable to run', 'Platform, reliability, state, health budgets'],
23
- ['Closing gaps', 'var(--cz-c-4894ea)', 'Match what PMs already expect', 'Features users expect but miss today'],
24
- ['Expansion', 'var(--cz-c-5e9c6a)', 'Reach partners and teams', 'New segments, partners, integrations'],
25
- ['Maturity', 'var(--cz-c-d4a13a)', 'Prove outcomes, then scale', 'Outcome proof, automation, scale'],
26
- ];
27
-
28
16
  const X = '<button type="button" class="bd-x" data-pop-close aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button>';
29
17
  const row = (cells, cls = '') => `<div class="bd-tr${cls}" role="row">${cells.map((c) => `<span role="${cls ? 'columnheader' : 'cell'}">${c}</span>`).join('')}</div>`;
30
18
 
@@ -35,13 +23,3 @@ export function stepsHelpHtml() {
35
23
  + `<div class="bd-tbl" role="table" aria-label="What finishes each step">${row(['Step', 'Type', 'Output that finishes it', 'How progress is counted', 'Where the count comes from'], ' th')}`
36
24
  + STEP_HELP.map(([n, ms, o, how, src]) => row([`<b>${ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(n)}</b>`, `<em>${ms ? 'Milestone' : 'Stage'}</em>`, esc(o), esc(how), `<em>${esc(src)}</em>`])).join('') + '</div></div>';
37
25
  }
38
-
39
- /** AgBoardTlRules: what a row is at each span, and the themes (an example: themes are not set in PMOS yet). */
40
- export function rulesHelpHtml() {
41
- return `<div class="bd-help"><div class="bd-help-h"><h2 id="hRules">The longer the span, the higher the grouping</h2>${X}</div>`
42
- + '<p class="bd-help-p">The timeline switches what a row is as you zoom out. Each initiative belongs to one theme, set in its panel and on the PRD. Themes are set per product.</p>'
43
- + `<div class="bd-tbl bd-tbl4" role="table" aria-label="Timeline spans">${row(['Span', 'Covers', 'Rows are', 'You see'], ' th')}`
44
- + SPAN_HELP.map(([s, c, r, y]) => row([`<b>${esc(s)}</b>`, `<em>${esc(c)}</em>`, esc(r), esc(y)])).join('') + '</div>'
45
- + `<div class="bd-tbl bd-tbl3" role="table" aria-label="Themes">${row(['Theme (example)', 'What it is for', 'Typical work'], ' th')}`
46
- + THEME_HELP.map(([n, c, w, t], i) => row([`<b><i class="tg-sw k${i}"></i>${esc(n)}</b>`, esc(w), esc(t)])).join('') + '</div></div>';
47
- }