create-pmos 0.421.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.
- package/package.json +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/anchor-resolve.js +93 -15
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +87 -3
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +13 -11
- package/workspace/briefing-premium-initiative-test.js +30 -38
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/report-api/draft.json +2 -1
- package/workspace/guide/briefing-premium.md +2 -1
- package/workspace/guide/home.md +14 -4
- package/workspace/guide/programs.md +5 -3
- package/workspace/guide/workflows.md +5 -1
- package/workspace/home-other-product-test.js +55 -0
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/board-premium.js +21 -6
- package/workspace/lib/custom-docs.js +65 -3
- package/workspace/lib/doc-live-root.js +37 -0
- package/workspace/lib/engine/anchor-resolve.js +93 -15
- package/workspace/lib/engine/boards.js +30 -2
- package/workspace/lib/engine/intake.js +1 -1
- package/workspace/lib/hold-spans.js +24 -10
- package/workspace/lib/initiative-writer.js +63 -1
- package/workspace/lib/kg.js +1 -1
- package/workspace/lib/plan-items.js +36 -5
- package/workspace/lib/programs.js +11 -3
- package/workspace/lib/report-draft.js +3 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-board-premium.js +28 -0
- package/workspace/lib/routes-boards.js +92 -13
- package/workspace/lib/routes-doc-sheet.js +29 -1
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-programs.js +44 -5
- package/workspace/lib/routes-task-links.js +329 -0
- package/workspace/lib/routes-task-plans.js +333 -0
- package/workspace/lib/split-merge-suggest.js +162 -0
- package/workspace/lib/split-merge.js +379 -0
- package/workspace/lib/task-cli.js +73 -13
- package/workspace/lib/task-items.js +15 -3
- package/workspace/lib/task-links.js +422 -0
- package/workspace/lib/task-plans.js +232 -0
- package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
- package/workspace/lib/vendor/scripts/intake.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-core-doc-issue-test.js +2 -2
- package/workspace/premium-vw-backlog-test.js +3 -3
- package/workspace/premium-vw-doc-test.js +26 -3
- package/workspace/premium-vw-item-test.js +3 -3
- package/workspace/premium-vw-jira-test.js +6 -6
- package/workspace/product-lane-test.js +165 -0
- package/workspace/program-leave-test.js +203 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +5 -2
- package/workspace/public/pm/bd-ini-panel.js +32 -9
- package/workspace/public/pm/bd-prog-panel.js +22 -7
- package/workspace/public/pm/bd-prog.js +6 -1
- package/workspace/public/pm/bd-span.js +234 -30
- package/workspace/public/pm/bd-views.js +3 -2
- package/workspace/public/pm/cozy-board.css +90 -0
- package/workspace/public/pm/cozy-home.css +3 -0
- package/workspace/public/pm/doc-follow.js +36 -0
- package/workspace/public/pm/home-app.js +62 -14
- package/workspace/public/pm/home-ini-model.js +0 -34
- package/workspace/public/pm/home-ini.js +81 -204
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-today.js +3 -1
- package/workspace/public/pm/ini-groups.js +228 -0
- package/workspace/public/pm/ini-links.js +561 -0
- package/workspace/public/pm/ini-tasks.js +131 -30
- package/workspace/public/pm/ini-versions.js +348 -0
- package/workspace/public/pm/ini-view-model.js +113 -43
- package/workspace/public/pm/ini-view.css +341 -18
- package/workspace/public/pm/ini-view.js +153 -38
- package/workspace/public/pm/premium-board.js +160 -21
- package/workspace/public/pm/premium-report-read.js +20 -1
- package/workspace/public/pm/premium-shell.js +29 -4
- package/workspace/public/pm/premium-vw-doc.js +46 -11
- package/workspace/public/pm/prog-move.js +69 -0
- package/workspace/public/pm/split-merge.css +77 -0
- package/workspace/public/pm/split-merge.js +265 -0
- package/workspace/public/pm/stage-line.js +414 -0
- package/workspace/public/pm/task-card.css +3 -0
- package/workspace/public/pm/task-card.js +15 -6
- package/workspace/public/pm/wf-page.css +2 -0
- package/workspace/public/pm/wf-page.js +2 -0
- package/workspace/public/pm/wf-stage.js +2 -1
- package/workspace/server.js +15 -1
- package/workspace/split-merge-ui-test.js +175 -0
- package/workspace/stage-card-test.js +12 -11
- package/workspace/task-card-test.js +3 -2
- package/workspace/task-delete-test.js +126 -0
- package/workspace/task-links-test.js +227 -0
- package/workspace/task-milestones-test.js +176 -0
- package/workspace/task-plans-test.js +181 -0
- package/workspace/task-views-test.js +3 -3
- package/workspace/test-lists/bd-ini-panel.json +8 -2
- package/workspace/test-lists/product-lane.json +6 -0
- package/workspace/test-lists/program-leave.json +6 -0
- package/workspace/test-lists/split-merge.json +15 -0
- package/workspace/test-lists/task-delete.json +5 -0
- package/workspace/test-lists/task-links.json +6 -0
- package/workspace/test-lists/task-milestones.json +6 -0
- package/workspace/test-lists/task-plans.json +6 -0
- package/workspace/test-lists/viewer-live-file.json +9 -0
- package/workspace/timeline-holds-test.js +61 -4
- package/workspace/tk-tasks-test.js +173 -57
- package/workspace/workflows-setup-test.js +4 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* pm/prog-move.js — move an initiative out of its program, or to another one (feedback batch 11 item 2, option A agreed 2026-10-26; canvas
|
|
2
|
+
* LpA1More, LpA2Other, LpA3Done, LpA4Phone, LpA5PhoneDone). The initiative's ⋯ gets the two items on the Board panel (bd-ini-panel.js), the Home
|
|
3
|
+
* initiative page (home-ini.js) and the phone sheet that uses the same menu. "Turn into a program" stays for an initiative in no program.
|
|
4
|
+
*
|
|
5
|
+
* moveItems(o) the ⋯ items, or [] when the initiative is in no program:
|
|
6
|
+
* "Move out of <program>" one press, no confirm (POST /api/programs/member leave)
|
|
7
|
+
* "Move to another program ›" the other open programs, "state · N initiatives"; hidden when there is none
|
|
8
|
+
* o: { programs() GET /api/programs' list, ws the initiative's workspace, id, product the product group it lands in, pmPost, say(msg, undo)
|
|
9
|
+
* the page's toast, reload() the page and its programs read again, openList(anchor, label, rows [{ label, sub, icon, go }]) the page's
|
|
10
|
+
* small menu, phone() true on a phone, stateOf?(p) the program's state from programState }
|
|
11
|
+
* outText(program, product, n, phone) the toast: "Moved out of Project Ascent · now under IDPF · off 1 milestone"; a phone says only
|
|
12
|
+
* "Now under IDPF · off 1 milestone". Zero milestones is silence.
|
|
13
|
+
*
|
|
14
|
+
* The leave also takes the initiative off the charter's milestones that wait on it (lib/routes-programs.js answers `off`): a milestone that waits
|
|
15
|
+
* on an initiative that left could never be done. Undo rejoins the old program with `back` = that list, so the milestones wait on it again; the
|
|
16
|
+
* program's order line still names it, so it comes back to its place. Tasks, the KR anchor, the workflow, Jira links and the chat do not move. */
|
|
17
|
+
import { programOf } from './program-model.js';
|
|
18
|
+
|
|
19
|
+
export const OUT_ICON = 'M14 4h6v6M20 4l-8 8M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5';
|
|
20
|
+
export const LAYERS_ICON = 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5';
|
|
21
|
+
const ms = (n) => (n ? ' · off ' + n + ' milestone' + (n === 1 ? '' : 's') : '');
|
|
22
|
+
|
|
23
|
+
export function outText(p, product, n, phone) {
|
|
24
|
+
if (phone && product) return 'Now under ' + product + ms(n);
|
|
25
|
+
return 'Moved out of ' + p.title + (product ? ' · now under ' + product : '') + ms(n);
|
|
26
|
+
}
|
|
27
|
+
/** The program's line in the list: its state and how many initiatives it holds ("Running · 3 initiatives"). */
|
|
28
|
+
function subOf(o, p) {
|
|
29
|
+
const n = (p.members || []).length, st = o.stateOf ? o.stateOf(p) : null;
|
|
30
|
+
return (st && st.state ? st.state + ' · ' : '') + n + ' initiative' + (n === 1 ? '' : 's');
|
|
31
|
+
}
|
|
32
|
+
/** The workspace of the initiative's member line: the leave goes beside it, where the ledger folds it. */
|
|
33
|
+
const wsIn = (p, o) => ((p.members || []).find((m) => m.initiative === o.id && (!m.ws || !o.ws || m.ws === o.ws)) || {}).ws || o.ws || null;
|
|
34
|
+
|
|
35
|
+
export function moveItems(o) {
|
|
36
|
+
const L = (o.programs && o.programs()) || [], p = o.id ? programOf(L, o.ws || '', o.id) : null;
|
|
37
|
+
if (!p) return [];
|
|
38
|
+
const out = [{ label: 'Move out of ' + p.title, icon: OUT_ICON, on: () => moveOut(o, p) }];
|
|
39
|
+
const others = L.filter((x) => x && x.id !== p.id && !x.archived);
|
|
40
|
+
if (others.length) {
|
|
41
|
+
out.push({ label: 'Move to another program', icon: LAYERS_ICON, note: '›',
|
|
42
|
+
on: (b) => o.openList(b, 'Move to', others.map((x) => ({ label: x.title, sub: subOf(o, x), icon: LAYERS_ICON, go: () => moveInto(o, p, x) }))) });
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function moveOut(o, p) {
|
|
48
|
+
const ws = wsIn(p, o);
|
|
49
|
+
const r = await o.pmPost('/api/programs/member', { ws, program: p.id, initiative: o.id, leave: true }).catch(() => null);
|
|
50
|
+
if (!r || !r.ok) { o.say((r && r.error) || 'It did not move out. The server did not say why.'); return; }
|
|
51
|
+
const off = r.off || [];
|
|
52
|
+
o.say(outText(p, o.product, off.length, o.phone && o.phone()), () => back(o, ws, p, off));
|
|
53
|
+
await o.reload();
|
|
54
|
+
}
|
|
55
|
+
async function moveInto(o, p, to) {
|
|
56
|
+
const ws = wsIn(p, o);
|
|
57
|
+
const r = await o.pmPost('/api/programs/member', { ws, program: to.id, initiative: o.id }).catch(() => null);
|
|
58
|
+
if (!r || !r.ok) { o.say((r && r.error) || 'It did not move. The server did not say why.'); return; }
|
|
59
|
+
const off = (r.left && r.left.off) || [];
|
|
60
|
+
o.say('Moved to ' + to.title + ms(off.length), () => back(o, ws, p, off));
|
|
61
|
+
await o.reload();
|
|
62
|
+
}
|
|
63
|
+
/** Undo: rejoin the old program (which leaves the new one), and wait on the milestones again. */
|
|
64
|
+
async function back(o, ws, p, off) {
|
|
65
|
+
const u = await o.pmPost('/api/programs/member', { ws, program: p.id, initiative: o.id, back: off }).catch(() => null);
|
|
66
|
+
o.say(u && u.ok ? 'Back in ' + p.title + '.' : (u && u.error) || 'The undo did not land.');
|
|
67
|
+
await o.reload();
|
|
68
|
+
return u;
|
|
69
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* pm/split-merge.css — split or merge initiatives (pm/split-merge.js; canvas In development, row "Split or merge initiatives"). split-merge.js
|
|
2
|
+
* loads it once, so it works on the Board and on Home. Token vars only, over pm/cozy.css; Claude's purple is the program's (cozy-panel.css),
|
|
3
|
+
* with the frames' value when the page sets none. Quiet: no motion. Every class starts with sm-. */
|
|
4
|
+
.sm-card, .sm-dot, .sm-v, .sm-gone { --sm-prog: var(--pp-prog, var(--cz-c-6b4fa3)); --sm-progbg: var(--pp-progbg, rgba(107,79,163,.10)); }
|
|
5
|
+
b:has(> .sm-nm), span:has(> .sm-nm) { display: flex; align-items: center; min-width: 0; }
|
|
6
|
+
.sm-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
7
|
+
.sm-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--sm-prog); margin-left: 8px; vertical-align: 2px; flex: none; box-shadow: 0 0 0 2px var(--cz-card); }
|
|
8
|
+
|
|
9
|
+
/* the card under the summary (XsmA1Suggest) */
|
|
10
|
+
.sm-card { background: var(--sm-progbg); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
|
|
11
|
+
.sm-h { display: flex; align-items: center; gap: 8px; color: var(--sm-prog); font-size: 13.5px; }
|
|
12
|
+
.sm-h b { font-weight: 800; }
|
|
13
|
+
.sm-h.q { color: var(--cz-ink3); }
|
|
14
|
+
.sm-why { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--cz-ink2); }
|
|
15
|
+
.sm-pl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--cz-card); font-size: 13px; color: var(--cz-ink3); font-weight: 600; }
|
|
16
|
+
.sm-pl svg { color: var(--sm-prog); flex: none; }
|
|
17
|
+
.sm-pl b { color: var(--cz-ink); font-weight: 800; }
|
|
18
|
+
.sm-acts { display: flex; justify-content: flex-end; gap: 6px; }
|
|
19
|
+
.sm-ib { all: unset; box-sizing: border-box; cursor: pointer; width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink2); background: var(--cz-card); }
|
|
20
|
+
.sm-ib.ok { background: var(--cz-ink); color: var(--cz-card); }
|
|
21
|
+
.sm-ib[disabled] { opacity: .4; cursor: default; }
|
|
22
|
+
@media (hover: hover) { .sm-ib:not([disabled]):hover { color: var(--cz-ink); box-shadow: 0 0 0 1px var(--cz-hair); } .sm-ib.ok:not([disabled]):hover { filter: brightness(1.15); color: var(--cz-card); } }
|
|
23
|
+
.sm-ib:focus-visible, .sm-pk:focus-visible, .sm-gone .sm-lk:focus-visible, .sm-seg button:focus-visible, .sm-cb:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
24
|
+
|
|
25
|
+
/* the merged summary (XsmA7Closed) */
|
|
26
|
+
.sm-gone { background: var(--cz-well); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
|
|
27
|
+
.sm-gone p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--cz-ink2); }
|
|
28
|
+
.sm-gone .sm-lk { all: unset; cursor: pointer; color: var(--cz-blueink); font-weight: 700; }
|
|
29
|
+
|
|
30
|
+
/* the split editor and the merge check (XsmA2Split, XsmA5MergeCheck) */
|
|
31
|
+
.sm-v { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 8px; min-height: 100%; box-sizing: border-box; }
|
|
32
|
+
.sm-nf { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px 0 14px; border-radius: 16px; background: var(--cz-well); color: var(--cz-ink2); }
|
|
33
|
+
.sm-nf input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 17px; font-weight: 800; color: var(--cz-ink); outline: none; }
|
|
34
|
+
.sm-sg, .sm-sg2 { display: inline-flex; color: var(--sm-prog); }
|
|
35
|
+
.sm-sg2 { margin-left: 6px; vertical-align: -1px; }
|
|
36
|
+
.sm-keep { margin: 0 4px; font-size: 12.5px; font-weight: 700; color: var(--cz-ink3); line-height: 1.6; }
|
|
37
|
+
.sm-st { display: inline-flex; align-items: center; gap: 2px; position: relative; }
|
|
38
|
+
.sm-st select { all: unset; cursor: pointer; font: inherit; color: var(--cz-ink2); padding-right: 2px; }
|
|
39
|
+
.sm-list { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--cz-hair); border-radius: 18px; padding: 6px; }
|
|
40
|
+
.sm-gh { display: flex; align-items: center; gap: 10px; padding: 8px 8px 4px; font-size: 12px; font-weight: 800; color: var(--cz-ink3); }
|
|
41
|
+
.sm-gh .n { margin-left: auto; color: var(--cz-blueink); }
|
|
42
|
+
.sm-pk { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px; border-radius: 12px; cursor: pointer; }
|
|
43
|
+
.sm-pk.on { background: var(--cz-bluebg); }
|
|
44
|
+
.sm-t { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
|
|
45
|
+
.sm-t b { font-size: 13.5px; font-weight: 700; color: var(--cz-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
46
|
+
.sm-t span { margin-left: auto; font-size: 12px; color: var(--cz-ink3); font-weight: 600; white-space: nowrap; }
|
|
47
|
+
.sm-cb { all: unset; box-sizing: border-box; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--cz-ink3); background: var(--cz-card); display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--cz-onsolid); cursor: pointer; }
|
|
48
|
+
.sm-cb.on { background: var(--cz-blueink); border-color: var(--cz-blueink); }
|
|
49
|
+
.sm-cb.some { border-color: var(--cz-blueink); }
|
|
50
|
+
.sm-cb.some i { width: 9px; height: 2px; border-radius: 1px; background: var(--cz-blueink); }
|
|
51
|
+
.sm-ki { display: inline-flex; color: var(--cz-ink3); }
|
|
52
|
+
.sm-q { margin: 8px; font-size: 12.5px; color: var(--cz-ink3); }
|
|
53
|
+
.sm-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 2px; }
|
|
54
|
+
.sm-cnt { flex: 1; font-size: 13px; font-weight: 700; color: var(--cz-ink2); }
|
|
55
|
+
.sm-foot .sm-ib { width: 44px; height: 44px; box-shadow: 0 0 0 1px var(--cz-hair); }
|
|
56
|
+
.sm-foot .sm-ib.ok { box-shadow: none; }
|
|
57
|
+
.sm-mc { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--cz-hair); }
|
|
58
|
+
.sm-mc .sm-t { flex-direction: column; gap: 2px; align-items: flex-start; }
|
|
59
|
+
.sm-mc .sm-t span { margin-left: 0; }
|
|
60
|
+
.sm-mc.gone { background: var(--cz-well); }
|
|
61
|
+
.sm-mc.gone b { color: var(--cz-ink2); }
|
|
62
|
+
.sm-mc.stay { border-color: color-mix(in srgb, var(--cz-blueink) 35%, transparent); box-shadow: 0 0 0 3px var(--cz-bluebg); }
|
|
63
|
+
.sm-vi { width: 28px; height: 28px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--cz-bluebg); color: var(--cz-blueink); }
|
|
64
|
+
.sm-mc.gone .sm-vi { background: var(--cz-card); color: var(--cz-ink3); }
|
|
65
|
+
.sm-mid { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -4px 0; color: var(--cz-ink3); }
|
|
66
|
+
.sm-mid .sm-ib { box-shadow: 0 0 0 1px var(--cz-hair); }
|
|
67
|
+
.sm-r { margin: -2px 0 0 4px; font-size: 12px; color: var(--cz-ink3); font-weight: 600; }
|
|
68
|
+
.sm-dfs { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
|
|
69
|
+
.sm-df { display: flex; align-items: center; gap: 10px; }
|
|
70
|
+
.sm-dl { width: 90px; font-size: 12.5px; font-weight: 800; color: var(--cz-ink3); }
|
|
71
|
+
.sm-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--cz-well); gap: 2px; }
|
|
72
|
+
.sm-seg button { all: unset; cursor: pointer; height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--cz-ink3); display: inline-flex; align-items: center; }
|
|
73
|
+
.sm-seg button[aria-checked="true"] { background: var(--cz-card); color: var(--cz-ink); box-shadow: 0 1px 3px rgba(42,46,53,.12); }
|
|
74
|
+
.sm-dn { margin: 0; display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--cz-ink2); line-height: 1.45; }
|
|
75
|
+
.sm-dn svg { color: var(--cz-ink3); flex: none; }
|
|
76
|
+
/* a phone: the Viewer is the full-screen sheet; the touch targets grow to 44 px */
|
|
77
|
+
@media (max-width: 760px) { .sm-ib { width: 44px; height: 44px; } .sm-pk { min-height: 48px; } .sm-card { border-radius: 18px; } }
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* pm/split-merge.js — split one initiative in two, or merge two into one (feedback batch 11 item 14, option A grilled 2026-10-26; canvas
|
|
2
|
+
* In development, row "Split or merge initiatives": XsmA1Suggest, XsmA1Menu, XsmA2Split, XsmA3SplitDone, XsmA5MergeCheck, XsmA7Closed).
|
|
3
|
+
* Claude suggests and the PM approves: the suggestion holds the whole proposal, and one ✓ does it. Nothing is written without a page press.
|
|
4
|
+
*
|
|
5
|
+
* dotHtml(r) the purple dot after a row's name on the Board and Home lists while Claude suggests something for it. Not a "your turn".
|
|
6
|
+
* nameHtml(r, title?) the name and the dot, for a name that clips: the dot stays in view.
|
|
7
|
+
* cardHtml(sg, title) the card under the initiative's summary (pm/ini-view.js draws it): the spark title, a one-line reason, the proposal
|
|
8
|
+
* lines and three icon buttons, ✕ Not now, ✎ Change it first, ✓ Split as suggested / Merge as suggested (data-sm).
|
|
9
|
+
* menuItems(c) the ⋯ items above "Move out of <program>": Split into a new initiative (scissors) and Merge into › (its own program
|
|
10
|
+
* first, then the rest of its board). [] for a row with no record.
|
|
11
|
+
* press(c, act, btn) a card press: 'no' hides the suggestion until the tasks change (POST /api/initiatives/suggest), 'edit' opens the
|
|
12
|
+
* split editor or the merge check with Claude's picks set, 'yes' does it as suggested.
|
|
13
|
+
* c: { row the Board model's row, rows() the open rows of its board, ws, board, product the product's name, program the program it is in
|
|
14
|
+
* or null, pmPost(path, body), say(text, undo?) the page's toast, reload() a new read, openIni(id) select a row and open it,
|
|
15
|
+
* openList(btn, label, rows [{ label, sub, icon, go }]) the page's small menu }
|
|
16
|
+
*
|
|
17
|
+
* The split editor and the merge check are drill-ins of the Viewer (← and ✕ go back to the initiative). After a split the new row is
|
|
18
|
+
* selected and opened; after a merge the one that stays is. Both toasts carry Undo (POST /api/initiatives/sm-undo), which puts both back.
|
|
19
|
+
* On a phone the Viewer is the full-screen sheet, so the card and both views are the phone sheet too. CSS: pm/split-merge.css, loaded here. */
|
|
20
|
+
import * as VW from './cozy-viewer.js';
|
|
21
|
+
|
|
22
|
+
const CSS = new URL('./split-merge.css', import.meta.url).href;
|
|
23
|
+
if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
|
|
24
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
|
|
25
|
+
}
|
|
26
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
27
|
+
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>`;
|
|
28
|
+
export const ICON = {
|
|
29
|
+
spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
|
|
30
|
+
scissors: 'M9 6.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM9 17.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM20 4L8.6 15.4M14.5 14.5L20 20M8.6 8.6L12 12',
|
|
31
|
+
merge: 'M5 4v3a5 5 0 0 0 5 5h9M5 20v-3a5 5 0 0 1 5-5M16 9l3 3-3 3',
|
|
32
|
+
stay: 'M5 12l5 5 9-10',
|
|
33
|
+
x: 'M6 6l12 12M18 6L6 18', edit: 'M4 20h4L19 9l-4-4L4 16zM14 6l4 4', ok: 'M5 12.5l4.5 4.5L19 7.5',
|
|
34
|
+
swap: 'M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7', down: 'M7 10l5 5 5-5', jira: 'M12 3l9 9-9 9-9-9z', doc: 'M7 3h7l5 5v13H7zM14 3v5h5', task: 'M5 5h14v14H5z',
|
|
35
|
+
};
|
|
36
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
37
|
+
/** "3 tasks · 1 ticket · 1 doc": zero is silence. */
|
|
38
|
+
export function countText(k) {
|
|
39
|
+
return [k.tasks ? plural(k.tasks, 'task', 'tasks') : '', k.tickets ? plural(k.tickets, 'ticket', 'tickets') : '', k.docs ? plural(k.docs, 'doc', 'docs') : ''].filter(Boolean).join(' · ');
|
|
40
|
+
}
|
|
41
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
42
|
+
const md = (iso) => (/^\d{4}-\d{2}-\d{2}/.test(String(iso || '')) ? MON[+iso.slice(5, 7) - 1] + ' ' + +iso.slice(8, 10) : '');
|
|
43
|
+
|
|
44
|
+
/* ── the dot and the card ── */
|
|
45
|
+
export function dotHtml(r) {
|
|
46
|
+
const sg = r && r.suggest; if (!sg) return '';
|
|
47
|
+
return `<i class="sm-dot" role="img" aria-label="${esc('Claude suggests: ' + sg.title)}" title="${esc('Claude suggests: ' + sg.title)}"></i>`;
|
|
48
|
+
}
|
|
49
|
+
/** The row's name with the dot: the name clips and the dot stays in view. Without a suggestion, the name alone. */
|
|
50
|
+
export function nameHtml(r, title) {
|
|
51
|
+
const t = esc(title == null ? (r && r.title) || '' : title);
|
|
52
|
+
return r && r.suggest ? `<span class="sm-nm">${t}</span>${dotHtml(r)}` : t;
|
|
53
|
+
}
|
|
54
|
+
export function cardHtml(sg, title) {
|
|
55
|
+
if (!sg || !sg.kind) return '';
|
|
56
|
+
const split = sg.kind === 'split';
|
|
57
|
+
const lines = split
|
|
58
|
+
? [[ICON.scissors, sg.name, countText(sg.counts || {})], [ICON.stay, 'Stays here', sg.stays || '']]
|
|
59
|
+
: [[ICON.stay, sg.intoTitle + ' stays', sg.reason ? 'Because ' + sg.reason : ''], [ICON.merge, (title || 'This one') + ' closes', 'Its work moves; its chats, run log and history stay']];
|
|
60
|
+
const ok = split ? 'Split as suggested' : 'Merge as suggested';
|
|
61
|
+
return `<section class="sm-card" role="region" aria-label="${esc('Claude suggests: ' + sg.title)}"><div class="sm-h">${SVG(ICON.spark, 15)}<b>${esc(sg.title)}</b></div>`
|
|
62
|
+
+ (sg.why ? `<p class="sm-why">${esc(sg.why)}</p>` : '')
|
|
63
|
+
+ lines.map(([d, b, t]) => `<div class="sm-pl">${SVG(d, 15)}<span><b>${esc(b)}</b>${t ? ' · ' + esc(t) : ''}</span></div>`).join('')
|
|
64
|
+
+ `<div class="sm-acts"><button type="button" class="sm-ib" data-sm="no" aria-label="Not now" title="Not now">${SVG(ICON.x, 16)}</button>`
|
|
65
|
+
+ `<button type="button" class="sm-ib" data-sm="edit" aria-label="Change it first" title="Change it first">${SVG(ICON.edit, 16)}</button>`
|
|
66
|
+
+ `<button type="button" class="sm-ib ok" data-sm="yes" aria-label="${ok}" title="${ok}">${SVG(ICON.ok, 16, 2.2)}</button></div></section>`;
|
|
67
|
+
}
|
|
68
|
+
/** The summary of an initiative that was merged (XsmA7Closed): "Merged · Oct 26" and where its work went. */
|
|
69
|
+
export function mergedHtml(m) {
|
|
70
|
+
if (!m || !m.intoId) return '';
|
|
71
|
+
return `<section class="sm-gone" aria-label="Merged"><div class="sm-h q">${SVG(ICON.merge, 15)}<b>Merged${m.at ? ' · ' + esc(m.at) : ''}</b></div>`
|
|
72
|
+
+ `<p>Its tasks, tickets and documents are now in <button type="button" class="sm-lk" data-sm-open="${esc(m.intoId)}">${esc(m.into || m.intoId)}</button>.</p></section>`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ── the ⋯ items ── */
|
|
76
|
+
const along = (r) => (r && r.wfStage && Number.isFinite(r.wfStage.n) ? r.wfStage.n : 0);
|
|
77
|
+
const openOf = (r) => ((r && r.tasks) || []).filter((t) => t.status !== 'Done' && t.status !== "Won't do" && t.status !== 'Archived').length
|
|
78
|
+
+ (((r && r.track && r.track.tickets) || []).filter((k) => k.status !== 'Done').length);
|
|
79
|
+
function targets(c) {
|
|
80
|
+
const me = c.row, mine = new Set(((c.program && c.program.members) || []).map((m) => m && m.initiative));
|
|
81
|
+
const L = (c.rows() || []).filter((x) => x && x.id && x.id !== me.id && !(x.acts && x.acts.archived));
|
|
82
|
+
return L.filter((x) => mine.has(x.id)).concat(L.filter((x) => !mine.has(x.id)));
|
|
83
|
+
}
|
|
84
|
+
export function menuItems(c) {
|
|
85
|
+
if (!c || !c.row || !c.row.id) return [];
|
|
86
|
+
const out = [{ label: 'Split into a new initiative', icon: ICON.scissors, on: () => openSplit(c) }];
|
|
87
|
+
const T = targets(c);
|
|
88
|
+
if (T.length) {
|
|
89
|
+
out.push({ label: 'Merge into', icon: ICON.merge, note: '›', on: (b) => c.openList(b, 'Merge into', T.map((x) => ({ label: x.title, sub: (x.wfStage && x.wfStage.name) || x.stage || '', icon: ICON.merge, go: () => openMerge(c, x.id) }))) });
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ── the card's presses ── */
|
|
95
|
+
export async function press(c, act) {
|
|
96
|
+
const r = c.row, sg = r && r.suggest; if (!sg) return;
|
|
97
|
+
if (act === 'no') {
|
|
98
|
+
// the pressed button holds the focus inside the Viewer, and a host does not redraw a body that holds it
|
|
99
|
+
if (typeof document !== 'undefined' && document.activeElement && document.activeElement.blur) document.activeElement.blur();
|
|
100
|
+
const x = await c.pmPost('/api/initiatives/suggest', { ws: c.ws, id: r.id, of: sg.kind, fp: sg.fp }).catch(() => null);
|
|
101
|
+
if (!x || !x.ok) { c.say((x && x.error) || 'It is still shown. The server did not say why.'); return; }
|
|
102
|
+
c.say('Not now. Claude asks again when the tasks change.');
|
|
103
|
+
await c.reload();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (act === 'edit') { if (sg.kind === 'split') openSplit(c, sg); else openMerge(c, sg.into, sg); return; }
|
|
107
|
+
if (act === 'yes') {
|
|
108
|
+
if (sg.kind === 'split') await doSplit(c, { name: sg.name, tasks: (sg.tasks || []).filter((u) => !isItem(r, u)), tickets: sg.tickets || [], docs: sg.docs || [], items: (sg.tasks || []).filter((u) => isItem(r, u)) });
|
|
109
|
+
else await doMerge(c, r.id, sg.into, {});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const isItem = (r, uid) => !!((r.tasks || []).find((t) => t.uid === uid && t.item));
|
|
113
|
+
|
|
114
|
+
/* ── the writes, each with Undo ── */
|
|
115
|
+
async function doSplit(c, p) {
|
|
116
|
+
const r = c.row;
|
|
117
|
+
const body = { ws: c.ws, from: r.id, name: p.name, tasks: [...(p.tasks || []), ...(p.items || [])], tickets: p.tickets || [], docs: p.docs || [], ...(p.stage ? { stage: p.stage } : {}) };
|
|
118
|
+
const x = await c.pmPost('/api/initiatives/split', body).catch(() => null);
|
|
119
|
+
if (!x || !x.ok) { c.say((x && x.error) || 'Nothing was split. The server did not say why.'); return false; }
|
|
120
|
+
const k = countText(x.counts || {});
|
|
121
|
+
c.say('Split off ' + x.title + (k ? ' · ' + k : ''), () => undo(c, x.undo, r.id));
|
|
122
|
+
await c.reload();
|
|
123
|
+
c.openIni(x.id);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
async function doMerge(c, from, into, p) {
|
|
127
|
+
const x = await c.pmPost('/api/initiatives/merge', { ws: c.ws, from, into, ...(p.anchor ? { anchor: p.anchor } : {}) }).catch(() => null);
|
|
128
|
+
if (!x || !x.ok) { c.say((x && x.error) || 'Nothing was merged. The server did not say why.'); return false; }
|
|
129
|
+
const k = countText(x.counts || {});
|
|
130
|
+
c.say('Merged into ' + (x.title || into) + (k ? ' · ' + k : ''), () => undo(c, x.undo, from));
|
|
131
|
+
await c.reload();
|
|
132
|
+
c.openIni(into);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
async function undo(c, op, back) {
|
|
136
|
+
const u = await c.pmPost('/api/initiatives/sm-undo', { ws: c.ws, undo: op }).catch(() => null);
|
|
137
|
+
c.say(u && u.ok ? 'Undone. Both are as they were.' : (u && u.error) || 'The undo did not land.');
|
|
138
|
+
await c.reload();
|
|
139
|
+
if (u && u.ok && back) c.openIni(back);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* ── the split editor (XsmA2Split): Claude's picks are ticked; the PM only changes them ── */
|
|
143
|
+
function stageKeyOf(t) { return t.section || t.itemStage || (t.from && t.from.stage) || ''; }
|
|
144
|
+
export function splitModel(c, preset) {
|
|
145
|
+
const r = c.row, stages = (r.wfStages || []).map((s) => ({ key: s.key, name: s.name }));
|
|
146
|
+
const tasks = (r.tasks || []).filter((t) => t.status !== 'Archived').map((t) => ({ id: t.uid, title: t.title, sub: [stages.find((s) => s.key === stageKeyOf(t)) ? stages.find((s) => s.key === stageKeyOf(t)).name : '', md(t.end)].filter(Boolean).join(' · '), stage: stageKeyOf(t), item: !!t.item }));
|
|
147
|
+
const tickets = ((r.track && r.track.tickets) || []).map((k) => ({ id: k.key, title: k.key + ' ' + (k.title || ''), sub: [k.status, k.assignee].filter(Boolean).join(' · ') }));
|
|
148
|
+
const pick = new Set([...((preset && preset.tasks) || []), ...((preset && preset.tickets) || []), ...((preset && preset.docs) || [])]);
|
|
149
|
+
return { from: r, stages, tasks, tickets, docs: null, pick, name: (preset && preset.name) || '', stage: '', claude: !!preset };
|
|
150
|
+
}
|
|
151
|
+
/** The stage the new one starts at: the PM's pick, else the earliest of the picked tasks', else the one it is in now. */
|
|
152
|
+
export function startOf(S) {
|
|
153
|
+
if (S.stage) return S.stages.find((s) => s.key === S.stage) || null;
|
|
154
|
+
let best = -1;
|
|
155
|
+
for (const t of S.tasks) if (S.pick.has(t.id)) { const i = S.stages.findIndex((s) => s.key === t.stage); if (i >= 0 && (best < 0 || i < best)) best = i; }
|
|
156
|
+
if (best < 0) { const n = S.from.wfStage && S.from.wfStage.key; best = Math.max(0, S.stages.findIndex((s) => s.key === n)); }
|
|
157
|
+
return S.stages[best] || null;
|
|
158
|
+
}
|
|
159
|
+
function pickRow(x, on, icon) {
|
|
160
|
+
return `<button type="button" class="sm-pk${on ? ' on' : ''}" data-sm-pick="${esc(x.id)}" role="checkbox" aria-checked="${on}"><span class="sm-cb${on ? ' on' : ''}" aria-hidden="true">${on ? SVG(ICON.ok, 13, 2.6) : ''}</span>`
|
|
161
|
+
+ `${icon ? `<span class="sm-ki">${SVG(icon, 15)}</span>` : ''}<span class="sm-t"><b>${esc(x.title)}</b>${x.sub ? `<span>${esc(x.sub)}</span>` : ''}</span></button>`;
|
|
162
|
+
}
|
|
163
|
+
function groupHtml(label, list, S, icon) {
|
|
164
|
+
if (!list || !list.length) return '';
|
|
165
|
+
const n = list.filter((x) => S.pick.has(x.id)).length, all = n === list.length, some = n > 0 && !all;
|
|
166
|
+
return `<div class="sm-gh"><button type="button" class="sm-cb${all ? ' on' : some ? ' some' : ''}" data-sm-all="${esc(label)}" role="checkbox" aria-checked="${all ? 'true' : some ? 'mixed' : 'false'}" aria-label="${esc('Pick all ' + label.toLowerCase())}">${all ? SVG(ICON.ok, 13, 2.6) : some ? '<i></i>' : ''}</button><b>${esc(label)}</b>${n ? `<span class="n">${n}</span>` : ''}</div>`
|
|
167
|
+
+ list.map((x) => pickRow(x, S.pick.has(x.id), icon)).join('');
|
|
168
|
+
}
|
|
169
|
+
export function splitHtml(c, S) {
|
|
170
|
+
const r = S.from, st = startOf(S);
|
|
171
|
+
const keep = [c.product, c.program && c.program.title, (r.kr && r.kr.label) || r.anchor].filter(Boolean);
|
|
172
|
+
const k = { tasks: S.tasks.filter((x) => S.pick.has(x.id)).length, tickets: S.tickets.filter((x) => S.pick.has(x.id)).length, docs: (S.docs || []).filter((x) => S.pick.has(x.id)).length };
|
|
173
|
+
const can = !!(S.name.trim() && (k.tasks || k.tickets || k.docs));
|
|
174
|
+
const stageSel = S.stages.length ? `<label class="sm-st">starts at <select data-sm-stage aria-label="The stage it starts at">${S.stages.map((s) => `<option value="${esc(s.key)}"${st && st.key === s.key ? ' selected' : ''}>${esc(s.name)}</option>`).join('')}</select>${SVG(ICON.down, 13)}</label>` : '';
|
|
175
|
+
return `<div class="sm-v" data-sm-v="split"><div class="sm-nf">${SVG(ICON.scissors, 17)}<input id="smName" type="text" maxlength="120" aria-label="Name of the new initiative" placeholder="Name the new initiative" value="${esc(S.name)}">`
|
|
176
|
+
+ (S.claude && S.name ? `<span class="sm-sg" title="Claude named it from the picked tasks">${SVG(ICON.spark, 15)}</span>` : '') + '</div>'
|
|
177
|
+
+ `<p class="sm-keep">${keep.length ? 'Keeps ' + keep.map(esc).join(' · ') + (stageSel ? ' · ' : '') : ''}${stageSel}</p>`
|
|
178
|
+
+ `<div class="sm-list">${groupHtml('Tasks', S.tasks, S, null)}${groupHtml('Jira tickets', S.tickets, S, ICON.jira)}${S.docs == null ? '<p class="sm-q">Reading the documents…</p>' : groupHtml('Documents', S.docs, S, ICON.doc)}`
|
|
179
|
+
+ (!S.tasks.length && !S.tickets.length && S.docs && !S.docs.length ? '<p class="sm-q">It has no tasks, tickets or documents to move yet.</p>' : '') + '</div>'
|
|
180
|
+
+ `<div class="sm-foot"><span class="sm-cnt">${esc(countText(k) || 'Pick what moves')}</span><button type="button" class="sm-ib" data-sm-x aria-label="Cancel" title="Cancel">${SVG(ICON.x, 17)}</button>`
|
|
181
|
+
+ `<button type="button" class="sm-ib ok" data-sm-go${can ? '' : ' disabled'} aria-label="Split into a new initiative" title="Split">${SVG(ICON.scissors, 17)}</button></div></div>`;
|
|
182
|
+
}
|
|
183
|
+
export function openSplit(c, preset) {
|
|
184
|
+
const S = splitModel(c, preset);
|
|
185
|
+
VW.drill();
|
|
186
|
+
VW.open({ kind: 'Split', title: 'Split ' + c.row.title, icon: ICON.scissors, id: 'sm-split:' + c.row.id, render: (body) => {
|
|
187
|
+
const draw = () => { const f = document.activeElement && document.activeElement.id === 'smName'; body.innerHTML = splitHtml(c, S); if (f) { const i = body.querySelector('#smName'); i.focus(); i.setSelectionRange(i.value.length, i.value.length); } };
|
|
188
|
+
draw();
|
|
189
|
+
fetch('/api/custom-docs?ws=' + encodeURIComponent(c.ws || '') + '&scope=' + encodeURIComponent('initiative:' + c.row.id), { credentials: 'same-origin' }).then((x) => x.json()).catch(() => null).then((x) => {
|
|
190
|
+
S.docs = x && x.ok ? (x.docs || []).map((d) => ({ id: d.id, title: d.title, sub: d.writer || '' })) : [];
|
|
191
|
+
draw();
|
|
192
|
+
});
|
|
193
|
+
body.oninput = (e) => { if (e.target.id === 'smName') { S.name = e.target.value; S.claude = false; const g = body.querySelector('[data-sm-go]'); if (g) g.disabled = !(S.name.trim() && S.pick.size); const s = body.querySelector('.sm-sg'); if (s) s.remove(); } };
|
|
194
|
+
body.onchange = (e) => { if (e.target.matches('[data-sm-stage]')) { S.stage = e.target.value; } };
|
|
195
|
+
body.onclick = async (e) => {
|
|
196
|
+
const b = e.target.closest('button'); if (!b) return;
|
|
197
|
+
const d = b.dataset;
|
|
198
|
+
if (d.smPick) { if (S.pick.has(d.smPick)) S.pick.delete(d.smPick); else S.pick.add(d.smPick); draw(); return; }
|
|
199
|
+
if (d.smAll) { const L = d.smAll === 'Tasks' ? S.tasks : d.smAll === 'Jira tickets' ? S.tickets : S.docs || []; const all = L.every((x) => S.pick.has(x.id)); for (const x of L) { if (all) S.pick.delete(x.id); else S.pick.add(x.id); } draw(); return; }
|
|
200
|
+
if ('smX' in d) { VW.back(); return; }
|
|
201
|
+
if ('smGo' in d) {
|
|
202
|
+
b.disabled = true;
|
|
203
|
+
const ok = await doSplit(c, { name: S.name.trim(), stage: S.stage || '', tasks: S.tasks.filter((x) => S.pick.has(x.id)).map((x) => x.id), tickets: S.tickets.filter((x) => S.pick.has(x.id)).map((x) => x.id), docs: (S.docs || []).filter((x) => S.pick.has(x.id)).map((x) => x.id) });
|
|
204
|
+
if (!ok) b.disabled = false;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
} });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* ── the merge check (XsmA5MergeCheck): the one that closes on top, the one that stays under it; only the real differences ── */
|
|
211
|
+
const hasPrd = (r) => !!((r && r.trail && r.trail.links && r.trail.links.prd) || (r && r.track && r.track.links && r.track.links.prd) || (r && r.prd));
|
|
212
|
+
export function stayReason(go, stay) {
|
|
213
|
+
if (along(stay) > along(go)) return openOf(stay) > openOf(go) ? 'further along, with more open work' : 'further along';
|
|
214
|
+
if (along(stay) === along(go) && openOf(stay) > openOf(go)) return 'more open work';
|
|
215
|
+
return 'the one you picked';
|
|
216
|
+
}
|
|
217
|
+
export function mergeModel(c, intoId, preset) {
|
|
218
|
+
const rows = c.rows() || [], into = rows.find((x) => x.id === intoId) || null;
|
|
219
|
+
const S = { a: c.row, b: into, anchor: '', claude: !!preset };
|
|
220
|
+
S.anchor = (preset && preset.anchor && into && preset.anchor === ((into.kr && into.kr.label) || into.anchor) ? into.anchor : '') || (into && into.anchor) || '';
|
|
221
|
+
return S;
|
|
222
|
+
}
|
|
223
|
+
function cardOf(r, gone) {
|
|
224
|
+
const k = { tasks: ((r.tasks || []).filter((t) => t.status !== 'Archived')).length, tickets: ((r.track && r.track.tickets) || []).length };
|
|
225
|
+
const sub = gone ? countText(k) || 'Nothing to move' : [(r.wfStage && r.wfStage.name) || r.stage, (r.kr && r.kr.label) || r.anchor].filter(Boolean).join(' · ');
|
|
226
|
+
return `<div class="sm-mc${gone ? ' gone' : ' stay'}"><span class="sm-vi">${SVG(gone ? ICON.merge : ICON.stay, 15)}</span><span class="sm-t"><b>${esc(r.title)}</b><span>${esc(sub)}</span></span></div>`;
|
|
227
|
+
}
|
|
228
|
+
export function mergeHtml(c, S) {
|
|
229
|
+
const a = S.a, b = S.b;
|
|
230
|
+
if (!b) return '<div class="sm-v"><p class="sm-q">That initiative is not on this board any more.</p></div>';
|
|
231
|
+
const lbl = (r) => (r.kr && r.kr.label) || r.anchor || 'No anchor';
|
|
232
|
+
const diffs = [];
|
|
233
|
+
if ((a.anchor || '') !== (b.anchor || '') && a.anchor) {
|
|
234
|
+
const opt = (r) => `<button type="button" role="radio" aria-checked="${S.anchor === (r.anchor || '')}" data-sm-anchor="${esc(r.anchor || '')}">${esc(lbl(r))}${r === b ? `<span class="sm-sg2" title="Claude’s pick">${SVG(ICON.spark, 12)}</span>` : ''}</button>`;
|
|
235
|
+
diffs.push(`<div class="sm-df"><span class="sm-dl">Anchor</span><div class="sm-seg" role="radiogroup" aria-label="Anchor">${opt(a)}${opt(b)}</div></div>`);
|
|
236
|
+
}
|
|
237
|
+
const prd = hasPrd(a) && hasPrd(b) ? `<p class="sm-dn">${SVG(ICON.doc, 15)}Both have a PRD. ${esc(b.title)}’s stays the PRD; the other joins its documents.</p>`
|
|
238
|
+
: hasPrd(a) ? `<p class="sm-dn">${SVG(ICON.doc, 15)}Its PRD joins the documents of ${esc(b.title)}.</p>` : '';
|
|
239
|
+
const k = { tasks: ((a.tasks || []).filter((t) => t.status !== 'Archived')).length, tickets: ((a.track && a.track.tickets) || []).length };
|
|
240
|
+
return `<div class="sm-v" data-sm-v="merge">${cardOf(a, true)}<div class="sm-mid">${SVG(ICON.down, 16)}<button type="button" class="sm-ib" data-sm-swap aria-label="${esc('Swap: keep ' + a.title + ' instead')}" title="Swap which one stays">${SVG(ICON.swap, 16)}</button></div>`
|
|
241
|
+
+ `${cardOf(b, false)}<p class="sm-r">Stays: ${esc(stayReason(a, b))}.</p>`
|
|
242
|
+
+ (diffs.length || prd ? `<div class="sm-dfs">${diffs.join('')}${prd}</div>` : '')
|
|
243
|
+
+ `<div class="sm-foot"><span class="sm-cnt">${esc(countText(k) || 'Nothing moves but the record')}</span><button type="button" class="sm-ib" data-sm-x aria-label="Cancel" title="Cancel">${SVG(ICON.x, 17)}</button>`
|
|
244
|
+
+ `<button type="button" class="sm-ib ok" data-sm-go aria-label="${esc('Merge into ' + b.title)}" title="Merge">${SVG(ICON.merge, 17)}</button></div></div>`;
|
|
245
|
+
}
|
|
246
|
+
export function openMerge(c, intoId, preset) {
|
|
247
|
+
const S = mergeModel(c, intoId, preset);
|
|
248
|
+
VW.drill();
|
|
249
|
+
VW.open({ kind: 'Merge', title: 'Merge', icon: ICON.merge, id: 'sm-merge:' + c.row.id, render: (body) => {
|
|
250
|
+
const draw = () => { body.innerHTML = mergeHtml(c, S); };
|
|
251
|
+
draw();
|
|
252
|
+
body.onclick = async (e) => {
|
|
253
|
+
const b = e.target.closest('button'); if (!b) return;
|
|
254
|
+
const d = b.dataset;
|
|
255
|
+
if ('smSwap' in d && S.b) { const t = S.a; S.a = S.b; S.b = t; if (!S.claude || !S.anchor) S.anchor = S.b.anchor || ''; draw(); return; }
|
|
256
|
+
if (d.smAnchor != null) { S.anchor = d.smAnchor; draw(); return; }
|
|
257
|
+
if ('smX' in d) { VW.back(); return; }
|
|
258
|
+
if ('smGo' in d && S.b) {
|
|
259
|
+
b.disabled = true;
|
|
260
|
+
const ok = await doMerge(c, S.a.id, S.b.id, { anchor: S.anchor && S.anchor !== (S.b.anchor || '') ? S.anchor : '' });
|
|
261
|
+
if (!ok) b.disabled = false;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
} });
|
|
265
|
+
}
|