create-pmos 0.427.0 → 0.428.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 (63) hide show
  1. package/package.json +13 -13
  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 +16 -2
  7. package/workspace/briefing-premium-board-test.js +25 -20
  8. package/workspace/briefing-premium-test.js +2 -1
  9. package/workspace/changelog.json +12 -0
  10. package/workspace/guide/briefing-premium.md +4 -2
  11. package/workspace/guide/home.md +32 -7
  12. package/workspace/guide/programs.md +1 -0
  13. package/workspace/home-other-product-test.js +12 -2
  14. package/workspace/lib/routes-meeting-material.js +22 -1
  15. package/workspace/lib/settings-store.js +14 -0
  16. package/workspace/milestone-pins-test.js +13 -0
  17. package/workspace/milestone-suggest-test.js +10 -4
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/premium-board-actions-test.js +40 -13
  21. package/workspace/premium-rec-tab-test.js +8 -0
  22. package/workspace/premium-vw-item-test.js +7 -3
  23. package/workspace/premium-vw-jira-test.js +2 -1
  24. package/workspace/program-charter-test.js +1 -1
  25. package/workspace/program-leave-test.js +2 -2
  26. package/workspace/program-order-test.js +3 -2
  27. package/workspace/program-panel-test.js +2 -1
  28. package/workspace/public/pm/bd-acts.js +20 -26
  29. package/workspace/public/pm/bd-ini-panel.js +90 -32
  30. package/workspace/public/pm/bd-pin-card.js +4 -1
  31. package/workspace/public/pm/bd-span.js +22 -12
  32. package/workspace/public/pm/cozy-rec-tab.js +12 -3
  33. package/workspace/public/pm/cozy-viewer.js +157 -23
  34. package/workspace/public/pm/cozy-vw-shell.css +13 -0
  35. package/workspace/public/pm/hi-pop.css +82 -0
  36. package/workspace/public/pm/hi-pop.js +65 -0
  37. package/workspace/public/pm/home-app.js +55 -26
  38. package/workspace/public/pm/home-ini.css +6 -76
  39. package/workspace/public/pm/home-ini.js +50 -68
  40. package/workspace/public/pm/home-list.js +29 -3
  41. package/workspace/public/pm/home-today.js +18 -7
  42. package/workspace/public/pm/ini-more.js +67 -0
  43. package/workspace/public/pm/ini-view-model.js +3 -2
  44. package/workspace/public/pm/ini-view.css +3 -1
  45. package/workspace/public/pm/ini-view.js +7 -5
  46. package/workspace/public/pm/order-model.js +85 -0
  47. package/workspace/public/pm/premium-board.js +57 -11
  48. package/workspace/public/pm/premium-insights.js +11 -1
  49. package/workspace/public/pm/premium-vw-item.js +3 -1
  50. package/workspace/public/pm/premium-vw-jira.js +2 -0
  51. package/workspace/public/pm/prog-order.js +15 -2
  52. package/workspace/public/pm/sort-order.css +17 -0
  53. package/workspace/public/pm/sort-order.js +108 -0
  54. package/workspace/public/pm/tk-view.js +3 -2
  55. package/workspace/public/pm/wf-page.js +1 -1
  56. package/workspace/public/premium-board.html +1 -0
  57. package/workspace/sort-order-test.js +201 -0
  58. package/workspace/stage-card-test.js +1 -0
  59. package/workspace/task-card-test.js +1 -1
  60. package/workspace/test-lists/sort-order.json +6 -0
  61. package/workspace/test-lists/viewer-trail.json +5 -0
  62. package/workspace/tk-tasks-test.js +5 -3
  63. package/workspace/viewer-trail-test.js +145 -0
@@ -19,6 +19,7 @@ import { needsOf, boardRows, productCard, productName, sessionRow, nameOf, iniOf
19
19
  import { programState, groupRows } from './program-model.js';
20
20
  import { homeSub } from './ms-suggest.js';
21
21
  import { STEPS, stageKey } from './premium-initiative-head.js';
22
+ import { sortTop, sortInis, prodKey } from './order-model.js'; // ONE order for Home and the Board (batch 14 item 8)
22
23
 
23
24
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
25
  const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -75,6 +76,16 @@ export function productsOf(D) {
75
76
  return out;
76
77
  }
77
78
 
79
+ /* ── the order (batch 14 item 8): what order-model.js reads from Home's groups and rows ── */
80
+ const minDate = (xs) => xs.filter(Boolean).map(String).sort()[0] || '';
81
+ const TOP_ACC = {
82
+ key: (g) => (g.kind === 'program' ? 'g:' + g.program.id : prodKey(g.name)),
83
+ turn: (g) => !!(g.turnN || g.yours),
84
+ date: (g) => (g.kind === 'program' ? (g.st && g.st.next && g.st.next.date) || '' : minDate(g.inis.concat(g.rest).map((x) => x.board && x.board.end))),
85
+ name: (g) => g.name,
86
+ };
87
+ const INI_ACC = { id: (x) => x.ini || x.id, turn: (x) => !!x.turn, date: (x) => (x.board && x.board.end) || '', stage: (x) => x.at, name: (x) => x.name };
88
+
78
89
  /* ── rows ── */
79
90
  function taskHint(t, now, mine) {
80
91
  const d = t.end ? dayDiff(t.end, now) : null;
@@ -187,11 +198,22 @@ export function programGroups(D, groups, products, o, now) {
187
198
  }
188
199
 
189
200
  /* ── the list ── */
201
+ /** The next steps Home shows: one on a cancelled, done or archived initiative is moot, so it neither brings that initiative back to Home
202
+ * nor falls to "Not in an initiative" (batch 14 item 3). A session that waits on the PM stays. */
203
+ function openNeeds(D) {
204
+ const iniOf = (p) => (p.model && p.model.initiatives) || (p.primary && D.board && D.board.initiatives) || {};
205
+ const shut = new Set();
206
+ for (const p of productsOf(D)) {
207
+ const I = iniOf(p), G = I.gone || {};
208
+ for (const r of ((I.list && I.list.rows) || (p.primary ? boardRows(D) : [])).filter((x) => !OPEN(x)).concat(G.cancelled || [], G.archived || [])) if (r && r.id) shut.add(r.id);
209
+ }
210
+ return needsOf(D).filter((x) => !x.ini || x.needSession || !shut.has(x.ini));
211
+ }
190
212
  const sameName = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
191
213
  /** o: { filter ('today' | 'kept' | 'done'), now }. The products are the ticked ones (productsOf). */
192
214
  export function homeList(D, o = {}) {
193
215
  const now = o.now || D.now || Date.now();
194
- const needs = needsOf(D);
216
+ const needs = openNeeds(D);
195
217
  const products = productsOf(D);
196
218
  const primary = products.find((p) => p.primary) || null;
197
219
  const used = new Set();
@@ -216,7 +238,9 @@ export function homeList(D, o = {}) {
216
238
  for (const x of mineNeeds) if (x.ini && x.ini !== 'product' && !ids.has(x.ini) && !x.needSession && !extra.has(x.ini)) extra.set(x.ini, { id: x.ini, title: (x.row && x.row.subject) || x.ini, lane: (x.row && x.row.lane) || '', stage: (x.row && x.row.stage) || '', made: true });
217
239
  for (const id of extra.keys()) ids.add(id);
218
240
  const inis = open.concat([...extra.values()]).map((r) => iniRowOf(D, r, mineNeeds, now));
219
- inis.sort((a, b) => (b.turn - a.turn) || (b.busy - a.busy) || (RANK[b.state] || 0) - (RANK[a.state] || 0));
241
+ // ONE order with the Board (batch 14 item 8): the PM's sort, or the order they arranged; the blue dot still marks your turn
242
+ const sorted = sortInis(prodKey(p.name), inis, D.order, INI_ACC);
243
+ inis.splice(0, inis.length, ...sorted);
220
244
  // the product's own next steps (its weekly update, a decision with no initiative) sit under its header, before the initiatives
221
245
  const flat = mineNeeds.filter((x) => !x.ini || !ids.has(x.ini)).filter((x) => !x.needSession).map((x) => ({ ...x, flat: true, hint: bareHint(x) }));
222
246
  const turnN = inis.filter((x) => x.turn).length + flat.length;
@@ -226,6 +250,8 @@ export function homeList(D, o = {}) {
226
250
  }
227
251
  // programs first (program-hierarchy P3): each program takes its initiatives out of their product groups, so an initiative shows once
228
252
  groups.unshift(...programGroups(D, groups, products, o, now));
253
+ // the programs and products in the PM's sort or own order, the same as the Board's (batch 14 item 8, order-model.js)
254
+ groups.splice(0, groups.length, ...sortTop(groups, D.order, TOP_ACC));
229
255
  // sessions that wait on the PM and belong to no initiative of a product: they are next steps too, under "Not in an initiative"
230
256
  const looseNeeds = needs.filter((x) => !used.has(x.id) && !(x.ini && groups.some((g) => g.inis.concat(g.rest).some((i) => i.ini === x.ini))));
231
257
  const loose = [];
@@ -354,7 +380,7 @@ const listWords = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ')
354
380
  export function todayCard(D, o = {}) {
355
381
  const now = o.now || D.now || Date.now();
356
382
  const t = todayOf(D);
357
- const needs = needsOf(D);
383
+ const needs = openNeeds(D);
358
384
  const titleOf = o.titleOf || ((id) => id);
359
385
  if (o.rec && !o.rec.meeting) {
360
386
  const s = o.rec.at ? Math.max(0, Math.round((now - Date.parse(o.rec.at)) / 1000)) : null;
@@ -15,6 +15,8 @@ import { whenOf } from './home-list.js';
15
15
  import { chipHtml } from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
16
16
  import { ringHtml } from './home-line.js';
17
17
  import { gripHtml, sugHtml } from './prog-order.js'; // a program's order: the grip and ✦ (canvas RoADrag, RoAPhone)
18
+ import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
19
+ import { prodKey } from './order-model.js';
18
20
  import * as CW from './ctx-wedge.js'; // how full a session's context is: the pie, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
19
21
 
20
22
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -162,17 +164,20 @@ function productHtml(g, o) {
162
164
  const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
163
165
  + `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
164
166
  + `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(say)}. ${open ? 'Close' : 'Open'} the group">${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
165
- if (!open) return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}</section>`;
167
+ const sec = `<section class="hm-pg hv-g" aria-label="${esc(g.name)}" data-po-id="${esc(prodKey(g.name))}">${SO.gripHtml(g.name)}`;
168
+ if (!open) return `${sec}${head}</section>`;
166
169
  const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
167
170
  const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
168
171
  const QUIET = 3;
169
172
  const restAll = o.restOpen(g.key);
170
- const rest = restAll ? g.rest : g.rest.slice(0, Math.max(0, QUIET - g.inis.length));
173
+ // the open initiative always shows, wherever the PM's order puts it (batch 14 item 8)
174
+ const rest = restAll ? g.rest : g.rest.filter((r, i) => i < Math.max(0, QUIET - g.inis.length) || r.id === o.sel);
171
175
  const more = g.rest.length - rest.length;
172
- const body = flat + g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key })).join('')
176
+ // the product's initiatives are one list the grip arranges, shared with the Board (batch 14 item 8)
177
+ const body = flat + `<div class="po-list" data-po-list="@${esc(prodKey(g.name))}">${g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key }, true)).join('')}</div>`
173
178
  + (more > 0 ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="false" aria-label="${more} more ${more === 1 ? 'initiative' : 'initiatives'} with nothing today. Show"><span class="hv-mk"></span>${more} more${svg(P.chevD, 16)}</button>`
174
179
  : restAll && g.rest.length > QUIET ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="true"><span class="hv-mk"></span>Fewer${svg(P.chevU, 16)}</button>` : '');
175
- return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</div></section>`;
180
+ return `${sec}${head}<div class="hv-card">${g.inis.length + rest.length + g.flat.length ? body : `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</div></section>`;
176
181
  }
177
182
  /** A program's group (canvas PgHomePhone, PgHomeDesk): above the products. Its header: the program tile, the name, the next milestone's
178
183
  * diamond with its date and one small diamond per initiative it waits on (filled when that initiative is past the Deliver milestone), a chevron.
@@ -187,13 +192,16 @@ function programHtml(g, o) {
187
192
  const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
188
193
  + `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
189
194
  + `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
190
- if (!open) return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}</section>`;
195
+ const sec = `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}" data-po-id="g:${esc(g.program.id)}">${SO.gripHtml(g.name)}`;
196
+ if (!open) return `${sec}${head}</section>`;
191
197
  // the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
192
198
  // a product's sub-heading only when the program's rows on Home come from two or more products (batch 12 item 6): one product repeated
193
199
  // under every program said nothing
194
200
  const many = g.subs.length > 1;
195
201
  const body = g.subs.map((x) => `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}<div class="po-list" data-po-list="${esc(g.program.id)}">${x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, true)).join('')}</div>`).join('');
196
- return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
202
+ // the program's milestone changes that wait on the PM lead its card (batch 14 item 4: they were only in Your day, which a desktop no longer has)
203
+ const msr = g.msRow ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
204
+ return `${sec}${head}<div class="hv-card">${msr}${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
197
205
  }
198
206
  /** "Not in an initiative" (HvAC .lh): a line under the groups. Folded it shows a blue dot when a row waits on you, an amber square when one
199
207
  * of your own is late, and the count; open, the rows in a card. */
@@ -265,6 +273,7 @@ export function listHtml(M, T, o) {
265
273
  // the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
266
274
  + (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
267
275
  + (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
276
+ + SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
268
277
  + `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button></div>`
269
278
  + (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
270
279
  // the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
@@ -278,7 +287,9 @@ export function listHtml(M, T, o) {
278
287
  body = `<section class="hm-pg hv-g" aria-label="${esc(M.list.title)}"><div class="hv-lh">${esc(M.list.title)}<span class="n">${M.list.rows.length || ''}</span></div>`
279
288
  + `<div class="hv-card">${M.list.rows.map((r) => rowHtml(r, o)).join('') || `<p class="hm-none">${esc(M.list.empty)}</p>`}</div></section>`;
280
289
  } else {
281
- body += M.groups.map((g) => (g.kind === 'product' ? productHtml(g, o) : g.kind === 'program' ? programHtml(g, o) : looseHtml(g, o))).join('');
290
+ // the programs and products are one list the grip arranges (batch 14 item 8); "Not in an initiative" stays under them
291
+ body += `<div class="po-list" data-po-list="@top">${M.groups.filter((g) => g.kind !== 'loose').map((g) => (g.kind === 'product' ? productHtml(g, o) : programHtml(g, o))).join('')}</div>`
292
+ + M.groups.filter((g) => g.kind === 'loose').map((g) => looseHtml(g, o)).join('');
282
293
  if (!M.groups.some((g) => (g.kind === 'product' && (g.count || g.flat.length)) || g.kind === 'program' || (g.rows && g.rows.length))) body += '<p class="hm-none">Nothing is open. A new initiative or a task you add shows here.</p>';
283
294
  // the capture box shows only after New → A task → Not in an initiative (o.cap); an initiative's task is added in its Tasks view
284
295
  if (o.cap) body += `<form class="hm-cap" id="hmCapF"><label class="vh" for="hmCap">Add a task to your own list</label><input id="hmCap" autocomplete="off" maxlength="250" placeholder="A task for your own list. Esc to cancel">`
@@ -0,0 +1,67 @@
1
+ /* pm/ini-more.js — the ONE initiative ⋯ menu (feedback batch 14 item 5): Home's initiative page (home-ini.js) and the Board's initiative
2
+ * panel (bd-ini-panel.js) both build their ⋯ here, so the items, their words and their order cannot drift apart again.
3
+ *
4
+ * iniMore(c) → the Viewer's more list ([{ label, note?, on(btn), danger? } | { sep: true }]). c holds what the page can do; a missing
5
+ * press (null, false, undefined) hides its item. The page decides when an item applies (the PMOS-self board, an ended
6
+ * initiative, no stages); this module decides only the words and the order:
7
+ * change it wf { name, on }, rename, auto { on: bool, press }, back { prev, on }, toStage, dates, person
8
+ * its place sm [split, merge items], pm [program move items], turnProgram (only when pm is empty)
9
+ * look at it jira, board, record, link, text
10
+ * end it ended (true: Back to Triage in place of Won't do), wontDo, backToTriage, archive
11
+ * stop it hold, or resume when it is on hold; cancel (red, last)
12
+ * iniText(title, view, tickets) the initiative as plain text, for Copy as text: the summary, the stage, the open tasks and tickets.
13
+ * ORDER every label in menu order, for the tests and the guide.
14
+ * "Open in full" is not here: the header's expand already opens it wide (say it once). */
15
+
16
+ export const ORDER = ['Change workflow', 'Rename', 'Moves on by itself', 'Move back a stage', 'Move to a stage', 'Change the plan dates', 'Add a stakeholder',
17
+ 'Split into a new initiative', 'Merge into', 'Move out of', 'Move to another program', 'Turn into a program',
18
+ 'Read Jira again', 'Open on the Board', 'The record', 'Copy link', 'Copy as text',
19
+ 'Won’t do', 'Back to Triage', 'Archive',
20
+ 'Put on hold', 'Resume', 'Cancel the initiative'];
21
+
22
+ export function iniMore(c) {
23
+ const G = [[], [], [], [], []];
24
+ const [change, place, look, end, stop] = G;
25
+ if (c.wf) change.push({ label: 'Change workflow', note: c.wf.name || 'Product feature', on: c.wf.on });
26
+ if (c.rename) change.push({ label: 'Rename', on: c.rename });
27
+ if (c.auto) change.push({ label: 'Moves on by itself', note: c.auto.on ? 'On' : 'Off', on: c.auto.press });
28
+ if (c.back) change.push({ label: 'Move back a stage', note: c.back.prev, on: c.back.on });
29
+ if (c.toStage) change.push({ label: 'Move to a stage', on: c.toStage });
30
+ if (c.dates) change.push({ label: 'Change the plan dates', on: c.dates });
31
+ if (c.person) change.push({ label: 'Add a stakeholder', on: c.person });
32
+ // split or merge above the program moves (batch 11 item 14, canvas XsmA1Menu); an initiative in no program can become one (P7)
33
+ place.push(...(c.sm || []), ...(c.pm || []));
34
+ if (c.turnProgram && !(c.pm || []).length) place.push({ label: 'Turn into a program', on: c.turnProgram });
35
+ if (c.jira) look.push({ label: 'Read Jira again', on: c.jira });
36
+ if (c.board) look.push({ label: 'Open on the Board', on: c.board });
37
+ if (c.record) look.push({ label: 'The record', on: c.record });
38
+ if (c.link) look.push({ label: 'Copy link', on: c.link });
39
+ if (c.text) look.push({ label: 'Copy as text', on: c.text });
40
+ // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage (D99, WfAWontDo)
41
+ if (c.ended ? c.backToTriage : c.wontDo) end.push(c.ended ? { label: 'Back to Triage', on: c.backToTriage } : { label: 'Won’t do', on: c.wontDo });
42
+ if (c.archive) end.push({ label: 'Archive', on: c.archive });
43
+ if (c.hold) stop.push({ label: 'Put on hold', on: c.hold });
44
+ else if (c.resume) stop.push({ label: 'Resume', on: c.resume });
45
+ if (c.cancel) stop.push({ label: 'Cancel the initiative', danger: true, on: c.cancel });
46
+ const out = [];
47
+ for (const g of G) if (g.length) out.push(...(out.length ? [{ sep: true }] : []), ...g);
48
+ return out;
49
+ }
50
+
51
+ /** The initiative as plain text, for Copy as text: the summary, the stage and the open tasks (the one view's model, ini-view-model.js). */
52
+ export function iniText(title, v, tickets) {
53
+ const lines = [title];
54
+ if (v) {
55
+ const s = v.summary || {};
56
+ if (s.line) lines.push(s.line + (s.right ? ' · ' + s.right : ''));
57
+ if (s.text) lines.push(s.text);
58
+ const st = v.stage || {};
59
+ if (st.name) lines.push('', st.name + (st.n ? ' · ' + st.n + ' of ' + st.of : '') + (st.doneOf ? ' · ' + st.doneOf : ''));
60
+ for (const sec of (v.tasks && v.tasks.sections) || []) for (const x of sec.top || []) lines.push('- ' + x.title + (x.sub ? ' · ' + x.sub : ''));
61
+ }
62
+ for (const k of (tickets || []).filter((x) => x.status !== 'Done')) lines.push('- ' + k.key + ' ' + k.title + ' · ' + (k.blocked ? 'Blocked' + (k.reason ? ' by ' + k.reason.replace(/^Waiting on /i, '') : '') : k.status || 'To do') + (k.assignee ? ' · ' + k.assignee : ''));
63
+ return lines.join('\n');
64
+ }
65
+
66
+ /** The initiative's own address (the initiative page), for Copy link: the same on Home and the Board. */
67
+ export const pageHref = (id, ws, board) => '/premium-initiative.html?id=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(board || ws) : '');
@@ -124,10 +124,11 @@ function rowOf(k, today) {
124
124
  start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
125
125
  sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft, order: k.order,
126
126
  // planned versus actual (batch 11 item 8, pm/ini-versions.js): the compared version's days where they differ, ⊕ added after it, a draft's task
127
- cmp: k.cmp || null, added: !!k.added, dr: !!k.draft };
127
+ cmp: k.cmp || null, added: !!k.added, dr: !!k.draft, jkey: jiraKeyOf(k.title) };
128
128
  }
129
129
  /** The Jira key a task's title starts with ("MSD-4376 Navigation tabs" → 'MSD-4376'), or ''. A task named for a ticket IS that ticket:
130
- * Build's section shows it once, as the task (it carries the dates and the owner), not again as a Jira row (batch 11 item 4). */
130
+ * Build's section shows it once, as the task (it carries the dates and the owner), not again as a Jira row (batch 11 item 4), and it looks
131
+ * like a ticket: the Jira square and the key in blue (batch 14 item 6). */
131
132
  const KEY_RE = /^\s*([A-Z][A-Z0-9]+-\d+)\b/;
132
133
  export const jiraKeyOf = (title) => { const m = KEY_RE.exec(String(title || '')); return m ? m[1] : ''; };
133
134
  const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999') || (a.order != null && b.order != null ? a.order - b.order : 0);
@@ -63,7 +63,7 @@ button.iv-wf:hover, .iv-prog:hover { background: var(--cz-well2) !important; col
63
63
  .iv-chp { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; color: var(--cz-ink2); background: var(--cz-well); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
64
64
  .iv-chp.late { color: var(--cz-late); background: var(--cz-latebg); }
65
65
  .iv-chp.draft { color: var(--cz-blueink); background: var(--cz-bluebg); }
66
- .iv-scgo { width: 34px; height: 34px; border-radius: 999px !important; display: inline-flex !important; align-items: center; justify-content: center !important; flex: none; color: var(--cz-ink2); background: var(--cz-well) !important; }
66
+ .iv-scgo { min-width: 34px; height: 34px; padding: 0 10px 0 12px !important; gap: 4px; font-size: 13px; font-weight: 600; white-space: nowrap; border-radius: 999px !important; display: inline-flex !important; align-items: center; justify-content: center !important; flex: none; color: var(--cz-ink2); background: var(--cz-well) !important; }
67
67
  .iv-scgo.on { color: var(--cz-onsolid); background: var(--cz-solid) !important; }
68
68
  @media (hover: hover) { button.iv-scgo:hover { background: var(--cz-well2) !important; } button.iv-scgo.on:hover { background: var(--cz-blueink) !important; } }
69
69
  .iv-scb { width: 34px; height: 34px; }
@@ -193,6 +193,8 @@ button.iv-tt:hover { text-decoration: underline; text-decoration-color: var(--cz
193
193
  .iv-cb.on { background: color-mix(in srgb, var(--cz-ink3) 60%, var(--cz-card)) !important; }
194
194
  .iv-cb.off { opacity: .6; }
195
195
  .iv-jq { width: 12px; height: 12px; border-radius: 3px; background: var(--cz-blue); flex: none; margin: 4px 3px 0; }
196
+ .iv-jq.dn { background: var(--cz-ink3); }
197
+ .iv-bxw > .iv-jq { margin: 3px 3px 0; }
196
198
  .iv-more, .iv-grp { display: flex !important; align-items: center; gap: 8px; width: 100%; min-height: 40px; font-size: 13px; font-weight: 700; color: var(--cz-ink2); border-top: 1px solid var(--cz-hair) !important; }
197
199
  .iv-grp b { flex: 1; font-size: 13.5px; font-weight: 700; color: var(--cz-ink); }
198
200
  .iv-sub { padding-left: 12px; }
@@ -70,8 +70,8 @@ function summaryHtml(s, o = {}) {
70
70
 
71
71
  /* ── the stage card: its header and one line (batch 11 item 21, agreed A; it replaced the ladder, the dates line and the next stage) ──
72
72
  * The header: the stage's number and name, "N of M done" (a press shows the stage in Tasks), the clock, or the hold, done or draft chip that
73
- * replaces it, the calendar when a date is missing, and the icon-only → that opens the move sheet (blue when every task of the stage is done
74
- * and the next stage waits). The line is pm/stage-line.js. */
73
+ * replaces it, the calendar when a date is missing, and the next stage's name with → that opens the move sheet (blue when every task of the
74
+ * stage is done and the next stage waits; batch 14 item 11: a bare → did not say where it goes). The line is pm/stage-line.js. */
75
75
  const CLOCK = 'M12 7.5V12l3 2M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17';
76
76
  const LINE = new Map(); // id → what is unfolded under the line ('' | 'list' | 'list+' | 'ms:<i>' | 'gap:<i>')
77
77
  function stageHtml(st, o, id) {
@@ -83,7 +83,7 @@ function stageHtml(st, o, id) {
83
83
  const cal = L && L.cal === 'dates' ? `<button type="button" class="iv-ib iv-scb" data-iv-tlcal aria-label="No dates yet. Set them in Tasks" title="Set the dates">${SVG(P.cal, 16)}</button>`
84
84
  : L && L.cal === 'back' && o.hold ? `<button type="button" class="iv-ib iv-scb" data-iv-hold="${L.holdAt}" aria-label="On hold with no return date. Set it" title="Set the return date">${SVG(P.cal, 16)}</button>` : '';
85
85
  const n = st.next;
86
- const go = n ? `<${o.next ? 'button type="button" data-iv-next' : 'span'} class="iv-scgo${st.ready ? ' on' : ''}"${n.ms ? ' data-ms="1"' : ''} aria-label="${esc('Next: ' + (n.ms ? '◆ ' : '') + n.name + (o.next ? '. Move to ' + n.name : ''))}" title="${esc('Next: ' + n.name)}">${SVG(P.go, 16, 2.2)}</${o.next ? 'button' : 'span'}>` : '';
86
+ const go = n ? `<${o.next ? 'button type="button" data-iv-next' : 'span'} class="iv-scgo${st.ready ? ' on' : ''}"${n.ms ? ' data-ms="1"' : ''} aria-label="${esc('Next: ' + (n.ms ? '◆ ' : '') + n.name + (o.next ? '. Move to ' + n.name : ''))}" title="${esc('Next: ' + n.name)}"><span class="iv-scgn">${n.ms ? '◆ ' : ''}${esc(n.name)}</span>${SVG(P.go, 16, 2.2)}</${o.next ? 'button' : 'span'}>` : '';
87
87
  // a phone puts "N of M done" and the clock on a line of their own under the name (ScxA2Phone)
88
88
  const meta = of || clock || chip ? `<span class="iv-scm">${of}${clock}${chip}</span>` : '';
89
89
  const head = `<div class="iv-sch">${tile}<b>${esc(st.name)}</b><span class="iv-sp"></span>${meta}${cal}${go}</div>`;
@@ -95,9 +95,11 @@ function taskHtml(x, o, arch) {
95
95
  // the box marks done in one press; its caret opens the status picker right under it (an archived task has only the caret)
96
96
  const car = o.quick && x.uid ? `<button type="button" class="iv-car" data-iv-stat="${esc(x.uid)}" data-st="${esc(x.status)}" data-ms="${x.ms ? 1 : 0}" aria-haspopup="dialog" aria-label="${esc('Change the status: ' + x.title)}" title="Status">${SVG(P.down, 10, 2.6)}</button>` : '';
97
97
  const cls = ['iv-cb', x.done ? 'on' : '', x.prog ? 'pr' : '', x.wont ? 'wo' : ''].filter(Boolean).join(' ');
98
- const chk = x.dr ? `<span class="iv-bxw"><span class="iv-cb dr" aria-hidden="true"></span>${car}</span>` : x.canCheck && !arch ? `<span class="iv-bxw"><button type="button" class="${cls}" data-iv-check="${esc(x.uid)}" aria-pressed="${x.done}" aria-label="${esc((x.done ? 'Reopen: ' : 'Mark done: ') + x.title)}" title="${x.done ? 'Reopen' : 'Mark done'}">${x.done ? SVG(P.check, 12, 3) : ''}</button>${car}</span>`
98
+ const chk = x.jkey && !x.dr ? `<span class="iv-bxw"><span class="iv-jq${x.closed ? ' dn' : ''}" role="img" aria-label="${esc('Jira ' + x.jkey + ': ' + x.status)}" title="${esc('Jira · ' + x.status)}"></span>${arch ? car : ''}</span>` : x.dr ? `<span class="iv-bxw"><span class="iv-cb dr" aria-hidden="true"></span>${car}</span>` : x.canCheck && !arch ? `<span class="iv-bxw"><button type="button" class="${cls}" data-iv-check="${esc(x.uid)}" aria-pressed="${x.done}" aria-label="${esc((x.done ? 'Reopen: ' : 'Mark done: ') + x.title)}" title="${x.done ? 'Reopen' : 'Mark done'}">${x.done ? SVG(P.check, 12, 3) : ''}</button>${car}</span>`
99
99
  : `<span class="iv-bxw"><span class="iv-cb off${x.done ? ' on' : ''}" aria-hidden="true">${x.done ? SVG(P.check, 12, 3) : ''}</span>${arch ? car : ''}</span>`;
100
- const t = (o.openTask && x.uid && !x.dr ? `<button type="button" class="iv-tt" data-iv-task="${esc(x.uid)}">${esc(x.title)}</button>` : `<b class="iv-tt">${esc(x.title)}</b>`) + TV.msGlyph(x) + TV.addedMark(x);
100
+ // a task named for a Jira ticket looks like the ticket rows beside it (batch 14 item 6): the Jira square, the key in blue
101
+ const name = x.jkey ? `<em>${esc(x.jkey)}</em> ${esc(x.title.replace(/^\s*[A-Z][A-Z0-9]+-\d+\s*/, ''))}` : esc(x.title);
102
+ const t = (o.openTask && x.uid && !x.dr ? `<button type="button" class="iv-tt" data-iv-task="${esc(x.uid)}">${name}</button>` : `<b class="iv-tt">${name}</b>`) + TV.msGlyph(x) + TV.addedMark(x);
101
103
  // the meta: In progress, the dates (a press: the start and due picker opens under them), the late days, the owner
102
104
  let meta = x.sub ? `<span class="${x.late ? 'w' : ''}">${esc(x.sub)}</span>` : '';
103
105
  if (o.quick && x.uid) {
@@ -0,0 +1,85 @@
1
+ /* pm/order-model.js — ONE order for Home, the Board and the Timeline (batch 14 item 8, option A; canvas SoAHomePhone, SoABoardPhone, SoADesk).
2
+ * PURE: no DOM, no fetch, so home-list.js and the tests use it as is. pm/sort-order.js is its button, menu, drag and save.
3
+ *
4
+ * The layout L is the setting look.order (lib/settings-store.js, this computer):
5
+ * { sort: 'mine' | 'turn' | 'date' | 'stage' | 'name', top: [key], inis: { [product key]: [initiative id] } }
6
+ * top the programs and products of the top of Home and the Board, by key: 'g:<program id>' or 'p:<product name, lower case>'
7
+ * inis the initiatives under one product (a program's own initiatives keep the program's order, lib/programs.js `order`)
8
+ *
9
+ * MODES the sort choices, [key, label], My order first
10
+ * prodKey(name) a product's key: Home and the Board name a product the same way, so the key is its name
11
+ * sortTop(list, L, acc) the programs and products in the layout's sort. acc: { key(x), turn(x), date(x), name(x), base(x)? }
12
+ * sortInis(pk, list, L, acc) the initiatives of product pk. acc: { id(x), turn(x), date(x), stage(x), name(x) }
13
+ * arranged(L, listKey, ids) the layout after the PM arranged one list by hand (listKey 'top' or a product key): sort becomes My order
14
+ *
15
+ * Something the PM never placed (new, or nothing arranged yet) follows the placed ones: a program before a product, a program in the
16
+ * programs' own order, a product in the products' registered order with the page's own product first (acc.base; Home's list comes in that
17
+ * order, the Board ranks by the one product pick), an initiative by stage then A to Z. So a new program or product goes at the end, never the middle. */
18
+
19
+ export const MODES = [['mine', 'My order'], ['turn', 'Your turn first'], ['date', 'Next date first'], ['stage', 'By stage'], ['name', 'Name, A to Z']];
20
+ export const DEFAULT = { sort: 'mine', top: [], inis: {} };
21
+ export const prodKey = (name) => 'p:' + String(name || '').trim().toLowerCase();
22
+ export const labelOf = (sort) => (MODES.find((m) => m[0] === sort) || MODES[0])[1];
23
+
24
+ const norm = (L) => ({ sort: L && MODES.some((m) => m[0] === L.sort) ? L.sort : 'mine', top: (L && Array.isArray(L.top) && L.top) || [], inis: (L && L.inis && typeof L.inis === 'object' && !Array.isArray(L.inis) && L.inis) || {} });
25
+ const cmpName = (a, b) => String(a || '').localeCompare(String(b || ''), undefined, { sensitivity: 'base' });
26
+ const rankIn = (order) => (k) => { const i = order.indexOf(k); return i < 0 ? Infinity : i; };
27
+ const byNum = (a, b) => (a === b ? 0 : a < b ? -1 : 1);
28
+ // a date first, the soonest first; no date last
29
+ const byDate = (a, b) => (a && b ? String(a).localeCompare(String(b)) : a ? -1 : b ? 1 : 0);
30
+
31
+ /** The top of the list: programs and products. */
32
+ export function sortTop(list, L0, acc) {
33
+ const L = norm(L0), rank = rankIn(L.top);
34
+ const all = (list || []).map((x, i) => ({ x, i, k: acc.key(x) }));
35
+ // a product never placed: the place acc.base gives it (the products' registered order, the page's own product first), else where it came
36
+ const base = (e) => (acc.base ? acc.base(e.x) : e.i);
37
+ const mine = (a, b) => byNum(rank(a.k), rank(b.k)) || (rank(a.k) === Infinity
38
+ ? byNum(a.k.startsWith('g:') ? 0 : 1, b.k.startsWith('g:') ? 0 : 1) || (a.k.startsWith('g:') ? a.i - b.i : byNum(base(a), base(b)) || cmpName(acc.name(a.x), acc.name(b.x)))
39
+ : 0);
40
+ const by = {
41
+ mine,
42
+ stage: mine,
43
+ turn: (a, b) => byNum(acc.turn(a.x) ? 0 : 1, acc.turn(b.x) ? 0 : 1) || mine(a, b),
44
+ date: (a, b) => byDate(acc.date(a.x), acc.date(b.x)) || mine(a, b),
45
+ name: (a, b) => cmpName(acc.name(a.x), acc.name(b.x)) || mine(a, b),
46
+ }[L.sort];
47
+ return all.sort(by).map((e) => e.x);
48
+ }
49
+
50
+ /** The initiatives under one product. */
51
+ export function sortInis(pk, list, L0, acc) {
52
+ const L = norm(L0), rank = rankIn(Array.isArray(L.inis[pk]) ? L.inis[pk] : []);
53
+ const st = (x) => { const s = acc.stage(x); return s == null || s < 0 ? 99 : s; };
54
+ const stage = (a, b) => byNum(st(a), st(b)) || cmpName(acc.name(a), acc.name(b));
55
+ const mine = (a, b) => byNum(rank(String(acc.id(a))), rank(String(acc.id(b)))) || stage(a, b);
56
+ const by = {
57
+ mine,
58
+ stage,
59
+ turn: (a, b) => byNum(acc.turn(a) ? 0 : 1, acc.turn(b) ? 0 : 1) || mine(a, b),
60
+ date: (a, b) => byDate(acc.date(a), acc.date(b)) || mine(a, b),
61
+ name: (a, b) => cmpName(acc.name(a), acc.name(b)) || mine(a, b),
62
+ }[L.sort];
63
+ return (list || []).slice().sort(by);
64
+ }
65
+
66
+ /** The layout after one list was arranged by hand: that list in the new order, any key the list did not show kept after it, and My order.
67
+ * seen: { top: [key], inis: { pk: [id] } }, the order each list on screen shows now: when the sort was not My order, every list keeps the
68
+ * order the PM sees as its start (rule 8), not the order saved before. */
69
+ export function arranged(L0, listKey, ids, seen) {
70
+ const L = norm(L0), out = { sort: 'mine', top: L.top.slice(), inis: { ...L.inis } };
71
+ if (L.sort !== 'mine' && seen) {
72
+ if (Array.isArray(seen.top) && seen.top.length) out.top = merge(seen.top, L.top);
73
+ for (const [pk, v] of Object.entries(seen.inis || {})) out.inis[pk] = merge(v, L.inis[pk] || []);
74
+ }
75
+ if (listKey === 'top') out.top = merge(ids, out.top);
76
+ else out.inis[listKey] = merge(ids, out.inis[listKey] || []);
77
+ return trim(out);
78
+ }
79
+ const merge = (first, rest) => [...new Set((first || []).map(String).concat((rest || []).map(String)))];
80
+ /** The saved layout stays small: at most 200 top keys, 100 products of 300 initiatives each (lib/settings-store.js checks the same). */
81
+ export function trim(L) {
82
+ const inis = {};
83
+ for (const [pk, v] of Object.entries(L.inis || {}).slice(-100)) inis[pk] = v.slice(0, 300);
84
+ return { sort: L.sort, top: (L.top || []).slice(0, 200), inis };
85
+ }
@@ -37,6 +37,8 @@ import { open as viewerOpen, current as viewerCur } from './cozy-viewer.js';
37
37
  import * as VW from './cozy-viewer.js';
38
38
  import * as PP from './bd-prog-panel.js';
39
39
  import * as PO from './prog-order.js';
40
+ import * as SO from './sort-order.js'; // the sort button and ONE order with Home and the Timeline (batch 14 item 8, canvas SoADesk, SoABoardPhone)
41
+ import { sortTop, sortInis, prodKey } from './order-model.js';
40
42
  import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
41
43
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other)
42
44
  import * as Pop from './bd-pop.js'; // the order of a program's initiatives: the grip and Claude's order from the dates (canvas RoADrag, RoASuggest)
@@ -93,7 +95,24 @@ const PHONE = matchMedia('(max-width: 720px)');
93
95
  const goneRows = () => { const G = (M && M.initiatives && M.initiatives.gone) || {}; return [...(G.cancelled || []), ...(G.archived || [])]; };
94
96
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || goneRows().find((r) => r.key === key) || null;
95
97
  /** The rows on screen grouped (pm/bd-prog.js groupsOf): programs first, then the product; or By product. null when no program holds a row here. */
96
- const groups = (L) => PG.groupsOf(PGS, L, M, byProduct);
98
+ /** In the PM's sort or own order, the same as Home's (batch 14 item 8): the programs and products, then each product's initiatives. A
99
+ * program's own initiatives keep the program's order. */
100
+ const groups = (L) => {
101
+ const G = PG.groupsOf(PGS, L, M, byProduct);
102
+ if (!G) return G;
103
+ const lay = SO.layout();
104
+ for (const g of G) if (g.kind === 'product') g.rows = sortInis(prodKey(g.name), g.rows, lay, INI_ACC);
105
+ return sortTop(G, lay, TOP_ACC);
106
+ };
107
+ const youOf = (r) => statusOf(r).tone === 'you';
108
+ const minEnd = (rows) => rows.map((r) => r.end).filter(Boolean).map(String).sort()[0] || '';
109
+ const TOP_ACC = {
110
+ key: (g) => (g.kind === 'program' ? 'g:' + g.program.id : prodKey(g.name)), turn: (g) => g.rows.some(youOf), name: (g) => (g.kind === 'program' ? g.program.title : g.name),
111
+ date: (g) => (g.kind === 'program' ? ((progState(g.program) || {}).next || {}).date || '' : minEnd(g.rows)),
112
+ // a product never placed: the one pick's order with the home product first, as Home lists them (home-list.js productsOf)
113
+ base: (g) => { const P = (PKP && PKP.products) || [], i = P.findIndex((p) => String(p.name).toLowerCase() === String(g.name).toLowerCase()); return i < 0 ? Infinity : P[i].primary ? -1 : i; },
114
+ };
115
+ const INI_ACC = { id: (r) => r.id, turn: youOf, date: (r) => r.end || '', name: (r) => r.title || '', stage: (r) => (TK && TK.mode !== 'pf' ? WF.posOf(r) : r.track ? r.track.k : -1) };
97
116
  const progState = (p) => PG.stateOf(p, M, XR);
98
117
 
99
118
  /** A panel of pm/bd-acts.js or pm/bd-asks.js (New initiative, Accept ask, the first questions, a document, a release, the backlog, Metrics,
@@ -388,8 +407,8 @@ const isME = (r) => r.track && r.track.k >= 6;
388
407
  function drawTrack(L) {
389
408
  TK = trackMode(L);
390
409
  const S = TK.mode === 'pf' ? M.steps || [] : TK.steps || [];
391
- const sorted = TK.mode === 'pf' ? L.slice().sort((a, b) => ((a.track ? a.track.k : -1) < 0 ? 99 : a.track.k) - ((b.track ? b.track.k : -1) < 0 ? 99 : b.track.k))
392
- : L.slice().sort((a, b) => WF.posOf(a) - WF.posOf(b));
410
+ // one product and no program: its initiatives in the PM's sort or own order, the same as Home's (batch 14 item 8); grouped, groups() sorts each
411
+ const sorted = sortInis(prodKey((M.board && (M.board.product || M.board.name)) || ''), L, SO.layout(), INI_ACC);
393
412
  // Monitor and Evaluate fold away after the first row of each (AgBoard: "19 more in Monitor and Evaluate")
394
413
  const seen = new Set(), shown = [], folded = [];
395
414
  for (const r of sorted) { if (isME(r) && seen.has(r.track.k) && !foldOpen) folded.push(r); else { if (isME(r)) seen.add(r.track.k); shown.push(r); } }
@@ -409,20 +428,24 @@ function drawTrack(L) {
409
428
  const G = groups(sorted);
410
429
  let inGroups = 0;
411
430
  const meFold = (rs) => { const seen2 = new Set(), on = [], off = []; for (const r of rs) { if (isME(r) && seen2.has(r.track.k) && !foldOpen) off.push(r); else { if (isME(r)) seen2.add(r.track.k); on.push(r); } } return { on, off }; };
412
- const rows = G ? G.map((g) => {
431
+ // the programs and products are one list the grip arranges, and each product's initiatives another, shared with Home (batch 14 item 8)
432
+ const grp = (key, name, html) => `<div class="so-g" role="rowgroup" data-po-id="${esc(key)}">${SO.gripHtml(name)}${html}</div>`;
433
+ const own = (pk, html) => `<div role="presentation" class="po-list" data-po-list="@${esc(pk)}">${html}</div>`;
434
+ const rows = G ? `<div role="presentation" class="po-list" data-po-list="@top">${G.map((g) => {
413
435
  if (g.kind === 'program') {
414
436
  // a program's rows follow its order (option A): each product's rows are one list the grip reorders (RoADrag)
415
437
  const kids = PG.folded(g.key) ? '' : g.products.map((sub) => (g.products.length > 1 ? PG.subHtml(sub.name) : '') + `<div role="presentation" class="po-list" data-po-list="${esc(g.program.id)}">${sub.rows.map((r) => trackRow(r, ' bt-kid' + (r === g.rows[g.rows.length - 1] ? ' last' : ''), true)).join('')}</div>`).join('');
416
438
  const st = progState(g.program);
417
- return PG.bandHtml(g, st, { steps: S, plain: TK.mode !== 'pf', sug: PO.sugHtml(g.program, st) }) + kids;
439
+ return grp('g:' + g.program.id, g.program.title, PG.bandHtml(g, st, { steps: S, plain: TK.mode !== 'pf', sug: PO.sugHtml(g.program, st) }) + kids);
418
440
  }
419
- if (PG.folded(g.key)) return PG.prodHtml(g);
441
+ const pk = prodKey(g.name);
442
+ if (PG.folded(g.key)) return grp(pk, g.name, PG.prodHtml(g));
420
443
  const f = meFold(g.rows); inGroups += f.off.length;
421
- return PG.prodHtml(g) + f.on.map((r) => trackRow(r, ' bt-gr')).join('') + (f.off.length ? `<button type="button" class="dlink bt-gmore" data-mefold aria-expanded="false">${SV(I.chev)}${f.off.length} more</button>` : '');
422
- }).join('') : shown.map((r) => trackRow(r)).join('');
444
+ return grp(pk, g.name, PG.prodHtml(g) + own(pk, f.on.map((r) => trackRow(r, ' bt-gr', true)).join('')) + (f.off.length ? `<button type="button" class="dlink bt-gmore" data-mefold aria-expanded="false">${SV(I.chev)}${f.off.length} more</button>` : ''));
445
+ }).join('')}</div>` : own(prodKey((M.board && (M.board.product || M.board.name)) || ''), shown.map((r) => trackRow(r, '', true)).join(''));
423
446
  const rest = G ? Math.max(0, meTotal - sorted.filter(isME).length) : more; // grouped: the ones not loaded here
424
447
  const tf2 = !G ? tf : rest > 0 && !foldOpen && !inGroups ? `<button type="button" class="dlink" id="fold" aria-expanded="false">${SV(I.chev)}${rest} more in Monitor and Evaluate</button>` : foldOpen && meTotal > 1 ? tf : '<span></span>';
425
- return `<div class="bt" role="table" aria-label="Initiatives by stage">${head}${rows}<div class="bt-tf">${tf2}<span class="bt-srt">Sorted by stage</span></div>${PHONE.matches ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-steps aria-haspopup="dialog">What finishes each step</button><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : ''}</div>`; // the phone has no step heads: a plain entry to the steps help
448
+ return `<div class="bt" role="table" aria-label="Initiatives by stage">${head}${rows}<div class="bt-tf">${tf2}</div>${PHONE.matches ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-steps aria-haspopup="dialog">What finishes each step</button><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : ''}</div>`; // the phone has no step heads: a plain entry to the steps help
426
449
  }
427
450
 
428
451
  /* ── the timeline (AgBoardTimeline; TsCOpen, TsCDesk, TsAllSpans, TsCPhone) ───────────────────────────────────────── */
@@ -451,6 +474,7 @@ function drawInit() {
451
474
  if (v === 'time') TL.mount(body);
452
475
  $('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
453
476
  $$('#ibTabs [data-v]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.v === v)));
477
+ { const sb = $('#bdSort'), Ls = SO.labels(); if (sb) { sb.setAttribute('aria-label', Ls.aria); sb.title = Ls.title; sb.classList.toggle('on', Ls.on); } }
454
478
  $('#bdView').innerHTML = SV(v === 'time' ? I.time : I.track); $('#bdView').setAttribute('aria-label', 'Change view. Now: ' + (v === 'time' ? 'Timeline' : 'Stage track'));
455
479
  $('#bdSpans').hidden = v !== 'time' || phone;
456
480
  $$('#bdSpans [data-sp]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.sp === span)));
@@ -890,6 +914,26 @@ function focusOnce() {
890
914
  const b = $$('#ibBody [data-key]').find((x) => x.dataset.key === r.key);
891
915
  openIni(r, b || null, 'track');
892
916
  }
917
+ /* The address follows the initiative or program open in the Viewer (?focus=, ?program=), so Back from another page comes back to it
918
+ * (batch 14 item 7). The Viewer writes it once the history has settled on the entry the Board shows. */
919
+ VW.onChange((d) => {
920
+ const q = new URLSearchParams(location.search), f = d.open && d.kind === 'Initiative' && !/^bd:/.test(d.id || '') ? d.id : null, g = d.open && /^program:/.test(d.id || '') ? d.id.slice(8) : null;
921
+ if ((q.get('focus') || null) === f && (q.get('program') || null) === g) return;
922
+ if (f) q.set('focus', f); else q.delete('focus');
923
+ if (g) q.set('program', g); else q.delete('program');
924
+ const s = q.toString(); VW.replaceUrl(location.pathname + (s ? '?' + s : ''));
925
+ });
926
+ /** ?new=initiative (Home's New → Initiative, batch 14 item 10): open New initiative once, on the first read, then drop the word from the link
927
+ * so a reload does not open it again. */
928
+ let newDone = false;
929
+ function newOnce() {
930
+ if (newDone) return;
931
+ newDone = true;
932
+ const q = new URLSearchParams(location.search); if (q.get('new') !== 'initiative') return;
933
+ q.delete('new'); const s = q.toString();
934
+ history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
935
+ Acts.open.new($('#newIni'));
936
+ }
893
937
  /** One board's model (GET /api/board-premium); { r, status }. */
894
938
  async function readBoard(q) {
895
939
  let r = null, status = 0;
@@ -932,7 +976,7 @@ async function load() {
932
976
  return;
933
977
  }
934
978
  M = r.model; holdNames(); draw();
935
- focusOnce(); programOnce(); loadOthers(); loadWorkflows();
979
+ focusOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
936
980
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
937
981
  else { loadTrail(); loadGrill(); }
938
982
  }
@@ -1026,7 +1070,7 @@ Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePa
1026
1070
  grouping: () => ({ on: groupingOn(), byProduct }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time' });
1027
1071
  BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
1028
1072
  send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),
1029
- acts: (r, b) => Acts.open.row(r, b), hold: (r, i, b) => Acts.open.hold(r, i, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
1073
+ moreAct: (r, k, b) => Acts.open.more(r, k, b), hold: (r, i, b) => Acts.open.hold(r, i, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
1030
1074
  programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), openProgram: (id, b) => PG.openProgram(id, b), reload: load, toast: say, rename: renameIni, setTask, setDates, removeTask, addTask, openTask, turnProgram, moveItems, smItems, smPress, openIniId });
1031
1075
  /** Tap the title to rename (canvas RnAIni): the list, the Timeline and the panel show the new name at once; Undo is the same press.
1032
1076
  * The Jira box opens Home's chat about it with the request typed, for the PM to send (PMOS holds no Jira credential, D53). */
@@ -1050,6 +1094,8 @@ setSay(say);
1050
1094
  PO.mount({ programs: () => PGS, stateOf: (p) => progState(p), say,
1051
1095
  saved: (p) => { const i = PGS.findIndex((x) => x.id === p.id); if (i >= 0) PGS[i] = { ...PGS[i], ...p }; if (M) drawInit(); },
1052
1096
  openIni: (id, from) => { const r = (M.rows || []).find((x) => x.id === id && x.track); if (r) openIni(r, from); } });
1097
+ SO.mount({ redraw: () => { if (M) drawInit(); }, say });
1098
+ SO.load().then(() => { if (M) drawInit(); }); // the PM's sort and own order (look.order), shared with Home
1053
1099
  PP.mount({ M: () => M, programs: () => PGS, openIni: (id, from) => openIni((M.rows || []).find((x) => x.id === id && x.track), from), close: closePanel, reload: loadPrograms, say }); // the program panel (PgProgram)
1054
1100
  setTab('ini');
1055
1101
  load();
@@ -201,8 +201,18 @@ function setTab(t) {
201
201
  for (const x of $$('.ins-vw')) x.hidden = t !== 'goals';
202
202
  document.body.dataset.tab = t;
203
203
  if (M) drawPeriod(); // the period chip says "shipped or judged" on Outcomes
204
- try { history.replaceState(null, '', setQ({ tab: t === 'goals' ? null : t })); } catch { /* no history */ }
204
+ addr({ tab: t === 'goals' ? null : t });
205
205
  }
206
+ /** The address follows the tab and the goal open in the Viewer, so Back from another page comes back to it (batch 14 item 7). It goes
207
+ * through the Viewer, which writes it once the history has settled on the entry this page shows, and keeps that entry's trail. */
208
+ function addr(o) {
209
+ const u = setQ(o), V = window.czViewer;
210
+ if (V && typeof V.replaceUrl === 'function') V.replaceUrl(u); else try { history.replaceState(history.state, '', u); } catch { /* no history */ }
211
+ }
212
+ document.addEventListener('cz-viewer', (e) => {
213
+ const d = e.detail || {}, id = d.open && /^goal:/.test(d.id || '') ? d.id.slice(5) : null;
214
+ if ((new URLSearchParams(location.search).get('goal') || null) !== id) addr({ goal: id });
215
+ });
206
216
  $('.ins-tabs').addEventListener('click', (e) => { const b = e.target.closest('[role="tab"]'); if (b) setTab(b.dataset.tab); });
207
217
  $('.ins-tabs').addEventListener('keydown', (e) => {
208
218
  if (!/^Arrow(Left|Right)$/.test(e.key)) return;
@@ -9,7 +9,7 @@ import { vwOpen, vwStyle, vwClose } from './premium-viewer.js';
9
9
  import { esc, iniId, taskId, stateOf, readingHtml, errorHtml, iniHtml, taskHtml, findTask, cardTask } from './premium-vw-item-model.js';
10
10
  import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry, historyFor } from './task-card.js';
11
11
  import { pmPost } from './http.js';
12
- import { setCheck } from './cozy-viewer.js';
12
+ import { setCheck, retitle } from './cozy-viewer.js';
13
13
 
14
14
  const TRIES = 20, WAIT = 1500, KEEP = 30000;
15
15
  const cache = new Map(); // query → { at, p }: two tabs of one initiative read once
@@ -91,6 +91,8 @@ export function openWorkItem(o) {
91
91
  openRef: (ref) => import('./premium-vw-jira.js').then((J) => J.openTicket({ ws, board, initiative: m.id, ref })) });
92
92
  const R = await TV.readTicket({ ws, board, ini: m.id, iniTitle: m.title, ref: t.jira.key });
93
93
  if (!host.isConnected) return;
94
+ // the header names the ticket by its key and Jira's title, not the key alone (batch 14 item 12: "MSD-4329" said nothing)
95
+ if (R.model && R.model.ok && R.model.title && R.model.title !== t.jira.key) { try { retitle('vw:' + vid, t.jira.key + ' ' + R.model.title); } catch { /* the old dialog has no header */ } }
94
96
  Object.assign(v.ticket, TV.ticketOf({ base, model: R.model, notes: R.notes != null ? R.notes : t.notes, ini: m.id, iniTitle: m.title, readAt: t.jira.readAt || (R.model && R.model.readAt) }));
95
97
  v.draw();
96
98
  });
@@ -79,6 +79,8 @@ export async function openTicket(o) {
79
79
  const rd = el.querySelector('[data-jread]'); if (rd) rd.onclick = async () => { rd.disabled = true; toast(await askHere(readAsk(ref)) ? 'Claude is reading ' + ref + ' in this popup\'s chat.' : 'Open the ticket from its popup to read it.'); };
80
80
  return;
81
81
  }
82
+ // the header names the ticket by its key and its title, not the key alone (batch 14 item 12: "MSD-4329" alone said nothing)
83
+ if (R.model.title && R.model.title !== ref) { try { (await import('./cozy-viewer.js')).retitle('vw:jira:' + ref, (R.model.key || ref) + ' ' + R.model.title); } catch { /* the old dialog keeps its tab name */ } }
82
84
  TV.mountTicket(el, TV.ticketOf({ base: { key: R.model.key || ref, epic: R.epicKey }, model: R.model, notes: R.notes, ini: R.ini, iniTitle: R.iniTitle }), { ws, board, post: (p, b) => import('./http.js').then((H) => H.pmPost(p, b)),
83
85
  openRef: (k) => openTicket({ ws, board, initiative, ref: k }) });
84
86
  };