create-pmos 0.535.0 → 0.537.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 (36) hide show
  1. package/package.json +27 -41
  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 +18 -13
  7. package/workspace/board-publish-ui-test.js +1 -1
  8. package/workspace/board-shared-ui-test.js +3 -3
  9. package/workspace/board-workflows-test.js +26 -32
  10. package/workspace/briefing-premium-board-test.js +34 -29
  11. package/workspace/changelog.json +26 -0
  12. package/workspace/fixtures/board-workflows-facts.js +7 -1
  13. package/workspace/guide/board.md +12 -1
  14. package/workspace/guide/programs.md +2 -2
  15. package/workspace/guide/reports.md +11 -1
  16. package/workspace/lib/report-engine.js +27 -6
  17. package/workspace/lib/report-library.js +1 -1
  18. package/workspace/lib/report-orders.js +218 -0
  19. package/workspace/lib/route-modules.js +1 -0
  20. package/workspace/lib/routes-report-flow.js +1 -1
  21. package/workspace/lib/routes-report-orders.js +161 -0
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/premium-vw-jira-test.js +1 -1
  25. package/workspace/public/pm/bd-acts.js +16 -11
  26. package/workspace/public/pm/bd-publish.js +1 -1
  27. package/workspace/public/pm/bd-wf.js +5 -28
  28. package/workspace/public/pm/cozy-board.css +64 -31
  29. package/workspace/public/pm/cozy-vw-rp.css +40 -0
  30. package/workspace/public/pm/premium-board.js +85 -52
  31. package/workspace/public/pm/premium-report-read.js +90 -9
  32. package/workspace/public/pm/readonly.js +1 -1
  33. package/workspace/public/pm/report-orders-ui.js +115 -0
  34. package/workspace/public/premium-board.html +27 -30
  35. package/workspace/skills/report-write.skill +1 -1
  36. package/workspace/test-lists/report-orders.json +11 -0
@@ -44,7 +44,7 @@ import * as PP from './bd-prog-panel.js';
44
44
  import * as PO from './prog-order.js';
45
45
  import * as SO from './sort-order.js';
46
46
  import { faceOr } from './cozy-adler.js'; // Adler on the Jira chip (batch 17 item 4-A, canvas AdM2 Jira freshness) // the sort button and ONE order with Home and the Timeline (batch 14 item 8, canvas SoADesk, SoABoardPhone)
47
- import { sortTop, sortInis, prodKey } from './order-model.js';
47
+ import { sortTop, sortInis, prodKey, MODES as SORT_MODES } from './order-model.js';
48
48
  import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
49
49
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other)
50
50
  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)
@@ -111,7 +111,9 @@ const I = {
111
111
  flag: 'M5 21V4M5 4h11l-2 4 2 4H5', note: 'M4 5h16v11h-9l-5 4v-4H4z', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
112
112
  doc: 'M6 3h9l4 4v14H6zM14 3v5h5', 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', chev: 'M7 10l5 5 5-5', chevUp: 'M7 14l5-5 5 5',
113
113
  move: 'M4 12h12M12 6l6 6-6 6M20 5v14', hold: 'M9 5v14M15 5v14', archive: 'M4 5h16v4H4zM6 9v10h12V9M10 13h4',
114
- track: 'M3 5h18v4H3zM3 11h18v4H3zM3 17h12v3H3z', time: 'M4 6h9M8 12h11M6 18h7', info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 11v5M12 8h.01',
114
+ track: 'M3 5h18v4H3zM3 11h18v4H3zM3 17h12v3H3z', time: 'M4 6h9M8 12h11M6 18h7', list: 'M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01',
115
+ stages: 'M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z', ok: 'M5 12.5l4.5 4.5L19 7', group: 'M4 7h16M4 12h10M4 17h5',
116
+ people: 'M9 5a3 3 0 1 0 0 6a3 3 0 1 0 0-6M3 20c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5M16 5.2a3 3 0 0 1 0 5.6M18 14.8c1.8.7 3 2.3 3 5.2', info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 11v5M12 8h.01',
115
117
  };
116
118
  const plural = (n, a, b) => (n === 1 ? a : b);
117
119
  const ago = (iso, short) => { const t = Date.parse(iso || ''); if (!t) return ''; const m = Math.max(0, Math.round((Date.now() - t) / 60000)); return m < 1 ? 'just now' : m < 60 ? m + ' min' + (short ? '' : ' ago') : m < 60 * 36 ? Math.round(m / 60) + ' h' + (short ? '' : ' ago') : Math.round(m / 1440) + ' days' + (short ? '' : ' ago'); };
@@ -282,7 +284,6 @@ function drawChips() {
282
284
  const J = M.jira || {}, C = M.chips || {}, sp = J.sprint, rel = J.release, phone = small();
283
285
  const jira = J.readAt ? 'Jira · read ' + ago(J.readAt) : 'Jira · not read';
284
286
  const sprint = [sp ? sp.name : null, rel ? rel.name + ' ships ' + rel.at.replace(/^(\d+) (\w+)$/, '$2 $1') : null].filter(Boolean).join(' · ') || ''; // no sprint and no release on record: no chip (workspace grill W4, zero is silence)
285
- const thisSprint = sp && (view === 'track' || view === 'time' || phone) && sprintFilterOn() ? `<button type="button" class="bd-chip${F.chips.has('sprint') ? ' on' : ''}" data-f="sprint" aria-pressed="${F.chips.has('sprint')}" title="${F.chips.has('sprint') ? 'Shows only the initiatives with work in ' + esc(sp.name) + '. Press to show all.' : 'Press to show only the initiatives with work in ' + esc(sp.name) + '.'}">${esc(sp.name)} only</button>` : ''; // it named no sprint and read like a heading (testing fixes)
286
287
  // All products (PgBoard): one Jira control with the oldest read of any product, and every product's new asks; the sprint stays per product
287
288
  // AdM2: Adler's S face carries the read's mood: calm when Jira was read within a day and a half, honest when it was not, glasses on while
288
289
  // a press reads it again. Settings > Adler > Off keeps the refresh icon. Batch 24 item 7 (BbB): the face alone, an amber pip when the read is
@@ -291,17 +292,43 @@ function drawChips() {
291
292
  const jSay = jira + '. ' + (ALL ? 'Press to read Jira again for every product' : 'Press to read Jira again');
292
293
  const jiraChip = `<button type="button" class="bd-chip bd-jf" id="chJira" title="${esc(jSay)}" aria-label="${esc(jSay)}">${faceOr(jMood, 's', SV(I.refresh), { label: false })}${jMood === 'honest' ? '<i class="bd-pip" aria-hidden="true"></i>' : ''}<span class="vh">${esc(jira)}</span></button>`;
293
294
  const need = needHtml(C, menuOpen('bdNeedMenu'), phone);
294
- if (phone) {
295
- $('#bdChipset').innerHTML = thisSprint + jiraChip + need + `<button type="button" class="bd-chip" id="chShared">Shared${SH_N ? ' ' + SH_N : ''}</button>`;
296
- return;
297
- }
298
- // the timeline's legend (PgTimeline) goes behind an info icon at the end of the row (BbB), with a program milestone only where a program is drawn
295
+ // the tune button's dot (BhA): the Jira read is old, or a filter is on
296
+ { const fb = $('#bdFilter'), pip = fb.querySelector('.bd-pip'), say = phone ? 'Group, sort and filter' : 'Filter by owner, category or sprint';
297
+ if (pip) pip.hidden = !(phone && (jMood === 'honest' || filtered())); fb.setAttribute('aria-label', say); fb.title = say; }
298
+ // one row (batch 28 item 3, canvas BhA): what needs a look sits after the view; a phone reads Jira again from the tune sheet
299
+ TUNE = { jira, jMood };
300
+ $('#bdJiraw').innerHTML = phone ? '' : jiraChip;
301
+ if (phone) { $('#bdChipset').innerHTML = need; return; }
302
+ // the timeline's legend (PgTimeline) goes behind an info icon after the pill (BbB), with a program milestone only where a program is drawn
299
303
  // and "On hold" only where a hold is drawn (feedback batch 9 item 8: zero is silence)
300
304
  const lo = menuOpen('bdLgdMenu');
301
305
  const lgd = view === 'time' && span !== 'sprint' ? `<span class="bd-grpw2 bd-lgdw"><button type="button" class="bd-ib bd-lgdb" id="bdLgdBtn" aria-haspopup="true" aria-expanded="${lo}" aria-controls="bdLgdMenu" aria-label="What the bars mean" title="What the bars mean">${SV(I.info)}</button>`
302
306
  + `<span class="bd-grpm bd-lgdm" id="bdLgdMenu"${lo ? '' : ' hidden'}><span class="bd-mlbl">What the bars mean</span>${legendHtml(!byProduct && !!groups(visible()), hasHold(visible()), { ...planKeys(visible()), ...gapKeys(visible()), range: visible().some((r) => fcRange(r)) })}</span></span>` : '';
303
- $('#bdChipset').innerHTML = (ALL || !sprint ? '' : `<button type="button" class="bd-chip" id="chSprint" aria-haspopup="dialog">${SV(I.cal)}<span>${esc(sprint)}</span></button>`)
304
- + thisSprint + '<span class="bd-sp"></span>' + need + lgd + jiraChip;
307
+ // the sprints and releases (BdSprint): one icon, its words on hover; no sprint and no release on record draws nothing
308
+ const spr = ALL || !sprint ? '' : `<button type="button" class="bd-ib" id="chSprint" aria-haspopup="dialog" aria-label="${esc(sprint)}. Sprints and releases" title="${esc(sprint)}">${SV(I.cal)}</button>`;
309
+ $('#bdChipset').innerHTML = need + lgd + spr;
310
+ }
311
+ /** What the tune sheet (a phone's #bdFilter, BhA) adds to Filter: Sort first, the Jira read last. Null on a desktop, which has their own buttons. */
312
+ let TUNE = { jira: '', jMood: 'honest' };
313
+ function tuneParts() {
314
+ if (!small()) return null;
315
+ const say = TUNE.jira.replace(/^Jira · /, 'Jira ');
316
+ const now = SO.layout().sort;
317
+ return { top: `<p class="bd-mlbl">Sort</p><div class="bd-fg" role="radiogroup" aria-label="Sort">${SORT_MODES.map(([k, n]) => `<button type="button" class="bd-chip${k === now ? ' on' : ''}" role="radio" aria-checked="${k === now}" data-so-pick="${esc(k)}">${esc(n)}</button>`).join('')}</div>`,
318
+ bottom: `<div class="bd-tjr">${faceOr(jiraReading ? 'thinking' : TUNE.jMood, 's', '', { label: false })}<span>${esc(say)}.${TUNE.jMood === 'honest' ? ' Read it again?' : ''}</span>`
319
+ + `<button type="button" class="bd-chip bd-jread" data-jread aria-label="Read Jira again" title="Read Jira again"${jiraReading ? ' disabled' : ''}>${SV(I.refresh)}</button></div>` };
320
+ }
321
+ /** A sort picked in the tune sheet: saved as the sort menu saves it (look.order, shared with Home), then read back (pm/sort-order.js). */
322
+ async function sortPick(k) {
323
+ const L = SO.layout(); if (k === L.sort) return;
324
+ const r = await pmPost('/api/settings', { key: 'look.order', value: { ...L, sort: k } }).catch(() => null);
325
+ if (!r || !r.ok) { say((r && r.error) || 'The order was not saved.'); return; }
326
+ await SO.load(); if (M) drawInit();
327
+ }
328
+ /** "<sprint> only" (on by default when the board has a sprint): Filter's first sprint chip now that the chip row is gone (BhA). */
329
+ function sprintOnly() {
330
+ const sp = M && M.jira && M.jira.sprint;
331
+ return sp && (view === 'track' || view === 'time' || small()) && sprintFilterOn() ? { name: sp.name, on: F.chips.has('sprint') } : null;
305
332
  }
306
333
  const closeMenu = (id, btn) => { const m = $('#' + id); if (m && !m.hidden) { m.hidden = true; const b = $('#' + btn); if (b) b.setAttribute('aria-expanded', 'false'); return true; } return false; };
307
334
  const toggleMenu = (id, btn) => { const m = $('#' + id), o = m.hidden; m.hidden = !o; $('#' + btn).setAttribute('aria-expanded', String(o)); if (o) { const f = m.querySelector('button'); if (f) f.focus(); } };
@@ -317,16 +344,15 @@ $('#bdChipset').addEventListener('click', (e) => {
317
344
  if (F.chips.has(k)) F.chips.delete(k); else F.chips.add(k); drawChips(); drawInit(); if (inNeed) { const b = $('#chNeed') || $('#bdFilter'); b.focus(); } return;
318
345
  }
319
346
  const b = e.target.closest('button'); if (!b) return;
320
- if (b.id === 'chJira') refreshJira(b);
347
+ if (b.id === 'chSprint') Acts.open.sprint(b);
321
348
  else if (b.id === 'chNoSig') { closeMenu('bdNeedMenu', 'chNeed'); refreshJira($('#chJira') || b); }
322
- else if (b.id === 'chSprint') Acts.open.sprint(b);
323
349
  else if (b.id === 'chAsks') { closeMenu('bdNeedMenu', 'chNeed'); Acts.open.asks($('#chNeed')); }
324
- else if (b.id === 'chShared') setTab('shared');
325
350
  });
326
351
  $('#bdChipset').addEventListener('keydown', (e) => {
327
352
  if (e.key !== 'Escape') return;
328
353
  if (closeMenu('bdNeedMenu', 'chNeed')) { e.stopPropagation(); $('#chNeed').focus(); } else if (closeMenu('bdLgdMenu', 'bdLgdBtn')) { e.stopPropagation(); $('#bdLgdBtn').focus(); }
329
354
  });
355
+ $('#bdJiraw').addEventListener('click', (e) => { const b = e.target.closest('#chJira'); if (b) refreshJira(b); });
330
356
  document.addEventListener('click', (e) => { if (!e.target.closest('#bdNeedw')) closeMenu('bdNeedMenu', 'chNeed'); if (!e.target.closest('.bd-lgdw')) closeMenu('bdLgdMenu', 'bdLgdBtn'); });
331
357
  /** Read Jira again: the Jira source's own refresh (POST /api/sources/refresh), the one the Sources list runs. It starts a read and changes no record. */
332
358
  async function refreshJira(btn) {
@@ -371,11 +397,9 @@ function inSprint(r, sp) {
371
397
  }
372
398
  function visible() {
373
399
  const sp = M.jira && M.jira.sprint;
374
- const W = wfState(), only = WF.narrowed(W.list) ? W.cur.id : null;
375
400
  return M.initiatives.list.rows.filter((r) => {
376
401
  const t = r.track || {};
377
402
  if (r.ended) return false; // Won't do and Archived are their own strips (pm/bd-wf.js endedRows)
378
- if (only && WF.wfOf(r).id !== only) return false;
379
403
  if (F.chips.has('late') && !r.late) return false;
380
404
  if (F.chips.has('risk') && r.status !== 'at risk') return false;
381
405
  if (F.chips.has('blocked') && !t.blocked) return false;
@@ -388,19 +412,16 @@ function visible() {
388
412
  return true;
389
413
  });
390
414
  }
391
- const filtered = () => [...F.chips].some((k) => k !== 'sprint') || !!F.q || F.owners.size > 0 || F.cats.size > 0 || F.sprints.size > 0 || WF.narrowed(wfState().list);
392
- const clearFilters = () => { F.chips.forEach((k) => { if (k !== 'sprint') F.chips.delete(k); }); F.q = ''; F.owners.clear(); F.cats.clear(); F.sprints.clear(); WF.setPick(''); };
393
- /** The workflows on the board, the picked one (null for All) and the rows that ended (pm/bd-wf.js). */
415
+ const filtered = () => [...F.chips].some((k) => k !== 'sprint') || !!F.q || F.owners.size > 0 || F.cats.size > 0 || F.sprints.size > 0;
416
+ const clearFilters = () => { F.chips.forEach((k) => { if (k !== 'sprint') F.chips.delete(k); }); F.q = ''; F.owners.clear(); F.cats.clear(); F.sprints.clear(); };
417
+ /** The workflows on the board, the one whose stages are drawn (the only one, else null for All) and the rows that ended (pm/bd-wf.js). */
394
418
  const wfState = () => { const list = WF.workflowsOf(M); return { list, cur: WF.picked(list), ended: WF.endedRows(M) }; };
395
419
  /** The "Showing" bar (BdFilter): what Filter has on, each with its own ×, Clear all, and how many initiatives show. */
396
420
  function showingHtml(n) {
397
421
  const G = [['owners', 'Owner'], ['cats', 'Category'], ['sprints', 'Sprint']].filter(([k]) => F[k].size);
398
- // the picked workflow shows here only where no chip row says it already: the desktop List (WfAElse)
399
- const W = wfState(), wfOn = WF.narrowed(W.list) && view === 'list' && !small();
400
- if (!G.length && !F.q && !wfOn) return '';
422
+ if (!G.length && !F.q) return '';
401
423
  const word = (k, v) => (k === 'cats' ? WF.catLabel(v) : v);
402
- const chips = (wfOn ? `<button type="button" class="bd-chip on" data-unf="wf" aria-label="Remove Workflow: ${esc(W.cur.name)}">Workflow: ${esc(W.cur.name)}${SV(I.x)}</button>` : '')
403
- + G.map(([k, n2]) => `<button type="button" class="bd-chip on" data-unf="${k}" aria-label="Remove ${n2}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}">${esc(n2)}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}${SV(I.x)}</button>`).join('')
424
+ const chips = G.map(([k, n2]) => `<button type="button" class="bd-chip on" data-unf="${k}" aria-label="Remove ${n2}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}">${esc(n2)}: ${esc([...F[k]].map((v) => word(k, v)).join(', '))}${SV(I.x)}</button>`).join('')
404
425
  + (F.q ? `<button type="button" class="bd-chip on" data-unf="q" aria-label="Remove the search">“${esc(F.q)}”${SV(I.x)}</button>` : '');
405
426
  return `<div class="bd-showing" role="status"><span class="bd-mlbl">Showing</span>${chips}<button type="button" class="dlink" id="fClear">Clear all</button><span class="bd-sp"></span><span class="bd-amut">${n} of ${M.initiatives.list.rows.length} initiatives</span></div>`;
406
427
  }
@@ -535,46 +556,61 @@ function drawTime(L) {
535
556
  lane: (c) => DL.laneHtml(c, { span, progState }) });
536
557
  return T.html;
537
558
  }
538
- /** A phone's view switch (BdPhone): List, By stage, the stage track and the timeline (TsCPhone: it scrolls sideways like the desktop's). */
539
- const phoneSeg = (v) => `<div class="bd-phseg"><div class="bd-seg" role="group" aria-label="View">${[['list', 'List'], ['stages', 'By stage'], ['track', 'Track'], ['time', 'Timeline']].map(([k, n]) => `<button type="button" data-pv="${k}" aria-pressed="${v === k}">${n}</button>`).join('')}</div></div>`;
559
+ /** A phone's view button (batch 28 item 3, canvas BhA): the four views, the span where it applies (the timeline), then Shared with me. */
560
+ const VIEW_ITEMS = [['list', 'List'], ['stages', 'By stage'], ['track', 'Track'], ['time', 'Timeline']];
561
+ function drawViewMenu() {
562
+ const v = curView(), open = menuOpen('bdViewMenu'), name = (VIEW_ITEMS.find(([k]) => k === v) || VIEW_ITEMS[0])[1];
563
+ const b = $('#bdView');
564
+ b.innerHTML = SV(I[v] || I.list) + `<svg class="bd-chv" viewBox="0 0 24 24" aria-hidden="true"><path d="${I.chev}"/></svg>`;
565
+ b.setAttribute('aria-label', 'View: ' + (tab === 'shared' ? 'Shared with me' : name) + '. Change view');
566
+ b.setAttribute('aria-expanded', String(open));
567
+ const sp = v === 'time' ? `<span class="bd-mlbl">Span</span><span class="bd-fg bd-vsp" role="radiogroup" aria-label="Span">${SPANS.map(([k, n]) => `<button type="button" class="bd-chip${k === span ? ' on' : ''}" role="radio" aria-checked="${k === span}" data-spick="${k}">${esc(n)}</button>`).join('')}</span>` : '';
568
+ $('#bdViewMenu').innerHTML = VIEW_ITEMS.map(([k, n]) => { const on = tab === 'ini' && k === v; return `<button type="button" class="bd-vmi${on ? ' on' : ''}" data-pv="${k}" aria-pressed="${on}">${SV(I[k])}<span>${n}</span>${on ? `<span class="ck">${SV(I.ok)}</span>` : ''}</button>`; }).join('')
569
+ + sp + '<span class="bd-vsep" aria-hidden="true"></span>'
570
+ + `<button type="button" class="bd-vmi${tab === 'shared' ? ' on' : ''}" data-vshared aria-pressed="${tab === 'shared'}">${SV(I.people)}<span>Shared with me</span>${SH_N ? `<span class="k">${SH_N}</span>` : ''}</button>`;
571
+ }
572
+ $('#bdVieww').addEventListener('click', (e) => {
573
+ const pv = e.target.closest('[data-pv]'); if (pv && M) { closeMenu('bdViewMenu', 'bdView'); setTab('ini'); setView(pv.dataset.pv); $('#bdView').focus(); return; }
574
+ const sk = e.target.closest('[data-spick]'); if (sk && M) { setSpan(sk.dataset.spick); const n = $(`#bdViewMenu [data-spick="${sk.dataset.spick}"]`); if (n) n.focus(); return; }
575
+ if (e.target.closest('[data-vshared]')) { closeMenu('bdViewMenu', 'bdView'); setTab(tab === 'shared' ? 'ini' : 'shared'); drawViewMenu(); $('#bdView').focus(); return; }
576
+ if (e.target.closest('#bdView')) { const m = $('#bdViewMenu'), o = m.hidden; if (o) { closeMenu('bdNeedMenu', 'chNeed'); drawViewMenu(); } m.hidden = !o; $('#bdView').setAttribute('aria-expanded', String(o)); if (o) (m.querySelector('[aria-pressed="true"]') || m.querySelector('button')).focus(); }
577
+ });
578
+ $('#bdVieww').addEventListener('keydown', (e) => { if (e.key === 'Escape' && closeMenu('bdViewMenu', 'bdView')) { e.stopPropagation(); $('#bdView').focus(); } });
579
+ document.addEventListener('click', (e) => { if (!e.target.closest('#bdVieww')) closeMenu('bdViewMenu', 'bdView'); });
540
580
  function drawInit() {
541
- $('#nIni').textContent = String(M.initiatives.open || M.initiatives.list.rows.length);
542
581
  const phone = small(), L = visible(), v = curView();
543
582
  const body = $('#ibBody');
544
583
  body.dataset.view = v; body.dataset.span = v === 'time' ? span : '';
545
584
  const html = v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
546
585
  // a phone has no ⋯ menu: Metrics and Cancelled and archived stay one press away in every view, not only the track
547
586
  const phx = phone && v !== 'track' ? `<div class="bd-whead bd-phx"><span class="bd-phb"><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>` : '';
548
- // the workflow chips (WfABoard, WfATrack, WfAPhone): By stage and the track on a desktop, every view on a phone; the List filters in Filter
549
- const W = wfState(), wfc = phone || v === 'stages' || v === 'track' ? WF.chipsHtml(W.list, W.cur, { phone }) : '';
550
587
  if (v === 'time') TL.hold(); else TL.forget();
551
588
  // a row with the focus keeps it when the rows are drawn again (the page panel changes form as a Viewer opens or closes beside it)
552
589
  const fe = document.activeElement, fk = fe && body.contains(fe) && fe.matches('[data-key]') ? fe.dataset.key : null;
553
- body.innerHTML = (phone ? phoneSeg(v) : '') + wfc + html + phx;
590
+ body.innerHTML = html + phx;
554
591
  if (fk) { const n = $$('#ibBody [data-key]').find((x) => x.dataset.key === fk); if (n) n.focus({ preventScroll: true }); }
555
592
  if (v === 'time') TL.mount(body);
556
593
  $('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
557
594
  $$('#ibTabs [data-v]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.v === v)));
558
595
  { const sb = $('#bdSort'), Ls = SO.labels(); if (sb) { sb.setAttribute('aria-label', Ls.aria); sb.title = Ls.title; sb.classList.toggle('on', Ls.on); } }
559
- $('#bdView').innerHTML = SV(v === 'time' ? I.time : I.track); $('#bdView').setAttribute('aria-label', 'Change view. Now: ' + (v === 'time' ? 'Timeline' : 'Stage track'));
596
+ drawViewMenu();
560
597
  drawSpanPicker('desk', v === 'time' && !phone);
561
598
  $('#bdColsw').hidden = v !== 'time' || phone; if ($('#bdColsw').hidden) closeCols();
562
- drawSpanPick(phone && v === 'time');
563
599
  document.body.dataset.bdView = v;
564
600
  $('#stage').dataset.bdDesk = view; // what fit() measures: the desktop's view, so the narrow form never flips it back and forth
565
601
  drawGrouping();
566
602
  markOpen();
567
603
  }
568
604
  PHONE.addEventListener('change', () => { if (M) { drawChips(); drawInit(); } });
569
- /** The grouping (PgBoard, PgBoardProduct): programs first is the default and draws nothing in the toolbar (PgBoard); the choice is in Filter.
570
- * "By product" shows as an on chip after the views (PgBoardProduct), whose menu switches back. Only when a program holds a row here. */
605
+ /** The grouping (PgBoard, PgBoardProduct): programs first (the default) or By product. A desktop has its own Group button after the Jira read
606
+ * (BhA), blue while By product is on; a phone has it in the tune sheet. Only when a program holds a row here (zero is silence). */
571
607
  const groupingOn = () => !!(M && PGS.length && PG.groupsOf(PGS, M.initiatives.list.rows, M, false));
572
608
  function setGrouping(bp) { byProduct = !!bp; store.set(GROUPING_KEY, byProduct ? 'product' : 'program'); const m = $('#bdGrpMenu'); if (m) m.hidden = true; drawChips(); drawInit(); }
573
609
  function drawGrouping() {
574
- const w = $('#bdGrpw'), on = groupingOn() && byProduct;
610
+ const w = $('#bdGrpw'), on = groupingOn();
575
611
  w.hidden = !on; if (!on) { w.innerHTML = ''; return; }
576
- const open = !!$('#bdGrpMenu') && !$('#bdGrpMenu').hidden;
577
- const btn = `<button type="button" class="bd-chip bd-grp on" id="bdGroup" aria-haspopup="menu" aria-expanded="${open}" aria-label="Grouped by product. Change grouping">By product${SV(I.chev)}</button>`;
612
+ const open = !!$('#bdGrpMenu') && !$('#bdGrpMenu').hidden, now = byProduct ? 'By product' : 'Programs first';
613
+ const btn = `<button type="button" class="bd-ib bd-grp${byProduct ? ' on' : ''}" id="bdGroup" aria-haspopup="menu" aria-expanded="${open}" aria-label="Group: ${now}. Change grouping" title="Group · ${now}">${SV(I.group)}</button>`;
578
614
  w.innerHTML = btn + `<span class="bd-grpm" id="bdGrpMenu" role="menu"${open ? '' : ' hidden'}>${[['program', 'Programs first'], ['product', 'By product']].map(([k, n]) => `<button type="button" role="menuitemradio" aria-checked="${(k === 'product') === byProduct}" data-grping="${k}">${n}</button>`).join('')}</span>`;
579
615
  }
580
616
  $('#bdGrpw').addEventListener('click', (e) => {
@@ -603,17 +639,15 @@ new ResizeObserver(() => {
603
639
  }).observe($('#ibBody'));
604
640
  function setView(v) { if (PHONE.matches) { pview = v; store.set(PVIEW_KEY, v); } else if (narrow()) nview = v; else { view = v; store.set(VIEW_KEY, view); } if (!narrow()) closePanel(); drawChips(); drawInit(); }
605
641
  $('#ibTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-v]'); if (!b || !M) return; setTab('ini'); setView(b.dataset.v); });
606
- $('#bdView').addEventListener('click', () => { if (M) { const c = curView(); setView(small() ? (c === 'list' ? 'stages' : c === 'stages' ? 'track' : c === 'track' ? 'time' : 'list') : view === 'time' ? 'track' : 'time'); } });
607
642
  $('#bdShowing').addEventListener('click', (e) => {
608
643
  if (e.target.closest('#fClear')) { clearFilters(); drawChips(); drawInit(); return; }
609
644
  const u = e.target.closest('[data-unf]'); if (!u) return;
610
- if (u.dataset.unf === 'q') F.q = ''; else if (u.dataset.unf === 'wf') WF.setPick(''); else F[u.dataset.unf].clear(); drawChips(); drawInit();
645
+ if (u.dataset.unf === 'q') F.q = ''; else F[u.dataset.unf].clear(); drawChips(); drawInit();
611
646
  });
612
647
  function setSpan(s) { span = s; store.set(SPAN_KEY, span); drawChips(); drawInit(); }
613
- /** The span picker: one chip that opens the six spans (batch 24 item 7, canvas BbB, as a phone's TsCPhone, TsCPhoneSpan). A desktop draws it in the
614
- * chip row after the tabs (#bdSpans, items data-sp); a phone draws it beside the product picker (#bdSpanPick, items data-spick), and the page title
615
- * gives it the room. */
616
- const SPK = { desk: ['bdSpans', 'bdSpansBtn', 'bdSpansMenu', 'sp'], phone: ['bdSpanPick', 'bdSpanBtn', 'bdSpanMenu', 'spick'] };
648
+ /** The span picker: one chip that opens the six spans (batch 24 item 7, canvas BbB). A desktop timeline draws it after the views (#bdSpans,
649
+ * items data-sp); a phone has the spans in its view button (BhA, items data-spick). */
650
+ const SPK = { desk: ['bdSpans', 'bdSpansBtn', 'bdSpansMenu', 'sp'] };
617
651
  function drawSpanPicker(which, on) {
618
652
  const [wid, bid, mid, attr] = SPK[which], w = $('#' + wid);
619
653
  w.hidden = !on; if (!on) { w.innerHTML = ''; return; }
@@ -621,7 +655,6 @@ function drawSpanPicker(which, on) {
621
655
  w.innerHTML = `<button type="button" class="bd-chip bd-spk" id="${bid}" aria-haspopup="menu" aria-expanded="${open}" aria-label="Span: ${esc(name)}. Change the span">${esc(name)}${SV(I.chev)}</button>`
622
656
  + `<span class="bd-grpm" id="${mid}" role="menu"${open ? '' : ' hidden'}>${SPANS.map(([k, n]) => `<button type="button" role="menuitemradio" aria-checked="${k === span}" data-${attr}="${k}">${esc(n)}</button>`).join('')}</span>`;
623
657
  }
624
- function drawSpanPick(on) { document.body.classList.toggle('bd-spick', on); drawSpanPicker('phone', on); }
625
658
  for (const which of Object.keys(SPK)) {
626
659
  const [wid, bid, mid, attr] = SPK[which], w = $('#' + wid);
627
660
  w.addEventListener('click', (e) => {
@@ -634,7 +667,6 @@ for (const which of Object.keys(SPK)) {
634
667
  $('#ibBody').addEventListener('click', (e) => {
635
668
  if (e.target.closest('#fold, [data-mefold]')) { foldOpen = !foldOpen; drawInit(); const f = $('#fold') || $('#ibBody [data-mefold]'); if (f) f.focus(); return; }
636
669
  const gf = e.target.closest('[data-fold]'); if (gf) { const k = gf.dataset.fold; PG.fold(k); drawInit(); const b = $$('#ibBody [data-fold]').find((x) => x.dataset.fold === k); if (b) b.focus(); return; }
637
- const wp = e.target.closest('[data-wfpick]'); if (wp) { const id = wp.dataset.wfpick; WF.setPick(wp.getAttribute('aria-pressed') === 'true' ? '' : id); drawChips(); drawInit(); const b = $$('#ibBody [data-wfpick]').find((x) => x.dataset.wfpick === (WF.picked(wfState().list) || { id: '' }).id) || $('#ibBody [data-wfpick]'); if (b) b.focus(); return; }
638
670
  const pc = e.target.closest('[data-pcat]'); if (pc) { const k = pc.dataset.pcat; V.togglePcat(k); drawInit(); const b = $$('#ibBody [data-pcat]').find((x) => x.dataset.pcat === k); if (b) b.focus(); return; }
639
671
  const pm = e.target.closest('[data-pmore]'); if (pm) { V.morePcat(pm.dataset.pmore); drawInit(); return; }
640
672
  const cf = e.target.closest('[data-colfold]'); if (cf) { const k = cf.dataset.colfold; V.toggleCol(k); drawInit(); const b = $$('#ibBody [data-colfold]').find((x) => x.dataset.colfold === k); if (b) b.focus(); return; }
@@ -910,16 +942,16 @@ $('#bdPublish').addEventListener('click', (e) => { const btn = e.currentTarget;
910
942
  let SH_PASTE = ''; // ?shared=<link>: Open in my PMOS on a shared board (batch 27 item 3) lands on Shared with the link in the paste field
911
943
  function setTab(t) {
912
944
  tab = t;
913
- $('#tabIni').setAttribute('aria-selected', String(t === 'ini')); $('#tabShared').setAttribute('aria-selected', String(t === 'shared'));
945
+ $('#tabShared').setAttribute('aria-pressed', String(t === 'shared'));
946
+ $$('#ibTabs [data-v]').forEach((b) => b.setAttribute('aria-pressed', String(t === 'ini' && b.dataset.v === curView())));
914
947
  $('#cIni').hidden = t !== 'ini'; $('#cShared').hidden = t !== 'shared';
915
- // Shared (initiative board-publish, slice 4): reads each joined team's host now, on opening the tab and on Refresh, and never in between
948
+ // Shared (initiative board-publish, slice 4): reads each joined team's host now, on opening it and on Refresh, and never in between
916
949
  if (t === 'shared') { closePanel(); import('./bd-shared.js').then((S) => { SH_FULL = true; const paste = SH_PASTE; SH_PASTE = ''; S.show($('#cShared'), { onCount: setSharedCount, paste }); }); }
917
950
  }
918
- $('#tabIni').onclick = () => setTab('ini');
919
- $('#tabShared').onclick = () => setTab('shared');
920
- $('.bd-tabs').addEventListener('keydown', (e) => { if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return; const ord = ['ini', 'shared']; const n = ord[(ord.indexOf(tab) + (e.key === 'ArrowRight' ? 1 : ord.length - 1)) % ord.length]; setTab(n); $('#' + { ini: 'tabIni', shared: 'tabShared' }[n]).focus(); });
921
- /** The number on the Shared tab and on the phone's Shared chip: nothing when there is nothing (zero is silence). Your own open links at load, every open copy after a read. */
922
- function setSharedCount(n) { SH_N = n; $('#nShared').textContent = n ? String(n) : ''; const c = $('#chShared'); if (c) c.textContent = 'Shared' + (n ? ' ' + n : ''); }
951
+ // Shared is one button in the row (BhA): pressed again, the initiatives come back
952
+ $('#tabShared').onclick = () => setTab(tab === 'shared' ? 'ini' : 'shared');
953
+ /** The number on the Shared button and in the phone's view menu: nothing when there is nothing (zero is silence). Your own open links at load, every open copy after a read. */
954
+ function setSharedCount(n) { SH_N = n; $('#nShared').textContent = n ? String(n) : ''; if (menuOpen('bdViewMenu')) drawViewMenu(); }
923
955
  document.addEventListener('bd:links', (e) => { if (!SH_FULL && e.detail) setSharedCount(e.detail.n); });
924
956
 
925
957
  /** The history of the documents (GET /api/board-docs) for the document panel of pm/bd-acts.js. Batch 24 item 7 took the Documents tab off the Board,
@@ -1198,7 +1230,8 @@ V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, docMeta,
1198
1230
  Asks.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, rowOf, openIni: openIniAny, openDoc: viewDoc, anchors, programs: () => PGS, reloadPrograms: loadPrograms });
1199
1231
  Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); }, F, rowOf, statusOf, openIni: openIniAny,
1200
1232
  openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, docMeta, loadDocMeta, viewDoc,
1201
- grouping: () => ({ on: groupingOn(), byProduct }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time' });
1233
+ grouping: () => ({ on: groupingOn(), byProduct }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
1234
+ tune: tuneParts, sprintOnly, toggleSprintOnly: () => { if (F.chips.has('sprint')) F.chips.delete('sprint'); else F.chips.add('sprint'); }, sortPick, refreshJira: () => refreshJira() });
1202
1235
  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,
1203
1236
  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 })),
1204
1237
  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,
@@ -57,6 +57,7 @@ import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting
57
57
  import { placeholderHtml } from './cozy-placeholder.js';
58
58
  import { vzStyle } from './premium-vw-open.js';
59
59
  import { reviewHtml, chatOf as rfChatOf, ICON as RF_ICON } from './report-flow.js'; // Claude's review and the template icon (batch 22 item 14, canvas RfH2, RfH6)
60
+ import * as OU from './report-orders-ui.js'; // batch 27 item 16: the orders of a draft (canvas TpA, TpD, TpE)
60
61
  import { adler } from './cozy-adler.js'; // registers window.czViews; vzStyle adds the Viewer's sheet (cozy-vw.css)
61
62
  import { cycleGroups, cycleName, briefModel, briefGlanceHtml, briefConfirmHtml, briefWhyHtml, briefLooksHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon, reportSummary,
62
63
  rpSumHtml, rpBarHtml, cadenceWords, goesOutWords, FORMATS, RP_ICONS } from './rp-parts.js';
@@ -73,7 +74,7 @@ const P = {
73
74
  warn: '<path d="M12 4l9 16H3zM12 10v4M12 17h.01"/>', bin: '<path d="M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13"/>', box: '<path d="M4 5h16v4H4zM5 9v10h14V9M10 13h4"/>', lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',
74
75
  redo2: '<path d="M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7"/>', undo: '<path d="M9 14 4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3"/>', redo: '<path d="m15 14 5-5-5-5M20 9H9a5 5 0 0 0 0 10h3"/>',
75
76
  people: '<path d="M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 1 0 0 7M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 6.5M18 14a6 6 0 0 1 3.5 6"/>', list: '<path d="M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01"/>',
76
- plus: '<path d="M12 5v14M5 12h14"/>', dl: '<path d="M12 4v11M7 10l5 5 5-5M5 20h14"/>', live: '<path d="M3 17l5-5 4 4 8-8M16 8h4v4"/>', layout: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 10h16M10 10v10"/>',
77
+ plus: '<path d="M12 5v14M5 12h14"/>', grid: '<rect x="4" y="4" width="7" height="7" rx="1"/><rect x="13" y="4" width="7" height="7" rx="1"/><rect x="4" y="13" width="7" height="7" rx="1"/><rect x="13" y="13" width="7" height="7" rx="1"/>', mark: '<path d="M7 4h10v16l-5-4-5 4z"/>', dl: '<path d="M12 4v11M7 10l5 5 5-5M5 20h14"/>', live: '<path d="M3 17l5-5 4 4 8-8M16 8h4v4"/>', layout: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 10h16M10 10v10"/>',
77
78
  theme: '<path d="M12 3a9 9 0 1 0 0 18c1 0 1.5-.8 1.5-1.6 0-1-.8-1.4-.8-2.4 0-1 .8-1.6 1.8-1.6H17a4 4 0 0 0 4-4c0-4.6-4-8.4-9-8.4z"/><circle cx="7.5" cy="11" r="1"/><circle cx="10.5" cy="7.5" r="1"/><circle cx="15" cy="7.5" r="1"/>',
78
79
  };
79
80
  const ic = (k, n) => svg(P[k], n);
@@ -437,7 +438,7 @@ function deckHtml() {
437
438
  if (!L.length) return '<p class="vz-empty">This cycle has no slides. Read it as a page.</p>';
438
439
  const i = R.i = Math.max(0, Math.min(R.i, L.length - 1));
439
440
  return `<div class="vz-slide" tabindex="0" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(L[i].h)}. Use the arrow keys to change slide." data-r="slide">${slideCard(L[i])}</div>`
440
- + `<div class="rp-nav">${ib('prev', ic('prev', 15), 'Previous slide', { off: i === 0 })}<span class="rp-count" aria-live="polite">Slide ${i + 1} of ${L.length}</span>${ib('next', ic('next', 15), 'Next slide', { off: i === L.length - 1 })}</div>`
441
+ + `<div class="rp-nav">${ib('prev', ic('prev', 15), 'Previous slide', { off: i === 0 })}<span class="rp-count" aria-live="polite">Slide ${i + 1} of ${L.length}</span>${ib('next', ic('next', 15), 'Next slide', { off: i === L.length - 1 })}${R.pyr && !R.cyc && R.ord && R.ord.engine && !R.edit ? ib('ord|slide', ic('mark', 15), 'Save this slide\'s layout to My slides', { cls: ' ro-slmark', off: R.busy }) : ''}</div>`
441
442
  + `<div class="vz-thumbs rp-thumbs" role="group" aria-label="Slides">`
442
443
  + L.map((x, j) => `<button type="button" class="vz-th rp-th${x.k === 'title' ? ' rp-tt' : ''}" data-r="go|${j}"${j === i ? ' aria-current="true"' : ''} aria-label="Slide ${j + 1}: ${esc(x.h)}" title="${j + 1} · ${esc(x.h)}"><span>${slideCard(x, true)}</span></button>`).join('')
443
444
  + '</div>';
@@ -473,11 +474,11 @@ function rfhHtml() {
473
474
  R.archived ? null : { act: 'share', label: 'Share', icon: 'share', exp: R.pop === 'share', pop: 'dialog' },
474
475
  { act: 'dlm', label: 'Download', icon: 'dl', exp: R.pop === 'dl' }] });
475
476
  const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
476
- : R.view === 'doc' ? pageHtml() : deckHtml();
477
+ : R.gal ? galView() : (R.view === 'doc' ? pageHtml() : deckHtml()) + ordAssHtml();
477
478
  const conf = confirm && R.BF ? czSections([{ id: 'confirm', title: 'Please confirm', count: confirm, open: true, render: () => briefConfirmHtml(R.BF, { issued: R.issued, busy: R.busy }) + (R.bfMsg ? `<p class="vz-msg" role="status">${esc(R.bfMsg)}</p>` : '') }], { key: 'report' }) : '';
478
479
  const pri = R.archived ? { act: 'unarch|' + R.row.path, label: 'Bring back', icon: 'back' } : R.issued ? null : { act: 'issue', label: 'Issue it', icon: 'send' };
479
480
  const foot = pri ? `<div class="rp-foot"><button type="button" class="rp-pri" data-r="${esc(pri.act)}" aria-label="${esc(pri.label)}" title="${esc(pri.label)}"${R.busy ? ' disabled' : ''}><svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${RP_ICONS[pri.icon]}"/></svg></button></div>` : '';
480
- return `<div class="vz-rpb rp-rfh">${R.conf ? confHtml() : ''}${chips}${st}${R.W && !R.err ? tools : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${conf}${askHtml()}${foot}</div>`;
481
+ return `<div class="vz-rpb rp-rfh">${R.conf ? confHtml() : ''}${chips}${st}${R.W && !R.err ? ordRowHtml() + tools : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${conf}${askHtml()}${foot}</div>`;
481
482
  }
482
483
  function bodyHtml() {
483
484
  if (!R.edit && rfhOn()) return rfhHtml();
@@ -488,8 +489,85 @@ function bodyHtml() {
488
489
  + (R.view === 'deck' ? '' : `<div class="vz-r1">${WAIT('Page editor')}</div>`) + '<div class="vz-ed" data-vz-ed></div></div>';
489
490
  }
490
491
  const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
491
- : R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml();
492
- return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
492
+ : R.gal ? galView() : (R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml()) + ordAssHtml();
493
+ return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() + ordRowHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
494
+ }
495
+ /* ── the orders of a draft (batch 27 item 16; canvas TpA, TpD, TpE; report-orders-ui.js, GET /api/report-orders) ── */
496
+ const ORD_HIDE = 'pmos-report-orders-hidden';
497
+ function ordHidden() { try { return new Set(JSON.parse(localStorage.getItem(ORD_HIDE) || '[]')); } catch { return new Set(); } }
498
+ const PICS = new Map(); // order id → its slides drawn small with placeholder words (GET /api/report-orders/preview), 'wait' while read
499
+ function ordOpts() {
500
+ return { esc, ic, slideCard, busy: R.busy, issued: R.issued, hidden: R.ordHide, now: R.pyr || R.cyc ? slides() : null,
501
+ pics: (id) => { const x = PICS.get(R.ws + '|' + id); return Array.isArray(x) ? x : null; } };
502
+ }
503
+ const ordRowHtml = () => (R.ord ? OU.rowHtml(R.ord, ordOpts()) : '');
504
+ const ordAssHtml = () => (R.ord && !R.edit ? OU.assHtml(R.ord, ordOpts()) : '');
505
+ function galView() { readPics(); return OU.galHtml(R.ord, R.gal, ordOpts()); }
506
+ /** The pictures of the orders the gallery shows, each read once and kept (they hold placeholder words only). */
507
+ function readPics() {
508
+ const me = R, S = R.ord; if (!S || !S.ok) return;
509
+ const ids = R.gal && R.gal.sel ? [R.gal.sel] : S.orders.map((o) => o.id).concat((S.slides || []).map((x) => x.id));
510
+ for (const id of ids) {
511
+ const k = R.ws + '|' + id; if (id === 'now' || PICS.has(k)) continue;
512
+ PICS.set(k, 'wait');
513
+ textOf('/api/report-orders/preview?' + q({ ws: R.ws, order: id })).then((h) => { const x = splitRender(h); PICS.set(k, x.slides.map((y) => ({ k: 'frame', h: y.h, html: y.html, css: x.style }))); })
514
+ .catch(() => PICS.set(k, [])).then(() => { if (R === me && R.gal) draw(); });
515
+ }
516
+ }
517
+ const dropPics = () => { for (const k of [...PICS.keys()]) if (/\|mine-/.test(k)) PICS.delete(k); };
518
+ let ordT = null;
519
+ async function readOrders() {
520
+ const me = R; if (!R || !R.row.path) return;
521
+ const j = await Promise.resolve(pmGet('/api/report-orders?' + q({ ws: R.ws, path: R.row.path }))).catch(() => null);
522
+ if (R !== me) return;
523
+ R.ord = j && j.ok ? j : null;
524
+ if (R.gal && !R.ord) R.gal = null;
525
+ draw();
526
+ // while the report's session writes the draft again, read the state until it lands (the file watch redraws the slides)
527
+ clearTimeout(ordT);
528
+ if (R.ord && R.ord.undo && R.ord.undo.state === 'drafting') ordT = setTimeout(() => { if (R === me) readOrders(); }, 6000);
529
+ }
530
+ async function ordAct(k, v) {
531
+ const me = R, S = R.ord;
532
+ if (k === 'gal') { R.gal = { sel: null }; R.pop = null; return draw(); }
533
+ if (k === 'close') { R.gal = null; return draw(); }
534
+ if (k === 'back') { R.gal = { sel: null }; return draw(); }
535
+ if (k === 'open') { R.gal = { sel: v, i: 0 }; return draw(); }
536
+ if (k === 'at') { if (R.gal) R.gal.i = +v; return draw(); }
537
+ if (k === 'hide') { R.ordHide.add(OU.hideKey(S, v)); try { localStorage.setItem(ORD_HIDE, JSON.stringify([...R.ordHide].slice(-200))); } catch { /* kept for this visit */ } return draw(); }
538
+ if (k === 'ren') { const o = S && [...S.orders, ...(S.slides || [])].find((x) => x.id === v); if (R.gal && o) R.gal.ren = o.name; draw(); const f = bodyEl() && bodyEl().querySelector('#roName'); if (f) f.focus(); return; }
539
+ if (R.busy) return;
540
+ const post = async (sub, body) => { R.busy = true; draw(); const r = await pmPost('/api/report-orders/' + sub, { ws: R.ws, ...body }).catch(() => null); if (R !== me) return null; R.busy = false; return r || { ok: false, error: 'the page could not reach PMOS' }; };
541
+ if (k === 'apply') {
542
+ const r = await post('apply', { path: R.row.path, order: v }); if (!r) return;
543
+ if (!r.ok) return say('The order was not applied: ' + r.error + '.', 'bad');
544
+ R.gal = null;
545
+ await readOrders(); if (R !== me) return;
546
+ return say(r.next ? `From the next cycle this report starts in the ${r.next.name} order. Today's draft stays as agreed.` : `Claude is writing this draft again in the ${r.order.name} order. Undo puts this one back, for one day.`);
547
+ }
548
+ if (k === 'undo') {
549
+ const r = await post('undo', { path: R.row.path }); if (!r) return;
550
+ if (!r.ok) return say('Nothing was undone: ' + r.error + '.', 'bad');
551
+ await reread(); if (R !== me) return; await readOrders(); if (R !== me) return;
552
+ return say('The draft is back as it was before the redraft.');
553
+ }
554
+ if (k === 'save' || k === 'slide') {
555
+ const r = await post(k, k === 'save' ? { path: R.row.path } : { path: R.row.path, n: R.i }); if (!r) return;
556
+ if (!r.ok) return say('Nothing was saved: ' + r.error + '.', 'bad');
557
+ R.ordHide.add(OU.hideKey(S, 'edit')); dropPics(); await readOrders(); if (R !== me) return;
558
+ return say(k === 'save' ? 'Saved to My orders. It is first in the orders, marked Mine. Only its parts and slide layouts are kept.' : `Saved to My slides: ${r.name}, its layout only.`);
559
+ }
560
+ if (k === 'renok') {
561
+ const r = await post('rename', { id: v, name: (R.gal && R.gal.ren) || '' }); if (!r) return;
562
+ if (!r.ok) return say('The name did not change: ' + r.error + '.', 'bad');
563
+ if (R.gal) R.gal.ren = null; dropPics(); return readOrders();
564
+ }
565
+ if (k === 'del') {
566
+ const r = await post('remove', { id: v }); if (!r) return;
567
+ if (!r.ok) return say('It was not deleted: ' + r.error + '.', 'bad');
568
+ R.gal = { sel: null }; dropPics(); await readOrders(); if (R !== me) return;
569
+ return say('Deleted from your orders. No report changed.');
570
+ }
493
571
  }
494
572
  /* ── Claude's review (batch 22 item 14, canvas RfH2): the checks PMOS runs on the draft, as ✦ fixes the report's own session makes ── */
495
573
  function rvHtml() {
@@ -605,9 +683,10 @@ function wire(b) {
605
683
  e.preventDefault(); act(t.dataset.r.split('|'), t);
606
684
  };
607
685
  b.onchange = (e) => { if (e.target.dataset.r === 'stime') R.sch.time = e.target.value || '09:00'; };
608
- b.oninput = (e) => { if (e.target.dataset.r === 'shpass') R.shr.pass = e.target.value; };
686
+ b.oninput = (e) => { if (e.target.dataset.r === 'shpass') R.shr.pass = e.target.value; if (e.target.dataset.r === 'ord-name' && R.gal) R.gal.ren = e.target.value; };
609
687
  b.onkeydown = (e) => {
610
688
  if (e.key === 'Escape' && R.pop) { e.preventDefault(); e.stopPropagation(); R.pop = null; draw(); return; }
689
+ if (e.key === 'Escape' && R.gal) { e.preventDefault(); e.stopPropagation(); R.gal = R.gal.sel ? { sel: null } : null; draw(); return; }
611
690
  if (!R.edit && R.view === 'deck' && /^Arrow(Left|Right)$/.test(e.key) && !e.target.closest('input')) { const L = slides().length, j = R.i + (e.key === 'ArrowRight' ? 1 : -1); if (j >= 0 && j < L) { e.preventDefault(); R.i = j; draw(); const s = bodyEl().querySelector('.vz-slide'); if (s) s.focus(); } }
612
691
  };
613
692
  /* a phone swipes the slide (RpPhone "swipe for the next") */
@@ -634,6 +713,7 @@ export function fit(root) { root.querySelectorAll('.vz-fr').forEach((c) => { if
634
713
  const say = (text, tone) => { R.msg = { text, tone }; draw(); const me = R, m = R.msg; if (tone !== 'bad') setTimeout(() => { if (R === me && R.msg === m) { R.msg = null; draw(); } }, 9000); };
635
714
  async function act([k, v], t) {
636
715
  if (k === 'rv-do' || k === 'rv-no' || k === 'rv-all') return rvAct(k, v);
716
+ if (k === 'ord') return ordAct(v, t.dataset.r.split('|').slice(2).join('|'));
637
717
  if (k === 'pop') { R.pop = v || null; return draw(); }
638
718
  if (k === 'cut') return cutTo(v);
639
719
  if (k === 'bf') return briefAct(v, t.dataset.r.split('|').slice(2).join('|'));
@@ -1030,7 +1110,7 @@ export async function openReport(row, hand = {}) {
1030
1110
  if (R) present(false);
1031
1111
  const me = R = { row, ws: hand.ws || '', id: c.cadence, name: hand.name || row.name || c.cadence || 'Report', audience: hand.audience || '', issued: row.state === 'issued', archived: !!row.archived,
1032
1112
  text: '', err: '', W: null, view: 'deck', BF: null, bfRaw: null, bfMsg: '', LV: null, blank: false, i: 0, cyc: null, pyr: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
1033
- sch: schedPick(null), schErr: '', shr: null, rv: null, rvHide: new Set(), rvSent: new Set(), shares: null, more: [], hand, cuts: hand.cuts ? { on: 'team', team: null, sponsors: null, err: '' } : null, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
1113
+ sch: schedPick(null), schErr: '', shr: null, ord: null, gal: null, ordHide: ordHidden(), rv: null, rvHide: new Set(), rvSent: new Set(), shares: null, more: [], hand, cuts: hand.cuts ? { on: 'team', team: null, sponsors: null, err: '' } : null, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
1034
1114
  const head = me.head = () => ({ id: me.vid, kind: 'Report' + (me.audience ? ' · ' + me.audience : ''), title: me.name, icon: me.view === 'doc' ? 'doc' : 'report', full: true, url: viewUrl(row, me.ws), more: me.more,
1035
1115
  // the template behind one icon (batch 22 item 14, canvas RfH1): format, readers, when it goes out, and its history
1036
1116
  presses: me.setup ? [{ act: 'chat', label: 'Talk to Claude about this report', icon: RF_ICON.chat }, { act: 'template', label: 'Template: format, readers, look, sources', icon: RF_ICON.tune }] : [],
@@ -1048,6 +1128,7 @@ export async function openReport(row, hand = {}) {
1048
1128
  if (R !== me) return me;
1049
1129
  readBrief(); // the Brief tab's count shows at once
1050
1130
  readReview();
1131
+ readOrders();
1051
1132
  if (hand.say) me.msg = { text: hand.say };
1052
1133
  if (vCur() && vCur().id === me.vid && (vCur().title !== me.name || me.audience || me.setup)) { me.reopen = true; vOpen(head()); me.reopen = false; } // the name and audience are known now
1053
1134
  draw();
@@ -1067,7 +1148,7 @@ async function watchFile(me) {
1067
1148
  if (R !== me || !h) continue;
1068
1149
  // a session writes the draft in many steps: read it when the file has been still for one more check, so a burst of writes is one redraw
1069
1150
  if (seen && h !== seen) { seen = h; pending = true; continue; }
1070
- if (pending) { pending = false; await reread(); if (R === me && !me.edit && !me.pop) { me.fromFile = true; draw(); me.fromFile = false; readReview(); } }
1151
+ if (pending) { pending = false; await reread(); if (R === me && !me.edit && !me.pop) { me.fromFile = true; draw(); me.fromFile = false; readReview(); readOrders(); } }
1071
1152
  seen = h;
1072
1153
  }
1073
1154
  }
@@ -32,7 +32,7 @@ export const VIEW_CONTROLS = [
32
32
  ].join(',');
33
33
 
34
34
  /** The Board's static toolbar and chips: hidden, so the page's own script keeps the elements it holds. */
35
- const HIDE = ['#ibTabs [data-v="stages"]', '#ibTabs [data-v="list"]', '#bdView', '#bdSpanPick', '.bd-title', '.bd-vr', '.bd-tabs', '#crumbHost', '#bdFind', '#bdColsw', '#bdSort', '#bdFilter', '#bdBell', '#bdPublish', '#chShared', '#newIni', '.tools-top', '#bdGrpw', '#czFab'];
35
+ const HIDE = ['#ibTabs [data-v="stages"]', '#ibTabs [data-v="list"]', '#bdVieww', '#bdView', '#crumbHost', '#bdJiraw', '#bdFind', '#bdColsw', '#bdSort', '#bdFilter', '#bdBell', '#bdPublish', '#tabShared', '#newIni', '.tools-top', '#bdGrpw', '#czFab'];
36
36
  /** Controls the code draws that write, or lead to something a share does not hold: removed. */
37
37
  const REMOVE = [
38
38
  '.po-grip', '.bd-nxa',