create-pmos 0.397.0 → 0.399.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 +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/briefing-premium-adddoc-test.js +105 -52
- package/workspace/briefing-premium-board-test.js +284 -128
- package/workspace/briefing-premium-calendar-2-test.js +135 -198
- package/workspace/briefing-premium-calendar-3-test.js +143 -418
- package/workspace/briefing-premium-calendar-test.js +85 -196
- package/workspace/briefing-premium-doc-edit-test.js +99 -83
- package/workspace/briefing-premium-initiative-test.js +175 -290
- package/workspace/briefing-premium-insights-test.js +414 -219
- package/workspace/briefing-premium-metrics-test.js +55 -97
- package/workspace/briefing-premium-products-test.js +44 -28
- package/workspace/briefing-premium-sources-test.js +70 -49
- package/workspace/briefing-premium-test.js +155 -648
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +24 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +68 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +121 -24
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +64 -15
- package/workspace/lib/insights-records.js +115 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/meeting-points.js +52 -0
- package/workspace/lib/news-for-you.js +88 -0
- package/workspace/lib/notes-series.js +29 -6
- package/workspace/lib/report-confirm.js +48 -0
- package/workspace/lib/route-modules.js +12 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-home-review.js +108 -0
- package/workspace/lib/routes-initiative-layout.js +57 -0
- package/workspace/lib/routes-insights-premium.js +16 -4
- package/workspace/lib/routes-insights-records.js +133 -0
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +3 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/search-index.js +176 -0
- package/workspace/lib/transcript-steps.js +123 -0
- package/workspace/lib/viewer-meeting.js +205 -0
- package/workspace/lib/viewer-report.js +89 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +128 -82
- package/workspace/premium-briefing-depth-test.js +104 -90
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +37 -37
- package/workspace/premium-chat-context-test.js +19 -18
- package/workspace/premium-chat-goal-view-test.js +23 -23
- package/workspace/premium-chat-notes-test.js +26 -31
- package/workspace/premium-chat-report-tab-test.js +46 -28
- package/workspace/premium-chat-term-test.js +16 -16
- package/workspace/premium-chat-viewer-test.js +60 -59
- package/workspace/premium-core-doc-issue-test.js +52 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +10 -3
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +152 -197
- package/workspace/premium-viewer-download-test.js +19 -22
- package/workspace/premium-viewer-flicker-test.js +11 -16
- package/workspace/premium-viewer-share-test.js +6 -9
- package/workspace/premium-viewer-test.js +41 -60
- package/workspace/premium-vw-backlog-test.js +53 -33
- package/workspace/premium-vw-cal-test.js +97 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +17 -10
- package/workspace/premium-vw-item-test.js +50 -49
- package/workspace/premium-vw-jira-test.js +53 -27
- package/workspace/premium-vw-meet-test.js +115 -187
- package/workspace/premium-vw-notes-test.js +88 -109
- package/workspace/premium-vw-rec-test.js +71 -194
- package/workspace/premium-vw-slides-test.js +46 -50
- package/workspace/premium-welcome-test.js +3 -2
- package/workspace/premium-work-depth-test.js +61 -53
- package/workspace/public/pm/bd-acts.js +383 -0
- package/workspace/public/pm/bd-asks.js +261 -0
- package/workspace/public/pm/bd-pop.js +59 -0
- package/workspace/public/pm/bd-span.js +222 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/bd-views.js +169 -0
- package/workspace/public/pm/c3-doc-sheet.js +1 -1
- package/workspace/public/pm/c3-md.js +3 -395
- package/workspace/public/pm/c3-phone-detail.js +1 -1
- package/workspace/public/pm/c3-phone-model.js +3 -68
- package/workspace/public/pm/chat-term.js +3 -3
- package/workspace/public/pm/cozy-board.css +798 -230
- package/workspace/public/pm/cozy-ev.css +228 -0
- package/workspace/public/pm/cozy-evmodel.js +106 -0
- package/workspace/public/pm/cozy-evui.js +47 -0
- package/workspace/public/pm/cozy-home.css +570 -142
- package/workspace/public/pm/cozy-home.js +5 -3
- package/workspace/public/pm/cozy-insights.css +437 -170
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +104 -29
- package/workspace/public/pm/cozy-news.js +140 -0
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-search.js +203 -0
- package/workspace/public/pm/cozy-settings.js +198 -0
- package/workspace/public/pm/cozy-sources.js +89 -0
- package/workspace/public/pm/cozy-today.css +217 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +145 -0
- package/workspace/public/pm/cozy-vw-mtg.css +350 -0
- package/workspace/public/pm/cozy-vw-rp.css +152 -0
- package/workspace/public/pm/cozy-vw.css +485 -0
- package/workspace/public/pm/cozy.css +83 -1
- package/workspace/public/pm/home-adddoc.js +48 -0
- package/workspace/public/pm/home-app.js +1179 -0
- package/workspace/public/pm/home-around.js +413 -0
- package/workspace/public/pm/home-chat.js +512 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-ini-model.js +190 -0
- package/workspace/public/pm/home-ini.css +171 -0
- package/workspace/public/pm/home-ini.js +456 -0
- package/workspace/public/pm/home-list.js +276 -0
- package/workspace/public/pm/home-more.js +132 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-review.js +104 -0
- package/workspace/public/pm/home-task.js +67 -0
- package/workspace/public/pm/home-today.js +144 -0
- package/workspace/public/pm/home-work.js +547 -0
- package/workspace/public/pm/phone-moment.js +69 -0
- package/workspace/public/pm/pm-work-view.js +1 -1
- package/workspace/public/pm/premium-attach.js +4 -0
- package/workspace/public/pm/premium-board.js +548 -395
- package/workspace/public/pm/premium-chart-tab.js +109 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +23 -21
- package/workspace/public/pm/premium-insights.js +1102 -581
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-mtg-present.js +138 -0
- package/workspace/public/pm/premium-mtg-replay.js +142 -0
- package/workspace/public/pm/premium-notes.js +1 -1
- package/workspace/public/pm/premium-report-frame.css +20 -0
- package/workspace/public/pm/premium-report-read.js +669 -476
- package/workspace/public/pm/premium-report-tab.js +116 -67
- package/workspace/public/pm/premium-shell.js +76 -123
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +277 -48
- package/workspace/public/pm/premium-vw-doc.css +6 -0
- package/workspace/public/pm/premium-vw-doc.js +40 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-meet.js +6 -83
- package/workspace/public/pm/premium-vw-mtg.js +958 -0
- package/workspace/public/pm/premium-vw-notes.js +116 -68
- package/workspace/public/pm/premium-vw-open.js +35 -0
- package/workspace/public/pm/premium-vw-page.js +16 -0
- package/workspace/public/pm/premium-vw-rec.js +11 -218
- package/workspace/public/pm/premium-vw-slides.css +5 -0
- package/workspace/public/pm/premium-vw-slides.js +44 -8
- package/workspace/public/pm/rp-parts.js +269 -0
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +29 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +26 -64
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +18 -107
- package/workspace/r/m1.png +0 -0
- package/workspace/r/m2.png +0 -0
- package/workspace/r/m3.png +0 -0
- package/workspace/r/nl.png +0 -0
- package/workspace/server.js +18 -3
- package/workspace/test-files.json +1 -0
- package/workspace/test-lists/home-libs.json +9 -0
- package/workspace/test-lists/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/test-lists/uf-everywhere.json +15 -0
- package/workspace/test-lists/uf-home.json +9 -0
- package/workspace/test-lists/uncovered-board.json +9 -0
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/* pm/bd-acts.js — the Board's presses and the panels and popovers around them (initiative premium-uncovered-features, Board: BdActions, BdFilter,
|
|
2
|
+
* BdSprint, BdPanel, BdDocs; built on premium-agreed-design's plain versions, whose function each designed one keeps). The routes are the ones the
|
|
3
|
+
* console presses, behind the launch nonce:
|
|
4
|
+
* a row's actions (BdActions) the ⋯ menu: Move to <next> with how much of the step is ready, Back to <prev> (asks why), Hold, Cancel (asks why,
|
|
5
|
+
* the same chips as Decline), Archive; Resume, Reopen, Restore. POST /api/boards/move { board, id, to, why? } ·
|
|
6
|
+
* /api/lifecycle { initiative_id, state, reason, back? } · /api/boards/archive { board, id, archived, reason? }.
|
|
7
|
+
* Each one is done at once, with Undo in the toast, which writes the opposite line through the same route.
|
|
8
|
+
* Cancelled and archived the side panel: All, On hold, Cancelled, Archived, each with Resume, Reopen or Restore
|
|
9
|
+
* Find, Filter (BdFilter) Find: a jump list of the initiatives and the Jira work-items on this Board. Filter: owner, kind, sprint, applied as
|
|
10
|
+
* the PM picks; the "Showing" bar above the view lists what is on (the page's filter state F)
|
|
11
|
+
* Sprints and releases (BdSprint) the chip's popover: the Jira sprints, the releases, the backlog; a release opens its panel (work-items done, days
|
|
12
|
+
* left, the initiatives it carries, your sign-off, the backlog preview). Sprint moves are proposals that go to Home.
|
|
13
|
+
* A metric's trend (BdPanel) a chip's popover: the count week by week where the records allow it, "Show only …" and Insights
|
|
14
|
+
* Documents (BdDocs) a document's panel: kind and initiative, who changed it and when, its health, a PRD that changed after the push,
|
|
15
|
+
* its edit log (GET /api/board-docs), Open in Home, Compare with Jira, Issue it for a draft (POST /api/core-docs/issue),
|
|
16
|
+
* and its text (GET /api/doc). Add a document POST /api/custom-docs/add; Draft it POST /api/core-docs/draft.
|
|
17
|
+
* Metrics, Notifications the board's measures (GET /api/board-metrics-premium) and what waits on you here
|
|
18
|
+
* Nothing here invents a value: what a record does not hold is not drawn. */
|
|
19
|
+
import { pmPost } from './http.js';
|
|
20
|
+
import { $, $$, esc } from './premium-shell.js';
|
|
21
|
+
import * as Pop from './bd-pop.js';
|
|
22
|
+
import * as V from './bd-views.js';
|
|
23
|
+
import * as Asks from './bd-asks.js';
|
|
24
|
+
|
|
25
|
+
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
26
|
+
const I = {
|
|
27
|
+
x: 'M6 6l12 12M18 6L6 18', go: 'M5 12h14M13 6l6 6-6 6', back: 'M19 12H5M11 6l-6 6 6 6', hold: 'M9 5v14M15 5v14', arch: 'M4 7h16v13H4zM4 7l2-3h12l2 3M10 11h4',
|
|
28
|
+
find: 'M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14M20 20l-4-4', list: 'M4 6h16M4 12h16M4 18h10', ext: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', play: 'M8 5v14l11-7z',
|
|
29
|
+
};
|
|
30
|
+
const WHY_NOT = ['Out of scope', 'Already planned', 'Not now', 'Other'];
|
|
31
|
+
const BACK_WHY = ['A part is missing', 'The scope changed', 'Not ready yet', 'Other'];
|
|
32
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
33
|
+
const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
34
|
+
const dm = (v) => { const d = day(v); return d ? d.getDate() + ' ' + MON[d.getMonth()] : ''; };
|
|
35
|
+
const span2 = (a, b) => { const x = day(a), y = day(b); if (!x || !y) return ''; return x.getMonth() === y.getMonth() ? x.getDate() + ' to ' + dm(b) : dm(a) + ' to ' + dm(b); };
|
|
36
|
+
const dayIso = (n) => { const t = new Date(Date.now() + n * 86400000); return t.getFullYear() + '-' + String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0'); };
|
|
37
|
+
const plural = (n, a, b) => (n === 1 ? a : b);
|
|
38
|
+
const cap = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : '');
|
|
39
|
+
|
|
40
|
+
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r), openTicket(ini, tk), askHref(r, q), pageHref(r), trail(r), docMeta(path), loadDocMeta(paths), viewDoc(path) }
|
|
41
|
+
export function init(api) { A = api; }
|
|
42
|
+
const M = () => A.M();
|
|
43
|
+
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
44
|
+
const errOf = (r) => (r && r.error) || 'Nothing was recorded. The server did not say why.';
|
|
45
|
+
|
|
46
|
+
/** A side panel of this module: its eyebrow, title, the tools and the body. */
|
|
47
|
+
function panel(title, body, from, o = {}) {
|
|
48
|
+
A.panel(`<div class="pk-h"><div class="pk-ht">${o.eye ? `<p class="pk-eye">${esc(o.eye)}</p>` : ''}<h2 id="pkTitle">${esc(title)}</h2>${o.sub ? `<p class="pk-sub">${esc(o.sub)}</p>` : ''}</div><div class="pk-tools">${o.tools || ''}<button type="button" class="bd-ib" data-pk="close" aria-label="Close" title="Close">${SV(I.x)}</button></div></div><div class="pk-b bd-pl">${body}</div>`, from, o.cls || '');
|
|
49
|
+
}
|
|
50
|
+
const msg = (id) => `<p class="bd-amsg" id="${id}" role="status"></p>`;
|
|
51
|
+
async function press(btn, m, fn) {
|
|
52
|
+
if (btn) btn.disabled = true; if (m) m.textContent = '';
|
|
53
|
+
const r = await fn().catch(() => null);
|
|
54
|
+
if (r && r.ok === true) return r;
|
|
55
|
+
if (btn) btn.disabled = false; if (m) m.textContent = errOf(r); else A.say(errOf(r)); return null;
|
|
56
|
+
}
|
|
57
|
+
async function done(r, text, undo) { Pop.close(false); A.say(text, undo); await A.load(); return r; }
|
|
58
|
+
const chipsRadio = (L, name) => `<div class="bd-chips" role="radiogroup" aria-label="${esc(name)}">${L.map((w, j) => `<button type="button" class="bd-chip${j === 0 ? ' on' : ''}" role="radio" aria-checked="${j === 0}" data-why="${esc(w)}">${esc(w)}</button>`).join('')}</div>`;
|
|
59
|
+
const whyOf = (root) => { const c = root.querySelector('[data-why].on'), t = (root.querySelector('input[name="why"]') || {}).value || ''; return ((c && c.dataset.why) || 'Other') + (t.trim() ? ': ' + t.trim().replace(/\s+/g, ' ') : ''); };
|
|
60
|
+
|
|
61
|
+
/* ── a row's actions (BdActions): the ⋯ menu ────────────────────────────────────────────────────────────────────── */
|
|
62
|
+
const life = (id, state, reason, back) => post('/api/lifecycle', { initiative_id: id, state, reason: reason || '', ...(back ? { back } : {}) });
|
|
63
|
+
const arch = (id, archived, reason) => post('/api/boards/archive', { board: M().board.id, id, archived, ...(reason ? { reason } : {}) });
|
|
64
|
+
const move = (id, to, why) => post('/api/boards/move', { board: M().board.id, id, to, ...(why ? { why } : {}) });
|
|
65
|
+
const prevOf = (r) => ({ life: r.acts.life, reason: r.acts.reason, backDay: r.acts.backDay || null });
|
|
66
|
+
const lifeBack = (r, p) => (p.life === 'hold' ? life(r.id, 'on-hold', p.reason, p.backDay) : p.life === 'cancelled' ? life(r.id, 'cancelled', p.reason) : life(r.id, 'active', 'undo'));
|
|
67
|
+
/** How much of the step is ready, for "Move to <next> · 2 of 4 ready": the parts or tickets counted toward its output. */
|
|
68
|
+
const readyOf = (r) => { const t = r.track || {}; return t.count && /\d+ of \d+/.test(t.count) ? t.count.replace(/ parts?$/, '') + ' ready' : ''; };
|
|
69
|
+
function menuItems(r) {
|
|
70
|
+
const a = r.acts || { stages: [], stage: '' }, cur = a.stages.indexOf(a.stage), out = [];
|
|
71
|
+
if (a.archived) return [['restore', 'Restore', I.back, 'Back in the lists, as it was']];
|
|
72
|
+
if (a.life === 'cancelled') return [['reopen', 'Reopen', I.back, 'Back to ' + (a.stage || 'its stage') + ', active again']];
|
|
73
|
+
if (!M().board.self && !a.life && cur >= 0) {
|
|
74
|
+
if (a.stages[cur + 1]) out.push(['mv:' + (cur + 1), 'Move to ' + a.stages[cur + 1], I.go, readyOf(r)]);
|
|
75
|
+
if (cur > 0) out.push(['back:' + (cur - 1), 'Back to ' + a.stages[cur - 1], I.back, '']);
|
|
76
|
+
}
|
|
77
|
+
out.push(['hr']);
|
|
78
|
+
if (a.life === 'hold') out.push(['resume', 'Resume', I.play, '']); else out.push(['hold', 'Hold', I.hold, '']);
|
|
79
|
+
out.push(['cancel', 'Cancel', I.x, ''], ['archive', 'Archive', I.arch, '']);
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function menuHtml(r) {
|
|
83
|
+
const it = menuItems(r), stage = it.some(([k]) => /^(mv|back):/.test(k));
|
|
84
|
+
const self = M().board.self ? '<p class="bd-amut bd-mnote">The stage of a PMOS-self initiative comes from the repository. It moves when the files land.</p>' : '';
|
|
85
|
+
return `<p class="bd-mlbl" id="mnT">${esc(r.title)}</p>${self}${stage ? '<p class="bd-mlbl">Stage</p>' : ''}`
|
|
86
|
+
+ it.map(([k, l, ic, s]) => (k === 'hr' ? (stage ? '<div class="bd-hr"></div>' : '') : `<button type="button" class="bd-mi" role="menuitem" data-rowact="${esc(k)}" data-id="${esc(r.key)}">${SV(ic)}<span>${esc(l)}</span>${s && /ready$/.test(s) ? `<span class="k">${esc(s)}</span>` : ''}</button>`)).join('');
|
|
87
|
+
}
|
|
88
|
+
function openRowMenu(r, btn) {
|
|
89
|
+
Pop.open(menuHtml(r), btn, { label: 'Actions for ' + r.title, role: 'menu', width: 270, align: 'right', cls: 'bd-menu', focus: '.bd-mi' });
|
|
90
|
+
}
|
|
91
|
+
function reasonHtml(r, kind, to) {
|
|
92
|
+
const L = kind === 'cancel' ? WHY_NOT : BACK_WHY;
|
|
93
|
+
const q = kind === 'cancel' ? 'Why cancel ' + r.title + '?' : 'Why back to ' + to + '?';
|
|
94
|
+
return `<p class="bd-mlbl">${esc(r.title)}</p><div class="bd-ppb"><b class="sm">${esc(q)}</b>${chipsRadio(L, 'Why')}<input class="bd-inp sm" name="why" maxlength="300" placeholder="Say a little more, optional" aria-label="Why, in your words">${msg('rowM')}`
|
|
95
|
+
+ `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-rowact="${kind === 'cancel' ? 'cancel-go' : 'back-go:' + to}" data-id="${esc(r.key)}">${kind === 'cancel' ? 'Cancel initiative' : 'Back to ' + esc(to)}</button><button type="button" class="bd-btn sm ghost" data-rowact="menu" data-id="${esc(r.key)}">Not now</button></div>`
|
|
96
|
+
+ `<p class="bd-amut">${kind === 'cancel' ? 'Keeps its stage, its work and its history. Reopen it any time.' : 'The reason is kept with the move in the board ledger.'}</p></div>`;
|
|
97
|
+
}
|
|
98
|
+
async function runRow(r, k, btn) {
|
|
99
|
+
const a = r.acts, p = prevOf(r), m = $('#rowM');
|
|
100
|
+
if (k === 'menu') { Pop.redraw(menuHtml(r)); return; }
|
|
101
|
+
if (k.startsWith('mv:') || k.startsWith('back-go:')) {
|
|
102
|
+
const to = k.startsWith('mv:') ? a.stages[+k.slice(3)] : k.slice(8), fromStage = a.stage, why = k.startsWith('back-go:') ? whyOf(Pop.el()) : '';
|
|
103
|
+
if (!to) return;
|
|
104
|
+
const res = await press(btn, m, () => move(r.id, to, why)); if (!res) return;
|
|
105
|
+
const w = Array.isArray(res.warnings) && res.warnings.length ? ' Warning: ' + res.warnings.join('; ') + '. Warnings never block.' : '';
|
|
106
|
+
await done(res, (why ? 'Back in ' : 'Moved to ') + to + ' · ' + r.title + '.' + w, async () => { const u = await move(r.id, fromStage, 'Undo'); A.say(u && u.ok ? 'Back in ' + fromStage + '.' : errOf(u)); await A.load(); });
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (k.startsWith('back:')) { Pop.redraw(reasonHtml(r, 'back', a.stages[+k.slice(5)])); const c = Pop.el().querySelector('[data-why]'); if (c) c.focus(); return; }
|
|
110
|
+
if (k === 'cancel') { Pop.redraw(reasonHtml(r, 'cancel')); const c = Pop.el().querySelector('[data-why]'); if (c) c.focus(); return; }
|
|
111
|
+
if (k === 'cancel-go') {
|
|
112
|
+
const res = await press(btn, m, () => life(r.id, 'cancelled', whyOf(Pop.el()))); if (!res) return;
|
|
113
|
+
await done(res, 'Cancelled · ' + r.title, async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? r.title + ' is back as it was.' : errOf(u)); await A.load(); });
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (k === 'hold') {
|
|
117
|
+
const back = dayIso(30);
|
|
118
|
+
const res = await press(btn, null, () => life(r.id, 'on-hold', 'Held from the Board', back)); if (!res) return;
|
|
119
|
+
await done(res, 'On hold · ' + r.title + ' · check back ' + dm(back), async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? r.title + ' is back as it was.' : errOf(u)); await A.load(); });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (k === 'archive') {
|
|
123
|
+
const res = await press(btn, null, () => arch(r.id, true)); if (!res) return;
|
|
124
|
+
await done(res, 'Archived · ' + r.title, async () => { const u = await arch(r.id, false); A.say(u && u.ok ? r.title + ' is restored.' : errOf(u)); await A.load(); });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (k === 'resume' || k === 'reopen') {
|
|
128
|
+
const res = await press(btn, null, () => life(r.id, 'active', k === 'resume' ? 'resumed' : 'reopened')); if (!res) return;
|
|
129
|
+
await done(res, (k === 'resume' ? 'Resumed · ' : 'Reopened · ') + r.title, async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? 'Undone.' : errOf(u)); await A.load(); });
|
|
130
|
+
if (gone) openGone(null);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (k === 'restore') {
|
|
134
|
+
const res = await press(btn, null, () => arch(r.id, false)); if (!res) return;
|
|
135
|
+
await done(res, 'Restored · ' + r.title, async () => { const u = await arch(r.id, true, a.archived && a.archived.reason); A.say(u && u.ok ? r.title + ' is archived again.' : errOf(u)); await A.load(); });
|
|
136
|
+
if (gone) openGone(null);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ── Cancelled and archived (BdActions' panel) ──────────────────────────────────────────────────────────────────── */
|
|
141
|
+
let gone = null; // the segment shown: all | hold | cancelled | archived
|
|
142
|
+
function openGone(from, seg) {
|
|
143
|
+
gone = seg || gone || 'all';
|
|
144
|
+
const G = M().initiatives.gone || { cancelled: [], archived: [] }, held = M().initiatives.list.rows.filter((r) => r.acts && r.acts.life === 'hold');
|
|
145
|
+
const L = { hold: held, cancelled: G.cancelled, archived: G.archived };
|
|
146
|
+
const all = [...held, ...G.cancelled, ...G.archived];
|
|
147
|
+
const sub = (r, k) => {
|
|
148
|
+
const a = r.acts || {};
|
|
149
|
+
if (k === 'hold') return ['On hold' + (a.since ? ' ' + a.since : ''), a.stage ? 'from ' + a.stage : '', a.back ? 'check back ' + a.back : ''].filter(Boolean).join(' · ');
|
|
150
|
+
if (k === 'cancelled') return ['Cancelled' + (a.since ? ' ' + a.since : ''), a.reason ? '“' + a.reason + '”' : ''].filter(Boolean).join(' · ');
|
|
151
|
+
const x = a.archived || {}; return ['Archived' + (x.at ? ' ' + x.at : ''), x.into ? 'merged into ' + x.into : x.reason || ''].filter(Boolean).join(' · ');
|
|
152
|
+
};
|
|
153
|
+
const btn = { hold: ['resume', 'Resume'], cancelled: ['reopen', 'Reopen'], archived: ['restore', 'Restore'] };
|
|
154
|
+
const rows = (k) => L[k].map((r) => `<div class="bd-gr"><span class="t"><b>${esc(r.title)}</b><small>${esc(sub(r, k))}</small></span><button type="button" class="bd-btn sm" data-rowact="${btn[k][0]}" data-id="${esc(r.key)}">${btn[k][1]}</button></div>`).join('');
|
|
155
|
+
const segH = `<div class="bd-seg bd-gseg" role="group" aria-label="Show">${[['all', 'All', all.length], ['hold', 'On hold', held.length], ['cancelled', 'Cancelled', G.cancelled.length], ['archived', 'Archived', G.archived.length]].map(([k, n, c]) => `<button type="button" data-gone="${k}" aria-pressed="${gone === k}">${n} ${c}</button>`).join('')}</div>`;
|
|
156
|
+
const body = (gone === 'all' ? ['hold', 'cancelled', 'archived'] : [gone]).map(rows).join('');
|
|
157
|
+
panel('Cancelled and archived', `<p class="bd-amut">Out of the Board, still searchable. Open one to Resume, Reopen or Restore.</p>${segH}<div class="bd-grs">${body || '<p class="bd-amut">Nothing here.</p>'}</div>${msg('goneM')}<div class="bd-box sm bd-pfoot">Cancel asks for a reason, the same chips as Decline. Archive needs none.</div>`, from, { cls: 'pk-wide' });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ── Find and Filter (BdFilter) ────────────────────────────────────────────────────────────────────────────────── */
|
|
161
|
+
let findQ = '', findAt = 0;
|
|
162
|
+
const mark = (t, q) => { if (!q) return esc(t); const i = t.toLowerCase().indexOf(q.toLowerCase()); return i < 0 ? esc(t) : esc(t.slice(0, i)) + '<mark>' + esc(t.slice(i, i + q.length)) + '</mark>' + esc(t.slice(i + q.length)); };
|
|
163
|
+
function findHits(q) {
|
|
164
|
+
const s = q.trim().toLowerCase(); if (!s) return { ini: [], tk: [] };
|
|
165
|
+
const rows = M().initiatives.list.rows;
|
|
166
|
+
const ini = rows.filter((r) => String(r.title).toLowerCase().includes(s)).slice(0, 6);
|
|
167
|
+
const tk = rows.flatMap((r) => ((r.track && r.track.tickets) || []).map((k) => ({ k, r }))).filter(({ k }) => k.key.toLowerCase().includes(s) || String(k.title).toLowerCase().includes(s)).slice(0, 6);
|
|
168
|
+
return { ini, tk };
|
|
169
|
+
}
|
|
170
|
+
function findList() {
|
|
171
|
+
const h = findHits(findQ), all = [...h.ini.map((r) => ({ r })), ...h.tk];
|
|
172
|
+
findAt = Math.max(0, Math.min(findAt, all.length - 1));
|
|
173
|
+
let i = -1;
|
|
174
|
+
const ini = h.ini.map((r) => { i++; const s = V.statusLine(r); return `<button type="button" class="bd-mi${i === findAt ? ' hl' : ''}" data-findini="${esc(r.key)}"><i class="cz-dot ${s.tone}"></i><span class="tx"><span>${mark(r.title, findQ)}</span><span class="bd-amut">${esc([(r.track && r.track.label) || r.stage, s.text].filter(Boolean).join(' · '))}</span></span>${i === findAt ? '<span class="k">Enter</span>' : ''}</button>`; }).join('');
|
|
175
|
+
const tk = h.tk.map(({ k, r }) => { i++; return `<button type="button" class="bd-mi${i === findAt ? ' hl' : ''}" data-findtk="${esc(k.key)}" data-ini="${esc(r.key)}"><span class="bd-pill">${mark(k.key, findQ)}</span><span class="tx"><span>${mark(k.title, findQ)}</span><span class="bd-amut">${esc([k.blocked ? 'Blocked' : k.status, k.assignee].filter(Boolean).join(' · '))}</span></span>${i === findAt ? '<span class="k">Enter</span>' : ''}</button>`; }).join('');
|
|
176
|
+
return (ini ? '<p class="bd-mlbl">Initiatives</p>' + ini : '') + (tk ? '<p class="bd-mlbl">Work-items in Jira</p>' + tk : '') + (findQ.trim() && !ini && !tk ? `<p class="bd-amut bd-mnote">Nothing on this Board matches “${esc(findQ.trim())}”.</p>` : '');
|
|
177
|
+
}
|
|
178
|
+
function openFind(from) {
|
|
179
|
+
findQ = ''; findAt = 0;
|
|
180
|
+
Pop.open(`<div class="bd-finp">${SV(I.find)}<input id="bdQ" type="search" maxlength="80" placeholder="Find an initiative or work-item" aria-label="Find an initiative or work-item" autocomplete="off"><span class="bd-kbd">Esc</span></div><div id="bdQr" class="bd-fres">${findList()}</div><p class="bd-amut bd-mnote">Find stays in the Board. Search in the menu looks everywhere.</p>`, from, { label: 'Find', width: 460, cls: 'bd-find', focus: '#bdQ' });
|
|
181
|
+
}
|
|
182
|
+
function pickFind() {
|
|
183
|
+
const b = $$('#bdQr .bd-mi')[findAt]; if (b) b.click();
|
|
184
|
+
}
|
|
185
|
+
/** The Filter's groups: owner, kind (the lane), sprint (from the Jira reading, and the backlog). */
|
|
186
|
+
function filterHtml() {
|
|
187
|
+
const rows = M().initiatives.list.rows, F = A.F;
|
|
188
|
+
const owners = [...new Set(rows.map((r) => r.owner || 'No owner'))].sort((a, b) => (a === 'No owner') - (b === 'No owner') || a.localeCompare(b));
|
|
189
|
+
const kinds = [...new Set(rows.map((r) => r.lane).filter(Boolean))].sort();
|
|
190
|
+
const sprints = (M().jira && M().jira.sprints) || [];
|
|
191
|
+
const chip = (k, v, label) => `<button type="button" class="bd-chip${F[k].has(v) ? ' on' : ''}" data-flt="${k}" data-v="${esc(v)}" aria-pressed="${F[k].has(v)}">${label || esc(v)}</button>`;
|
|
192
|
+
return `<p class="bd-mlbl">Owner</p><div class="bd-fg">${owners.map((o) => chip('owners', o, (o === 'No owner' ? '' : V.avatar(o, 'xs')) + esc(o))).join('')}</div>`
|
|
193
|
+
+ `<p class="bd-mlbl">Kind</p><div class="bd-fg">${kinds.map((l) => chip('lanes', l, esc(cap(l)))).join('') || '<span class="bd-amut">No kind is on record</span>'}</div>`
|
|
194
|
+
+ (sprints.length ? `<p class="bd-mlbl">Sprint</p><div class="bd-fg">${sprints.map((s) => chip('sprints', s.name, esc(s.name + (s.now ? ' · now' : '')))).join('')}${chip('sprints', 'Backlog')}</div>` : '')
|
|
195
|
+
+ `<div class="bd-arow bd-ffoot"><button type="button" class="bd-btn sm ghost" data-fclear>Clear</button><span class="bd-amut bd-push">Applies as you pick</span></div>`;
|
|
196
|
+
}
|
|
197
|
+
function openFilter(from) { Pop.open(filterHtml(), from, { label: 'Filter', width: 340, align: 'right', cls: 'bd-filter' }); }
|
|
198
|
+
|
|
199
|
+
/* ── Sprints, releases and the backlog (BdSprint) ──────────────────────────────────────────────────────────────── */
|
|
200
|
+
function sprintHtml() {
|
|
201
|
+
const J = M().jira || {}, S = J.sprints || [], R = (M().release && M().release.rel) || [], B = J.backlog || [], cur = M().sprint || {};
|
|
202
|
+
const sp = S.map((s) => {
|
|
203
|
+
const when = span2(s.start, s.end);
|
|
204
|
+
const k = s.now ? [when, cur.cap && cur.cap !== 'none' ? cur.cap : s.state].filter(Boolean).join(' · ') : s.state === 'closed' ? [when, 'closed', s.pts ? s.pts.done + ' of ' + s.pts.total + ' pts' : ''].filter(Boolean).join(' · ') : [when, s.pts ? s.pts.total + ' pts planned' : s.counts.todo + s.counts.doing + s.counts.done + ' work-items'].filter(Boolean).join(' · ');
|
|
205
|
+
return `<button type="button" class="bd-sp1${s.now ? ' now' : ''}" data-sprint="${esc(s.name)}" aria-pressed="${A.F.sprints.has(s.name)}">${s.now ? `<b>${esc(s.name)}</b>` : `<span>${esc(s.name)}</span>`}<span class="k">${esc(k)}</span></button>`;
|
|
206
|
+
}).join('');
|
|
207
|
+
const rel = R.map((r, i) => `<button type="button" class="bd-sp1${r.tag === 'Next' ? ' next' : ''}" data-rel="${i}"><i class="bd-dia${r.tag === 'Next' || r.tag === 'Released' ? ' on' : ''}" aria-hidden="true"></i>${r.tag === 'Next' ? `<b>${esc(r.name)}</b>` : `<span>${esc(r.name)}</span>`}<span class="k">${esc([r.tag === 'Released' ? 'shipped ' + r.at : r.tag === 'Next' ? 'ships ' + r.at : r.at, r.ini.length ? r.ini.length + ' ' + plural(r.ini.length, 'initiative', 'initiatives') : r.tag === 'Planned' ? 'not fixed yet' : ''].filter(Boolean).join(' · '))}</span></button>`).join('');
|
|
208
|
+
return `<p class="bd-mlbl">Sprints · from Jira</p>${sp || `<p class="bd-amut bd-mnote">${esc(cur.why || 'No sprint is on record. A Jira read writes one.')}</p>`}<div class="bd-hr"></div><p class="bd-mlbl">Releases</p>${rel || `<p class="bd-amut bd-mnote">${esc((M().release && M().release.why) || 'No release is on record.')}</p>`}<div class="bd-hr"></div><button type="button" class="bd-mi" data-backlog>${SV(I.list)}<span>Backlog</span><span class="k">${B.length} ${plural(B.length, 'work-item', 'work-items')}</span></button>`;
|
|
209
|
+
}
|
|
210
|
+
function openSprint(from) { Pop.open(sprintHtml(), from, { label: 'Sprints and releases', width: 380, cls: 'bd-sprints' }); }
|
|
211
|
+
const nextSprint = () => { const S = (M().jira && M().jira.sprints) || [], i = S.findIndex((s) => s.now); return S[i + 1] || null; };
|
|
212
|
+
function backlogTable(L, n) {
|
|
213
|
+
const ns = nextSprint();
|
|
214
|
+
if (!L.length) return '<p class="bd-amut">No open work-item sits outside a sprint in the Jira reading.</p>';
|
|
215
|
+
return `<div class="bd-bk h"><span>Key</span><span>Work-item</span><span>Initiative</span><span>Pts</span><span></span></div>${L.slice(0, n).map((t) => {
|
|
216
|
+
const q = t.ini ? 'Propose moving ' + t.key + ' (' + t.title + ') to ' + (ns ? ns.name : 'the next sprint') : 'Which initiative should ' + t.key + ' (' + t.title + ') belong to?';
|
|
217
|
+
return `<div class="bd-bk"><span class="bd-pill">${esc(t.key)}</span><span class="bd-ell">${esc(t.title)}</span><span class="bd-amut bd-ell">${esc(t.iniTitle || 'No initiative')}</span><span>${t.points != null ? t.points : '—'}</span><a class="bd-btn sm" href="${esc(A.askHref(t.ini ? A.rowOf('board:' + t.ini) : null, q))}">${t.ini ? 'To ' + esc(ns ? ns.name : 'next sprint') : 'Link'}</a></div>`;
|
|
218
|
+
}).join('')}${L.length > n ? `<p class="bd-amut">${L.length - n} more in the backlog</p>` : ''}`;
|
|
219
|
+
}
|
|
220
|
+
function openRelease(i, from, tab) {
|
|
221
|
+
const R = (M().release && M().release.rel) || [], r = R[i], B = (M().jira && M().jira.backlog) || [];
|
|
222
|
+
const tabs = `<div class="bd-tabs bd-ptabs" role="tablist">${r ? `<button type="button" role="tab" class="bd-tab" data-reltab="rel" data-i="${i}" aria-selected="${tab !== 'backlog'}">${esc(r.name)}</button>` : ''}<button type="button" role="tab" class="bd-tab" data-reltab="backlog" data-i="${i}" aria-selected="${tab === 'backlog' || !r}">Backlog</button></div>`;
|
|
223
|
+
if (tab === 'backlog' || !r) {
|
|
224
|
+
panel('Backlog', `${tabs}<p class="bd-amut">Open work-items in no sprint, from the Jira reading.</p><div class="bd-bkw">${backlogTable(B, 40)}</div><p class="bd-amut bd-pfoot">Sprint moves are proposals. PMOS writes them to Jira only when you press.</p>`, from, { eye: 'Jira · not in a sprint', cls: 'pk-wide' });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const rows = r.ini.map((x) => A.rowOf(x.key)).filter(Boolean);
|
|
228
|
+
const tk = rows.flatMap((x) => (x.track && x.track.tickets) || []), dn = tk.filter((k) => k.status === 'Done').length;
|
|
229
|
+
const you = rows.find((x) => x.track && x.track.you && x.track.key === 'deliver');
|
|
230
|
+
const left = r.days != null && r.days >= 0 ? r.days + ' ' + plural(r.days, 'day', 'days') + ' left' : r.days != null ? 'shipped' : '';
|
|
231
|
+
const ini = rows.map((x) => { const t = x.track || {}, k = t.tickets || [], b = k.find((y) => y.blocked), s = V.statusLine(x); return `<div class="bd-trow"><button type="button" class="bd-dlink" data-key="${esc(x.key)}">${esc(x.title)}<small class="bd-amut">${k.length ? k.filter((y) => y.status === 'Done').length + ' of ' + k.length + ' done' : 'No ticket read yet'}</small></button><span class="bd-pill ${b ? 'r' : s.tone === 'ok' ? 'ok' : s.tone === 'late' ? 'l' : s.tone === 'risk' ? 'w' : ''}">${esc(b ? b.key + ' blocked' : s.text)}</span></div>`; }).join('');
|
|
232
|
+
panel(r.name + (r.tag === 'Released' ? ' shipped ' : ' ships ') + r.at, `${tabs}`
|
|
233
|
+
+ (tk.length ? `<div class="bd-box"><div class="bd-boxh"><b>${dn} of ${tk.length} work-items done</b><span class="bd-amut">${esc(left)}</span></div>${V.barHtml({ pct: Math.round((dn / tk.length) * 100), count: true, label: dn + ' of ' + tk.length }, 'y')}</div>` : '')
|
|
234
|
+
+ `<div class="bd-th"><span>In this release</span><span>Status</span></div>${ini || '<p class="bd-amut">No initiative of this board rides on it.</p>'}`
|
|
235
|
+
+ (you ? `<div class="bd-need sm"><span class="bd-push0">Release notes ${esc(r.name)} wait on your sign-off.</span><a class="bd-btn sm solid" href="${esc(A.pageHref(you))}">Open in Home</a></div>` : '')
|
|
236
|
+
+ `<p class="bd-lbl">Backlog preview · not in a sprint</p><div class="bd-bkw">${backlogTable(B, 3)}</div><p class="bd-amut bd-pfoot">Sprint moves are proposals. PMOS writes them to Jira only when you press.</p>`,
|
|
237
|
+
from, { eye: 'Release · Jira fix version', sub: you ? 'Sign-off by you' : r.type ? cap(r.type) + ' release' : '', cls: 'pk-wide' });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ── a metric's trend (BdPanel) ───────────────────────────────────────────────────────────────────────────────── */
|
|
241
|
+
const TREND = { late: ['late', 'Late', 'late'], risk: ['risk', 'At risk', 'at risk'], blocked: ['red', 'Blocked', 'blocked'], idle: ['q', 'Idle 30+ days', 'idle'] };
|
|
242
|
+
/** Late, week by week for the last eight weeks: the initiatives open today whose end date had passed by the end of that week. The other
|
|
243
|
+
* measures keep no history, so they draw no line. */
|
|
244
|
+
function lateSeries() {
|
|
245
|
+
const rows = M().initiatives.list.rows.filter((r) => r.end && r.status !== 'done'), now = new Date(), out = [];
|
|
246
|
+
for (let w = 7; w >= 0; w--) { const at = new Date(now.getFullYear(), now.getMonth(), now.getDate() - w * 7); out.push(rows.filter((r) => day(r.end) < at && r.late).length); }
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
function trendHtml(k) {
|
|
250
|
+
const [tone, name, word] = TREND[k], n = (M().chips || {})[k] || 0, on = A.F.chips.has(k);
|
|
251
|
+
let chart = `<p class="bd-amut">No weekly count of ${esc(word)} initiatives is kept yet, so no line is drawn. Insights draws it once the records hold it.</p>`;
|
|
252
|
+
if (k === 'late') {
|
|
253
|
+
const s = lateSeries(), mx = Math.max(1, ...s), X = (i) => 10 + i * 40, Y = (v) => 62 - (v / mx) * 50;
|
|
254
|
+
const d = s.map((v, i) => (i ? 'L' : 'M') + X(i) + ' ' + Y(v).toFixed(1)).join('');
|
|
255
|
+
chart = `<svg class="bd-spark" viewBox="0 0 300 70" role="img" aria-label="Late initiatives per week: ${s.join(', ')}"><path class="ax" d="M0 64H300"/><path class="ln" d="${d}"/><circle cx="${X(7)}" cy="${Y(s[7]).toFixed(1)}" r="3.5"/></svg>`
|
|
256
|
+
+ `<p class="sm">${s[0] === s[7] ? 'The same as eight weeks ago' : (s[7] < s[0] ? 'Down from ' : 'Up from ') + s[0] + ' eight weeks ago'}. ${esc(M().initiatives.list.rows.filter((r) => r.late).map((r) => r.title).slice(0, 2).join(' and ') || 'None')} ${n === 1 ? 'is' : 'are'} late now. Counted from the end dates on record.</p>`;
|
|
257
|
+
}
|
|
258
|
+
return `<div class="bd-trh"><i class="cz-dot ${tone}"></i><b>${esc(name)} · ${n} now</b><span class="bd-amut">${k === 'late' ? '8 weeks' : ''}</span></div>${chart}<div class="bd-arow"><button type="button" class="bd-btn sm${on ? ' on' : ''}" data-trshow="${k}" aria-pressed="${on}">${on ? 'Show all' : 'Show only ' + esc(word)}</button><a class="bd-btn sm ghost" href="/premium-insights.html?ws=${encodeURIComponent(M().board.ws || '')}">See in Insights${SV(I.go)}</a></div>`;
|
|
259
|
+
}
|
|
260
|
+
function openTrend(k, from) { if (TREND[k]) Pop.open(trendHtml(k), from, { label: TREND[k][1] + ' trend', width: 330, cls: 'bd-trend' }); }
|
|
261
|
+
|
|
262
|
+
/* ── Documents (BdDocs) ───────────────────────────────────────────────────────────────────────────────────────── */
|
|
263
|
+
let docOpen = null;
|
|
264
|
+
export const docSel = () => docOpen;
|
|
265
|
+
function docById(id) { return V.docRows().find((x) => V.docId(x) === id) || null; }
|
|
266
|
+
async function openDocPanel(id, from) {
|
|
267
|
+
const x = docById(id); if (!x) return;
|
|
268
|
+
docOpen = id;
|
|
269
|
+
const meta = x.path ? A.docMeta(x.path) : null, h = V.healthOf(x), d = x.d || {};
|
|
270
|
+
const eye = (x.src === 'core' ? 'Board document' : x.kind) + ' · ' + (x.src === 'core' ? M().board.name || 'Board' : x.ini.title);
|
|
271
|
+
const sub = x.src === 'core' ? [d.by, d.cadence].filter(Boolean).join(' · ') : meta ? [meta.by, meta.changed].filter(Boolean).join(' · ') : '';
|
|
272
|
+
const home = x.src === 'ini' ? A.pageHref(x.ini) : null;
|
|
273
|
+
const tools = home ? `<a class="bd-ib" href="${esc(home)}" aria-label="Open in Home" title="Open in Home">${SV(I.ext)}</a>` : '';
|
|
274
|
+
let box = '';
|
|
275
|
+
if (x.parts) { const dn = x.parts.filter((p) => p.done), miss = x.parts.filter((p) => !p.done).map((p) => cap(p.name)); box = `<div class="bd-box"><div class="bd-boxh"><b>${dn.length} of ${x.parts.length} parts</b><span class="bd-amut">Health</span></div>${V.barHtml({ pct: Math.round((dn.length / x.parts.length) * 100), count: true, label: dn.length + ' of ' + x.parts.length + ' parts' })}${miss.length ? `<p class="sm">Missing: ${esc(miss.join(' · '))}</p>` : ''}</div>`; }
|
|
276
|
+
else box = `<div class="bd-box"><div class="bd-boxh"><b>${esc(h.text)}</b><span class="bd-amut">Health</span></div>${x.src === 'core' && d.what ? `<p class="sm">${esc(d.what)}</p>` : ''}</div>`;
|
|
277
|
+
const drift = x.drift && x.drift.length ? `<div class="bd-warn sm">The PRD changed after the tickets were pushed. ${esc(x.drift.join(', '))} may not match.</div>` : '';
|
|
278
|
+
const draft = x.src === 'core' && d.st === 'draft' && d.slot;
|
|
279
|
+
const issue = x.src === 'core' && d.path ? (draft ? `<div class="bd-issue" data-issue-bar="draft"><span>A draft. Nothing is sent: issuing marks it issued and sends nothing to anyone.</span><button type="button" class="bd-btn solid" data-act="issue" data-key="${esc(d.key)}">Issue it</button></div>` : `<div class="bd-issue done" data-issue-bar="done"><span>${esc(d.state || 'Issued')}. Nothing was sent to anyone.</span></div>`) : '';
|
|
280
|
+
const log = meta && meta.log && meta.log.length ? `<p class="bd-lbl">Edit log</p>${meta.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : x.path ? '<p class="bd-amut" id="dlogW">Reading the edit log…</p>' : '';
|
|
281
|
+
const cmp = x.drift && x.drift.length ? `<a class="bd-btn" href="${esc(A.askHref(x.ini, 'What changed in the PRD after ' + x.drift.join(', ') + ' ' + (x.drift.length === 1 ? 'was' : 'were') + ' pushed? Compare it with Jira.'))}">Compare with Jira</a>` : '';
|
|
282
|
+
const foot = home || cmp ? `<div class="bd-arow bd-pfoot">${home ? `<a class="bd-btn solid" href="${esc(home)}">Open in Home</a>` : ''}${cmp}</div>` : '';
|
|
283
|
+
const text = x.path ? `<details class="bd-read"${x.src === 'core' ? ' open' : ''}><summary>Read it</summary><p class="bd-amut">${esc(x.path)}</p><pre class="bd-doc" id="cdText">Reading the document…</pre></details>` : '';
|
|
284
|
+
panel(x.title, `${issue}${msg('formM')}${box}${drift}${log}${text}${foot}`, from, { eye, sub, tools, cls: 'pk-doc' });
|
|
285
|
+
A.redraw();
|
|
286
|
+
if (x.path) {
|
|
287
|
+
if (!meta) { await A.loadDocMeta([x.path]); const m2 = A.docMeta(x.path), w = $('#dlogW'); if (w && docOpen === id) w.outerHTML = m2 && m2.log ? `<p class="bd-lbl">Edit log</p>${m2.log.map((l) => `<div class="bd-trow sm">${V.avatar(l.by, 'b')}<span class="bd-push0">${esc(l.subject)}</span><span class="bd-amut">${esc(l.at)}</span></div>`).join('')}` : '<p class="bd-amut">No edit is in the git history yet.</p>'; }
|
|
288
|
+
let t = null; try { const res = await fetch('/api/doc?ws=' + encodeURIComponent(M().board.ws || '') + '&path=' + encodeURIComponent(x.path), { credentials: 'same-origin' }); t = res.ok ? await res.text() : null; } catch { t = null; }
|
|
289
|
+
const el = $('#cdText'); if (el && docOpen === id) el.textContent = t == null ? x.path + ' could not be read.' : t;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async function issueDoc(key, btn) {
|
|
293
|
+
const D = M().docs || {}, d = (D.rows || []).find((x) => x.key === key); if (!d) return;
|
|
294
|
+
const r = await press(btn, $('#formM'), () => post('/api/core-docs/issue', { scope: D.scope, key: d.key, slot: d.slot }));
|
|
295
|
+
if (!r) return;
|
|
296
|
+
A.say('Issued. Nothing was sent to anyone.'); await A.load(); openDocPanel('core:' + key, null);
|
|
297
|
+
}
|
|
298
|
+
/** Add a document: a board document written by you or drafted by PMOS, kept in PMOS or linked to a page elsewhere (POST /api/custom-docs/add).
|
|
299
|
+
* PMOS saves the title and the address on the board's record; it does not read or sync the linked page. */
|
|
300
|
+
const DKINDS = ['In PMOS', 'Confluence', 'Google Docs', 'Google Slides'];
|
|
301
|
+
const radios = (name, L, cur) => `<div class="bd-rad" role="radiogroup">${L.map(([v, l]) => `<label><input type="radio" name="${name}" value="${esc(v)}"${v === cur ? ' checked' : ''}><span>${esc(l)}</span></label>`).join('')}</div>`;
|
|
302
|
+
function openAddDoc(from) {
|
|
303
|
+
panel('Add a document', `<form class="bd-form" data-form="adddoc"><label>Title<input name="title" maxlength="80" placeholder="For example: UAT plan"></label><p class="bd-albl">Who writes it</p>${radios('writer', [['drafts', 'PMOS drafts it'], ['you', 'I write it']], 'drafts')}<label>Where it lives<select name="kind">${DKINDS.map((k) => `<option>${k}</option>`).join('')}</select></label><label>Address<input name="url" maxlength="300" placeholder="https://" disabled></label><p class="bd-amut">It is saved on the board's record. PMOS does not read or sync a linked page.</p>${msg('formM')}<div class="bd-arow"><button type="submit" class="bd-btn solid">Add</button><button type="button" class="bd-btn" data-pk="close">Not now</button></div></form>`, from, { eye: 'Documents' });
|
|
304
|
+
const f = $('#peek form[data-form="adddoc"]'); if (f) f.kind.onchange = () => { f.url.disabled = f.kind.value === 'In PMOS'; };
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* ── Metrics and Notifications ─────────────────────────────────────────────────────────────────────────────────── */
|
|
308
|
+
/** Metrics: the board's measures (GET /api/board-metrics-premium), each with its value, its week, its change, its target where Insights set
|
|
309
|
+
* one, and a fold with its definition and its values by week. Targets and longer ranges live on Insights. Asks again while some are derived. */
|
|
310
|
+
async function openMetrics(from, again) {
|
|
311
|
+
if (!again) panel('Metrics', '<p class="bd-amut" id="metW">Reading the metrics…</p>', from, { eye: 'Board' });
|
|
312
|
+
let r = null;
|
|
313
|
+
try { r = await (await fetch('/api/board-metrics-premium?ws=' + encodeURIComponent(M().board.ws || ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
|
|
314
|
+
const w = $('#metW'); if (!w) return;
|
|
315
|
+
if (!r || !r.ok || !r.model) { w.textContent = 'The metrics could not be read, so none is shown.' + (r && r.error ? ' The reason: ' + r.error + '.' : ''); return; }
|
|
316
|
+
const m = r.model, ws = encodeURIComponent(M().board.ws || '');
|
|
317
|
+
const tile = (t) => {
|
|
318
|
+
const weeks = (t.wk || []).map((k, i) => `<span>${esc(k)}</span><b>${t.ser && t.ser[i] != null ? esc(String(t.ser[i])) : 'Not kept yet'}</b>`).join('');
|
|
319
|
+
return `<details class="bd-met${t.look || t.kind === 'warn' || t.kind === 'bad' ? ' look' : ''}" data-met="${esc(t.key)}"><summary><span>${esc(t.label)}</span><b>${esc(t.absent || t.value || '')}</b><small>${esc(t.absent ? t.why || '' : t.text || '')}</small>`
|
|
320
|
+
+ `${t.change && !t.absent ? `<small>${esc(t.change.txt)}</small>` : ''}${t.chip ? `<em class="bd-mchip${t.ok ? ' ok' : ''}">${esc(t.chip)}${t.targetTxt ? ' · ' + esc(t.targetTxt) : ''}</em>` : t.look ? '<em class="bd-mchip">Needs a look</em>' : ''}</summary>`
|
|
321
|
+
+ `<p class="bd-amut">${esc(t.def || '')}</p>${weeks ? `<div class="bd-kv">${weeks}</div>` : ''}</details>`;
|
|
322
|
+
};
|
|
323
|
+
w.outerHTML = `<div id="metW"><p class="bd-amut">${esc(m.header || '')}${m.lead ? ' · ' + esc(m.lead) : ''}</p><div class="bd-mets">${(m.tiles || []).map(tile).join('')}</div><p class="bd-amut">${esc(m.note || '')} <a class="bd-alink" href="/premium-insights.html?ws=${ws}">Targets and longer ranges are on Insights</a>.</p></div>`;
|
|
324
|
+
if (m.pending) setTimeout(() => { if ($('#metW')) openMetrics(null, true); }, 3000);
|
|
325
|
+
}
|
|
326
|
+
function openBell(from) {
|
|
327
|
+
const rows = (M().rows || []).filter((r) => r.track && r.track.you), na = (M().chips || {}).asks;
|
|
328
|
+
const list = rows.map((r) => `<button type="button" class="bd-mi" data-act="ini" data-id="${esc(r.key)}"><i class="cz-dot you m-info"></i><span class="tx"><span>${esc(r.title)}</span><span class="bd-amut">${esc(r.track.you)}</span></span></button>`).join('');
|
|
329
|
+
const asks = na ? `<button type="button" class="bd-mi" data-act="asks"><i class="cz-dot you"></i><span class="tx"><span>${na} new ${na === 1 ? 'ask' : 'asks'}</span><span class="bd-amut">Waiting for triage</span></span></button>` : '';
|
|
330
|
+
Pop.open(`<p class="bd-mlbl">On this Board</p>${list || asks ? list + asks : '<p class="bd-amut bd-mnote">Nothing on this board waits on you, and no new ask waits for triage.</p>'}`, from, { label: 'Notifications', width: 340, align: 'right', cls: 'bd-bell' });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export const open = { new: (from) => Asks.openNew(from), asks: (from) => Asks.openAsks(from), row: openRowMenu, sprint: openSprint, metrics: openMetrics, find: openFind, filter: openFilter, gone: (from) => openGone(from, 'all'), bell: openBell, trend: openTrend, release: openRelease, doc: openDocPanel };
|
|
334
|
+
export const closeDoc = () => { docOpen = null; };
|
|
335
|
+
|
|
336
|
+
/* ── the presses ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
337
|
+
document.addEventListener('input', (e) => { if (e.target.id === 'bdQ') { findQ = e.target.value; findAt = 0; const r = $('#bdQr'); if (r) r.innerHTML = findList(); } });
|
|
338
|
+
document.addEventListener('keydown', (e) => {
|
|
339
|
+
if (e.target.id !== 'bdQ') return;
|
|
340
|
+
const n = $$('#bdQr .bd-mi').length;
|
|
341
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); findAt = n ? (findAt + (e.key === 'ArrowDown' ? 1 : n - 1)) % n : 0; $('#bdQr').innerHTML = findList(); }
|
|
342
|
+
else if (e.key === 'Enter') { e.preventDefault(); pickFind(); }
|
|
343
|
+
});
|
|
344
|
+
document.addEventListener('click', async (e) => {
|
|
345
|
+
if (!A || !M()) return;
|
|
346
|
+
const t = e.target;
|
|
347
|
+
const fi = t.closest('[data-findini]'); if (fi) { const r = A.rowOf(fi.dataset.findini); Pop.close(false); if (r) A.openIni(r); return; }
|
|
348
|
+
const ft = t.closest('[data-findtk]'); if (ft) { Pop.close(false); A.openTicket(ft.dataset.ini, ft.dataset.findtk); return; }
|
|
349
|
+
const fl = t.closest('[data-flt]'); if (fl && Pop.isOpen() && Pop.el().contains(fl)) { const S = A.F[fl.dataset.flt], v = fl.dataset.v; if (S.has(v)) S.delete(v); else S.add(v); Pop.redraw(filterHtml()); A.redraw(); return; }
|
|
350
|
+
if (t.closest('[data-fclear]')) { A.F.owners.clear(); A.F.lanes.clear(); A.F.sprints.clear(); Pop.redraw(filterHtml()); A.redraw(); return; }
|
|
351
|
+
const sp = t.closest('[data-sprint]'); if (sp) { const S = A.F.sprints, v = sp.dataset.sprint; if (S.has(v)) S.delete(v); else { S.clear(); S.add(v); } Pop.close(false); A.say(S.has(v) ? 'Showing the initiatives with work in ' + v + '.' : 'Showing every sprint.'); A.redraw(); return; }
|
|
352
|
+
const rl = t.closest('[data-rel]'); if (rl) { Pop.close(false); openRelease(+rl.dataset.rel, $('#chSprint')); return; }
|
|
353
|
+
if (t.closest('[data-backlog]')) { Pop.close(false); openRelease(-1, $('#chSprint'), 'backlog'); return; }
|
|
354
|
+
const rt = t.closest('[data-reltab]'); if (rt) { openRelease(+rt.dataset.i, null, rt.dataset.reltab); return; }
|
|
355
|
+
const tr = t.closest('[data-trshow]'); if (tr) { const k = tr.dataset.trshow; if (A.F.chips.has(k)) A.F.chips.delete(k); else A.F.chips.add(k); Pop.close(false); A.redraw(); return; }
|
|
356
|
+
const g = t.closest('[data-gone]'); if (g) { openGone(null, g.dataset.gone); return; }
|
|
357
|
+
const w = t.closest('[data-why]'); if (w && Pop.isOpen() && Pop.el().contains(w)) { $$('[data-why]', Pop.el()).forEach((b) => { const on = b === w; b.classList.toggle('on', on); b.setAttribute('aria-checked', String(on)); }); return; }
|
|
358
|
+
const ra = t.closest('[data-rowact]'); if (ra) { const r = A.rowOf(ra.dataset.id); if (r) runRow(r, ra.dataset.rowact, ra); return; }
|
|
359
|
+
const od = t.closest('[data-opendoc]'); if (od) { openDocPanel(od.dataset.opendoc, od); return; }
|
|
360
|
+
const b = t.closest('[data-act]'); if (!b) return;
|
|
361
|
+
const k = b.dataset.act;
|
|
362
|
+
if (k === 'gone') { openGone(b, 'all'); return; }
|
|
363
|
+
if (k === 'ini') { const r = A.rowOf(b.dataset.id); Pop.close(false); if (r && A.openIni) A.openIni(r); return; }
|
|
364
|
+
if (k === 'asks') { Pop.close(false); Asks.openAsks($('#chAsks') || b); return; }
|
|
365
|
+
if (k === 'adddoc') { openAddDoc(b); return; }
|
|
366
|
+
if (k === 'issue') { issueDoc(b.dataset.key, b); return; }
|
|
367
|
+
if (k === 'draft') {
|
|
368
|
+
b.disabled = true;
|
|
369
|
+
const r = await pmPost('/api/core-docs/draft', { ws: M().board.ws, scope: M().docs.scope, key: b.dataset.key }).catch(() => null);
|
|
370
|
+
if (r && r.ok) { A.say('The agent is drafting it. It lands as a draft for you to review; nothing is sent.'); await A.load(); } else { b.disabled = false; A.say(errOf(r)); }
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
document.addEventListener('submit', async (e) => {
|
|
374
|
+
const f = e.target.closest('form[data-form="adddoc"]'); if (!f || !A) return;
|
|
375
|
+
e.preventDefault();
|
|
376
|
+
const m = $('#formM'), go = f.querySelector('[type="submit"]'), val = (n) => (f.elements[n] ? String(f.elements[n].value || '').trim() : '');
|
|
377
|
+
const title = val('title'), kd = val('kind'), url = val('url'), writer = (f.querySelector('input[name="writer"]:checked') || {}).value || 'drafts';
|
|
378
|
+
if (!title) { m.textContent = 'Give the document a title.'; return; }
|
|
379
|
+
if (kd !== 'In PMOS' && !url) { m.textContent = 'Paste the address of the ' + kd + ' page, or choose In PMOS.'; return; }
|
|
380
|
+
const body = { scope: M().docs.scope, title, writer, ...(kd !== 'In PMOS' ? { kind: kd, url } : {}) };
|
|
381
|
+
const res = await press(go, m, () => post('/api/custom-docs/add', body));
|
|
382
|
+
if (res) { A.close(); A.say('“' + title + '” is added to the board\'s documents.'); await A.load(); }
|
|
383
|
+
});
|