create-pmos 0.401.0 → 0.403.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 -30
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/board-programs-test.js +227 -0
- package/workspace/board-shot.js +54 -0
- package/workspace/briefing-premium-adddoc-test.js +28 -22
- package/workspace/briefing-premium-board-test.js +107 -82
- package/workspace/briefing-premium-calendar-2-test.js +23 -10
- package/workspace/briefing-premium-calendar-3-test.js +23 -19
- package/workspace/briefing-premium-calendar-test.js +20 -15
- package/workspace/briefing-premium-initiative-test.js +25 -12
- package/workspace/briefing-premium-insights-test.js +31 -18
- package/workspace/briefing-premium-metrics-test.js +8 -8
- package/workspace/briefing-premium-sources-test.js +15 -10
- package/workspace/briefing-premium-test.js +39 -16
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-premium-facts.js +20 -3
- package/workspace/fixtures/briefing-premium-facts.js +18 -2
- package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
- package/workspace/fixtures/program-ascent.js +101 -0
- package/workspace/guide/home.md +11 -7
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/jira.md +38 -6
- package/workspace/guide/programs.md +37 -0
- package/workspace/home-rows-test.js +184 -0
- package/workspace/lib/briefing-premium-products.js +4 -4
- package/workspace/lib/briefing-premium.js +2 -2
- package/workspace/lib/calendar-layers.js +8 -4
- package/workspace/lib/initiative-layout.js +4 -3
- package/workspace/lib/jira-cli.js +17 -12
- package/workspace/lib/jira-status.js +1 -1
- package/workspace/lib/jira-tickets.js +126 -24
- package/workspace/lib/meeting-files.js +58 -0
- package/workspace/lib/meeting-learn.js +139 -0
- package/workspace/lib/meeting-material.js +12 -5
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/programs.js +129 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-brief-page.js +8 -1
- package/workspace/lib/routes-briefing-premium.js +1 -1
- package/workspace/lib/routes-calendar-views.js +24 -3
- package/workspace/lib/routes-meeting-material.js +38 -0
- package/workspace/lib/routes-meeting-points.js +23 -3
- package/workspace/lib/routes-programs.js +122 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +31 -25
- package/workspace/premium-chat-context-test.js +1 -1
- package/workspace/premium-chat-goal-view-test.js +1 -1
- package/workspace/premium-chat-viewer-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +13 -7
- package/workspace/premium-discuss-landing-test.js +83 -0
- package/workspace/premium-link-suggest-test.js +103 -0
- package/workspace/premium-report-read-test.js +86 -82
- package/workspace/premium-vw-backlog-test.js +6 -5
- package/workspace/premium-vw-cal-test.js +45 -19
- package/workspace/premium-vw-item-test.js +8 -6
- package/workspace/premium-vw-jira-test.js +3 -2
- package/workspace/premium-vw-meet-test.js +122 -66
- package/workspace/premium-vw-notes-test.js +7 -6
- package/workspace/premium-vw-rec-test.js +14 -13
- package/workspace/premium-vw-slides-test.js +11 -5
- package/workspace/program-panel-test.js +152 -0
- package/workspace/public/pm/bd-acts.js +24 -15
- package/workspace/public/pm/bd-asks.js +111 -30
- package/workspace/public/pm/bd-ini-panel.js +229 -0
- package/workspace/public/pm/bd-pop.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +436 -0
- package/workspace/public/pm/bd-prog.js +191 -0
- package/workspace/public/pm/bd-span.js +98 -15
- package/workspace/public/pm/bd-views.js +93 -29
- package/workspace/public/pm/cozy-board.css +214 -20
- package/workspace/public/pm/cozy-evui.js +4 -2
- package/workspace/public/pm/cozy-home-rows.css +54 -0
- package/workspace/public/pm/cozy-home.css +35 -0
- package/workspace/public/pm/cozy-insights.css +1 -2
- package/workspace/public/pm/cozy-mtg-present.css +160 -0
- package/workspace/public/pm/cozy-panel.css +155 -0
- package/workspace/public/pm/cozy-rec-pill.css +12 -0
- package/workspace/public/pm/cozy-rec-pill.js +46 -0
- package/workspace/public/pm/cozy-today.css +189 -0
- package/workspace/public/pm/cozy-viewer.js +307 -43
- package/workspace/public/pm/cozy-vw-mtg.css +96 -94
- package/workspace/public/pm/cozy-vw-rp.css +40 -25
- package/workspace/public/pm/cozy-vw-shell.css +127 -0
- package/workspace/public/pm/cozy-xv.css +51 -0
- package/workspace/public/pm/cozy-xv.js +34 -0
- package/workspace/public/pm/home-app.js +192 -72
- package/workspace/public/pm/home-chat.js +17 -4
- package/workspace/public/pm/home-data.js +1 -1
- package/workspace/public/pm/home-day.js +64 -0
- package/workspace/public/pm/home-ini-model.js +1 -1
- package/workspace/public/pm/home-ini.js +197 -54
- package/workspace/public/pm/home-list.js +100 -27
- package/workspace/public/pm/home-mentions.js +187 -0
- package/workspace/public/pm/home-rec-row.js +67 -0
- package/workspace/public/pm/home-review.js +20 -10
- package/workspace/public/pm/home-task.js +19 -18
- package/workspace/public/pm/home-today.js +137 -59
- package/workspace/public/pm/premium-board.js +294 -288
- package/workspace/public/pm/premium-insights.js +118 -82
- package/workspace/public/pm/premium-mtg-present.js +408 -100
- package/workspace/public/pm/premium-mtg-replay.js +70 -10
- package/workspace/public/pm/premium-report-read.js +118 -63
- package/workspace/public/pm/premium-vw-cal.js +62 -34
- package/workspace/public/pm/premium-vw-mtg.js +348 -192
- package/workspace/public/pm/program-model.js +192 -0
- package/workspace/public/pm/rec-state.js +63 -0
- package/workspace/public/pm/rp-parts.js +33 -8
- package/workspace/public/pm/tk-draft.js +107 -0
- package/workspace/public/pm/tk-model.js +134 -0
- package/workspace/public/pm/tk-send.js +124 -0
- package/workspace/public/pm/tk-tasks.css +120 -0
- package/workspace/public/premium-board.html +4 -2
- package/workspace/server.js +4 -2
- package/workspace/skills/jira-push.skill +3 -3
- package/workspace/test-lists/board-programs.json +9 -0
- package/workspace/test-lists/prd-to-jira.json +6 -0
- package/workspace/test-lists/program-hierarchy.json +11 -0
- package/workspace/test-lists/program-panel.json +9 -0
- package/workspace/test-lists/viewer-home-rows.json +9 -0
- package/workspace/test-lists/viewer-meetings.json +9 -0
- package/workspace/test-lists/viewer-shell-a.json +15 -0
- package/workspace/tk-tasks-test.js +199 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/* pm/bd-prog-panel.js — the program panel on the Board (initiative program-hierarchy, P5, P9; canvas PgProgram, PgMilestones), in the Viewer's
|
|
2
|
+
* shell A since the second kit (initiative viewer-shell-a, V9): the shell's header, summary card and folding rows in place of the panel's own
|
|
3
|
+
* head and tabs. The content is the same. The shell floats at 560 px over the page's right edge and does not push the page.
|
|
4
|
+
*
|
|
5
|
+
* mount(o) once, from premium-board.js. o: { M() the Board model, programs() GET /api/programs' programs, openIni(id, from) the initiative
|
|
6
|
+
* of a row of this board, close() what the shell shows for the Board, reload() reads the programs again, say(msg) the toast }
|
|
7
|
+
*
|
|
8
|
+
* The panel opens on document `bd:program` { id, from? }. A program row of the Board ([data-prog]) and ?program=<id> (Home links there) send
|
|
9
|
+
* that event through pm/bd-prog.js openProgram, the one path that opens it.
|
|
10
|
+
*
|
|
11
|
+
* What it shows, each part only when a record holds something for it:
|
|
12
|
+
* · the shell's header: the program icon, "title · goal" once, Discuss in chat (the question goes to Home), ⋯ and Close. ⋯ holds, in the
|
|
13
|
+
* shell's order: add an initiative, move one in, the charter, copy link, copy as text, and archive (red, last, with a confirmation)
|
|
14
|
+
* · the summary card: the next milestone, else what waits on you; the owner and the span; one primary, "Review the suggested homes", only
|
|
15
|
+
* after Turn into a program while tasks of the initiative it came from have no level yet; Claude sorts them in Home
|
|
16
|
+
* · the goals: the KRs its initiatives anchor to, for one year half with a period picker; the earlier halves fold into one chip
|
|
17
|
+
* · the milestone track: 3 milestones, the earlier done ones in a done cluster and the later ones in "N more"; both open Milestones
|
|
18
|
+
* · the folding rows (were tabs): Waits on you · On the program (its tasks, Done folded) · On its initiatives and On their epics (every
|
|
19
|
+
* open task, by level; each opens in Home) · Initiatives (per product, with their first tasks, what waits on you and their epics) · Milestones (Done, Next, Later; a program check's diamond marks it) · Documents (the charter, the PRDs, …)
|
|
20
|
+
* An initiative in another product is read from that product's board (GET /api/board-premium?ws=). Per product the panel also reads, once per
|
|
21
|
+
* page load: its KRs' names (GET /api/boards/anchors, the OKR files), whether each KR is met (GET /api/insights-premium, the goals Insights
|
|
22
|
+
* shows) and its PMOS tasks (GET /api/boards/items). A part whose read failed is left out, never guessed. Every fold is kept in this browser. */
|
|
23
|
+
import { pmPost } from './http.js';
|
|
24
|
+
import { esc, store } from './premium-shell.js';
|
|
25
|
+
import { programState, milestoneTrack, milestoneGroups, goalsByPeriod, shortDay } from './program-model.js';
|
|
26
|
+
import { STEPS } from './premium-initiative-head.js';
|
|
27
|
+
import * as VW from './cozy-viewer.js';
|
|
28
|
+
import * as Pop from './bd-pop.js';
|
|
29
|
+
import { copyText } from './cozy-xv.js';
|
|
30
|
+
|
|
31
|
+
const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
32
|
+
const I = {
|
|
33
|
+
prog: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5', ask: 'M4 5h16v11H9l-5 4z', doc: 'M7 3h7l5 5v13H7zM14 3v5h5', more: 'M5 12h.01M12 12h.01M19 12h.01',
|
|
34
|
+
x: 'M6 6l12 12M18 6L6 18', chev: 'M7 10l5 5 5-5', chevR: 'M10 7l5 5-5 5', plus: 'M12 5v14M5 12h14', go: 'M5 12h14M13 6l6 6-6 6', out: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
|
|
35
|
+
};
|
|
36
|
+
const FOLD_KEY = 'pmos.board.ppfold';
|
|
37
|
+
const PLAN = STEPS.findIndex((s) => s.key === 'plan');
|
|
38
|
+
const plural = (n, a, b) => (n === 1 ? a : b);
|
|
39
|
+
const initialsOf = (name) => { const w = String(name || '').trim().split(/[\s_-]+/).filter(Boolean); return (w.length > 1 ? w[0][0] + w[1][0] : String(name || '?').slice(0, 2)).toUpperCase(); };
|
|
40
|
+
const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
41
|
+
const daysTo = (iso) => { const d = dayOf(iso); if (!d) return null; const t = new Date(); t.setHours(0, 0, 0, 0); return Math.round((d - t) / 86400000); };
|
|
42
|
+
const lateBy = (d) => -d + ' ' + plural(-d, 'day', 'days') + ' late';
|
|
43
|
+
|
|
44
|
+
let O = null; // mount's options
|
|
45
|
+
let cur = null; // { id, from } the program shown and the element it was opened from
|
|
46
|
+
let period = null; // the year half the goals show (null: the current one)
|
|
47
|
+
let adding = false; // the add-a-task line of "On the program" is open
|
|
48
|
+
const fold = new Set((() => { try { return JSON.parse(store.get(FOLD_KEY) || '[]'); } catch { return []; } })());
|
|
49
|
+
const keepFold = () => store.set(FOLD_KEY, JSON.stringify([...fold].slice(-200)));
|
|
50
|
+
const AWAY = new Map(); // the boards of the other products: ws → { name, board, rows } | 'reading'
|
|
51
|
+
const MORE = new Map(); // per product: ws → { anchors, goals, items, you } (each null until read, or when its read failed)
|
|
52
|
+
|
|
53
|
+
/* ── what the panel reads ── */
|
|
54
|
+
const board = () => (O && O.M() && O.M().board) || {};
|
|
55
|
+
const progOf = (id) => ((O && O.programs()) || []).find((p) => p.id === id) || null;
|
|
56
|
+
/** A product's name and rows for programState. Each row keeps the Board model's own fields (anchor, track, epics, trail) beside its step key. */
|
|
57
|
+
function rowsOf(ws) {
|
|
58
|
+
const M = O.M(); if (!M) return null;
|
|
59
|
+
const steps = M.steps || [];
|
|
60
|
+
const shape = (rows) => (rows || []).filter((r) => r.id).map((r) => ({ ...r, stage: r.track && r.track.k >= 0 && steps[r.track.k] ? steps[r.track.k].key : r.stage }));
|
|
61
|
+
if (!ws || !board().ws || ws === board().ws) return { name: board().product || board().name || '', rows: shape(M.rows), here: true };
|
|
62
|
+
const a = AWAY.get(ws);
|
|
63
|
+
return a && a !== 'reading' ? { name: a.name, rows: shape(a.rows) } : null;
|
|
64
|
+
}
|
|
65
|
+
/** Reads the board of each product of the program that is not this one, once per page load; the panel draws again when one arrives. */
|
|
66
|
+
function readAway(p) {
|
|
67
|
+
for (const m of (p && p.members) || []) {
|
|
68
|
+
const ws = m.ws; if (!ws || ws === board().ws || AWAY.has(ws)) continue;
|
|
69
|
+
AWAY.set(ws, 'reading');
|
|
70
|
+
fetch('/api/board-premium?ws=' + encodeURIComponent(ws), { credentials: 'same-origin' }).then((r) => r.json()).catch(() => null).then((r) => {
|
|
71
|
+
if (!r || !r.ok || !r.model) { AWAY.delete(ws); return; } // still reading, or refused: the next open asks again
|
|
72
|
+
AWAY.set(ws, { name: (r.model.board && (r.model.board.product || r.model.board.name)) || ws, board: (r.model.board && r.model.board.id) || ws, rows: r.model.rows || [] });
|
|
73
|
+
if (cur && cur.id === p.id) draw();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Reads a product's KR names, its Insights goals and its PMOS tasks, once per page load; the panel draws again as each arrives. */
|
|
78
|
+
const getJson = (u) => fetch(u, { credentials: 'same-origin' }).then((r) => (r.status === 200 ? r.json() : null)).catch(() => null);
|
|
79
|
+
function readMore(p) {
|
|
80
|
+
const all = new Set([p.home, ...((p.members || []).map((m) => m.ws))].map((w) => w || board().ws || ''));
|
|
81
|
+
for (const ws of all) {
|
|
82
|
+
if (MORE.has(ws)) continue;
|
|
83
|
+
const here = !ws || ws === board().ws, a = here ? null : AWAY.get(ws);
|
|
84
|
+
const bid = here ? board().id : a && a !== 'reading' ? a.board : null;
|
|
85
|
+
if (!bid) continue; // the other product's board is still being read: asked again when it arrives
|
|
86
|
+
const one = { anchors: null, goals: null, items: null, you: null };
|
|
87
|
+
MORE.set(ws, one);
|
|
88
|
+
const q = 'ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(bid), again = () => { if (cur) draw(true); };
|
|
89
|
+
getJson('/api/boards/anchors?' + q).then((r) => { if (r && r.ok) { one.anchors = r.anchors || []; again(); } });
|
|
90
|
+
getJson('/api/insights-premium?ws=' + encodeURIComponent(ws)).then((r) => { if (r && r.ok && r.model) { one.goals = r.model.goals || []; again(); } });
|
|
91
|
+
getJson('/api/boards/items?' + q).then((r) => { if (r && r.ok) { one.items = r.items || []; again(); } });
|
|
92
|
+
// this board's rows carry what waits on you (the Board merges its trail); another product's rows do not, so its trail is read here
|
|
93
|
+
const ids = here ? [] : (p.members || []).filter((m) => m.ws === ws).map((m) => m.initiative);
|
|
94
|
+
if (ids.length) getJson('/api/board-trail?' + q + '&ids=' + ids.map(encodeURIComponent).join(',')).then((r) => {
|
|
95
|
+
if (!r || !r.ok) return;
|
|
96
|
+
one.you = Object.fromEntries(Object.entries(r.items || {}).filter(([, it]) => it && it.you && it.you.text).map(([id, it]) => [id, it.you.text])); again();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const moreAt = (ws) => MORE.get(ws || board().ws || '') || {};
|
|
101
|
+
/** What waits on you in an initiative: its track's next action that is yours (the Board's trail), or the one its own board's trail says. */
|
|
102
|
+
const youOf = (i) => (i.row.track && i.row.track.you) || (moreAt(i.ws).you || {})[i.id] || '';
|
|
103
|
+
/** What the page knows of a KR (pm/program-model.js goalsByPeriod krsOf): its name from the OKR files, and whether Insights reads it as met.
|
|
104
|
+
* met: its goal reached its target · tone: 'ok' (met or on course) or 'off' (behind); both left out when no Insights goal names the KR. */
|
|
105
|
+
function krsOf(anchor, i) {
|
|
106
|
+
const x = moreAt(i.ws), [, o, k] = String(anchor).split(':'), want = (o + '.' + k).toUpperCase(), out = {};
|
|
107
|
+
const a = (x.anchors || []).find((y) => y.kind === 'kr' && String(y.value).toUpperCase() === want);
|
|
108
|
+
if (a) out.name = String(a.label || '').replace(/^\S+\s+/, '').replace(/\.$/, '');
|
|
109
|
+
const raw = String((i.row && (i.row.anchor || i.row.parent_kr)) || '');
|
|
110
|
+
const g = (x.goals || []).find((y) => y.id === raw || y.title === raw || (y.moves || []).some((m) => m.id === i.id));
|
|
111
|
+
if (g && g.pace) {
|
|
112
|
+
out.met = /^(Reached|Done|Within)/.test(g.pace.head || '');
|
|
113
|
+
out.tone = out.met || g.pace.tone === 'ok' ? 'ok' : g.pace.tone === 'late' ? 'off' : '';
|
|
114
|
+
if (!out.name) out.name = g.title;
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
/** The open PMOS tasks of the program's initiatives (GET /api/boards/items), each with its level: on an epic, or on the initiative itself. */
|
|
119
|
+
function iniTasks(st) {
|
|
120
|
+
const out = [];
|
|
121
|
+
for (const i of st.inis) {
|
|
122
|
+
const items = moreAt(i.ws).items || [];
|
|
123
|
+
for (const t of items) {
|
|
124
|
+
if (t.src !== 'pmos' || t.kind === 'Epic' || t.ini !== i.id || t.status === 'Done') continue;
|
|
125
|
+
const e = t.epic ? items.find((y) => y.uid === t.epic) : null;
|
|
126
|
+
out.push({ uid: t.uid, title: t.title, owner: t.owner || '', due: t.end || '', ini: i, level: t.epic ? 'epic' : 'initiative', epic: e ? e.title || e.key : t.epic || '' });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out.sort((a, b) => String(a.due || '9999').localeCompare(String(b.due || '9999')));
|
|
130
|
+
}
|
|
131
|
+
/** After Turn into a program (p.from names the initiative it came from): that initiative's open tasks on no epic have no level yet. */
|
|
132
|
+
const unsorted = (p, st) => (p.from ? iniTasks(st).filter((t) => t.ini.id === p.from && (!t.ini.ws || !p.home || t.ini.ws === p.home) && t.level === 'initiative').length : 0);
|
|
133
|
+
/** Your program task: its owner is the program's owner (the PM who keeps the charter), or it has none. */
|
|
134
|
+
const mine = (p, t) => !t.owner || (p.owner && t.owner.toLowerCase() === p.owner.toLowerCase());
|
|
135
|
+
const homeHref = (o) => { const q = new URLSearchParams(); for (const [k, v] of Object.entries(o)) if (v) q.set(k, v); return '/premium.html?' + q.toString(); };
|
|
136
|
+
const boardHref = (ws, id) => '/premium-board.html?ws=' + encodeURIComponent(ws) + (id ? '&focus=' + encodeURIComponent(id) : '');
|
|
137
|
+
|
|
138
|
+
/* ── the parts ── */
|
|
139
|
+
/** The products' tiles: the first product blue, the second warm, the third grey, as the frames draw them. */
|
|
140
|
+
const tileHtml = (st, name, cls) => { const j = st.products.indexOf(name); return `<span class="pp-t2 t${j < 0 ? 2 : j % 3}${cls ? ' ' + cls : ''}" aria-hidden="true">${esc(initialsOf(name))}</span>`; };
|
|
141
|
+
function goalsHtml(st) {
|
|
142
|
+
const G = goalsByPeriod(st, krsOf);
|
|
143
|
+
const all = G.periods.concat(G.earlier ? G.earlier.periods : []);
|
|
144
|
+
if (!all.length) return '';
|
|
145
|
+
const on = all.find((h) => h.label === period) || G.periods[0] || all[all.length - 1];
|
|
146
|
+
// the dot: green when Insights reads the KR as met or on course, amber when it is behind; no dot when no goal names it (zero is silence)
|
|
147
|
+
const chip = (g) => { const k = krsOf(g.anchor, st.inis.find((i) => i.id === g.inis[0]) || {}), how = k.met ? 'met' : k.tone === 'ok' ? 'on course' : k.tone === 'off' ? 'behind' : '';
|
|
148
|
+
const dot = k.tone ? `<i class="pp-gd${k.tone === 'off' ? ' off' : ''}" aria-hidden="true"></i>` : '';
|
|
149
|
+
return `<span class="pp-kr" title="${esc([g.products.join(', '), how].filter(Boolean).join(' · '))}"${how ? ` aria-label="${esc(g.kr + (g.name ? ' ' + g.name : '') + ', ' + how)}"` : ''}>${dot}${g.products[0] ? tileHtml(st, g.products[0]) : ''}<b>${esc(g.kr)}</b>${g.name ? esc(g.name) : ''}</span>`; };
|
|
150
|
+
// the picker: only when there is more than one half to pick; the earlier halves fold into one chip that picks the latest of them
|
|
151
|
+
const pick = all.length > 1 ? `<button type="button" class="pp-per" data-pp="period" aria-haspopup="menu" aria-label="Period ${esc(on.label)}. Change period" title="KRs are set per half; the program spans several">${esc(on.label)}${SV(I.chev, 12)}</button>`
|
|
152
|
+
: `<span class="pp-per" title="KRs are set per half; the program spans several">${esc(on.label)}</span>`;
|
|
153
|
+
const early = G.earlier && !G.earlier.periods.includes(on)
|
|
154
|
+
? `<button type="button" class="pp-kr ghost" data-pp="early" data-per="${esc(G.earlier.label)}" aria-label="${G.earlier.n} ${plural(G.earlier.n, 'KR', 'KRs')} from ${esc(G.earlier.label)}${G.earlier.periods.length > 1 ? ' and before' : ''}, ${G.earlier.met} met. Show them">${esc(G.earlier.label)} · ${G.earlier.met} met</button>` : '';
|
|
155
|
+
const menu = O._perOpen ? `<div class="pp-menu pp-pmenu" role="menu" aria-label="Period">${all.slice().sort((a, b) => b.key.localeCompare(a.key)).map((h) => `<button type="button" role="menuitemradio" aria-checked="${h === on}" data-pp="per" data-per="${esc(h.label)}">${esc(h.label)} <span>${h.goals.length}</span></button>`).join('')}</div>` : '';
|
|
156
|
+
return `<div class="pp-goal" role="group" aria-label="Goals: the KRs its initiatives anchor to">${pick}${on.goals.map(chip).join('')}${early}${menu}</div>`;
|
|
157
|
+
}
|
|
158
|
+
/** The readiness dots of a milestone: one per initiative it waits on, filled when that one is past Deliver. */
|
|
159
|
+
const rdHtml = (m) => (m.n ? `<span class="pp-rd" role="img" aria-label="${m.ready} of ${m.n} ${plural(m.n, 'initiative', 'initiatives')} ready">${Array.from({ length: m.n }, (_, j) => `<i${j < m.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : '');
|
|
160
|
+
const waitsLine = (m) => (m.check ? 'A program check, no initiative to wait on' : 'Waits on ' + m.titles.join(' and '));
|
|
161
|
+
function trackHtml(st) {
|
|
162
|
+
if (!st.milestones.length) return '';
|
|
163
|
+
const T = milestoneTrack(st, 3), n = Math.max(1, T.shown.length);
|
|
164
|
+
const lastDone = T.shown.map((m) => m.done).lastIndexOf(true);
|
|
165
|
+
// the filled line runs to halfway between the last done milestone in view and the next one; with none in view, to the done cluster
|
|
166
|
+
const f = T.shown.length && lastDone === T.shown.length - 1 ? lastDone + 0.5 : lastDone >= 0 ? lastDone + 1 : T.done.length ? 0 : -1;
|
|
167
|
+
const cl = (L, done) => (L.length ? `<button type="button" class="pp-cap${done ? ' dn' : ''}" data-pp="ms" aria-label="${L.length} ${done ? 'earlier ' + plural(L.length, 'milestone', 'milestones') + ', done' : 'later ' + plural(L.length, 'milestone', 'milestones')}. Show all milestones"><span class="st3" aria-hidden="true">${L.slice(0, 3).map(() => '<i></i>').join('')}</span>${L.length} ${done ? 'done' : 'more'}</button>` : '<span></span>');
|
|
168
|
+
const one = (m) => `<div class="pp-m${m.late ? ' late' : ''}" title="${esc(waitsLine(m))}${m.check ? '' : ' reaching Deliver'}"><span class="pp-dm${m.done ? ' d' : st.next && m.id === st.next.id ? ' n' : ''}" aria-hidden="true"></span><b>${esc(m.name)}</b><span class="pp-md">${esc(m.day)}${m.done ? '' : rdHtml(m)}</span></div>`;
|
|
169
|
+
return `<div class="pp-sec"><p class="lbl">Program milestones</p><div class="pp-mt" style="--pp-n:${n};--pp-f:${f}"${f < 0 ? ' data-nofill' : ''}>${cl(T.done, true)}${T.shown.map(one).join('')}${cl(T.more, false)}</div></div>`;
|
|
170
|
+
}
|
|
171
|
+
/** What waits on you in the program: your open program tasks, then each initiative's next action that is yours. Each opens in Home. */
|
|
172
|
+
function needs(p, st) {
|
|
173
|
+
const out = [];
|
|
174
|
+
for (const t of st.openTasks.filter((x) => mine(p, x)).sort((a, b) => String(a.due || '9999').localeCompare(String(b.due || '9999')))) {
|
|
175
|
+
const d = daysTo(t.due);
|
|
176
|
+
out.push({ task: true, late: d != null && d < 0, title: t.title, sub: ['On the program', d == null ? '' : d < 0 ? lateBy(d) : d === 0 ? 'due today' : 'due ' + shortDay(t.due)].filter(Boolean).join(' · '),
|
|
177
|
+
href: homeHref({ ws: t.ws || p.home, item: 'pt:' + p.id + ':' + t.key }) });
|
|
178
|
+
}
|
|
179
|
+
for (const i of st.inis) {
|
|
180
|
+
const you = youOf(i); if (!you) continue;
|
|
181
|
+
out.push({ task: false, title: you, sub: i.title, href: homeHref({ ws: i.ws, ask: i.id }) });
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
/* ── the folding rows (were the tabs Tree, Tasks, Milestones, Documents) ── */
|
|
186
|
+
const avHtml = (p, who) => { const you = !who || (p.owner && who.toLowerCase() === p.owner.toLowerCase()); return `<span class="pp-av${you ? ' y' : ''}" role="img" aria-label="${esc(you ? 'You' : who)}">${esc(initialsOf(you ? p.owner || 'You' : who).slice(0, 1))}</span>`; };
|
|
187
|
+
const twHtml = (k) => `<button type="button" class="tw" data-pp="fold" data-fold="${esc(k)}" aria-expanded="${!fold.has(k)}" aria-label="${fold.has(k) ? 'Open' : 'Close'} the group">${SV(fold.has(k) ? I.chevR : I.chev, 14)}</button>`;
|
|
188
|
+
function taskRow(p, t) {
|
|
189
|
+
const d = daysTo(t.due), late = !t.done && d != null && d < 0;
|
|
190
|
+
return `<div class="pp-nd l2${t.done ? ' dn' : ''}" role="treeitem"><button type="button" class="pp-ck${late ? ' late' : ''}${t.done ? ' on' : ''}" data-pp="done" data-key="${esc(t.key)}" data-ws="${esc(t.ws || '')}" data-done="${t.done ? '0' : '1'}" aria-pressed="${!!t.done}" aria-label="${t.done ? 'Open again' : 'Mark done'}: ${esc(t.title)}" title="${t.done ? 'Open again' : 'Done'}"></button><span class="x">${esc(t.title)}</span>${t.due && !t.done ? `<span class="r${late ? ' late' : ''}">${esc(late ? lateBy(d) : shortDay(t.due))}</span>` : ''}${avHtml(p, t.owner)}</div>`;
|
|
191
|
+
}
|
|
192
|
+
const addHtml = () => (adding ? `<form class="pp-nd l2 pp-add" data-pp-form="task"><input name="t" maxlength="200" autocomplete="off" placeholder="A task on the program" aria-label="A task on the program"><button type="submit" class="bd-ib solid" aria-label="Add the task" title="Add">${SV(I.plus, 15)}</button></form>` : '');
|
|
193
|
+
/** An open task of an initiative or an epic: a check box (a task), its title, where it sits, its day and its owner. It opens in Home. */
|
|
194
|
+
function iniTaskRow(p, t, where) {
|
|
195
|
+
const d = daysTo(t.due), late = d != null && d < 0;
|
|
196
|
+
return `<a class="pp-nd l2 pp-tk" role="treeitem" href="${esc(homeHref({ ws: t.ini.ws, ini: t.ini.id }))}" aria-label="Task: ${esc(t.title)}. Opens in Home"><span class="pp-ck${late ? ' late' : ''}" aria-hidden="true"></span><span class="x">${esc(t.title)}</span>${where ? `<span class="r">${esc(where)}</span>` : ''}${t.due ? `<span class="r${late ? ' late' : ''}">${esc(late ? lateBy(d) : shortDay(t.due))}</span>` : ''}${avHtml(p, t.owner)}</a>`;
|
|
197
|
+
}
|
|
198
|
+
const TREE_TASKS = 3; // an initiative shows its first 3 open tasks in the tree; the rest are one press away in "On its initiatives"
|
|
199
|
+
function iniNode(p, st, i, tasks) {
|
|
200
|
+
const k = 'i:' + p.id + ':' + i.id, r = i.row, t = r.track || {}, here = rowsOf(i.ws) && rowsOf(i.ws).here;
|
|
201
|
+
const name = here ? `<button type="button" class="x pp-open" data-pp="ini" data-ini="${esc(i.id)}" aria-haspopup="dialog">${esc(i.title)}</button>` : `<a class="x pp-open" href="${esc(boardHref(i.ws, i.id))}" title="Opens on its product's board">${esc(i.title)}</a>`;
|
|
202
|
+
const stg = t.label || (STEPS[i.at] && STEPS[i.at].label) || i.stage;
|
|
203
|
+
let kids = '';
|
|
204
|
+
if (!fold.has(k)) {
|
|
205
|
+
const you = youOf(i);
|
|
206
|
+
if (you) kids += `<div class="pp-nd l2" role="treeitem"><span class="pp-dt" aria-hidden="true"></span><span class="x">${esc(you)}</span>${avHtml(p, '')}</div>`;
|
|
207
|
+
const mineT = (tasks || []).filter((x) => x.ini === i && x.level === 'initiative');
|
|
208
|
+
kids += mineT.slice(0, TREE_TASKS).map((x) => iniTaskRow(p, x, '')).join('');
|
|
209
|
+
if (mineT.length > TREE_TASKS) kids += `<button type="button" class="pp-nd l2 pp-more" role="treeitem" data-pp="itasks">${mineT.length - TREE_TASKS} more ${plural(mineT.length - TREE_TASKS, 'task', 'tasks')}</button>`;
|
|
210
|
+
const tk = t.tickets || [], done = tk.filter((x) => x.status === 'Done').length;
|
|
211
|
+
const epics = r.epics || [];
|
|
212
|
+
epics.forEach((e, j) => { kids += `<div class="pp-nd l2" role="treeitem"><span class="k">${esc(e)}</span><span class="x">${j === 0 && epics.length === 1 && tk.length ? esc(tk.length + ' ' + plural(tk.length, 'ticket', 'tickets')) : ''}</span>${j === 0 && epics.length === 1 && tk.length ? `<span class="r">${done} of ${tk.length} done</span>` : ''}</div>`; });
|
|
213
|
+
const drafted = ((r.trail && r.trail.drafted) || []).filter((x) => !x.key).length;
|
|
214
|
+
if (drafted) kids += `<div class="pp-nd l2 q" role="treeitem"><span class="x">${drafted} draft ${plural(drafted, 'ticket', 'tickets')}, not in Jira yet</span></div>`;
|
|
215
|
+
if (!epics.length && !drafted) kids += `<div class="pp-nd l2 q" role="treeitem"><span class="x">${i.at >= 0 && i.at < PLAN ? 'No epics yet · they come from the work breakdown at Plan' : 'No epic in Jira yet'}</span></div>`;
|
|
216
|
+
}
|
|
217
|
+
return `<div class="pp-nd ini" role="treeitem" aria-expanded="${!fold.has(k)}">${twHtml(k)}${name}${stg ? `<span class="pp-stg">${esc(stg)}</span>` : ''}</div>${kids}`;
|
|
218
|
+
}
|
|
219
|
+
/** The initiatives, per product, each with its first tasks, what waits on you and its epics; a member no read board holds is listed by its id. */
|
|
220
|
+
function treeHtml(p, st) {
|
|
221
|
+
let h = '';
|
|
222
|
+
const tasks = iniTasks(st);
|
|
223
|
+
const by = new Map();
|
|
224
|
+
for (const i of st.inis) { if (!by.has(i.product)) by.set(i.product, []); by.get(i.product).push(i); }
|
|
225
|
+
for (const [prod, list] of by) h += `<div class="pp-nd prd2" role="presentation">${tileHtml(st, prod)}${esc(prod || 'This board')}</div>` + list.map((i) => iniNode(p, st, i, tasks)).join('');
|
|
226
|
+
// a member no read board holds: listed by its id with its product's board, never guessed
|
|
227
|
+
for (const m of st.missing) h += `<div class="pp-nd ini q" role="treeitem"><span class="tw"></span><a class="x pp-open" href="${esc(boardHref(m.ws, m.initiative))}" title="Opens on its product's board">${esc(m.initiative)}</a><span class="r">${AWAY.get(m.ws) === 'reading' ? 'reading its board' : 'not read'}</span></div>`;
|
|
228
|
+
return h ? `<div class="pp-tree" role="tree" aria-label="${esc(p.title)}">${h}</div>` : '';
|
|
229
|
+
}
|
|
230
|
+
/** The program's own tasks: the open ones, the add line, and the done ones folded. */
|
|
231
|
+
function tasksHtml(p, st) {
|
|
232
|
+
const done = st.tasks.filter((t) => t.done), dk = 'd:' + p.id;
|
|
233
|
+
const add = adding ? addHtml() : `<button type="button" class="pp-nd pp-doc" data-pp="add">${SV(I.plus, 15)}<span class="x">Add a task</span></button>`;
|
|
234
|
+
if (!st.tasks.length && !adding) return `<div class="pp-tree"><div class="pp-nd q"><span class="x">No task on the program itself. Its initiatives keep their own tasks in Home.</span><button type="button" class="bd-ib pp-ibs" data-pp="add" aria-label="Add a task to the program" title="Add a task">${SV(I.plus, 15)}</button></div></div>`;
|
|
235
|
+
return `<div class="pp-tree" role="tree" aria-label="Tasks on the program">${st.openTasks.map((t) => taskRow(p, t)).join('')}${add}`
|
|
236
|
+
+ (done.length ? `<div class="pp-nd ini" role="treeitem" aria-expanded="${!fold.has(dk)}">${twHtml(dk)}<span class="x">Done on the program</span><span class="r">${done.length}</span></div>${fold.has(dk) ? '' : done.map((t) => taskRow(p, t)).join('')}` : '') + '</div>';
|
|
237
|
+
}
|
|
238
|
+
/** The open tasks of its initiatives at one level (on the initiative, or on one of its epics); each opens in Home, where its initiative keeps it. */
|
|
239
|
+
function levelHtml(p, L, label) {
|
|
240
|
+
return `<div class="pp-tree" role="tree" aria-label="${esc(label)}">${L.map((t) => iniTaskRow(p, t, t.level === 'epic' ? [t.epic, t.ini.title].filter(Boolean).join(' · ') : t.ini.title)).join('')}</div>`;
|
|
241
|
+
}
|
|
242
|
+
function msHtml(st) {
|
|
243
|
+
const G = milestoneGroups(st);
|
|
244
|
+
return `<div class="pp-ml" role="list">${G.map((g) => {
|
|
245
|
+
const k = 'm:' + st.id + ':' + g.key;
|
|
246
|
+
return `<button type="button" class="pp-mg" data-pp="fold" data-fold="${esc(k)}" aria-expanded="${!fold.has(k)}">${SV(fold.has(k) ? I.chevR : I.chev, 12)}${esc(g.label)} · ${g.items.length}</button>`
|
|
247
|
+
+ (fold.has(k) ? '' : g.items.map((m) => {
|
|
248
|
+
// a program check's diamond is its own mark: a press marks it done or open again (POST /api/programs/check)
|
|
249
|
+
const dm = m.check ? `<button type="button" class="pp-dm${m.done ? ' d' : g.key === 'next' ? ' n' : ''}" data-pp="check" data-ms="${esc(m.id)}" data-done="${m.done ? '0' : '1'}" aria-pressed="${m.done}" aria-label="${m.done ? 'Open again' : 'Mark done'}: ${esc(m.name)}" title="${m.done ? 'Open again' : 'Mark done'}"></button>`
|
|
250
|
+
: `<span class="pp-dm${m.done ? ' d' : g.key === 'next' ? ' n' : ''}" aria-hidden="true"></span>`;
|
|
251
|
+
return `<div class="pp-mr${m.done ? ' done' : ''}${m.late ? ' late' : ''}" role="listitem">${dm}<b>${esc(m.name)}</b><span class="d">${m.done ? '' : rdHtml(m)}${esc(m.day)}${m.late ? ' · late' : ''}</span>${m.done ? '' : `<span class="w">${esc(waitsLine(m))}</span>`}</div>`;
|
|
252
|
+
}).join(''));
|
|
253
|
+
}).join('')}</div>`;
|
|
254
|
+
}
|
|
255
|
+
/** The documents of its initiatives on record (PRD, rubric, evaluation, release notes), each opening in the Viewer, and the charter. */
|
|
256
|
+
function docsOf(st) {
|
|
257
|
+
const out = [];
|
|
258
|
+
for (const i of st.inis) {
|
|
259
|
+
const L = (i.row.trail && i.row.trail.links) || {};
|
|
260
|
+
for (const [k, n] of [['prd', 'PRD'], ['rubric', 'Rubric'], ['evaluation', 'Evaluation'], ['notes', 'Release notes']]) if (L[k]) out.push({ name: n, path: L[k], ini: i.title });
|
|
261
|
+
}
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
264
|
+
function docsHtml(p, st) {
|
|
265
|
+
const D = docsOf(st);
|
|
266
|
+
return `<div class="pp-tree" role="list"><button type="button" class="pp-nd pp-doc" role="listitem" data-pp="charter">${SV(I.doc, 15)}<span class="x">Charter</span><span class="r">${esc(p.title)}</span></button>`
|
|
267
|
+
+ D.map((d) => `<button type="button" class="pp-nd pp-doc" role="listitem" data-doc="${esc(d.path)}" title="${esc(d.path)}">${SV(I.doc, 15)}<span class="x">${esc(d.name)}</span><span class="r">${esc(d.ini)}</span></button>`).join('')
|
|
268
|
+
+ (D.length ? '' : '<div class="pp-nd q"><span class="x">No PRD, rubric or release notes of its initiatives on this board yet</span></div>') + '</div>';
|
|
269
|
+
}
|
|
270
|
+
/** The charter in the Viewer, as a drill-in: ← comes back to the program. Why, goal, owner, span and the Jira key, as the record holds them. */
|
|
271
|
+
function openCharter(p) {
|
|
272
|
+
const st = programState(p, rowsOf);
|
|
273
|
+
VW.open({ kind: 'Charter', title: p.title, icon: 'doc', id: 'charter:' + p.id, back: true, render: (body) => {
|
|
274
|
+
const rows = [['Goal', p.goal], ['Why', p.why], ['Owner', p.owner], ['Span', st.span.label], ['Products', st.products.join(', ')], ['Jira', p.jira]].filter(([, v]) => v);
|
|
275
|
+
body.innerHTML = rows.length ? `<dl class="pp-cdl">${rows.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('')}</dl>` : '<p class="bd-amut">The charter holds only the program\'s name so far.</p>';
|
|
276
|
+
} });
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* ── the shell: summary first, then the folding rows ── */
|
|
280
|
+
/** The summary card: the next milestone (else what waits on you); the owner and the span; one primary only when tasks from before Turn into a
|
|
281
|
+
* program (p.from) still have no level. */
|
|
282
|
+
function summaryOf(p, st) {
|
|
283
|
+
const N = needs(p, st), n = unsorted(p, st), nx = st.next;
|
|
284
|
+
const meta = [p.owner, st.span.label].filter(Boolean).join(' · ');
|
|
285
|
+
const sortText = n ? n + ' ' + plural(n, 'task', 'tasks') + ' from before the split ' + (n === 1 ? 'has' : 'have') + ' no level yet. Claude suggests a home for each: the program, an initiative or an epic.' : '';
|
|
286
|
+
const primary = n ? { label: 'Review the suggested homes', href: homeHref({ ws: p.home, ask: 'program:' + p.id, q: 'Suggest a home for each task of ' + p.title + ' that has no level yet' }) } : null;
|
|
287
|
+
const next = nx ? 'Next: ' + nx.name + (nx.day ? ' · ' + nx.day : '') : '';
|
|
288
|
+
// The Waits on you row already counts what waits on you (say it once), so the line is the next milestone while there is one.
|
|
289
|
+
if (!nx && N.length) return { line: N.length + ' ' + plural(N.length, 'waits', 'wait') + ' on you', tone: 'you', text: sortText, meta, primary };
|
|
290
|
+
if (nx) return { line: next, tone: nx.late ? 'warn' : '', text: sortText || waitsLine(nx) + (nx.check ? '.' : ' reaching Deliver.'), meta, primary };
|
|
291
|
+
return { line: '', text: sortText, meta, primary };
|
|
292
|
+
}
|
|
293
|
+
function needsList(p, st) {
|
|
294
|
+
const L = needs(p, st);
|
|
295
|
+
return L.map((x) => `<a class="pp-nr" href="${esc(x.href)}" aria-label="${x.task ? 'Task' : 'Waits on you'}: ${esc(x.title)}. Opens in Home"><span class="mk2">${x.task ? `<span class="pp-ck${x.late ? ' late' : ''}"></span>` : '<span class="pp-dt"></span>'}</span><span class="t"><b>${esc(x.title)}</b><span>${esc(x.sub)}</span></span><span class="go">${SV(I.out, 14)}</span></a>`).join('');
|
|
296
|
+
}
|
|
297
|
+
function bodyHtml(p) {
|
|
298
|
+
const st = programState(p, rowsOf), N = needs(p, st), D = docsOf(st), T = iniTasks(st);
|
|
299
|
+
const L = T.filter((t) => t.level === 'initiative'), E = T.filter((t) => t.level === 'epic');
|
|
300
|
+
const rows = [
|
|
301
|
+
N.length ? { id: 'needs', title: 'Waits on you', count: N.length, open: true, render: () => `<div class="pp-needs" role="group" aria-label="Waits on you">${needsList(p, st)}</div>` } : null,
|
|
302
|
+
{ id: 'tasks', title: 'On the program', count: st.openTasks.length, open: adding, render: () => tasksHtml(p, st) },
|
|
303
|
+
// every open task of its initiatives, by level (PgProgram "Tasks"): on the initiative itself, then on their epics
|
|
304
|
+
L.length ? { id: 'itasks', title: 'On its initiatives', count: L.length, render: () => levelHtml(p, L, 'Tasks on its initiatives') } : null,
|
|
305
|
+
E.length ? { id: 'etasks', title: 'On their epics', count: E.length, render: () => levelHtml(p, E, 'Tasks on their epics') } : null,
|
|
306
|
+
st.inis.length || st.missing.length ? { id: 'tree', title: 'Initiatives', count: st.inis.length + st.missing.length, open: true, render: () => treeHtml(p, st) } : null,
|
|
307
|
+
st.milestones.length ? { id: 'ms', title: 'Milestones', count: st.milestones.length, render: () => msHtml(st) } : null,
|
|
308
|
+
{ id: 'docs', title: 'Documents', count: D.length + 1, render: () => docsHtml(p, st) },
|
|
309
|
+
];
|
|
310
|
+
return VW.czSummary(summaryOf(p, st)) + goalsHtml(st) + trackHtml(st) + VW.czSections(rows, { key: 'program' });
|
|
311
|
+
}
|
|
312
|
+
const shownHere = () => { const c = VW.current && VW.current(); return !!(cur && c && c.id === 'program:' + cur.id); };
|
|
313
|
+
/** Draws the program again in place, keeping the scroll and the focus on the same press. */
|
|
314
|
+
function draw(keepFocus) {
|
|
315
|
+
if (!cur || !shownHere()) return;
|
|
316
|
+
const p = progOf(cur.id); if (!p) { VW.close(); return; }
|
|
317
|
+
readAway(p); readMore(p);
|
|
318
|
+
const b = VW.body(); if (!b) return;
|
|
319
|
+
const f = keepFocus && document.activeElement && b.contains(document.activeElement) ? document.activeElement : null;
|
|
320
|
+
const sel = f ? (f.dataset.pp ? `[data-pp="${f.dataset.pp}"]` + (f.dataset.fold ? `[data-fold="${CSS.escape(f.dataset.fold)}"]` : '') + (f.dataset.key ? `[data-key="${CSS.escape(f.dataset.key)}"]` : '') + (f.dataset.ms ? `[data-ms="${CSS.escape(f.dataset.ms)}"]` : '') : f.dataset.czsFold ? `[data-czs-fold="${CSS.escape(f.dataset.czsFold)}"]` : null) : null;
|
|
321
|
+
const top = b.scrollTop;
|
|
322
|
+
b.innerHTML = bodyHtml(p);
|
|
323
|
+
b.scrollTop = top;
|
|
324
|
+
const again = sel && b.querySelector(sel); if (again) again.focus();
|
|
325
|
+
}
|
|
326
|
+
/** ⋯ in the shell's order: change it (add, move in), look back (the charter), copy, then archive in red, last. */
|
|
327
|
+
function moreOf(p) {
|
|
328
|
+
const M = O.M(), taken = new Set(((O.programs()) || []).flatMap((x) => (x.members || []).filter((m) => !m.ws || m.ws === board().ws).map((m) => m.initiative)));
|
|
329
|
+
const free = ((M && M.rows) || []).filter((r) => r.id && r.track && !taken.has(r.id)).slice(0, 8);
|
|
330
|
+
const more = [{ label: 'Add a new initiative', on: () => { VW.close(); const n = document.getElementById('newIni'); if (n) n.click(); } }];
|
|
331
|
+
if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((r) => `<button type="button" class="bd-mi" role="menuitem" data-ppjoin="${esc(r.id)}">${esc(r.title)}</button>`).join('')}`, b, { label: 'Move an initiative in', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' }) });
|
|
332
|
+
more.push({ label: 'Add a task to the program', on: () => { adding = true; try { localStorage.setItem('cz-vw-fold:program:tasks', '1'); } catch { /* a private window */ } draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); } });
|
|
333
|
+
more.push({ sep: true }, { label: 'Open the charter', on: () => openCharter(p) });
|
|
334
|
+
more.push({ sep: true }, { label: 'Copy link', on: () => copyText(new URL('/premium-board.html?' + (p.home ? 'ws=' + encodeURIComponent(p.home) + '&' : '') + 'program=' + encodeURIComponent(p.id), location.href).href, 'Link copied.') },
|
|
335
|
+
{ label: 'Copy as text', on: () => copyText(textOf(p), 'Copied as text.') });
|
|
336
|
+
more.push({ sep: true }, { label: 'Archive the program', danger: true, on: (b) => Pop.open(`<p class="bd-mlbl">Archive ${esc(p.title)}?</p><div class="bd-ppb"><p class="bd-amut">Its initiatives stay where they are.</p><div class="bd-arow"><button type="button" class="bd-btn sm solid" data-pparch="1">Archive</button><button type="button" class="bd-btn sm ghost" data-pparch="0">Not now</button></div></div>`, b, { label: 'Archive the program', width: 280, align: 'right', focus: '[data-pparch="1"]' }) });
|
|
337
|
+
return more;
|
|
338
|
+
}
|
|
339
|
+
/** The program as plain text, for Copy as text. */
|
|
340
|
+
function textOf(p) {
|
|
341
|
+
const st = programState(p, rowsOf), s = summaryOf(p, st);
|
|
342
|
+
const lines = [p.title + (p.goal ? ' · ' + p.goal : ''), [s.line, s.meta].filter(Boolean).join(' · ')];
|
|
343
|
+
for (const m of st.milestones) lines.push('Milestone: ' + m.name + ' · ' + m.day + (m.done ? ' · done' : ''));
|
|
344
|
+
for (const i of st.inis) lines.push('- ' + i.title + ' · ' + ((i.row.track && i.row.track.label) || i.stage || ''));
|
|
345
|
+
return lines.join('\n');
|
|
346
|
+
}
|
|
347
|
+
function openPanel(id, from) {
|
|
348
|
+
if (!O || !O.M() || !progOf(id)) return false;
|
|
349
|
+
const p = progOf(id);
|
|
350
|
+
adding = false; period = null; O._perOpen = false;
|
|
351
|
+
VW.open({ kind: 'Program', title: p.title + (p.goal ? ' · ' + p.goal : ''), icon: I.prog, id: 'program:' + id,
|
|
352
|
+
discuss: true, more: moreOf(p),
|
|
353
|
+
render: (body) => {
|
|
354
|
+
cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
|
|
355
|
+
body.classList.add('pp-vw');
|
|
356
|
+
const q = progOf(id); if (q) { readAway(q); readMore(q); body.innerHTML = bodyHtml(q); }
|
|
357
|
+
body.onclick = (e) => { const b = e.target.closest('[data-pp]'); if (b && body.contains(b)) press(b); };
|
|
358
|
+
body.onsubmit = submit;
|
|
359
|
+
document.querySelectorAll('#ibBody [data-prow]').forEach((x) => x.classList.toggle('sel', x.dataset.prow === id));
|
|
360
|
+
},
|
|
361
|
+
onClose: () => {
|
|
362
|
+
document.querySelectorAll('#ibBody [data-prow].sel').forEach((x) => x.classList.remove('sel'));
|
|
363
|
+
cur = null;
|
|
364
|
+
} });
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
function setFold(k) { if (fold.has(k)) fold.delete(k); else fold.add(k); keepFold(); draw(true); }
|
|
368
|
+
/** Opens one folding row (the track's clusters open Milestones, "N more tasks" opens On its initiatives) and scrolls to it. */
|
|
369
|
+
function showRow(id) {
|
|
370
|
+
try { localStorage.setItem('cz-vw-fold:program:' + id, '1'); } catch { /* a private window */ }
|
|
371
|
+
draw();
|
|
372
|
+
const r = VW.body() && VW.body().querySelector(`[data-czs-fold="${id}"]`); if (r) { r.scrollIntoView({ block: 'start' }); r.focus({ preventScroll: true }); }
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async function press(b) {
|
|
376
|
+
const a = b.dataset.pp, p = cur && progOf(cur.id); if (!p) return;
|
|
377
|
+
if (a === 'fold') setFold(b.dataset.fold);
|
|
378
|
+
else if (a === 'ms' || a === 'itasks') showRow(a);
|
|
379
|
+
else if (a === 'period') { O._perOpen = !O._perOpen; draw(true); }
|
|
380
|
+
else if (a === 'per' || a === 'early') { period = b.dataset.per; O._perOpen = false; draw(); const pb = VW.body() && VW.body().querySelector('[data-pp="period"]'); if (pb) pb.focus(); }
|
|
381
|
+
else if (a === 'ini') { const id = b.dataset.ini, from = document.querySelector(`#ibBody [data-prog="${CSS.escape(p.id)}"]`); VW.close(); O.openIni(id, from); }
|
|
382
|
+
else if (a === 'add') { adding = true; draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); }
|
|
383
|
+
else if (a === 'charter') openCharter(p);
|
|
384
|
+
else if (a === 'done') {
|
|
385
|
+
const r = await pmPost('/api/programs/task-done', { ws: b.dataset.ws || p.home || board().ws || null, program: p.id, key: b.dataset.key, done: b.dataset.done === '1' });
|
|
386
|
+
if (!r || !r.ok) { O.say((r && r.error) || 'Not marked. The server did not say why.'); return; }
|
|
387
|
+
O.say(b.dataset.done === '1' ? 'Done.' : 'Open again.'); O.reload();
|
|
388
|
+
} else if (a === 'check') {
|
|
389
|
+
const r = await pmPost('/api/programs/check', { program: p.id, milestone: b.dataset.ms, done: b.dataset.done === '1' });
|
|
390
|
+
if (!r || !r.ok) { O.say((r && r.error) || 'Not marked. The server did not say why.'); return; }
|
|
391
|
+
O.say(b.dataset.done === '1' ? 'Marked done.' : 'Open again.'); O.reload();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
async function submit(e) {
|
|
395
|
+
const f = e.target.closest('[data-pp-form="task"]'); if (!f) return;
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
const p = cur && progOf(cur.id), title = f.t.value.trim(); if (!p) return;
|
|
398
|
+
if (!title) { adding = false; draw(); return; }
|
|
399
|
+
const r = await pmPost('/api/programs/task', { ws: p.home || board().ws || null, program: p.id, title });
|
|
400
|
+
if (!r || !r.ok) { O.say((r && r.error) || 'The task was not added. The server did not say why.'); return; }
|
|
401
|
+
adding = false; O.say('Added to ' + p.title + '.'); O.reload();
|
|
402
|
+
}
|
|
403
|
+
/** The presses in the popovers ⋯ opens: move an initiative in, archive. */
|
|
404
|
+
async function popPress(e) {
|
|
405
|
+
const j = e.target.closest('[data-ppjoin]'), x = e.target.closest('[data-pparch]'); if (!j && !x) return;
|
|
406
|
+
const p = cur && progOf(cur.id); Pop.close(true); if (!p) return;
|
|
407
|
+
if (j) {
|
|
408
|
+
const r = await pmPost('/api/programs/member', { ws: board().ws || null, program: p.id, initiative: j.dataset.ppjoin });
|
|
409
|
+
if (!r || !r.ok) { O.say((r && r.error) || 'It did not move in. The server did not say why.'); return; }
|
|
410
|
+
O.say('Moved into ' + p.title + '.'); O.reload();
|
|
411
|
+
} else if (x.dataset.pparch === '1') {
|
|
412
|
+
const r = await pmPost('/api/programs/archive', { ws: p.home || board().ws || null, program: p.id });
|
|
413
|
+
if (!r || !r.ok) { O.say((r && r.error) || 'Not archived. The server did not say why.'); return; }
|
|
414
|
+
O.say(p.title + ' is archived. Its initiatives stay where they are.'); VW.close(); O.reload();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export function mount(o) {
|
|
419
|
+
if (O) return;
|
|
420
|
+
O = o;
|
|
421
|
+
document.addEventListener('click', popPress);
|
|
422
|
+
// a program row of the Board, and ?program=<id> once the Board has unfolded and scrolled to it, send bd:program (pm/bd-prog.js openProgram)
|
|
423
|
+
document.addEventListener('bd:program', (e) => { const d = e.detail || {}; if (d.id) openPanel(String(d.id), d.from || document.activeElement); });
|
|
424
|
+
// the period menu is a layer inside the panel: Escape closes it first, then the shell closes the panel
|
|
425
|
+
window.addEventListener('keydown', (e) => {
|
|
426
|
+
if (e.key !== 'Escape' || !cur || !O._perOpen) return;
|
|
427
|
+
e.preventDefault(); e.stopImmediatePropagation(); O._perOpen = false; draw();
|
|
428
|
+
}, true);
|
|
429
|
+
// a new read draws the rows again: the open panel follows it
|
|
430
|
+
const body = document.getElementById('ibBody');
|
|
431
|
+
if (body) new MutationObserver(() => {
|
|
432
|
+
const b = VW.body();
|
|
433
|
+
if (cur && shownHere() && !(b && b.contains(document.activeElement))) draw();
|
|
434
|
+
if (cur && shownHere()) document.querySelectorAll('#ibBody [data-prow]').forEach((x) => x.classList.toggle('sel', x.dataset.prow === cur.id));
|
|
435
|
+
}).observe(body, { childList: true });
|
|
436
|
+
}
|