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
@@ -0,0 +1,65 @@
1
+ /* pm/hi-pop.js — the initiative's small popovers and the toast with Undo, the same on Home and the Board (feedback batch 14 item 5).
2
+ * Home's initiative page drew them first (home-ini.js); the one ⋯ menu (pm/ini-more.js) opens them on the Board too, so they live here.
3
+ *
4
+ * ensureCss() adds hi-pop.css once, before home-ini.css, so Home's phone rules still win
5
+ * openPop(anchor, kind, html, onClick, o?) a dialog (or o.menu: a menu) under the button that opened it; a sheet on a phone.
6
+ * o: { menu, wide, role, label, focus, sheetFocus }. → the popover element
7
+ * closePop() · popEl() the open popover, or null
8
+ * undoToast(text, undo) the dark toast with Undo, for 9 seconds */
9
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
+ const PHONE = 760;
11
+ const isPhone = () => innerWidth <= PHONE;
12
+ const P = { pop: null, toastT: 0 };
13
+
14
+ export function ensureCss() {
15
+ if (typeof document === 'undefined' || document.querySelector('link[data-hi-pop-css]')) return;
16
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./hi-pop.css', import.meta.url).href; l.dataset.hiPopCss = '';
17
+ const home = document.querySelector('link[data-hi-css]');
18
+ if (home) home.before(l); else document.head.appendChild(l);
19
+ }
20
+ export const popEl = () => (P.pop ? P.pop.el : null);
21
+ export function closePop() {
22
+ if (!P.pop) return;
23
+ const a = P.pop.anchor; P.pop.el.remove(); if (P.pop.scrim) P.pop.scrim.remove(); P.pop = null;
24
+ if (a && a.isConnected) { a.setAttribute('aria-expanded', 'false'); try { a.focus(); } catch { /* gone */ } }
25
+ }
26
+ export function openPop(anchor, kind, html, onClick, o = {}) {
27
+ ensureCss();
28
+ closePop();
29
+ const el = document.createElement('div');
30
+ const sheet = isPhone() && !o.menu;
31
+ el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
32
+ el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
33
+ el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
34
+ let scrim = null;
35
+ if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
36
+ document.body.appendChild(el);
37
+ if (!sheet) { // under the button that opened it, kept inside the window: run-time geometry, set as two custom properties
38
+ const r = anchor.getBoundingClientRect(), w = el.offsetWidth, hh = el.offsetHeight;
39
+ const col = !o.menu && anchor.closest('#hmList'); // a dialog from the list column opens beside the column (InStage), not over it
40
+ let x, y;
41
+ if (col) { const c = col.getBoundingClientRect(); x = c.right + 12; y = Math.min(innerHeight - hh - 12, Math.max(12, r.top - 60)); }
42
+ else { x = r.left + w > innerWidth - 12 ? r.right - w : r.left; y = r.bottom + 8 + hh > innerHeight - 12 ? r.top - hh - 8 : r.bottom + 8; }
43
+ x = Math.max(12, Math.min(innerWidth - w - 12, x)); y = Math.max(12, y);
44
+ el.style.setProperty('--hi-x', Math.round(x) + 'px'); el.style.setProperty('--hi-y', Math.round(y) + 'px');
45
+ }
46
+ anchor.setAttribute('aria-expanded', 'true');
47
+ P.pop = { el, scrim, anchor, kind };
48
+ el.addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && !b.disabled) onClick(b, el); });
49
+ el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePop(); } });
50
+ const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
51
+ return el;
52
+ }
53
+ export function undoToast(text, undo) {
54
+ ensureCss();
55
+ let el = document.getElementById('hiToast');
56
+ if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
57
+ el.innerHTML = `<span>${esc(text)}</span><button type="button" data-hi-undo>Undo</button>`;
58
+ el.hidden = false; el.classList.add('on');
59
+ el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
60
+ const hide = () => { el.classList.remove('on'); el.hidden = true; };
61
+ clearTimeout(P.toastT); P.toastT = setTimeout(hide, 9000);
62
+ }
63
+ // Escape closes the popover first: on window in the capture phase, so the page's own Escape (the phone's list sheet, the Viewer) waits for the next press
64
+ if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && P.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
65
+ if (typeof document !== 'undefined') document.addEventListener('mousedown', (e) => { if (P.pop && !P.pop.el.contains(e.target) && !(P.pop.anchor && P.pop.anchor.contains(e.target)) && !(P.pop.scrim && P.pop.scrim === e.target)) closePop(); }, true);
@@ -45,6 +45,7 @@ import { mountSesName } from './home-ses-name.js'; // session names A: tap the
45
45
  import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
46
46
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other, LpA4Phone)
47
47
  import * as CW from './ctx-wedge.js'; // how full a session's context is, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
48
+ import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
48
49
  import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
49
50
  import * as LPV from './loose-props.js'; // Claude's clean-up of "Not in an initiative": the ✦ on its header and the Viewer (batch 13 item 3)
50
51
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
@@ -160,7 +161,7 @@ async function load() {
160
161
  const [brief, board, ses, desk, today, sch, work, day, rev, progs, , pick] = await Promise.all([
161
162
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
162
163
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
163
- pmGet('/api/programs'), MEN.load(menCtx()), PP.readPick(),
164
+ pmGet('/api/programs'), MEN.load(menCtx()), PP.readPick(), SO.load(),
164
165
  ]);
165
166
  const D = S.D;
166
167
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
@@ -173,6 +174,7 @@ async function load() {
173
174
  D.phoneDay = day && day.ok ? day : null; // what finished today, the recap and tomorrow (the end-of-day card, the Done filter)
174
175
  D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
175
176
  D.programs = progs && progs.ok ? progs.programs : []; // programs above initiatives, across products (GET /api/programs)
177
+ D.order = SO.layout(); // the PM's sort and own order, shared with the Board (batch 14 item 8)
176
178
  D.pick = pick || D.pick || null; // the one product pick (the chip): which products are on Home and read
177
179
  if (D.pick && WS) D.pick = { ...D.pick, products: D.pick.products.map((p) => ({ ...p, on: p.ws === WS })) }; // ?ws= is a one-off view of that product
178
180
  D.now = Date.now();
@@ -292,13 +294,16 @@ function homeListHtml() {
292
294
  pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
293
295
  });
294
296
  }
295
- /** Your day (XvAPhDay, was the HvAOpen sheet): "Good morning" opens it in the Viewer, shell A. Full screen on a phone, beside the chat on a
296
- * desktop; on a phone the moment card (TfPhone) is its Now section, and the calendar is under ⋯. */
297
+ /** Your day (XvAPhDay, was the HvAOpen sheet), a phone only: "Good morning" opens it in the Viewer, full screen; the moment card (TfPhone) is
298
+ * its Now section, and the calendar is under ⋯. On a desktop "Good morning" opens the calendar (batch 14 item 4). */
297
299
  function dayHtml() { return ''; }
298
300
  function day(on) {
299
301
  S.day = !!on;
300
302
  if (!on) { const c = VW.current(); if (c && c.id === 'day') VW.close(); return; }
301
303
  if (!S.M) return;
304
+ // a desktop has no Your day any more (batch 14 item 4): the greeting opens the calendar in the Viewer; the list already holds every next step.
305
+ // A phone keeps Your day: its moment card (TfPhone) lives there
306
+ if (!isPhone()) { S.day = false; openCalendar(); return; }
302
307
  const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW());
303
308
  const ph = isPhone() && PHC;
304
309
  const P = YD.dayParts(Y, { moment: !!ph });
@@ -694,12 +699,24 @@ function productTarget() {
694
699
  context: 'Product ' + name + '. ' + C.of + (C.items.length ? ': ' + C.items.map((x) => x.label).join('; ') : '') + '.', also: null };
695
700
  }
696
701
  /** The list's key of the board's own product group ('p:<key>'): its heading shows as selected while the product's page is open. */
702
+ /** Tap the product's name in its page's header to rename it (batch 14 item 9, the rename press RnA* agreed for programs, initiatives and
703
+ * tasks): POST /api/workspaces/rename keeps the PM's name for the repository (its id does not move), so Home, the Board and the pick
704
+ * show it. Undo puts the old name back. A product with no workspace id has no press. */
705
+ const productRename = (ws, name, vid) => (ws ? { value: name, max: 80, save: async (t) => {
706
+ let r = null; try { r = await pmPost('/api/workspaces/rename', { id: ws, name: t }); } catch { r = null; }
707
+ if (!r || !r.ok) return { ok: false, error: (r && r.error) || 'The name could not be saved.' };
708
+ toastUndo('Renamed', async () => { let u = null; try { u = await pmPost('/api/workspaces/rename', { id: ws, name }); } catch { u = null; } if (u && u.ok) { VW.retitle(vid, name); load(); } return u && u.ok ? { ok: true } : { ok: false, error: 'The old name could not be put back.' }; });
709
+ load();
710
+ return { ok: true, title: t };
711
+ } } : null);
712
+ /** The name Home shows for the board's own product: its group's name (the PM's name for the repository wins), else the board's. */
713
+ const ownProductName = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return (g && g.name) || H.productName(S.D); };
697
714
  const productKey = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return g ? g.key : null; };
698
715
  /** The product's page in the Viewer (HbCProduct): Goals, the KRs and budgets with what is at risk, and This week, the weekly update and the
699
716
  * metrics review. A press opens that one; ← comes back to the page. */
700
717
  function openProductPage() {
701
- const name = H.productName(S.D);
702
- VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart',
718
+ const name = ownProductName();
719
+ VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart', rename: productRename(boardWs(), name, 'product'),
703
720
  render: (b) => {
704
721
  const C = H.productCard(S.D, S.D.now), U = H.weeklyUpdate(S.D, S.D.now), sent = (U.sent || []).some((x) => x.week === U.week.iso);
705
722
  const goals = C.items.map((x) => itemHtml({ kind: x.kind === 'ok' ? 'done' : 'risk', label: x.label })).join('') || '<p class="hm-none">No KR or budget is anchored on this board.</p>';
@@ -818,11 +835,12 @@ async function goIni(id, o = {}) {
818
835
  S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false; S.stepsMore = false;
819
836
  if (was !== id) { S.IM = null; S.IMid = null; }
820
837
  if (isPhone()) sheet(false);
821
- syncUrl();
822
838
  drawList();
823
- if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } return; }
839
+ // the address follows the page, so the entry before it (the trail's start, batch 14 item 7) keeps Home's own address
840
+ if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } syncUrl(); return; }
824
841
  openTarget(iniTarget(id));
825
842
  if (o.page !== false) { pushPage(); iniPage(); }
843
+ syncUrl();
826
844
  await loadIni();
827
845
  if (S.ini !== id) return;
828
846
  drawList(); openTarget(iniTarget(id));
@@ -841,7 +859,7 @@ function goOtherProduct(g) {
841
859
  openTarget(t);
842
860
  pushPage();
843
861
  const own = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
844
- VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart',
862
+ VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart', rename: productRename(ws, name, 'product:' + ws),
845
863
  render: (b) => {
846
864
  const goals = C.items.map((x) => itemHtml({ kind: x.kind === 'ok' ? 'done' : 'risk', label: x.label })).join('') || '<p class="hm-none">No KR or budget is anchored on this board.</p>';
847
865
  b.innerHTML = `<div class="hi-v hi-page"><section class="hi-pg" aria-label="Goals"><div class="hi-pgh"><b>Goals</b><span class="hi-n">${esc(C.of)}</span></div>${goals}</section>`
@@ -862,12 +880,11 @@ function goProgram(id) {
862
880
  programPanel().then(() => { if (S.head === 'g:' + id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id } })); }).catch(() => toast('The program could not open.'));
863
881
  }
864
882
  function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); }
865
- /* The browser's Back closes the page a name opened (HbC): opening one adds an entry to the history, Back takes it off and Home is as it
866
- * was. Close (×, Escape) takes the entry off too, so Back never stops at a page that is already closed. */
867
- let pushed = false;
868
- function pushPage() { if (pushed) return; pushed = true; history.pushState({ hmVw: 1 }, '', location.href); }
869
- addEventListener('popstate', () => { if (!pushed) return; pushed = false; if (VW.isOpen()) VW.close(); goHome(); });
870
- VW.onChange((d) => { if (!d.open && pushed) { pushed = false; history.back(); } });
883
+ /* The browser's Back closes the page a name opened (HbC). The Viewer keeps the one trail and its history entries (batch 14 item 7): Back
884
+ * at the trail's first item closes it, and Home is then as it was. Close (×, Escape) takes the entries off and keeps the initiative's chat. */
885
+ let paged = false;
886
+ function pushPage() { paged = true; }
887
+ VW.onChange((d) => { if (!d.open && paged) { paged = false; if (d.via === 'history') goHome(); } }); // × keeps the initiative's chat
871
888
  function syncUrl() {
872
889
  const q = new URLSearchParams(location.search);
873
890
  ['ini', 'open', 'item', 'session', 'ask', 'say', 'q', 'about', 'label', 'meeting', 'id', 'view', 'vk', 'vid'].forEach((k) => { if (!(k === 'open' && /^(report|chart|dashboard):/.test(q.get('open') || ''))) q.delete(k); });
@@ -876,7 +893,7 @@ function syncUrl() {
876
893
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
877
894
  else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
878
895
  const s = q.toString();
879
- history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
896
+ VW.replaceUrl(location.pathname + (s ? '?' + s : '')); // after the history settles, so it lands on the entry Home shows
880
897
  }
881
898
 
882
899
  /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
@@ -920,7 +937,7 @@ function openReviewVw() {
920
937
  },
921
938
  }));
922
939
  }
923
- /* New → A task: the PM names the initiative first. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
940
+ /* New → Task: in the open initiative, else the PM names the initiative. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
924
941
  * "Not in an initiative" opens the capture box in the list, on the PM's own list (POST /api/pm-items/add). The box is not on Home otherwise. */
925
942
  async function addTaskIn(id) {
926
943
  if (!id) { S.cap = true; drawList(); const i = $('#hmCap'); if (i) i.focus(); return; }
@@ -1321,21 +1338,32 @@ function recLive() {
1321
1338
  }
1322
1339
 
1323
1340
  /* ── New, end, kids ── */
1341
+ /* New (batch 14 item 10, canvas PmA*): four kinds, an icon and one word each, the Board's New in the same look. Each lands where the PM is:
1342
+ * the open initiative, else the open product's chat, else Home (a task asks where, "Not in an initiative" first; a chat is loose, linked
1343
+ * later). The place shows on the right, quiet. Quick ask and "Next step of an initiative" went: Home's chat box is always there, and the
1344
+ * list's rows already open where a next step waits. Initiative opens the Board's New initiative panel (?new=initiative), in that product. */
1345
+ const NEW_ICON = { task: 'M5 5h14v14H5zM9 12l2 2 4-4', ini: 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6' };
1324
1346
  function newItems() {
1325
1347
  const here = S.ini && S.ini !== 'product' ? S.ini : null;
1326
1348
  const inis = H.boardRows(S.D);
1327
1349
  const cur = chat.current(), prod = !here && cur && /^chat:product/.test(cur.key || '') && cur.newChat ? cur : null; // a product's chat is open: its own new session
1350
+ const where = here ? iniTitle(here) : prod ? prod.about : '';
1351
+ const pickTask = (b) => menu(b, [{ label: 'Not in an initiative', icon: NEW_ICON.task, go: () => addTaskIn(null) }, { sep: true }]
1352
+ .concat(inis.filter(H.OPEN).map((r) => ({ label: r.title, sub: r.stage, go: () => addTaskIn(r.id) }))), 'Task in');
1353
+ const ws = here ? iniWsOf(here) : prod ? prod.ws : boardWs();
1328
1354
  return [
1329
- { label: 'A task', sub: 'Choose its initiative first', go: (b) => menu(b, inis.filter(H.OPEN).map((r) => ({ label: r.title, sub: r.stage, go: () => addTaskIn(r.id) }))
1330
- .concat([{ sep: true }, { label: 'Not in an initiative', sub: 'Your own list', go: () => addTaskIn(null) }]), 'Under which initiative') },
1331
- { label: 'Next step of an initiative', sub: 'Open where it waits', go: (b) => menu(b, inis.map((r) => ({ label: r.title, sub: r.stage, go: () => goIni(r.id) })), 'Which initiative') },
1332
- prod ? { label: 'New session in ' + prod.about, sub: 'A fresh chat with its own history', go: () => prod.newChat() }
1333
- : { label: here ? 'New session in ' + iniTitle(here) : 'New session in an initiative', sub: 'A fresh chat with its own history', go: (b) => (here ? newIn(here) : menu(b, inis.map((r) => ({ label: r.title, sub: r.stage, go: () => newIn(r.id) })), 'In which initiative')) },
1334
- { label: 'Quick ask', sub: 'Your own chat, about all work', go: () => { goHome(); chat.focus(); } },
1335
- { label: 'Something unrelated', sub: 'A loose chat; link it later', go: () => newLoose() },
1336
- { label: 'Record a note now', sub: 'A conversation that is not on the calendar', go: () => MORE.openRecorder().then(() => drawList()) },
1355
+ { label: 'Task', icon: NEW_ICON.task, k: here ? where : '', go: (b) => (here ? addTaskIn(here) : pickTask(b)) },
1356
+ { label: 'Chat', icon: TD.P.chat, k: where, go: () => (here ? newIn(here) : prod ? prod.newChat() : newLoose()) },
1357
+ { label: 'Recording', icon: TD.P.mic, go: () => MORE.openRecorder().then(() => drawList()) },
1358
+ { sep: true },
1359
+ { label: 'Initiative', icon: NEW_ICON.ini, k: prod ? where : '', go: () => { location.href = '/premium-board.html?new=initiative' + (ws ? '&ws=' + encodeURIComponent(ws) : ''); } },
1337
1360
  ];
1338
1361
  }
1362
+ /** The initiative's conversation with a question typed in the box, not sent (the ⋯ menu's Change the plan dates, as the Board's ?ask=&q=). */
1363
+ function askIn(id, q) {
1364
+ S.phoneChat = isPhone(); openTarget(iniTarget(id));
1365
+ setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = q; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); ta.setSelectionRange(q.length, q.length); } }, 0);
1366
+ }
1339
1367
  function newIn(id) {
1340
1368
  const used = new Set(S.D.sessions.map((s) => H.keyOfSession(s)).filter(Boolean));
1341
1369
  let n = 2; while (used.has('init:' + id + ':' + n)) n++;
@@ -1489,7 +1517,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1489
1517
  if (d.hmEnd) { endRow(d.hmEnd); return; }
1490
1518
  if (d.hmGroup) { if (S.shut.has(d.hmGroup)) S.shut.delete(d.hmGroup); else S.shut.add(d.hmGroup); store.set('pmos.home.shut', JSON.stringify([...S.shut])); drawList(); return; }
1491
1519
  if ('hmAllneeds' in d) { S.allNeeds = !S.allNeeds; drawList(); return; }
1492
- if ('hmNew' in d) { menu(b, newItems(), 'What is it for?'); return; }
1520
+ if ('hmNew' in d) { menu(b, newItems(), 'New'); return; }
1493
1521
  if ('hmFold' in d) { S.folded = true; store.set('pmos.home.fold', '1'); drawList(); return; }
1494
1522
  if ('hmMeet' in d) { const m = H.meetLineOf(S.D.today); if (m) openMeeting(m.meeting); return; }
1495
1523
  if ('hmCal' in d) { openCalendar(); return; }
@@ -1586,7 +1614,7 @@ function cta() {
1586
1614
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1587
1615
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1588
1616
  openBoardTask: (t) => openBoardTask(t),
1589
- cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1617
+ cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), askIn: (id, q) => askIn(id, q), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1590
1618
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1591
1619
  /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
1592
1620
  * Read on the first program press, never at start: the panel's modules load premium-shell.js, whose start reads ?session= for the old dialog. */
@@ -1595,6 +1623,7 @@ const programPanel = () => progPanel || (progPanel = import('./bd-prog-panel.js'
1595
1623
  PO.mount({ programs: () => S.D.programs || [], stateOf: (p) => (((S.M && S.M.groups) || []).find((g) => g.kind === 'program' && g.program.id === p.id) || {}).st || null,
1596
1624
  saved: (p) => { const L2 = S.D.programs || [], i = L2.findIndex((x) => x.id === p.id); if (i >= 0) L2[i] = { ...L2[i], ...p }; drawList(); },
1597
1625
  say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), openIni: (id) => goIni(id) });
1626
+ SO.mount({ redraw: () => { S.D.order = SO.layout(); drawList(); }, say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) });
1598
1627
  mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings(), here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1599
1628
  // the Live pill (batch 6 item 2): on Home a row opens in place, the session's chat (with its Viewer page) or the meeting; the open one is tinted
1600
1629
  mountLivePill(document, {
@@ -16,19 +16,7 @@
16
16
  .hi-mvb { display: flex; align-items: center; gap: 6px; }
17
17
  .hi-mvb .cz-ms { margin-right: 2px; }
18
18
 
19
- /* buttons, as the canvas draws them */
20
- .hi-btn { height: 36px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; font-weight: 700; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); white-space: nowrap; cursor: pointer; }
21
- .hi-btn svg { flex: none; }
22
- .hi-btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
23
- .hi-btn.dark { background: var(--cz-ink); border-color: transparent; color: var(--cz-card); }
24
- .hi-btn.ghost { border-color: transparent; background: transparent; color: var(--cz-ink2); }
25
- .hi-btn.ghost:hover { background: var(--cz-well); }
26
- .hi-btn:disabled { opacity: .45; cursor: default; }
27
19
  .hi-self { align-self: flex-start; }
28
- .hi-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-grid; place-items: center; flex: none; padding: 0; border: 0; background: none; color: var(--cz-ink2); cursor: pointer; }
29
- .hi-ib:hover { background: var(--cz-well2); }
30
- .hi-ib.solid { background: var(--cz-ink); color: var(--cz-card); }
31
- .hi-ib.sm { width: 28px; height: 28px; }
32
20
 
33
21
  /* ── the list column groups (InTasks, InDocs) ── */
34
22
  .hi-g .hm-gh .hi-n { margin-left: auto; font-weight: 700; font-size: 12px; color: var(--cz-ink3); }
@@ -48,47 +36,6 @@
48
36
  .hi-chk.off { cursor: default; border-style: dashed; }
49
37
  .hi-chk.off.on { border-style: solid; opacity: .6; }
50
38
 
51
- /* ── the popovers: Move anyway, Back, the menus ── */
52
- .hi-pop { position: fixed; z-index: 90; left: var(--hi-x, 24px); top: var(--hi-y, 24px); width: 360px; max-width: calc(100vw - 24px); box-sizing: border-box; background: var(--cz-card); color: var(--cz-ink); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; font-family: var(--cz-sans); font-size: 14px; box-shadow: 0 24px 60px -24px rgba(42,46,53,.45), 0 0 0 1px var(--cz-hair); }
53
- .hi-pop.menu { width: 290px; padding: 8px; gap: 2px; }
54
- .hi-pop.sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; border-radius: 28px 28px 0 0; padding: 10px 16px 28px; box-shadow: 0 -20px 50px -20px rgba(42,46,53,.35); }
55
- .hi-pop.sheet .hi-btn { height: 48px; justify-content: center; }
56
- .hi-pop.sheet .hi-acts { flex-direction: column; align-items: stretch; }
57
- .hi-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--cz-c-d9dce1); align-self: center; margin-bottom: 4px; }
58
- .hi-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(42,46,53,.18); }
59
- .hi-pop p { margin: 0; }
60
- .hi-h3 { font-size: 15px; font-weight: 800; }
61
- .hi-lbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); }
62
- .hi-small { margin: 0; font-size: 12.5px; color: var(--cz-ink3); }
63
- .hi-warn { background: var(--cz-riskbg); color: var(--cz-risk); border-radius: 14px; padding: 12px 14px; font-size: 12.5px; }
64
- .hi-field { display: flex; flex-direction: column; gap: 6px; }
65
- .hi-field > span { font-size: 12.5px; font-weight: 800; color: var(--cz-ink2); }
66
- .hi-field em { font-style: normal; font-weight: 600; color: var(--cz-ink3); }
67
- .hi-field input, .hi-field textarea { box-sizing: border-box; width: 100%; border: 0; border-radius: 14px; background: var(--cz-well); color: var(--cz-ink); font: inherit; font-size: 14px; padding: 10px 14px; outline: 0; }
68
- .hi-field input { height: 42px; }
69
- .hi-field textarea { min-height: 56px; resize: vertical; }
70
- .hi-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
71
- .hi-chips { display: flex; flex-wrap: wrap; gap: 6px; }
72
- .hi-chips .cz-chip[aria-pressed="true"] { background: var(--cz-bluebg); border-color: transparent; color: var(--cz-blueink); }
73
- .hi-cks { display: flex; flex-direction: column; gap: 4px; }
74
- .hi-pop:not(.sheet) .hi-cks { display: none; } /* the card shows the items; the phone's sheet repeats them (InPhone) */
75
- .hi-ck { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cz-ink2); padding: 2px 0; }
76
- .hi-ck i { width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--cz-c-c5c9d0); box-sizing: border-box; display: inline-grid; place-items: center; flex: none; color: var(--cz-card); }
77
- .hi-ck.on i { background: var(--cz-ink); border-color: var(--cz-ink); }
78
- .hi-mlbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); padding: 8px 12px 4px; }
79
- .hi-hr { height: 1px; background: var(--cz-hair); margin: 4px 0; }
80
- .hi-mi { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--cz-ink); width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
81
- .hi-mi:hover, .hi-mi.on { background: var(--cz-well); }
82
- .hi-mi span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
83
- .hi-mi em { font-style: normal; margin-left: auto; font-size: 12px; color: var(--cz-ink3); font-weight: 600; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
84
- .hi-mi:disabled { opacity: .45; cursor: default; }
85
- .hi-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
86
-
87
- /* the toast with Undo: info, so it does not move */
88
- .hi-toast { position: fixed; z-index: 95; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--cz-ink); color: var(--cz-card); font-family: var(--cz-sans); font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }
89
- .hi-toast[hidden] { display: none; }
90
- .hi-toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
91
- .hi-toast button { height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: inherit; font: inherit; font-weight: 700; cursor: pointer; flex: none; }
92
39
 
93
40
  /* ── the Viewer: Tasks, Documents, Stage (InTasks, InDocs) ── */
94
41
  .hi-v { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 24px; font-size: 14px; color: var(--cz-ink); }
@@ -148,6 +95,12 @@ button.hi-pill { cursor: pointer; }
148
95
  @media (max-width: 760px) {
149
96
  /* every target in the Viewer is at least 44 px (the phone floor); a check box keeps its 18 px look inside a 44 px press */
150
97
  .hi-v button, .hi-v input, .hi-pop button, .hi-pop input { min-height: 44px; }
98
+ /* a task row's check box and its dates keep their size inside the 44 px floor (batch 14 item 6: the box stretched tall and the dates fell a line) */
99
+ .hi-v .iv-cb { min-height: 0; position: relative; }
100
+ .hi-v .iv-car, .hi-v .iv-tr .iv-tt { min-height: 0; }
101
+ .hi-v .iv-cb::after { content: ""; position: absolute; inset: -13px; }
102
+ .hi-v .iv-dc { min-height: 22px; position: relative; }
103
+ .hi-v .iv-dc::after { content: ""; position: absolute; left: 0; right: 0; top: -11px; bottom: -11px; }
151
104
  .hi-v .cz-seg button { height: 44px; }
152
105
  .hi-v .hi-ib, .hi-pop .hi-ib { width: 44px; height: 44px; }
153
106
  .hi-trow { min-height: 52px; padding: 0 2px; gap: 6px; }
@@ -190,29 +143,6 @@ button.hi-pill { cursor: pointer; }
190
143
  .hm-br .hm-wf { margin-left: auto; display: inline-flex; align-items: center; padding: 3px; border: 0; border-radius: 9px; background: none; cursor: pointer; color: inherit; }
191
144
  .hm-br .hm-wf:hover, .hm-br .hm-wf[aria-expanded="true"] { background: var(--cz-well); }
192
145
  .hm-br .hm-wf + .st { margin-left: 0; }
193
- .hi-pop.wide:not(.sheet) { width: 560px; }
194
- .hi-pop.menu .hi-mi .wfi { margin-left: -2px; }
195
- .hi-wfpad { padding: 4px 12px 6px; }
196
- .hi-wfchain { line-height: 1.5; }
197
- .hi-mut { color: var(--cz-ink3); }
198
- .hi-wfh { display: flex; align-items: center; gap: 8px; }
199
- .hi-wfh .hi-h3 { flex: 1; min-width: 0; }
200
- .hi-wfrows { display: flex; flex-direction: column; }
201
- .hi-wfrow { display: grid; grid-template-columns: minmax(0, 130px) 14px minmax(0, 130px) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: 13.5px; }
202
- .hi-wfrow:first-child { border-top: 0; }
203
- .hi-wfrow span { min-width: 0; }
204
- .hi-wfrow em { display: block; font-style: normal; font-size: 12px; color: var(--cz-ink3); }
205
- .hi-wfland { display: flex; align-items: center; gap: 8px; }
206
- .hi-wfland span { flex: 1; }
207
- .hi-wfland select { font: inherit; font-size: 13px; font-weight: 700; color: var(--cz-ink); background: var(--cz-well); border: 0; border-radius: 10px; padding: 6px 10px; max-width: 60%; }
208
- .hi-end { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--cz-well); font-size: 13px; }
209
- .hi-end p { margin: 0; flex: 1; min-width: 0; color: var(--cz-ink2); }
210
- .hi-endi { display: inline-flex; color: var(--cz-ink3); }
211
- @media (max-width: 760px) {
212
- .hi-wfrow { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); }
213
- .hi-wfrow > .hi-small { grid-column: 1 / -1; }
214
- .hi-end { flex-wrap: wrap; }
215
- }
216
146
 
217
147
  /* ── stage card D: the stage as a live step list (canvas XscD, XscDDesk); the list itself is cozy-steps.css ── */
218
148
  .hm-card.hm-sc { padding: 0; background: transparent; box-shadow: none; }
@@ -27,6 +27,8 @@
27
27
  * page; the phone keeps the Documents | Stage switch. */
28
28
  import * as MD from './home-ini-model.js';
29
29
  import * as WF from './ini-wf.js';
30
+ import { openPop, closePop, undoToast, popEl, ensureCss as ensurePopCss } from './hi-pop.js';
31
+ import { iniMore, iniText, pageHref } from './ini-more.js'; // the one initiative ⋯ menu, the same on the Board (batch 14 item 5) // the popovers and the toast with Undo, shared with the Board
30
32
  import * as SC from './home-stage-card.js';
31
33
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
32
34
  import { ensureCss as ensureStepsCss } from './cozy-steps.js'; // stage card D: the card's last node and the move sheet's words // D99: the initiative's own workflow (Change picker, switch, Won't do, Archive)
@@ -39,7 +41,7 @@ const I = {
39
41
  };
40
42
  const PHONE = 760;
41
43
  const isPhone = () => innerWidth <= PHONE;
42
- const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() }, pop: null, toastT: 0 };
44
+ const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() } };
43
45
 
44
46
  /* ── reading the layout record ── */
45
47
  const curM = () => { const S = X.ctx && X.ctx.S; return S && S.ini && S.ini !== 'product' && S.IMid === S.ini ? S.IM : null; };
@@ -104,15 +106,6 @@ async function doMove(id, M, to, why, o = {}) {
104
106
  await X.ctx.load();
105
107
  return true;
106
108
  }
107
- function undoToast(text, undo) {
108
- let el = document.getElementById('hiToast');
109
- if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
110
- el.innerHTML = `<span>${esc(text)}</span><button type="button" data-hi-undo>Undo</button>`;
111
- el.hidden = false; el.classList.add('on');
112
- el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
113
- const hide = () => { el.classList.remove('on'); el.hidden = true; };
114
- clearTimeout(X.toastT); X.toastT = setTimeout(hide, 9000);
115
- }
116
109
  function autoCheck(id, M, mv) {
117
110
  const L = Lof(id);
118
111
  if (!L.read || !mv.autoReady) return;
@@ -122,42 +115,7 @@ function autoCheck(id, M, mv) {
122
115
  doMove(id, M, mv.next, MD.whyOf('auto'), { auto: true });
123
116
  }
124
117
 
125
- /* ── the popovers: Move anyway, Back, and the small menus ── */
126
- function closePop() {
127
- if (!X.pop) return;
128
- const a = X.pop.anchor; X.pop.el.remove(); if (X.pop.scrim) X.pop.scrim.remove(); X.pop = null;
129
- if (a && a.isConnected) { a.setAttribute('aria-expanded', 'false'); try { a.focus(); } catch { /* gone */ } }
130
- }
131
- function openPop(anchor, kind, html, onClick, o = {}) {
132
- closePop();
133
- const el = document.createElement('div');
134
- const sheet = isPhone() && !o.menu;
135
- el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
136
- el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
137
- el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
138
- let scrim = null;
139
- if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
140
- document.body.appendChild(el);
141
- if (!sheet) { // under the button that opened it, kept inside the window: run-time geometry, set as two custom properties
142
- const r = anchor.getBoundingClientRect(), w = el.offsetWidth, hh = el.offsetHeight;
143
- const col = !o.menu && anchor.closest('#hmList'); // a dialog from the list column opens beside the column (InStage), not over it
144
- let x, y;
145
- if (col) { const c = col.getBoundingClientRect(); x = c.right + 12; y = Math.min(innerHeight - hh - 12, Math.max(12, r.top - 60)); }
146
- else { x = r.left + w > innerWidth - 12 ? r.right - w : r.left; y = r.bottom + 8 + hh > innerHeight - 12 ? r.top - hh - 8 : r.bottom + 8; }
147
- x = Math.max(12, Math.min(innerWidth - w - 12, x)); y = Math.max(12, y);
148
- el.style.setProperty('--hi-x', Math.round(x) + 'px'); el.style.setProperty('--hi-y', Math.round(y) + 'px');
149
- }
150
- anchor.setAttribute('aria-expanded', 'true');
151
- X.pop = { el, scrim, anchor, kind };
152
- el.addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && !b.disabled) onClick(b, el); });
153
- el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePop(); } });
154
- const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
155
- return el;
156
- }
157
- // Escape closes the popover first: on window in the capture phase, so Home's own Escape (the phone's list sheet, the Viewer) waits for the next press
158
- if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && X.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
159
- if (typeof document !== 'undefined') document.addEventListener('mousedown', (e) => { if (X.pop && !X.pop.el.contains(e.target) && !(X.pop.anchor && X.pop.anchor.contains(e.target)) && !(X.pop.scrim && X.pop.scrim === e.target)) closePop(); }, true);
160
-
118
+ /* ── the popovers: Move anyway, Back, and the small menus (the kit is pm/hi-pop.js, shared with the Board) ── */
161
119
  function popMove(anchor, id, M, mv) {
162
120
  const title = X.ctx.iniTitle(id);
163
121
  const ck = mv.items.map((x) => `<span class="hi-ck${x.done ? ' on' : ''}"><i aria-hidden="true">${x.done ? SVG(I.check, 10, 3.5) : ''}</i>${esc(x.label)}</span>`).join('');
@@ -226,7 +184,7 @@ function menu(anchor, items, label) {
226
184
  function ask(anchor, label, value, go, o = {}) { // one line of words, inline (no browser prompt)
227
185
  openPop(anchor, 'ask', `<label class="hi-field"><span>${esc(label)}</span><input id="hiAsk" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}"></label><div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-x>Cancel</button></div>`,
228
186
  (b, el) => { if ('hiX' in b.dataset) { closePop(); return; } if ('hiGo' in b.dataset) { const v = el.querySelector('#hiAsk').value.trim(); if (!v) return; closePop(); go(v); } }, { label });
229
- const i = X.pop.el.querySelector('#hiAsk');
187
+ const i = popEl().querySelector('#hiAsk');
230
188
  i.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); const v = i.value.trim(); if (v) { closePop(); go(v); } } });
231
189
  }
232
190
 
@@ -366,29 +324,52 @@ async function setDates(id, uid, patch) {
366
324
  if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast('Dates saved: ' + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
367
325
  else C.toast('Dates saved.');
368
326
  }
369
- /** ⋯ of the page (HbCMore): change it, look at it elsewhere, then stop it, red and last. */
327
+ /** ⋯ of the page: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5), the same words and order as the Board's panel.
328
+ * This page says which items apply and what each press does; the menu decides the order. */
370
329
  function pageMore(id) {
371
330
  const M = curM(); if (!M) return [];
372
- const mv = mvOf(id, M), out = [], row = rowOf(id), self = !!(M.acts && M.acts.self);
373
- // D99 (WfAWontDo): Change workflow and Rename first; the PMOS-self board keeps its derived ladder, so it has no workflow to change
374
- if (!self && !row.ended) out.push({ label: 'Change workflow', note: (row.wf || {}).name || 'Product feature', on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) });
375
- if (X.ctx.renameIni) out.push({ label: 'Rename', on: () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } });
376
- if (!mv.why) out.push({ label: 'Moves on by itself', note: mv.auto ? 'On' : 'Off', on: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) });
377
- if (mv.canBack) out.push({ label: 'Move back a stage', note: mv.prev, on: (b) => popBack(b || document.querySelector('#czViewer [data-cz-vw="more"]'), id, M, mv) });
378
- if ((M.acts.stages || []).length && !M.acts.self) out.push({ label: 'Move to a stage', on: () => iniOverview('stage', { back: true }) });
379
- out.push({ label: 'Add a stakeholder', on: () => X.ctx.addPerson() });
380
- // P7: an initiative in no program can become one; one in a program can move out of it or to another (batch 11 item 2, canvas LpA1More)
381
- const pm = X.ctx.moveItems ? X.ctx.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [];
382
- if (X.ctx.turnProgram && !pm.length) out.push({ label: 'Turn into a program', on: () => X.ctx.turnProgram(id) });
383
- // split it into a new initiative, or merge it into another, above the program moves (batch 11 item 14, canvas XsmA1Menu)
384
- const sm = X.ctx.smItems && !row.ended ? X.ctx.smItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label)) : [];
385
- if (sm.length || pm.length) out.push({ sep: true }, ...sm, ...pm);
386
- out.push({ sep: true }, { label: 'Open on the Board', on: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); } },
387
- { label: 'The record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) });
388
- // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage. Cancel stays red and last (HbCMore)
389
- if (!self) out.push({ sep: true }, row.ended ? { label: 'Back to Triage', on: () => WF.backToTriage(wfUi(), id) } : { label: 'Won’t do', on: (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) }, { label: 'Archive', on: () => WF.archive(wfUi(), id) });
390
- if (!M.acts.life && !row.ended) out.push({ sep: true }, { label: 'Put on hold', on: () => { iniOverview('stage', { back: true, ask: 'on-hold' }); } }, { label: 'Cancel the initiative', danger: true, on: () => { iniOverview('stage', { back: true, ask: 'cancelled' }); } });
391
- return out;
331
+ const C = X.ctx, mv = mvOf(id, M), row = rowOf(id), self = !!(M.acts && M.acts.self), B = (C.S.D && C.S.D.board) || {};
332
+ const openList = (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label);
333
+ const copy = (t, said) => navigator.clipboard.writeText(t).then(() => C.toast(said), () => C.toast('This browser did not allow the copy.'));
334
+ const ask = (q) => { if (C.askIn) C.askIn(id, q); };
335
+ return iniMore({
336
+ // D99 (WfAWontDo): the PMOS-self board keeps its derived ladder, so it has no workflow to change
337
+ wf: !self && !row.ended ? { name: (row.wf || {}).name, on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) } : null,
338
+ rename: C.renameIni ? () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } : null,
339
+ auto: !mv.why ? { on: mv.auto, press: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) } : null,
340
+ back: mv.canBack ? { prev: mv.prev, on: (b) => popBack(b || moreBtn(), id, M, mv) } : null,
341
+ toStage: (M.acts.stages || []).length && !self ? () => iniOverview('stage', { back: true }) : null,
342
+ dates: C.askIn ? () => ask('Propose new start and end dates for ' + C.iniTitle(id)) : null,
343
+ person: () => C.addPerson(),
344
+ // split or merge, then the program moves (batch 11 items 2 and 14)
345
+ sm: C.smItems && !row.ended ? C.smItems(id, openList) : [],
346
+ pm: C.moveItems ? C.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [],
347
+ turnProgram: C.turnProgram ? () => C.turnProgram(id) : null,
348
+ jira: B.jira ? () => readJira(M) : null,
349
+ board: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); },
350
+ record: async () => (C.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }),
351
+ link: () => copy(new URL(pageHref(id, M.board.ws, M.board.id), location.href).href, 'Link copied.'),
352
+ text: () => copy(iniText(C.iniTitle(id), C.view ? C.view(id) : null, (row.track && row.track.tickets) || []), 'Copied as text.'),
353
+ ended: !!row.ended,
354
+ wontDo: !self ? (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) : null,
355
+ backToTriage: !self ? () => WF.backToTriage(wfUi(), id) : null,
356
+ archive: !self ? () => WF.archive(wfUi(), id) : null,
357
+ hold: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'on-hold' }) : null,
358
+ resume: M.acts.life === 'hold' && !row.ended ? () => resume(id, M) : null,
359
+ cancel: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'cancelled' }) : null,
360
+ });
361
+ }
362
+ /** Resume an initiative on hold (POST /api/lifecycle, the Stage view's Resume and the Board's). */
363
+ async function resume(id, M) {
364
+ const r = await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'active', reason: 'resumed' });
365
+ if (!r || r.ok === false) { X.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
366
+ X.ctx.toast('Resumed · ' + X.ctx.iniTitle(id) + '.'); await X.ctx.load(); redrawView();
367
+ }
368
+ /** Read Jira again (the Board's press): the initiative's product reads its Jira source again; the page reads the Board after it lands. */
369
+ async function readJira(M) {
370
+ const r = await X.ctx.pmPost('/api/sources/refresh', { ws: M.board.ws, source: 'jira' });
371
+ X.ctx.toast(r && r.ok ? 'Reading Jira again. The page shows it when the read lands.' : 'Jira was not read again: ' + ((r && r.error) || 'the server did not answer') + '.');
372
+ if (r && r.ok) setTimeout(() => X.ctx.load(), 4000);
392
373
  }
393
374
  const moreBtn = () => document.querySelector('#czViewer [data-cz-vw="more"]') || document.body;
394
375
  /** Moves on by itself for this one initiative, on a workflow of the library (POST /api/boards/ini-auto): the stage sets the default. */
@@ -627,6 +608,7 @@ function pagePress(t, id, M) {
627
608
  export function mountIni(ctx) {
628
609
  X.ctx = ctx;
629
610
  if (typeof document === 'undefined') return X;
611
+ ensurePopCss(); // before home-ini.css, so its phone rules win
630
612
  if (!document.querySelector('link[data-hi-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./home-ini.css', import.meta.url).href; l.dataset.hiCss = ''; document.head.appendChild(l); }
631
613
  ensureStepsCss(); // the stage card's step list (cozy-steps.css), before the first draw
632
614
  if (!document.querySelector('link[data-tk-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./tk-tasks.css', import.meta.url).href; l.dataset.tkCss = ''; document.head.appendChild(l); }