create-pmos 0.688.0 → 0.689.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 (38) hide show
  1. package/package.json +20 -14
  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/briefing-premium-insights-test.js +23 -1
  7. package/workspace/briefing-premium-test.js +3 -0
  8. package/workspace/changelog.json +19 -0
  9. package/workspace/guide/breakdown.md +24 -1
  10. package/workspace/guide/cli.md +2 -0
  11. package/workspace/guide/intelligence-okr-goals.md +1 -1
  12. package/workspace/lib/board-premium.js +13 -3
  13. package/workspace/lib/engine/boards.js +18 -3
  14. package/workspace/lib/jira-cli.js +21 -2
  15. package/workspace/lib/jira-epics.js +125 -0
  16. package/workspace/lib/jira-status.js +18 -3
  17. package/workspace/lib/route-modules.js +1 -0
  18. package/workspace/lib/routes-boards.js +109 -6
  19. package/workspace/lib/routes-jira-epics.js +65 -0
  20. package/workspace/lib/task-cli.js +25 -7
  21. package/workspace/lib/task-store.js +2 -2
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/public/pm/bd-backlog.js +25 -4
  25. package/workspace/public/pm/bd-pop-ds.css +22 -0
  26. package/workspace/public/pm/bd-pop-ds.js +48 -11
  27. package/workspace/public/pm/bd-sprint-ds.js +5 -4
  28. package/workspace/public/pm/bd-sprint.js +10 -3
  29. package/workspace/public/pm/bd-work-ds.css +4 -0
  30. package/workspace/public/pm/cozy-pop-work.css +12 -0
  31. package/workspace/public/pm/cozy-pop-work.js +172 -9
  32. package/workspace/public/pm/ini-view-model.js +12 -1
  33. package/workspace/public/pm/pop-work-model.js +40 -7
  34. package/workspace/public/pm/premium-insights.js +1 -1
  35. package/workspace/public/pm/work-select.js +73 -0
  36. package/workspace/public/pm/work-tree.js +111 -0
  37. package/workspace/skills/jira-epic.skill +35 -0
  38. package/workspace/test-lists/work-subtasks.json +11 -0
@@ -19,9 +19,11 @@ export const I = {
19
19
  star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16z', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18',
20
20
  plus: 'M12 5v14M5 12h14', more: 'M5 12h.01M12 12h.01M19 12h.01', open: 'M14 5h5v5M19 5l-8 8M18 14v5H5V6h5', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
21
21
  dia: 'M12 4l8 8-8 8-8-8z', doc: 'M7 3h7l4 4v14H7zM14 3v4h4M9.5 12h6M9.5 16h6', deck: 'M4 5h16v11H4zM12 16v4M8 20h8', 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',
22
- proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5',
22
+ proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', jira: 'M12 3l9 9-9 9-9-9zM12 8l4 4-4 4-4-4z',
23
23
  who: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM5 20a7 7 0 0 1 14 0', cal: 'M5 6h14v14H5zM5 10h14M9 4v4M15 4v4', stage: 'M5 7h14M5 12h10M5 17h6',
24
24
  };
25
+ import * as WT from './work-tree.js'; // subtasks and the epic check (initiative work-subtasks)
26
+ import { barHtml as selBar } from './work-select.js'; // the bulk bar (WorkBulkDS)
25
27
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
26
28
  const DAY = 864e5;
27
29
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
@@ -116,9 +118,9 @@ export function stagesHtml(st, W) {
116
118
  }
117
119
 
118
120
  /* ── the Work breakdown ── */
119
- export function wbsHead(view) {
121
+ export function wbsHead(view, epic = '', epicUrl = '') {
120
122
  const t = (k, l) => `<button type="button" class="pm-tab" role="tab" aria-selected="${view === k}" data-pwv="${k}">${l}</button>`;
121
- return `<div class="pm-row pwd-bh"><h2 class="pm-h-sm">Work breakdown</h2><div class="pm-tabs" role="tablist" aria-label="View of the work breakdown">${t('list', 'List')}${t('gantt', 'Gantt')}</div></div>`;
123
+ return `<div class="pm-row pwd-bh"><h2 class="pm-h-sm">Work breakdown</h2>${epic ? `<span class="pm-meta pwd-ep">epic</span>${keyChip({ ckey: epic, jurl: epicUrl || '' })}` : ''}<div class="pm-tabs" role="tablist" aria-label="View of the work breakdown">${t('list', 'List')}${t('gantt', 'Gantt')}</div></div>`;
122
124
  }
123
125
  /** The stage a captured line names: "Write the runbook in Plan" → Plan; else the stage in progress, else the first stage. */
124
126
  export function stageKeyOf(text, st) {
@@ -131,8 +133,34 @@ export function stageKeyOf(text, st) {
131
133
  const cur = L.find((x) => x.now) || L.find((x) => !x.done) || L[0];
132
134
  return cur ? { key: cur.key, name: cur.name, title: s, guessed: true } : null;
133
135
  }
134
- /** rows: the breakdown with every stage open but a finished one, done tasks in their date order and no "more" fold (pop-work-model.js
135
- * breakdownOf with openAll). A stage head is a press that folds it (data-pw-fold, the Gantt's own). o: { ro, looseN, ms } */
136
+ /** A Jira row's key chip (WorkJiraDS): it opens the ticket in Jira; a PMOS-only row has none. */
137
+ export function keyChip(x) {
138
+ const k = WT.keyOf(x); if (!k) return '';
139
+ const inner = `${SV(I.jira, 12)}<span>${esc(k)}</span>`;
140
+ return x.jurl && /^https:\/\//.test(x.jurl) ? ` <a class="pm-chip code pwd-key" href="${esc(x.jurl)}" target="_blank" rel="noopener" aria-label="${esc('Open ' + k + ' in Jira')}" title="Open in Jira">${inner}</a>` : ` <span class="pm-chip code pwd-key">${inner}</span>`;
141
+ }
142
+ /** The red dot of the epic check (WorkJiraDS): "No epic" or "Other epic", its reason on hover. Nothing when the ticket fits. */
143
+ export function epicDot(x, epics) {
144
+ const f = WT.epicFlag(x, epics); if (!f) return '';
145
+ return `<span class="pwd-epic" title="${esc(WT.epicWhy(x, f, epics))}" aria-label="${esc(WT.epicWhy(x, f, epics))}"><i aria-hidden="true"></i>${f === 'none' ? 'No epic' : 'Other epic'}</span>`;
146
+ }
147
+ /** The ✦ fix of the epic check, above the list: put the flagged tickets under the initiative's epic. */
148
+ export function epicSugHtml(fx) {
149
+ if (!fx) return '';
150
+ return `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">${esc(fx.say)}</b></div>`
151
+ + `<dl><dt>Why</dt><dd>${esc(fx.why)}</dd><dt>PMOS will</dt><dd><ul>${fx.will.map((w) => `<li>${esc(w)}</li>`).join('')}</ul></dd><dt>What changes</dt><dd>${esc('Every ticket in this work sits under ' + fx.epic + ', so the epic\'s progress in Jira matches this page.')}</dd></dl>`
152
+ + `<div class="ans"><button type="button" class="pm-btn primary" data-pw-epic-fix aria-label="Yes, do it" title="Yes, do it">${SV(I.ok)}</button>`
153
+ + `<button type="button" class="pm-btn outline" data-pw-epic-drop aria-label="No" title="No">${SV(I.x)}</button></div></div>`;
154
+ }
155
+ /** Ticking a parent asks once (WorkSubtasksDS): tick its open subtasks too? */
156
+ export function tickAskHtml(x, n) {
157
+ return `<div class="pm-sug pwd-ask" role="group" aria-label="Tick the subtasks too?"><div class="ttl">${SV(I.ok)}<span>You ticked <b>${esc(x.title)}</b>. Tick its ${esc(n === 1 ? 'open subtask' : n + ' open subtasks')} too?</span></div>`
158
+ + `<div class="ans"><button type="button" class="pm-btn primary" data-pw-tick-all="${esc(x.uid)}" aria-label="Yes, tick them all" title="Yes, tick them all">${SV(I.ok)}</button>`
159
+ + `<button type="button" class="pm-btn outline" data-pw-tick-no aria-label="No" title="No">${SV(I.x)}</button></div></div>`;
160
+ }
161
+ /** rows: the breakdown with every stage open, its done tasks shown and no fold (pop-work-model.js breakdownOf).
162
+ * Every stage is open but a finished one; done tasks keep their date order; a stage head is a press that folds it (data-pw-fold).
163
+ * o: { ro, looseN, ms, epics (the initiative's Jira epics), sel (Set of picked uids), fix (the epic ✦, WT.epicFix), ask (a parent ticked: { x, n }) } */
136
164
  export function listHtml(rows, W, o = {}) {
137
165
  const groups = [], empty = [];
138
166
  let g = null;
@@ -140,8 +168,9 @@ export function listHtml(rows, W, o = {}) {
140
168
  if (x.kind === 'stage') { g = x.key === '' ? null : { s: x, tasks: [] }; if (g) groups.push(g); continue; }
141
169
  if (g && x.kind === 'task') g.tasks.push(x);
142
170
  }
171
+ const sel = o.sel || new Set();
143
172
  const li = (x) => {
144
- const sub = [x.date, x.who && x.who !== 'You' ? x.who : ''].filter(Boolean).join(' · ');
173
+ const sub = x.jsub ? [x.who && x.who !== 'You' ? x.who : '', x.date].filter(Boolean).join(' · ') : [x.date, x.who && x.who !== 'You' ? x.who : ''].filter(Boolean).join(' · ');
145
174
  // the tick (WorkStatesDS 3): marks it done, with Undo; a done task and a Jira ticket show their state only
146
175
  const box = x.done ? `<span class="pwd-ck dn" aria-label="Done" role="img">${SV(I.ok, 14)}</span>`
147
176
  : o.ro || x.jira ? `<span class="pwd-ck" aria-hidden="true">${SV(x.ms ? I.dia : I.box, 14)}</span>`
@@ -154,21 +183,29 @@ export function listHtml(rows, W, o = {}) {
154
183
  + (x.done ? '' : ab(`data-pw-date="${esc(x.uid)}" aria-haspopup="dialog"`, x.date ? (x.ms ? 'Date: ' : 'Due: ') + x.date : 'Set a date', I.cal))
155
184
  + (x.jira ? '' : ab(`data-pw-stage="${esc(x.uid)}" aria-haspopup="menu"`, 'Stage', I.stage))
156
185
  + ab(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, I.more) + '</span>';
157
- return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}">${box}<span class="txt">${title}${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${acts}</div>`;
186
+ // a parent (WorkSubtasksDS): the fold chevron, "n of m done" with its bar; children indent one step per level, up to three
187
+ const chev = x.kids ? `<button type="button" class="pwd-chev" data-pw-sub="${esc(x.uid)}" aria-expanded="${!!x.open}" aria-label="${esc((x.open ? 'Fold ' : 'Open ') + x.title)}">${SV(x.open ? I.down : I.right, 14)}</button>` : (x.depth || (o.nested && !x.depth) ? '<span class="pwd-chev sp" aria-hidden="true"></span>' : '');
188
+ const prog = x.kids ? `<span class="pwd-prog" aria-hidden="true"><i style="width:${x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0}%"></i></span><span class="pm-meta pwd-cnt">${esc(x.count)}</span>` : '';
189
+ const jira = keyChip(x) + (x.jsub ? ' <span class="pm-meta">Jira sub-task</span>' : '');
190
+ const dot = epicDot(x, o.epics);
191
+ return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}${sel.has(String(x.uid)) ? ' sel' : ''}${x.kids ? ' par' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}"${x.depth ? ` style="--pwd-d:${x.depth}"` : ''}>${chev}${box}<span class="txt"><span class="pwd-tl">${title}${jira}</span>${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${prog}${dot}${acts}</div>`;
158
192
  };
159
193
  const body = groups.map((G) => {
160
194
  // a stage row from breakdownOf says whether it has tasks (can) and is open; a row without them is open when tasks follow it
161
195
  const has = G.s.can != null ? !!G.s.can : G.tasks.length > 0, open = G.s.open != null ? !!G.s.open : true;
162
196
  if (!has) { empty.push(G.s.name); return ''; }
163
- const count = G.s.count || G.tasks.filter((x) => x.done).length + ' of ' + G.tasks.length + ' done';
164
- // the head folds the stage (Wawan, 2026-11-22: "completed stage can be collapsed"); its tasks keep their date order, done ones in place
197
+ // a top-level task counts its subtasks (initiative work-subtasks); every task keeps its date order, done ones in place (Part A)
198
+ const top = G.tasks.filter((x) => !x.depth), nAll = top.reduce((k, x) => k + (x.kids ? x.nLeaf : 1), 0), nDn = top.reduce((k, x) => k + (x.kids ? x.nDone : x.done ? 1 : 0), 0);
199
+ const count = G.s.count || nDn + ' of ' + nAll + ' done';
200
+ // the head folds the stage (Wawan, 2026-11-22: "completed stage can be collapsed")
165
201
  const head = `<button type="button" class="pm-group pwd-gh${G.s.now ? ' now' : ''}" data-pw-fold="${esc(G.s.key)}" aria-expanded="${open}"><b>${esc(G.s.name)}</b> <span class="pm-meta">${esc(count)}</span>${SV(open ? I.down : I.right, 14)}</button>`;
166
202
  return head + (open ? G.tasks.map(li).join('') : '');
167
203
  }).join('');
168
204
  const fold = empty.length ? `<div class="pm-fold pwd-fold">${esc(empty.length === 1 ? empty[0] + ' has no tasks yet' : empty.slice(0, -1).join(', ') + ' and ' + empty[empty.length - 1] + ' have no tasks yet')}</div>` : '';
169
- const cap = o.ro ? '' : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or PMOS picks one" aria-label="Add a task. Say its stage, or PMOS picks one" maxlength="200" autocomplete="off">`;
205
+ const cap = o.ro ? '' : sel.size ? selBar(sel.size) : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or type &quot;under Batch 2:&quot; to add a subtask" aria-label="Add a task. Say its stage, or type under, a parent's name and a colon to add a subtask" maxlength="200" autocomplete="off">`;
206
+ const top = o.ro ? '' : (o.ask ? tickAskHtml(o.ask.x, o.ask.n) : '') + (o.fix && !sel.size ? epicSugHtml(o.fix) : '');
170
207
  const loose = o.looseN && !o.ro ? `<p class="pwd-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(o.looseN === 1 ? '1 task with no stage is in the Backlog' : o.looseN + ' tasks with no stage are in the Backlog')}${SV(I.right, 13)}</button></p>` : '';
171
- return cap + `<div class="pwd-list" role="list" aria-label="Work breakdown">${body || (fold ? '' : '<p class="pm-meta pwd-none">No task yet.</p>')}${fold}</div>` + loose;
208
+ return cap + top + `<div class="pwd-list${sel.size ? ' picking' : ''}" role="list" aria-label="Work breakdown">${body || (fold ? '' : '<p class="pm-meta pwd-none">No task yet.</p>')}${fold}</div>` + loose;
172
209
  }
173
210
 
174
211
  /* ── the side column ── */
@@ -87,14 +87,15 @@ export function groupsOf(rows, o = {}) {
87
87
  }
88
88
 
89
89
  const badgeOf = (s) => `<span class="pm-badge${s === 'In progress' || s === 'In review' ? ' blue' : ''}">${esc(s)}</span>`;
90
- function rowHtml(r, nest) {
90
+ function rowHtml(r, nest, sel) {
91
+ const on = !!(sel && sel.has(r.uid));
91
92
  const t = r.open ? `<button type="button" class="wk-tt" data-spopen="${esc(r.uid)}">${esc(r.title)}</button>`
92
93
  : r.url ? `<a class="wk-tt" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title)}</a>` : esc(r.title);
93
94
  const src = r.key ? `<span class="pm-meta code">${esc(r.key)}</span>` : '<span class="pm-chip">Not in Jira</span>';
94
95
  const due = `<span class="pm-row wk-due">${r.due ? `<span class="pm-meta code">${dayText(r.due)}</span>` : ''}${r.late ? `<span class="pm-badge alert">${lateText(r.late)}</span>` : ''}${movedText(r.moved) ? `<span class="pm-badge">${movedText(r.moved).replace(/^m/, 'M')}</span>` : ''}</span>`;
95
- return `<tr class="wk-sr${r.state === 'Done' ? ' wk-dn' : ''}" data-sp="${esc(r.uid)}"><td class="${nest ? 'wk-nest' : ''}"><b>${t}</b></td><td>${esc(r.who) || '<span class="pm-meta">No one</span>'}</td><td>${badgeOf(r.state)}</td><td>${src}</td><td>${due}</td></tr>`;
96
+ return `<tr class="wk-sr${r.state === 'Done' ? ' wk-dn' : ''}${on ? ' sel' : ''}" data-sp="${esc(r.uid)}"${sel && sel.size ? ` aria-selected="${on}"` : ''}><td class="${nest ? 'wk-nest' : ''}"><b>${t}</b></td><td>${esc(r.who) || '<span class="pm-meta">No one</span>'}</td><td>${badgeOf(r.state)}</td><td>${src}</td><td>${due}</td></tr>`;
96
97
  }
97
- /** The Tasks block. o: { tab, group, menu (the Group menu is open), themes } */
98
+ /** The Tasks block. o: { tab, group, menu (the Group menu is open), themes, sel (the picked rows, Set of uid: Cmd, Ctrl or Shift-click picks) } */
98
99
  export function tasksHtml(N, o = {}) {
99
100
  const c = countsOf(N), tab = o.tab || 'all', group = o.group || 'ini';
100
101
  const tabs = `<div class="pm-tabs" role="tablist" aria-label="Show">${TABS.filter(([k]) => k === 'all' || c[k] || k === tab).map(([k, n]) => `<button type="button" class="pm-tab" role="tab" aria-selected="${k === tab}" data-sptab="${k}">${n} <span class="pm-meta">${c[k]}</span></button>`).join('')}</div>`;
@@ -107,7 +108,7 @@ export function tasksHtml(N, o = {}) {
107
108
  const body = GG.map((g) => {
108
109
  const whole = all.find((x) => x.k === g.k) || g;
109
110
  const head = g.name ? `<tr class="wk-g"><td colspan="5"><div class="pm-group"><b>${esc(g.name)}</b> <span class="pm-meta">${whole.rows.filter((r) => r.state === 'Done').length} of ${whole.rows.length} done</span></div></td></tr>` : '';
110
- return head + g.rows.map((r) => rowHtml(r, !!g.name)).join('');
111
+ return head + g.rows.map((r) => rowHtml(r, !!g.name, o.sel)).join('');
111
112
  }).join('');
112
113
  const table = R.length ? `<table class="pm-table wk-spx"><thead><tr><th>Task</th><th>Who</th><th>State</th><th>Source</th><th>Due</th></tr></thead><tbody>${body}</tbody></table>`
113
114
  : '<p class="pm-meta">Nothing here.</p>';
@@ -114,10 +114,10 @@ function nowOf(sp) {
114
114
  return { name: sp.name, label: sp.label, start: null, end: null, rows, jira, other: rows.length - jira, done: 0, total: rows.length };
115
115
  }
116
116
  /** The Tasks block of the sprint shown (WorkSprintDS); '' when a past sprint shows (its list is pastListHtml). */
117
- export function tasksNowHtml() {
117
+ export function tasksNowHtml(sel) {
118
118
  if (!CUR || !CUR.now || CURP) return '';
119
119
  const themes = (CUR.themes || []).filter((t) => !t.spare && (t.uids || []).length).map((t) => ({ id: t.id, name: t.name, uids: t.uids }));
120
- return DS.tasksHtml(CUR.now, { tab: VIEW.tab, group: VIEW.group === 'theme' && !themes.length ? 'ini' : VIEW.group, menu: GMENU, themes });
120
+ return DS.tasksHtml(CUR.now, { tab: VIEW.tab, group: VIEW.group === 'theme' && !themes.length ? 'ini' : VIEW.group, menu: GMENU, themes, sel });
121
121
  }
122
122
 
123
123
  /* ── past sprints (initiative sprint-snapshots) ───────────────────────────────────────────────────────────── */
@@ -245,7 +245,7 @@ export function themeOf() {
245
245
  }
246
246
  export function clearTheme() { THEME = ''; }
247
247
 
248
- /** A press in the Backlog. → true when it was the band's. deps: { post, say, draw, load, reload, readJira, newInitiative, taskOf(uid) } */
248
+ /** A press in the Backlog. → true when it was the band's. deps: { post, say, draw, load, reload, readJira, newInitiative, taskOf(uid), sel, pick(uid, order, e) } */
249
249
  export async function press(e, deps) {
250
250
  const t0 = e.target;
251
251
  const hit = (a) => t0.closest('[' + a + ']');
@@ -323,6 +323,13 @@ export async function press(e, deps) {
323
323
  if (hit('data-spgroup')) { GMENU = !GMENU; deps.draw(); const n = document.querySelector('[data-spgrp][aria-checked="true"]'); if (GMENU && n) n.focus(); return true; }
324
324
  if ((b = hit('data-spgrp'))) { VIEW.group = b.dataset.spgrp; GMENU = false; saveView(); deps.draw(); const n = document.querySelector('[data-spgroup]'); if (n) n.focus(); return true; }
325
325
  if (GMENU) { GMENU = false; deps.draw(); }
326
+ // the bulk move (initiative work-subtasks, WorkBulkDS): Cmd, Ctrl or Shift-click picks a row; with rows picked, a plain click does too.
327
+ // The Backlog's bar moves them, with one Undo.
328
+ const row = t0.closest('tr[data-sp]');
329
+ if (row && deps.pick && (e.metaKey || e.ctrlKey || e.shiftKey || (deps.sel && deps.sel.size)) && !t0.closest('a')) {
330
+ const order = [...document.querySelectorAll('tr[data-sp]')].map((n) => n.dataset.sp);
331
+ if (deps.pick(row.dataset.sp, order, e)) return true;
332
+ }
326
333
  if ((b = hit('data-spopen'))) { const t = deps.taskOf(b.dataset.spopen); if (t && deps.openTask) deps.openTask(t, b); return true; }
327
334
  if ((b = hit('data-spno'))) { const p = CUR.props.find((x) => x.id === b.dataset.spno); return p ? dismiss(p, at, deps) : true; }
328
335
  if ((b = hit('data-spok'))) { const p = CUR.props.find((x) => x.id === b.dataset.spok); return p ? accept(p, b, deps) : true; }
@@ -164,3 +164,7 @@ body.bd-page.bk-on [id="bkBody"] { display: flex; flex-direction: column; gap: v
164
164
  body.bd-page.wk-on .wk-path, body.bd-page.bk-on .wk-path { display: contents; }
165
165
  body.bd-page.wk-on .wk-path > span, body.bd-page.wk-on .wk-path > .pm-ic, body.bd-page.bk-on .wk-path > span, body.bd-page.bk-on .wk-path > .pm-ic { display: none; }
166
166
  }
167
+
168
+ /* This sprint: a picked row (the bulk move, initiative work-subtasks, WorkBulkDS) */
169
+ .wk-spx tr.wk-sr.sel td { background: var(--blue-tint); }
170
+ .wk-spx tr.wk-sr.sel td:first-child { box-shadow: inset 2px 0 0 var(--blue); }
@@ -289,3 +289,15 @@ button.pw-fv .grey { color: var(--cz-ink3); }
289
289
  /* the item's header on a phone: back and the title; the page's ⋯ (cozy-nav.js) holds the item's own ⋯ items */
290
290
  .cz-vw:has(.pw-ph) .cz-vw-hd .cz-vw-tile, .cz-vw:has(.pw-ph) .cz-vw-hd .cz-vw-kind, .cz-vw:has(.pw-ph) .cz-vw-hd [data-cz-vw="discuss"], .cz-vw:has(.pw-ph) .cz-vw-hd [data-cz-vw-p="kind"] { display: none; }
291
291
  }
292
+
293
+ /* subtasks in the Gantt (initiative work-subtasks, WorkSubtasksDS): indent per level, a parent's fold and count, its outlined bar */
294
+ .pw-kr[style*="--pw-d"] .pw-it { padding-left: calc(38px + var(--pw-d) * 18px) !important; }
295
+ .pw-kr.par .pw-it { padding-left: 18px !important; }
296
+ .pw-kr.par[style*="--pw-d"] .pw-it { padding-left: calc(18px + var(--pw-d) * 18px) !important; }
297
+ .pw-chev { width: 20px; height: 20px; flex: none; display: inline-grid; place-items: center; border: 0; background: none; padding: 0; color: var(--cz-ink3); cursor: pointer; border-radius: 4px; }
298
+ .pw-chev:hover { color: inherit; }
299
+ .pw-cnt { color: var(--cz-ink3); white-space: nowrap; }
300
+ .pw-kr.sel { box-shadow: inset 3px 0 0 var(--blue); }
301
+ .pw-pbar { position: absolute; top: 50%; height: 10px; margin-top: -5px; border: 1.5px solid currentColor; border-radius: 3px; box-sizing: border-box; color: var(--cz-ink2); overflow: hidden; }
302
+ .pw-pbar b { display: block; height: 100%; background: currentColor; }
303
+ .pw-pbar.dn { opacity: .6; }
@@ -27,6 +27,8 @@ import * as SW from './cozy-status-when.js'; // When did this happen? after a
27
27
  import * as DP from './cozy-day-pick.js'; // the app's own day field, "15 Oct 2026"
28
28
  const { localToday } = DP;
29
29
  import * as AK from './artefact-kind.js';
30
+ import * as WT from './work-tree.js'; // subtasks, the epic check and its fix (initiative work-subtasks)
31
+ import * as SEL from './work-select.js'; // select several rows and move them together (WorkBulkDS)
30
32
  import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
31
33
 
32
34
  const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
@@ -52,10 +54,13 @@ const store = {
52
54
  // 'pw-cols2': a column choice saved before round 3 (Status and Date hidden by an older tune menu) no longer hides them (round 3 point 5)
53
55
  const COLS = 'pw-cols2', SPAN = 'pw-span', BIG = 'pw-big', TLW = 'pw-tlw';
54
56
  const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true, ...store.get(COLS, {}) });
55
- const ST = new Map(); // initiative id → { open, shut, moreOpen, farOpen, details, top }
57
+ const ST = new Map(); // initiative id → { open, shut, moreOpen, farOpen, details, top, subOpen, subShut, sel, anchor, tickAsk }
58
+ let RSEL = new Set(); // the rows picked in the initiative drawn last (WorkBulkDS)
56
59
  const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
57
60
  const stOf = (id) => {
58
- if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '' });
61
+ if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '',
62
+ // subtasks and the bulk move (initiative work-subtasks): the parents the PM opened or folded, the picked rows, the parent ticked
63
+ subOpen: new Set(), subShut: new Set(), sel: new Set(), anchor: '', tickAsk: '' });
59
64
  return ST.get(id);
60
65
  };
61
66
  const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
@@ -207,6 +212,12 @@ const xOf = (W) => { const a = Date.parse(W.span.a), b = Date.parse(W.span.b); r
207
212
  function barHtml(x, W) {
208
213
  const X = xOf(W);
209
214
  if (x.kind === 'stage') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: x.tone, late: x.late, ms: x.ms, name: x.name, gaps: x.gaps, marks: x.open ? [] : x.marks }, X, { today: W.today }) : '';
215
+ // a parent (WorkSubtasksDS): one outlined bar from its earliest subtask start to its latest end, filled as its subtasks finish
216
+ if (x.kids) {
217
+ if (!x.start && !x.end) return '';
218
+ const l = Math.max(0, X(x.start || x.end)), r = Math.min(100, X(x.end || x.start) + 0.6), f = x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0;
219
+ return `<i class="pw-pbar${x.done ? ' dn' : ''}" style="left:${l.toFixed(2)}%;width:${Math.max(0.8, r - l).toFixed(2)}%" title="${esc(x.title + ': ' + x.count)}"><b style="width:${f}%"></b></i>`;
220
+ }
210
221
  return CB.taskBar(x, X, W.today);
211
222
  }
212
223
  function rowHtml(x, W, C, sugRows) {
@@ -224,7 +235,10 @@ function rowHtml(x, W, C, sugRows) {
224
235
  if (x.kind === 'more') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}${SVG(P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${C.tl ? '<div class="pw-tl"></div>' : ''}</div>`;
225
236
  const s = sugRows.get(x.uid);
226
237
  const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
227
- return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
238
+ // subtasks (WorkSubtasksDS): indent one step per level, a parent's fold and count; a Jira row's key chip and the epic check's dot (WorkJiraDS)
239
+ const chev = x.kids ? `<button type="button" class="pw-chev" data-pw-sub="${esc(x.uid)}" aria-expanded="${!!x.open}" aria-label="${esc((x.open ? 'Fold ' : 'Open ') + x.title)}">${SVG(x.open ? P.down : P.right, 13)}</button>` : '';
240
+ const more2 = (x.kids ? `<small class="pw-cnt">${esc(x.count)}</small>` : '') + PD.keyChip(x) + PD.epicDot(x, W.epics || []);
241
+ return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}${x.kids ? ' par' : ''}${RSEL.has(String(x.uid)) ? ' sel' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"${x.depth ? ` style="--pw-d:${x.depth}"` : ''}><span class="pw-it">${chev}<i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${more2}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
228
242
  + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
229
243
  }
230
244
  function breakdownHtml(W, C, mode, full, S) {
@@ -287,8 +301,9 @@ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
287
301
  function model(r, v, o) {
288
302
  const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
289
303
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
290
- const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
304
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
291
305
  const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
306
+ W.epics = (r.epics || []).filter(Boolean); RSEL = S.sel; // the epic check and the picked rows, for the Gantt rows (initiative work-subtasks)
292
307
  return { W, S, id };
293
308
  }
294
309
  export function html(r, v, o = {}) {
@@ -312,15 +327,39 @@ function stagesOf(r, v, o, S) {
312
327
  }
313
328
  function dsHtml(r, v, o, W, S, C, mode) {
314
329
  const id = keyOf(v, o), view = store.get(VIEW, 'list') === 'gantt' ? 'gantt' : 'list';
315
- const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus }, S);
330
+ const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut }, S);
331
+ // the epic check (WorkJiraDS): the initiative's epics, the ✦ fix unless the PM said no to it; ticking a parent asks once
332
+ const epics = (r.epics || []).filter(Boolean), fix = dropped().has('epic:' + id) ? null : WT.epicFix(st, epics);
333
+ const askRow = S.tickAsk ? st.find((x) => x.uid === S.tickAsk) : null, ask = askRow ? { x: askRow, n: openUnder(stagesOf(r, v, { ...o, today: W.today, subAll: true }), askRow.uid).length } : null;
334
+ const head = (vw) => PD.wbsHead(vw, epics[0] || '', epics[0] ? jiraUrlOf(st, epics[0]) : '');
316
335
  const wbs = view === 'gantt'
317
- ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', PD.wbsHead('gantt')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
318
- : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${PD.wbsHead('list')}${PD.listHtml(st, W, { looseN: W.looseN })}</section>`;
336
+ ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', head('gantt') + (S.sel.size ? SEL.barHtml(S.sel.size) : '')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
337
+ : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${S.sel.size ? '' : head('list')}${PD.listHtml(st, W, { looseN: W.looseN, epics, fix, ask, sel: S.sel, nested: st.some((x) => x.kids) })}</section>`;
319
338
  const mg = mergeOf(W.artefacts), merge = mg ? `<div class="pw-sugs pw-amg" role="list" aria-label="PMOS suggests">${sugLine({ id: mg.id, say: mg.say, merge: mg })}</div>` : '';
320
339
  return `<div class="pw pwd">${'<div class="pwd-main">'}${PD.standsHtml(W, r)}${PD.stagesHtml(st, W)}${wbs}</div>`
321
340
  + `<aside class="pwd-side">${PD.caseHtml(W, { oid: id, dropped: dropped() })}${PD.artsHtml(W.artefacts, { merge })}</aside></div>`;
322
341
  }
323
342
 
343
+ /** The open rows under a parent, at any depth (a parent ticked asks to tick them too). */
344
+ /** A tick on a parent with open subtasks: ask once (true), else write the tick (false). */
345
+ function askKids(c, x, W, S, uid) {
346
+ if (S.tickAsk === uid) return false;
347
+ const kids = openUnder(stagesOf(c.r, c.v, { ...(x.o() || {}), today: W.today, subAll: true }), uid);
348
+ if (!kids.length) return false;
349
+ S.tickAsk = uid; return true;
350
+ }
351
+ function openUnder(rows, uid) {
352
+ const out = [], kids = new Map();
353
+ for (const x of rows || []) if (x.kind === 'task' && x.up) { if (!kids.has(x.up)) kids.set(x.up, []); kids.get(x.up).push(x); }
354
+ const walk = (u) => { for (const k of kids.get(u) || []) { if (!k.done && !k.jira) out.push(k); walk(k.uid); } };
355
+ walk(uid);
356
+ return out;
357
+ }
358
+ /** A Jira link for a key, from any row that carries a link to the same site. */
359
+ function jiraUrlOf(rows, key) {
360
+ const r = (rows || []).find((x) => x && x.jurl && /\/browse\//.test(x.jurl));
361
+ return r ? r.jurl.replace(/\/browse\/[^/?#]+/, '/browse/' + key) : '';
362
+ }
324
363
  /* ── a phone (board Ph2_init; build brief nav-structure/phone/build-brief-v2.md item 8): the popup's content in a phone layout. No cards and
325
364
  * no table: the stage and its days over, the gate line, ✦ Overview with the lines that are written and one proposal for the ones that are not,
326
365
  * the status line and PMOS's proposals, the Work breakdown as rows with a status dot (grey done, blue in progress, an empty ring to do), the
@@ -496,6 +535,13 @@ export function wire(body, h0, x0) {
496
535
  body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
497
536
  body.addEventListener('click', async (e) => {
498
537
  if (!live(e)) return;
538
+ // select several rows (WorkBulkDS): Cmd or Ctrl-click adds one, Shift-click a range; with rows picked, a click adds or takes out one
539
+ { const rw = e.target.closest('[data-pw-row]'), c0 = rw && !e.target.closest('a, input, textarea, [data-pw-tick], [data-pw-sub], [data-pw-row-more], .acts') ? cur() : null;
540
+ if (rw && c0 && !RO && (e.shiftKey || e.metaKey || e.ctrlKey || c0.S.sel.size)) {
541
+ const order = [...body.querySelectorAll('[data-pw-row]')].map((el) => el.dataset.pwRow);
542
+ const pk = SEL.pick(c0.S.sel, order, rw.dataset.pwRow, { shift: e.shiftKey, meta: e.metaKey || e.ctrlKey, anchor: c0.S.anchor });
543
+ if (pk) { e.preventDefault(); c0.S.sel = pk.sel; c0.S.anchor = pk.anchor; redraw(); return; }
544
+ } }
499
545
  const b = e.target.closest('button, [data-pw-line]');
500
546
  // a List row (work-ds-popup): a press on the rest of the row opens the task
501
547
  if (!b) { const li = e.target.closest('[data-pwli]'); if (li && !e.target.closest('input, textarea')) { const c0 = cur(); if (c0) openSmall(li.dataset.pwli, c0, body.__pwh, body.__pwx, body); } return; }
@@ -529,7 +575,19 @@ export function wire(body, h0, x0) {
529
575
  if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
530
576
  if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h, body); return; }
531
577
  // quick edit in the row (work-ds-quick-edit, WorkStatesDS 1 and 3): the tick, Who and Stage
532
- if (d.pwTick) { b.disabled = true; if (h.status) await h.status(d.pwTick, 'Done'); return; }
578
+ // a parent ticked asks once whether to tick its open subtasks too (WorkSubtasksDS)
579
+ // ticking a parent with open subtasks asks once (WorkSubtasksDS); otherwise the tick writes as before
580
+ if (d.pwTick) { if (askKids(c, x, W, S, d.pwTick)) return redraw(); b.disabled = true; S.tickAsk = ''; if (h.status) await h.status(d.pwTick, 'Done'); return; }
581
+ if (d.pwTickAll) {
582
+ const all = stagesOf(c.r, c.v, { ...(x.o() || {}), today: W.today, subAll: true }), row = all.find((q) => q.uid === d.pwTickAll);
583
+ const ids = openUnder(all, d.pwTickAll).map((q) => q.uid).concat(row && !row.jira && !row.done ? [row.uid] : []);
584
+ S.tickAsk = ''; await runBulk(ids, 'done', null, c, h, x); return;
585
+ }
586
+ if ('pwTickNo' in d) { const u = S.tickAsk; S.tickAsk = ''; redraw(); if (u && h.status) await h.status(u, 'Done'); return; }
587
+ if (d.pwSub) { const u = d.pwSub, open = b.getAttribute('aria-expanded') === 'true'; S.subOpen.delete(u); S.subShut.delete(u); (open ? S.subShut : S.subOpen).add(u); redraw(); return; }
588
+ if ('pwEpicFix' in d) { b.disabled = true; await epicFix(c, h, x); return; }
589
+ if ('pwEpicDrop' in d) { const dd = dropped(); dd.add('epic:' + c.id); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
590
+ if (d.wsOp) { await bulkPress(b, d.wsOp, c, h, x); return; }
533
591
  if (d.pwWho) { whoMenu(b, d.pwWho, c, h, x); return; }
534
592
  if (d.pwStage) { stageMenu(b, d.pwStage, c, h, x); return; }
535
593
  if ('pwAddty' in d) { S.msAdd = !S.msAdd; const f = b.closest('.pw-add'), k = f && f.querySelector('[data-pw-add]') && f.querySelector('[data-pw-add]').dataset.pwAdd; redraw(); if (k != null) setTimeout(() => { const i = body.querySelector(`[data-pw-add="${window.CSS.escape(k)}"]`); if (i) i.focus(); }, 0); return; }
@@ -547,10 +605,14 @@ export function wire(body, h0, x0) {
547
605
  body.addEventListener('keydown', async (e) => {
548
606
  if (!live(e)) return;
549
607
  const t = e.target, h = body.__pwh;
608
+ if (e.key === 'Escape') { const c0 = cur(); if (c0 && (c0.S.sel.size || c0.S.tickAsk)) { e.preventDefault(); c0.S.sel.clear(); c0.S.tickAsk = ''; redraw(); return; } }
550
609
  if (t.matches && t.matches('[data-pw-line]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
551
610
  // the List's one capture Input (work-ds-popup): the task goes to the stage it names ("… in Plan"), else the stage in progress
552
611
  if (t.matches && t.matches('[data-pw-cap]') && e.key === 'Enter') {
553
612
  e.preventDefault(); const v0 = t.value.trim(), c = cur(); if (!v0 || !h.addTask || !c) return;
613
+ // "under Batch 2: TM web" adds a subtask (WorkSubtasksDS): it takes its parent's stage
614
+ const all = stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today, subAll: true }), un = WT.parseUnder(v0, all);
615
+ if (un) { await addUnder(un, all, c, h, body.__pwx); setTimeout(() => { const f = body.querySelector('[data-pw-cap]'); if (f) { f.value = ''; f.focus(); } }, 0); return; }
554
616
  const ms = /^◇\s*/.test(v0), k = PD.stageKeyOf(v0.replace(/^◇\s*/, ''), stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today }));
555
617
  if (!k || !k.title) return;
556
618
  await h.addTask(k.title, t, { section: k.key, name: k.name, ...(ms ? { milestone: true } : {}) });
@@ -726,8 +788,13 @@ function rowMenu(btn, uid, c, h, body) {
726
788
  const row = c.W.rows.find((x) => x.uid === uid) || {};
727
789
  openPop(btn, 'pw-rowm', `<button type="button" class="hi-mi" role="menuitem" data-k="status">${SVG(P.box, 14, 2)} Status: ${esc(row.status || 'To do')}</button>`
728
790
  + `<button type="button" class="hi-mi" role="menuitem" data-k="kind">${SVG(row.ms ? P.box : P.dia, 14, 2)} ${row.ms ? 'Make it a task' : 'Make it a milestone'}</button>`
729
- + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>` + jiraNote(row), (b) => {
791
+ + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>`
792
+ // subtasks (WorkSubtasksDS): make it a subtask of another task, or move it out of its parent
793
+ + (row.jsub ? '' : `<button type="button" class="hi-mi" role="menuitem" data-k="under" aria-haspopup="menu">${SVG(P.right, 14)} Make subtask of…</button>`)
794
+ + (row.up && !row.jsub ? `<button type="button" class="hi-mi" role="menuitem" data-k="out">${SVG(P.show, 14)} Move out of ${esc(((c.W.rows.find((q) => q.uid === row.up) || {}).title) || 'its parent')}</button>` : '') + jiraNote(row), (b) => {
730
795
  const k = b.dataset.k;
796
+ if (k === 'under') { parentMenu(btn, [uid], c, h, body.__pwx); return; }
797
+ if (k === 'out') { closePop(); runBulk([uid], 'parent', '', c, h, body.__pwx); return; }
731
798
  // Status opens its own list (and its "when did this happen" line) in place of this menu
732
799
  if (k === 'status') { statusMenu(btn, uid, h, c); return; }
733
800
  closePop();
@@ -735,6 +802,102 @@ function rowMenu(btn, uid, c, h, body) {
735
802
  else if (k === 'open') openSmall(uid, c, h, body.__pwx, body);
736
803
  }, { menu: true, label: 'Task' });
737
804
  }
805
+ /* ── subtasks and the bulk move (initiative work-subtasks; WorkSubtasksDS, WorkBulkDS) ── */
806
+ const atOf = (h, x) => { const o = (x && x.o && x.o()) || {}, w = h.where ? h.where() : {}; return { ws: w.ws || o.ws, board: w.board || o.board, ini: o.id }; };
807
+ /** One bulk write (POST /api/boards/tasks/bulk) with one Undo; the picked rows clear. */
808
+ async function runBulk(ids, op, value, c, h, x, label) {
809
+ const at = atOf(h, x);
810
+ if (c && c.S) { c.S.sel.clear(); c.S.anchor = ''; }
811
+ await SEL.bulk(pmPost, { ws: at.ws, board: at.board }, ids, op, value, { say: (m, u) => (u ? undoToast(m, u) : h.toast ? h.toast(m) : undoToast(m)), reload: async () => { if (h.reload) await h.reload(); else if (h.redraw) h.redraw(); } }, label);
812
+ }
813
+ /** The parents a task can go under: the other tasks of this work, not the picked ones and not under them. "A new parent…" and the top level. */
814
+ function parentMenu(btn, ids, c, h, x) {
815
+ const all = stagesOf(c.r, c.v, { ...((x && x.o && x.o()) || {}), today: c.W.today, subAll: true }).filter((r) => r.kind === 'task' && !r.jsub);
816
+ const pick = new Set(ids), under = new Set();
817
+ const kids = new Map(); for (const r of all) if (r.up) { if (!kids.has(r.up)) kids.set(r.up, []); kids.get(r.up).push(r.uid); }
818
+ const walk = (u) => { for (const k of kids.get(u) || []) { under.add(k); walk(k); } };
819
+ for (const u of ids) walk(u);
820
+ const L = all.filter((r) => !pick.has(r.uid) && !under.has(r.uid)).slice(0, 60);
821
+ const n = ids.length;
822
+ openPop(btn, 'pw-under', `<p class="hi-small">${esc('Move ' + (n === 1 ? 'it' : n + ' tasks') + ' under')}</p>`
823
+ + `<button type="button" class="hi-mi" role="menuitem" data-new>${SVG(P.plus, 14)} A new parent…</button>`
824
+ + L.map((r, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}" style="padding-left:${10 + Math.min(r.depth || 0, 3) * 14}px">${esc(r.title)}${r.kids ? ` <span class="hi-small">${esc(String(r.kids))}</span>` : ''}</button>`).join('')
825
+ + `<button type="button" class="hi-mi" role="menuitem" data-top>Top level (no parent)</button>`, async (b) => {
826
+ if ('new' in b.dataset) { newParent(btn, ids, all, c, h, x); return; }
827
+ closePop();
828
+ if ('top' in b.dataset) { await runBulk(ids, 'parent', '', c, h, x, 'the top level'); return; }
829
+ const r = L[+b.dataset.i]; if (r) await runBulk(ids, 'parent', r.uid, c, h, x, r.title);
830
+ }, { menu: true, label: 'Under a parent' });
831
+ }
832
+ /** A new parent: its name, then it is made in the stage of the first picked task and the picked tasks move under it. */
833
+ function newParent(btn, ids, all, c, h, x) {
834
+ openPop(btn, 'pw-newp', `<label class="hi-small" for="pw-newp-in">The new parent's name</label><input id="pw-newp-in" class="pm-input" data-newp maxlength="200" autocomplete="off" placeholder="Batch 2 · go-live 1 Dec"><div class="pm-row"><button type="button" class="pm-btn primary" data-go aria-label="Make it and move the tasks under it" title="Make it">${SVG(P.plus, 14)}</button></div>`, async (b) => {
835
+ if (!('go' in b.dataset)) return;
836
+ const inp = document.querySelector('[data-newp]'), name = inp ? inp.value.trim() : '';
837
+ if (!name) return;
838
+ closePop();
839
+ const at = atOf(h, x), first = all.find((r) => r.uid === ids[0]);
840
+ const r = await pmPost('/api/boards/tasks/add', { ws: at.ws, board: at.board, initiative: at.ini, title: name, ...(first && first.sec ? { section: first.sec } : {}) }).catch(() => null);
841
+ if (!r || r.ok === false || !r.item) { (h.toast || undoToast)((r && r.error) || 'The parent was not made.'); return; }
842
+ await runBulk(ids, 'parent', r.item.uid, c, h, x, name);
843
+ }, { label: 'A new parent', focus: '[data-newp]' });
844
+ }
845
+ /** "under Batch 2: TM web": a new task under that parent, in its stage. Undo takes it back. */
846
+ async function addUnder(un, all, c, h, x) {
847
+ const at = atOf(h, x), p = all.find((r) => r.uid === un.parent);
848
+ const r = await pmPost('/api/boards/tasks/add', { ws: at.ws, board: at.board, initiative: at.ini, title: un.title, parent: un.parent, ...(p && p.sec ? { section: p.sec } : {}) }).catch(() => null);
849
+ if (!r || r.ok === false || !r.item) { (h.toast || undoToast)((r && r.error) || 'The subtask was not added.'); return; }
850
+ c.S.subOpen.add(un.parent); c.S.subShut.delete(un.parent);
851
+ undoToast(`Added under ${un.parentTitle}: ${un.title}.`, async () => { await pmPost('/api/boards/tasks/undo-add', { ws: at.ws, board: at.board, task: r.item.uid }).catch(() => null); if (h.reload) await h.reload(); });
852
+ if (h.reload) await h.reload();
853
+ }
854
+ /** The bar's presses (WorkBulkDS): under a parent, stage, who, move dates, done, clear. */
855
+ async function bulkPress(btn, op, c, h, x) {
856
+ const S = c.S, ids = [...S.sel];
857
+ if (op === 'clear') { S.sel.clear(); S.anchor = ''; if (h.redraw) h.redraw(); return; }
858
+ if (!ids.length) return;
859
+ if (op === 'done') { await runBulk(ids, 'done', null, c, h, x); return; }
860
+ if (op === 'parent') { parentMenu(btn, ids, c, h, x); return; }
861
+ if (op === 'section') {
862
+ const L = PD.stageList(stagesOf(c.r, c.v, { ...((x && x.o && x.o()) || {}), today: c.W.today }), '');
863
+ openPop(btn, 'pw-bstage', L.map((s2, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}">${esc(s2.name)}</button>`).join('') || '<p class="hi-small">This work has no stages.</p>', async (b) => {
864
+ const s2 = L[+b.dataset.i]; closePop(); if (s2) await runBulk(ids, 'section', s2.key, c, h, x, s2.name);
865
+ }, { menu: true, label: 'Stage' });
866
+ return;
867
+ }
868
+ if (op === 'owner') {
869
+ const L = PD.whoOf(c.W.rows, '').filter((p) => !p.pmos);
870
+ openPop(btn, 'pw-bwho', L.map((p, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}">${SVG(PD.I.who, 14, 2)} ${esc(p.label)}</button>`).join(''), async (b) => {
871
+ const p = L[+b.dataset.i]; closePop(); if (p) await runBulk(ids, 'owner', p.k === 'You' ? '' : p.k, c, h, x, p.label);
872
+ }, { menu: true, label: 'Who' });
873
+ return;
874
+ }
875
+ if (op === 'shift') {
876
+ const Q = [[-7, '1 week earlier'], [-1, '1 day earlier'], [1, '1 day later'], [7, '1 week later']];
877
+ openPop(btn, 'pw-bshift', Q.map(([n, l]) => `<button type="button" class="hi-mi" role="menuitem" data-n="${n}">${esc(l)}</button>`).join('')
878
+ + `<label class="hi-small" for="pw-bshift-in">Or a number of days (+3, -2, 1w)</label><input id="pw-bshift-in" class="pm-input" data-bshift maxlength="12" autocomplete="off"><div class="pm-row"><button type="button" class="pm-btn primary" data-go aria-label="Move the dates" title="Move the dates">${SVG(P.check, 14)}</button></div>`, async (b) => {
879
+ let n = b.dataset.n != null ? +b.dataset.n : null;
880
+ if ('go' in b.dataset) { const i = document.querySelector('[data-bshift]'); n = SEL.shiftOf(i ? i.value : ''); if (n == null) return; }
881
+ if (n == null) return;
882
+ closePop(); await runBulk(ids, 'shift', n, c, h, x);
883
+ }, { label: 'Move dates' });
884
+ }
885
+ }
886
+ /** The epic check's ✦ fix (WorkJiraDS): every flagged ticket goes under the initiative's epic; Undo withdraws what Jira has not done yet. */
887
+ async function epicFix(c, h, x) {
888
+ const o = (x && x.o && x.o()) || {}, at = atOf(h, x), epics = (c.r.epics || []).filter(Boolean);
889
+ const st = stagesOf(c.r, c.v, { ...o, today: c.W.today, subAll: true }), fx = WT.epicFix(st, epics);
890
+ if (!fx) return;
891
+ const tickets = fx.keys.map((k) => { const r = st.find((q) => WT.keyOf(q) === k) || {}; return { key: k, from: r.jepic || '', who: r.jassignee || '' }; });
892
+ const r = await pmPost('/api/jira-epics/fix', { ws: at.ws, ini: at.ini, epic: fx.epic, tickets }).catch(() => null);
893
+ const say = (m, u) => (u ? undoToast(m, u) : h.toast ? h.toast(m) : undoToast(m));
894
+ if (!r || r.ok === false) { say((r && r.error) || 'The fix was not asked.'); if (h.redraw) h.redraw(); return; }
895
+ const dd = dropped(); dd.add('epic:' + c.id); store.set(DROP, [...dd].slice(-200));
896
+ const words = [r.direct.length ? (r.direct.length === 1 ? r.direct[0] + ' moves' : r.direct.length + ' tickets move') + ' under ' + fx.epic + ' in Jira now.' : '',
897
+ r.draft.length ? (r.draft.length === 1 ? r.draft[0].key + ' is' : r.draft.length + ' tickets are') + ' in today\'s Jira draft for ' + [...new Set(r.draft.map((q) => q.who || 'their owner'))].join(', ') + '.' : ''].filter(Boolean).join(' ');
898
+ say(words, async () => { const u = await pmPost('/api/jira-epics/undo', { ws: at.ws, ids: r.ids }).catch(() => null); dd.delete('epic:' + c.id); store.set(DROP, [...dd].slice(-200)); say(u && u.kept && u.kept.length ? 'Put back, except ' + u.kept.join(', ') + ': Jira already has it.' : 'Put back.'); if (h.redraw) h.redraw(); });
899
+ if (h.redraw) h.redraw();
900
+ }
738
901
  /* Who (WorkStatesDS 1): You, the people who own this initiative's tasks, and "PMOS does it". A name writes the owner (Undo puts the old one
739
902
  * back, POST /api/boards/tasks/edit with `from`); PMOS does it gives the task to PMOS (POST /api/backlog/give; Undo is /api/backlog/stop). */
740
903
  function whoMenu(btn, uid, c, h, x) {
@@ -143,7 +143,18 @@ function rowOf(k0, today, J = null) {
143
143
  // planned versus actual (batch 11 item 8, pm/ini-versions.js): the compared version's days where they differ, ⊕ added after it, a draft's task
144
144
  cmp: k.cmp || null, added: !!k.added, dr: !!k.draft,
145
145
  // jkey: the key of the Jira ticket the task is linked to, only when PMOS read that ticket; jst: its own Jira status (it owns the status)
146
- jkey: J ? J.key : '', jst: J ? String(J.raw || J.status || '') : '', jmove: J && J.move ? J.move : null, _k: k0, _t: today }; // jmove: a move asked in PMOS (lib/jira-moves.js)
146
+ jkey: J ? J.key : '', jst: J ? String(J.raw || J.status || '') : '', jmove: J && J.move ? J.move : null, _k: k0, _t: today, // jmove: a move asked in PMOS (lib/jira-moves.js)
147
+ // subtasks and the Jira chip and epic check (initiative work-subtasks): the parent task; the ticket's link, epic (undefined: not read),
148
+ // assignee, type and sub-tasks, from the sprint read (J) or the read of the ticket the task names (k0.jira, lib/board-premium.js jiraOf)
149
+ parent: k0.parent || '', ...jiraFields(J, k0.jira) };
150
+ }
151
+ function jiraFields(J, R) {
152
+ if (!J && !R) return {};
153
+ const pick = (k) => (J && J[k] != null && J[k] !== '' ? J[k] : R && R[k] != null ? R[k] : '');
154
+ const read = (J && 'epic' in J) || (R && 'epic' in R);
155
+ // ckey: the key the row's chip shows: the linked ticket's, else the one the task names that PMOS read (the task keeps its own status then)
156
+ return { ckey: (J && J.key) || (R && R.key) || '', jurl: pick('url'), jassignee: pick('assignee'), jtype: pick('type'), ...(read ? { jepic: pick('epic') || '', jepicName: pick('epicName') } : {}),
157
+ ...(J && J.sub || (R && R.parentTicket) ? { jsubOf: (J && J.parentTicket) || R.parentTicket || '' } : {}), jsubs: (R && R.subs) || (J && J.subs) || [] };
147
158
  }
148
159
  /** The Jira keys a task's title holds ("MSD-4376 Navigation tabs" → ['MSD-4376']). A task whose title names a ticket PMOS read IS that ticket
149
160
  * (linkOf): it shows the Jira mark and the key once, its status is Jira's, and the ticket's own row does not show again (batch 11 item 4,