create-pmos 0.422.0 → 0.423.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 (79) 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 +28 -0
  7. package/workspace/briefing-premium-adddoc-test.js +1 -1
  8. package/workspace/briefing-premium-board-test.js +12 -10
  9. package/workspace/briefing-premium-initiative-test.js +30 -38
  10. package/workspace/changelog.json +12 -0
  11. package/workspace/guide/briefing-premium.md +1 -1
  12. package/workspace/guide/home.md +9 -2
  13. package/workspace/guide/programs.md +1 -0
  14. package/workspace/guide/workflows.md +5 -1
  15. package/workspace/ini-workflow-test.js +4 -4
  16. package/workspace/lib/board-premium.js +3 -2
  17. package/workspace/lib/custom-docs.js +65 -3
  18. package/workspace/lib/engine/boards.js +25 -2
  19. package/workspace/lib/initiative-writer.js +63 -1
  20. package/workspace/lib/plan-items.js +36 -5
  21. package/workspace/lib/programs.js +11 -3
  22. package/workspace/lib/route-modules.js +1 -0
  23. package/workspace/lib/routes-board-premium.js +22 -0
  24. package/workspace/lib/routes-boards.js +50 -10
  25. package/workspace/lib/routes-initiatives.js +12 -0
  26. package/workspace/lib/routes-task-links.js +329 -0
  27. package/workspace/lib/split-merge-suggest.js +162 -0
  28. package/workspace/lib/split-merge.js +379 -0
  29. package/workspace/lib/task-cli.js +58 -5
  30. package/workspace/lib/task-items.js +14 -2
  31. package/workspace/lib/task-links.js +422 -0
  32. package/workspace/package-lock.json +2 -2
  33. package/workspace/package.json +1 -1
  34. package/workspace/premium-board-actions-test.js +2 -2
  35. package/workspace/premium-core-doc-issue-test.js +2 -2
  36. package/workspace/premium-vw-backlog-test.js +3 -3
  37. package/workspace/premium-vw-item-test.js +3 -3
  38. package/workspace/premium-vw-jira-test.js +6 -6
  39. package/workspace/product-lane-test.js +165 -0
  40. package/workspace/program-panel-test.js +1 -1
  41. package/workspace/public/pm/bd-ini-panel.js +16 -6
  42. package/workspace/public/pm/bd-prog.js +6 -1
  43. package/workspace/public/pm/bd-span.js +69 -15
  44. package/workspace/public/pm/bd-views.js +3 -2
  45. package/workspace/public/pm/cozy-board.css +10 -0
  46. package/workspace/public/pm/home-app.js +25 -8
  47. package/workspace/public/pm/home-ini-model.js +0 -34
  48. package/workspace/public/pm/home-ini.js +72 -204
  49. package/workspace/public/pm/ini-groups.js +228 -0
  50. package/workspace/public/pm/ini-links.js +561 -0
  51. package/workspace/public/pm/ini-tasks.js +58 -22
  52. package/workspace/public/pm/ini-versions.js +14 -9
  53. package/workspace/public/pm/ini-view-model.js +88 -4
  54. package/workspace/public/pm/ini-view.css +259 -18
  55. package/workspace/public/pm/ini-view.js +140 -32
  56. package/workspace/public/pm/premium-board.js +54 -6
  57. package/workspace/public/pm/split-merge.css +77 -0
  58. package/workspace/public/pm/split-merge.js +265 -0
  59. package/workspace/public/pm/stage-line.js +414 -0
  60. package/workspace/public/pm/task-card.js +5 -3
  61. package/workspace/public/pm/wf-page.css +2 -0
  62. package/workspace/public/pm/wf-page.js +2 -0
  63. package/workspace/public/pm/wf-stage.js +2 -1
  64. package/workspace/server.js +15 -1
  65. package/workspace/split-merge-ui-test.js +175 -0
  66. package/workspace/stage-card-test.js +12 -11
  67. package/workspace/task-card-test.js +3 -2
  68. package/workspace/task-delete-test.js +126 -0
  69. package/workspace/task-links-test.js +227 -0
  70. package/workspace/task-milestones-test.js +1 -1
  71. package/workspace/task-plans-test.js +6 -0
  72. package/workspace/task-views-test.js +1 -1
  73. package/workspace/test-lists/bd-ini-panel.json +8 -2
  74. package/workspace/test-lists/product-lane.json +6 -0
  75. package/workspace/test-lists/split-merge.json +15 -0
  76. package/workspace/test-lists/task-delete.json +5 -0
  77. package/workspace/test-lists/task-links.json +6 -0
  78. package/workspace/tk-tasks-test.js +173 -57
  79. package/workspace/workflows-setup-test.js +4 -3
@@ -0,0 +1,228 @@
1
+ /* pm/ini-groups.js — Group by and Send to Jira in the initiative's Tasks (feedback batch 11 item 20; canvas In development, row "Tasks
2
+ * takes over the old All tasks panel": XtaA1Group, XtaA2Epic, XtaA3Mine, XtaA4NewTask, XtaA5Phone, the rules xtaRules). The old All
3
+ * tasks panel (home-ini.js) is gone; its two jobs live here, in the one Tasks section of Home's page and the Board's panel. The grouping
4
+ * itself is pure (ini-view-model.js groupBy, groupSections); this file reads what it needs, draws the presses and writes the PM's picks.
5
+ *
6
+ * view(v) → v with its Tasks grouped as the PM picked (tasks.by, tasks.sections, tasks.gsum); Stage leaves v as it is
7
+ * headHtml(v) the group icon (layers) in the Tasks header, before the view switch; none while Tasks is empty or has no record id
8
+ * sumHtml(v) By epic's card: "N tickets are drafted, not in Jira" with Send to Jira, or "Sending to Jira" (zero is silence)
9
+ * toolsHtml(sec) what a group's header carries after its fold: ⋯ on the PM's own group, the send icon on an epic with drafted tickets
10
+ * tkRowsHtml(sec) an epic's tickets: a drafted one has no box and opens the draft (tk-draft.js); a sent one shows its key and status
11
+ * tkEmptyHtml(sec) By epic with nothing drafted: Draft the tickets while the PRD has stories, else why there is nothing to draft
12
+ * attach(body, H) once per draw: reads the layout and the tickets for the initiative shown, then H.redraw()
13
+ * press(b, d, root, H) a press this file owns → true: the group icon and its menu, a group's ⋯, the send icons, a ticket, Draft the tickets
14
+ * wireDrag(body) once per body: drag a task between the PM's own groups (List), "Moved to X." with Undo
15
+ *
16
+ * The host gives h.where() → { ws, board }, h.redraw() and h.toast(text, undo?). Writes: POST /api/initiative-layout (by, groups, rename,
17
+ * place, set), POST /api/jira/draft; reads: GET /api/initiative-layout, GET /api/jira/tickets. Every write is the PM's press, file mode. */
18
+ import { pmGet, pmPost } from './http.js';
19
+ import * as VW from './cozy-viewer.js';
20
+ import { groupBy, groupSections, GROUP_BY } from './ini-view-model.js';
21
+ import { readLine } from './tk-model.js';
22
+
23
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
24
+ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
25
+ const P = {
26
+ layers: 'M3 7l9-4 9 4-9 4zM3 12l9 4 9-4M3 17l9 4 9-4', send: 'M4 12l16-8-6 16-3-7zM11 13l9-9', more: 'M5 12h.01M12 12h.01M19 12h.01',
27
+ check: 'M5 12l5 5 9-10', plus: 'M12 5v14M5 12h14', tk: 'M12 3l9 9-9 9-9-9z', draft: 'M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8',
28
+ };
29
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
30
+ const LAY = new Map(); // initiative id → its layout (GET /api/initiative-layout), as the last read or write answered
31
+ const TK = new Map(); // initiative id → its drafted tickets (GET /api/jira/tickets)
32
+ const READING = new Set(); // 'L|id', 'T|id' while a read is on its way
33
+ /** For the tests: forget every read. */
34
+ export const resetGroups = () => { LAY.clear(); TK.clear(); READING.clear(); };
35
+
36
+ const idOk = (id) => /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/.test(String(id || ''));
37
+ const atOf = (H) => (H && H.where ? H.where() || {} : {});
38
+ const q = (at, id) => '?initiative=' + encodeURIComponent(id) + (at.ws ? '&ws=' + encodeURIComponent(at.ws) : '');
39
+ async function readL(id, H) {
40
+ if (READING.has('L|' + id)) return;
41
+ READING.add('L|' + id);
42
+ const r = await pmGet('/api/initiative-layout' + q(atOf(H), id));
43
+ READING.delete('L|' + id);
44
+ LAY.set(id, r && r.ok ? r : { by: 'stage', names: [], of: {}, sets: [] });
45
+ if (H.redraw) H.redraw();
46
+ }
47
+ async function readT(id, H) {
48
+ if (READING.has('T|' + id)) return;
49
+ READING.add('T|' + id);
50
+ const r = await pmGet('/api/jira/tickets' + q(atOf(H), id));
51
+ READING.delete('T|' + id);
52
+ TK.set(id, r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The tickets could not be read.' });
53
+ if (H.redraw) H.redraw();
54
+ }
55
+ /** Reads what the initiative shown needs, once; a redraw follows each answer. */
56
+ export function attach(body, H) {
57
+ const n = body && body.querySelector('[data-iv]'), id = n && n.dataset.iv;
58
+ if (!idOk(id) || !H || !body.querySelector('[data-ig-by]')) return; // no group icon: no record id, or nothing to group
59
+ if (!LAY.has(id)) readL(id, H);
60
+ if (!TK.has(id)) readT(id, H);
61
+ }
62
+ const byOf = (id) => groupBy(LAY.get(id), TK.get(id));
63
+
64
+ /* ── the view ── */
65
+ export function view(v) {
66
+ const id = v && v.id;
67
+ if (!idOk(id) || !v.tasks || v.tasks.empty) return v;
68
+ const by = byOf(id);
69
+ if (by === 'stage') return { ...v, tasks: { ...v.tasks, by } };
70
+ const { sections, sum } = groupSections(v.tasks, by, LAY.get(id), TK.get(id));
71
+ return { ...v, tasks: { ...v.tasks, by, sections, gsum: sum } };
72
+ }
73
+ export function headHtml(v) {
74
+ if (!v || !idOk(v.id) || !v.tasks || v.tasks.empty) return '';
75
+ const by = v.tasks.by || 'stage';
76
+ return `<button type="button" class="iv-ib ig-by${by !== 'stage' ? ' on' : ''}" data-ig-by aria-haspopup="menu" aria-label="Group tasks by" title="${esc('Group tasks by · ' + GROUP_BY[by])}">${SVG(P.layers, 18)}</button>`;
77
+ }
78
+ export function sumHtml(v) {
79
+ const s = v && v.tasks && v.tasks.gsum; if (!s) return '';
80
+ const go = s.primary ? `<button type="button" class="ig-sb" data-ig-sendall>${SVG(P.send, 16)}${esc(s.primary.label)}</button>` : '';
81
+ return `<section class="iv-sum ig-sum" aria-label="Jira"><div class="iv-s1 ${s.tone === 'you' ? 'you' : ''}">${s.tone === 'you' ? '<span class="iv-dot" aria-hidden="true"></span>' : ''}<b>${esc(s.line)}</b></div>`
82
+ + `<p class="iv-why">${esc(s.text)}</p><div class="ig-sf"><span class="iv-meta">${esc(s.meta)}</span>${go}</div></section>`;
83
+ }
84
+ /** A group header's own presses, after the fold. */
85
+ export function toolsHtml(sec) {
86
+ if (sec.mine) return `<button type="button" class="iv-ib ig-gm" data-ig-gmore="${esc(sec.mine)}" aria-haspopup="menu" aria-label="${esc('More for ' + sec.mine)}" title="More">${SVG(P.more, 16, 3)}</button>`;
87
+ if (sec.kind === 'epic' && sec.send) return `<button type="button" class="iv-ib ig-snd" data-ig-send="${esc(sec.gid)}" aria-label="${esc('Send ' + sec.label + ' to Jira')}" title="Send to Jira">${SVG(P.send, 17)}</button>`;
88
+ return '';
89
+ }
90
+ export function tkRowsHtml(sec) {
91
+ return (sec.tk || []).map((r) => {
92
+ const mk = r.inJira ? `<span class="ig-sq ${esc(r.cat || 'todo')}" role="img" aria-label="${esc('In Jira: ' + (r.status || 'To do'))}" title="${esc('Jira · ' + (r.status || 'To do'))}"></span>`
93
+ : `<span class="ig-tkd" role="img" aria-label="Jira ticket drafted, not sent" title="Drafted, not in Jira">${SVG(P.tk, 16)}</span>`;
94
+ const flag = r.mark ? `<span class="ig-mk ${esc(r.mark[0])}" role="img" aria-label="${esc(r.mark[1])}" title="${esc(r.mark[1])}"></span>` : '';
95
+ return `<button type="button" class="iv-tr ig-tk" data-ig-tk="${esc(r.id)}">${mk}<span class="w"><b class="iv-tt">${r.inJira && r.key ? `<em>${esc(r.key)}</em> ` : ''}${esc(r.title)}</b>${!r.inJira && r.sub ? `<span>${esc(r.sub)}</span>` : ''}</span>${flag}`
96
+ + `${r.av ? `<span class="ivt-av" role="img" aria-label="${esc('Assigned to ' + r.who)}" title="${esc(r.who)}">${esc(r.av)}</span>` : ''}</button>`;
97
+ }).join('') + (sec.tkRead && readLine(sec.tkRead) ? `<p class="iv-q ig-read">${esc(readLine(sec.tkRead))}</p>` : '');
98
+ }
99
+ export function tkEmptyHtml(sec) {
100
+ const e = sec.tkEmpty; if (!e) return '';
101
+ if (e.reading) return '<p class="iv-q" role="status">Reading the tickets.</p>';
102
+ if (e.error) return `<p class="iv-q">${esc(e.error)}</p>`;
103
+ if (e.items) return `<div class="ig-emp"><p class="iv-q">The PRD lists ${esc(plural(e.items, 'story', 'stories'))}. Each one becomes a task with its Jira ticket drafted in your template. Nothing goes to Jira until you send it.</p><button type="button" class="iv-pbtn" data-ig-draft>${SVG(P.draft, 16, 2)}Draft the tickets</button></div>`;
104
+ return '<p class="iv-q">The PRD lists no user stories yet. Give it a "User stories" section, one subheading per story, and each one becomes a task here.</p>';
105
+ }
106
+
107
+ /* ── the popover: right under its press; a bottom sheet on a phone (XtaA5Phone) ── */
108
+ let POP = null;
109
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 640px)').matches;
110
+ function closePop() { if (!POP) return; const { el, scrim, anchor } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
111
+ function openPop(anchor, html, onPress, o = {}) {
112
+ closePop();
113
+ const sheet = phone();
114
+ const el = document.createElement('div');
115
+ el.className = 'tkc ivq vs-pop ig-pop' + (sheet ? ' sheet' : ''); el.dataset.escLayer = ''; el.innerHTML = html;
116
+ let scrim = null;
117
+ if (sheet) { scrim = document.createElement('div'); scrim.className = 'vs-scrim'; document.body.appendChild(scrim); }
118
+ document.body.appendChild(el);
119
+ if (!sheet) {
120
+ const r = anchor.getBoundingClientRect(), w = el.offsetWidth, h = el.offsetHeight;
121
+ const left = Math.max(8, Math.min(r.right - w, innerWidth - w - 8)), below = r.bottom + 6 + h <= innerHeight - 8;
122
+ el.style.setProperty('--tl-x', left + 'px'); el.style.setProperty('--tl-y', (below ? r.bottom + 6 : Math.max(8, r.top - 6 - h)) + 'px');
123
+ }
124
+ anchor.setAttribute('aria-expanded', 'true');
125
+ POP = { el, scrim, anchor, onPress };
126
+ const f = el.querySelector(o.focus || '[aria-checked="true"], button'); if (f) f.focus({ preventScroll: true });
127
+ return el;
128
+ }
129
+ if (typeof document !== 'undefined' && document.head) {
130
+ document.addEventListener('pointerdown', (e) => { if (POP && !POP.el.contains(e.target) && !(POP.anchor && POP.anchor.contains(e.target))) closePop(); }, true);
131
+ document.addEventListener('click', (e) => { if (!POP) return; const b = e.target.closest && e.target.closest('button'); if (b && POP.el.contains(b)) POP.onPress(b, e); });
132
+ document.addEventListener('keydown', (e) => {
133
+ if (!POP) return;
134
+ if (e.key === 'Escape') { e.stopPropagation(); const a = POP.anchor; closePop(); if (a && a.isConnected) a.focus(); return; }
135
+ if (e.key === 'Enter' && e.target && e.target.matches && e.target.matches('.ig-pop input')) { e.preventDefault(); const b = POP.el.querySelector('[data-ig-ok]'); if (b) b.click(); }
136
+ }, true);
137
+ addEventListener('resize', () => { if (POP && !POP.scrim) closePop(); });
138
+ }
139
+ /** A menu of rows: { head } a label, { hr } a divider, { label, sub?, on?, radio?, icon?, disabled?, go } a press. The tk-draft.js `ui.menu` too. */
140
+ function menu(anchor, items, label) {
141
+ const html = `<div class="tkc-pop ivq-m ig-m" role="menu" aria-label="${esc(label)}">${items.map((x, i) => (x.head ? `<p class="ig-h">${esc(x.head)}</p>` : x.hr ? '<div class="ig-hr" role="separator"></div>'
142
+ : `<button type="button" role="${x.radio ? 'menuitemradio' : 'menuitem'}" class="o${x.on ? ' hl' : ''}"${x.radio ? ` aria-checked="${!!x.on}"` : ''} data-ig-i="${i}"${x.disabled ? ' disabled' : ''}>`
143
+ + `<span class="ck" aria-hidden="true">${x.icon ? SVG(x.icon, 14, 2.2) : x.on ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(x.label)}</span>${x.sub ? `<span class="k">${esc(x.sub)}</span>` : ''}</button>`)).join('')}</div>`;
144
+ openPop(anchor, html, (b) => { const i = b.dataset.igI; if (i == null) return; const it = items[+i]; if (!it || it.disabled) return; if (!it.keep) closePop(); if (it.go) it.go(anchor); });
145
+ }
146
+ /** One line of words in place of the menu: New group, Rename. The tk-draft.js `ui.ask` too. */
147
+ function ask(anchor, label, value, go, o = {}) {
148
+ const html = `<div class="tkc-pop ig-m ig-ask" role="dialog" aria-label="${esc(label)}"><p class="ig-h">${esc(label)}</p><div class="ig-ar"><input type="text" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}" aria-label="${esc(label)}">`
149
+ + `<button type="button" class="vs-ok" data-ig-ok aria-label="Save" title="Save (Enter)">${SVG(P.check, 16, 2.4)}</button></div></div>`;
150
+ const el = openPop(anchor, html, (b) => { if (!('igOk' in b.dataset)) return; const v = el.querySelector('input').value.trim(); if (!v) return; closePop(); go(v); }, { focus: 'input' });
151
+ }
152
+
153
+ /* ── the writes ── */
154
+ async function lay(id, H, body) {
155
+ const r = await pmPost('/api/initiative-layout', { ws: atOf(H).ws, initiative: id, ...body });
156
+ if (r && r.ok) { LAY.set(id, r); if (H.redraw) H.redraw(); return r; }
157
+ if (H.toast) H.toast((r && r.error) || 'Nothing was changed.');
158
+ return null;
159
+ }
160
+ function groupMenu(b, id, H) {
161
+ const L = LAY.get(id) || { names: [], sets: [] }, T = TK.get(id), by = byOf(id), names = L.names || [];
162
+ const epics = T && T.ok === true ? new Set((T.tickets || []).map((t) => t.epic || '')).size : 0;
163
+ const same = (n) => n.join('|').toLowerCase() === names.join('|').toLowerCase();
164
+ const sets = L.sets || [];
165
+ const newGroup = { label: 'New group', icon: P.plus, keep: true, go: (a) => ask(a, 'Name the group', '', async (v) => { if (await lay(id, H, { kind: 'groups', names: names.concat(v) })) if (by !== 'mine') lay(id, H, { kind: 'by', by: 'mine' }); }) };
166
+ menu(b, [{ head: 'Group by' }, ...Object.entries(GROUP_BY).map(([k, l]) => ({ label: l, radio: true, on: by === k,
167
+ sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by', by: k }) })),
168
+ { hr: true }, ...(sets.length ? [{ head: 'Your group sets' }] : []),
169
+ ...sets.map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : '', go: async () => { if (await lay(id, H, { kind: 'groups', names: s.names })) if (by !== 'mine') lay(id, H, { kind: 'by', by: 'mine' }); } })),
170
+ ...(names.length && !sets.some((s) => same(s.names)) ? [{ label: 'Save these groups as a set', icon: P.plus, go: () => lay(id, H, { kind: 'set', name: names.join(' · '), names }) }] : []),
171
+ newGroup], 'Group tasks by');
172
+ }
173
+ function groupMore(b, id, H, g) {
174
+ const names = (LAY.get(id) || {}).names || [];
175
+ menu(b, [{ label: 'Rename', keep: true, go: (a) => ask(a, 'Rename ' + g, g, (v) => lay(id, H, { kind: 'rename', from: g, to: v })) },
176
+ { label: 'Delete the group', sub: 'Its tasks stay', go: async () => { if (await lay(id, H, { kind: 'groups', names: names.filter((x) => x !== g) }) && H.toast) H.toast(g + ' deleted. Its tasks stay.'); } }], 'More for ' + g);
177
+ }
178
+ async function send(id, H, o = {}) {
179
+ const at = atOf(H), S = await import('./tk-send.js');
180
+ S.openSend({ ws: at.ws, board: at.board, initiative: id, ...o, toast: H.toast,
181
+ onDone: async () => { TK.delete(id); await readT(id, H); setTimeout(() => { TK.delete(id); readT(id, H); }, 4000); } });
182
+ }
183
+ async function openTk(id, H, tid) {
184
+ const at = atOf(H), T = TK.get(id), t = T && T.ok === true ? (T.tickets || []).find((x) => x.id === tid) : null;
185
+ if (t && t.inJira && !t.selectable) { (await import('./premium-vw-jira.js')).openTicket({ ws: at.ws, board: at.board, initiative: id, ref: t.key }); return; }
186
+ const D = await import('./tk-draft.js');
187
+ D.openDraft({ VW, ws: at.ws, initiative: id, id: tid, view: T && T.ok === true ? T : null, toast: H.toast, ui: { menu, ask },
188
+ onChange: () => { TK.delete(id); readT(id, H); }, onSend: (x) => send(id, H, { ticket: x }) });
189
+ }
190
+ export function press(b, d, root, H) {
191
+ const id = root && root.dataset.iv; if (!idOk(id)) return false;
192
+ if ('igBy' in d) { if (POP && POP.anchor === b) closePop(); else groupMenu(b, id, H); return true; }
193
+ if (d.igGmore) { groupMore(b, id, H, d.igGmore); return true; }
194
+ if (d.igSend != null) { send(id, H, { group: d.igSend }); return true; }
195
+ if ('igSendall' in d) { send(id, H); return true; }
196
+ if (d.igTk) { openTk(id, H, d.igTk); return true; }
197
+ if ('igDraft' in d) {
198
+ b.disabled = true;
199
+ pmPost('/api/jira/draft', { ws: atOf(H).ws, initiative: id }).then(async (r) => {
200
+ if (!r || r.ok === false) { b.disabled = false; if (H.toast) H.toast((r && r.error) || 'The tickets were not drafted.'); return; }
201
+ if (H.toast) H.toast(plural(r.tickets, 'ticket', 'tickets') + ' drafted. Nothing is in Jira yet.');
202
+ TK.delete(id); readT(id, H);
203
+ });
204
+ return true;
205
+ }
206
+ return false;
207
+ }
208
+
209
+ /* ── Your groups: drag a task between them (XtaA3Mine), "Moved to X." with Undo ── */
210
+ export function wireDrag(body) {
211
+ if (!body || body.__igDrag) return;
212
+ body.__igDrag = true;
213
+ const zones = () => body.querySelectorAll('.ig-over');
214
+ body.addEventListener('dragstart', (e) => { const r = e.target.closest && e.target.closest('[data-ig-drag]'); if (!r) return; e.dataTransfer.setData('text/plain', r.dataset.igDrag); e.dataTransfer.effectAllowed = 'move'; r.classList.add('drag'); body.__igFrom = r.closest('[data-ig-drop]') ? r.closest('[data-ig-drop]').dataset.igDrop : ''; });
215
+ body.addEventListener('dragend', (e) => { const r = e.target.closest && e.target.closest('[data-ig-drag]'); if (r) r.classList.remove('drag'); zones().forEach((n) => n.classList.remove('ig-over')); body.__igFrom = null; });
216
+ body.addEventListener('dragover', (e) => { const z = e.target.closest && e.target.closest('[data-ig-drop]'); if (!z || body.__igFrom == null) return; e.preventDefault(); zones().forEach((n) => { if (n !== z) n.classList.remove('ig-over'); }); z.classList.add('ig-over'); });
217
+ body.addEventListener('drop', (e) => {
218
+ const z = e.target.closest && e.target.closest('[data-ig-drop]'); if (!z || body.__igFrom == null) return;
219
+ e.preventDefault(); z.classList.remove('ig-over');
220
+ const uid = e.dataTransfer.getData('text/plain'), from = body.__igFrom, to = z.dataset.igDrop, H = body.__iv || {};
221
+ body.__igFrom = null;
222
+ const root = body.querySelector('[data-iv]'), id = root && root.dataset.iv;
223
+ if (!uid || !idOk(id) || from === to) return;
224
+ lay(id, H, { kind: 'place', task: 'task:' + uid, group: to }).then((r) => {
225
+ if (r && H.toast) H.toast('Moved to ' + (to || 'Not in a group') + '.', () => lay(id, H, { kind: 'place', task: 'task:' + uid, group: from }));
226
+ });
227
+ });
228
+ }