create-pmos 0.398.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 +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +18 -14
- package/workspace/briefing-premium-board-test.js +80 -48
- package/workspace/briefing-premium-calendar-2-test.js +36 -36
- package/workspace/briefing-premium-calendar-3-test.js +39 -39
- package/workspace/briefing-premium-calendar-test.js +23 -24
- package/workspace/briefing-premium-doc-edit-test.js +6 -2
- package/workspace/briefing-premium-initiative-test.js +38 -16
- package/workspace/briefing-premium-insights-test.js +114 -37
- package/workspace/briefing-premium-metrics-test.js +6 -4
- package/workspace/briefing-premium-products-test.js +10 -7
- package/workspace/briefing-premium-sources-test.js +25 -22
- package/workspace/briefing-premium-test.js +46 -42
- package/workspace/briefing-premium-work-test.js +9 -9
- package/workspace/changelog.json +12 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
- package/workspace/guide/home.md +39 -18
- package/workspace/guide/index.md +1 -1
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +36 -5
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-premium.js +3 -2
- package/workspace/lib/insights-records.js +21 -7
- 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 +8 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -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 +4 -1
- package/workspace/lib/routes-insights-records.js +8 -4
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +2 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/search-index.js +176 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +86 -50
- package/workspace/premium-briefing-depth-test.js +55 -54
- package/workspace/premium-chat-chart-tab-test.js +4 -2
- package/workspace/premium-chat-report-tab-test.js +16 -2
- package/workspace/premium-core-doc-issue-test.js +15 -13
- package/workspace/premium-phone-card-test.js +5 -3
- package/workspace/premium-report-read-test.js +55 -18
- package/workspace/premium-vw-backlog-test.js +2 -2
- package/workspace/premium-vw-cal-test.js +50 -35
- package/workspace/premium-vw-doc-test.js +9 -3
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +2 -2
- package/workspace/premium-vw-meet-test.js +37 -40
- package/workspace/premium-vw-notes-test.js +21 -19
- package/workspace/premium-vw-rec-test.js +11 -12
- package/workspace/premium-welcome-test.js +3 -3
- package/workspace/premium-work-depth-test.js +3 -3
- package/workspace/public/pm/bd-acts.js +303 -225
- 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 +49 -13
- package/workspace/public/pm/bd-views.js +169 -0
- package/workspace/public/pm/cozy-board.css +301 -0
- 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-insights.css +148 -10
- package/workspace/public/pm/cozy-nav.js +103 -39
- package/workspace/public/pm/cozy-news.js +140 -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.js +1 -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/home-adddoc.js +5 -5
- package/workspace/public/pm/home-app.js +329 -55
- package/workspace/public/pm/home-around.js +24 -126
- package/workspace/public/pm/home-chat.js +67 -14
- package/workspace/public/pm/home-data.js +6 -6
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +6 -6
- 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 +17 -134
- package/workspace/public/pm/home-phone-card.js +4 -4
- 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 +54 -26
- package/workspace/public/pm/premium-board.js +163 -39
- package/workspace/public/pm/premium-chart-tab.js +4 -5
- package/workspace/public/pm/premium-first.js +5 -7
- package/workspace/public/pm/premium-insights.js +499 -202
- 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-report-read.js +216 -52
- package/workspace/public/pm/premium-report-tab.js +44 -19
- package/workspace/public/pm/premium-shell.js +7 -7
- package/workspace/public/pm/premium-vw-cal.js +150 -60
- package/workspace/public/pm/premium-vw-mtg.js +488 -261
- package/workspace/public/pm/premium-vw-notes.js +61 -0
- package/workspace/public/pm/rp-parts.js +269 -0
- package/workspace/public/premium-board.html +4 -3
- package/workspace/public/premium-insights.html +10 -10
- package/workspace/public/premium.html +3 -1
- 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/test-lists/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- 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
|
@@ -1,305 +1,383 @@
|
|
|
1
|
-
/* pm/bd-acts.js — the Board's
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Cancelled
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
15
18
|
* Nothing here invents a value: what a record does not hold is not drawn. */
|
|
16
19
|
import { pmPost } from './http.js';
|
|
17
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';
|
|
18
24
|
|
|
19
|
-
export const WTAG = '<span class="bd-wtag" title="This part has no Agreed design yet. It works as a plain version until it has one.">Waiting for design</span>';
|
|
20
25
|
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
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); };
|
|
26
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) : '');
|
|
27
39
|
|
|
28
|
-
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from), close(), redraw(), F, rowOf(key), statusOf(r), openIni(r) }
|
|
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) }
|
|
29
41
|
export function init(api) { A = api; }
|
|
30
42
|
const M = () => A.M();
|
|
31
43
|
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
32
44
|
const errOf = (r) => (r && r.error) || 'Nothing was recorded. The server did not say why.';
|
|
33
45
|
|
|
34
|
-
/** A side panel of this module: its title, the
|
|
35
|
-
function panel(title, body, from,
|
|
36
|
-
A.panel(`<div class="pk-h"><div class="pk-ht"
|
|
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 || '');
|
|
37
49
|
}
|
|
38
50
|
const msg = (id) => `<p class="bd-amsg" id="${id}" role="status"></p>`;
|
|
39
51
|
async function press(btn, m, fn) {
|
|
40
|
-
btn.disabled = true; if (m) m.textContent = '';
|
|
52
|
+
if (btn) btn.disabled = true; if (m) m.textContent = '';
|
|
41
53
|
const r = await fn().catch(() => null);
|
|
42
54
|
if (r && r.ok === true) return r;
|
|
43
|
-
btn.disabled = false; if (m) m.textContent = errOf(r); return null;
|
|
55
|
+
if (btn) btn.disabled = false; if (m) m.textContent = errOf(r); else A.say(errOf(r)); return null;
|
|
44
56
|
}
|
|
45
|
-
async function done(r, text, undo) {
|
|
46
|
-
const
|
|
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, ' ') : ''); };
|
|
47
60
|
|
|
48
|
-
/* ──
|
|
49
|
-
export function listHtml(L) {
|
|
50
|
-
if (!L.length) return tagHead('The list of initiatives') + '<p class="bd-amut">No initiative matches.</p>';
|
|
51
|
-
const row = (r) => { const s = A.statusOf(r); return `<button type="button" class="bd-lr ini2" data-key="${esc(r.key)}"><span class="t"><b>${esc(r.title)}</b><small>${esc([r.owner || 'No owner', r.lane].filter(Boolean).join(' · '))}</small></span><span class="st">${esc((r.track && r.track.label) || r.stage || '')}</span><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="fin${r.over ? ' over' : ''}">${esc(r.finish || 'Not planned')}</span></button>`; };
|
|
52
|
-
return tagHead('The list of initiatives, in the board\'s order') + `<div class="bd-rows" role="list">${L.map(row).join('')}</div>` + goneLink();
|
|
53
|
-
}
|
|
54
|
-
export function stagesHtml(L) {
|
|
55
|
-
const S = M().steps || [];
|
|
56
|
-
const col = (s, j) => { const rs = L.filter((r) => r.track && r.track.k === j); return `<section class="bd-col" aria-label="${esc(s.label)}"><h3>${s.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(s.label)} <span>${s.count}</span></h3>${rs.map((r) => { const st = A.statusOf(r); return `<button type="button" class="bd-card ini2" data-key="${esc(r.key)}"><b>${esc(r.title)}</b><span class="cs s-${st.tone}"><i class="cz-dot ${st.tone}"></i>${esc(st.text)}</span></button>`; }).join('') || '<p class="bd-amut">None loaded</p>'}</section>`; };
|
|
57
|
-
return tagHead('One column per stage of the board') + `<div class="bd-cols">${S.map(col).join('')}</div>`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* ── Cancelled and archived ────────────────────────────────────────────────────────────────────────────────────── */
|
|
61
|
-
export function goneLink() {
|
|
62
|
-
const G = M().initiatives.gone || { cancelled: [], archived: [] }, nc = G.cancelled.length, na = G.archived.length;
|
|
63
|
-
if (!nc && !na) return '';
|
|
64
|
-
return `<p class="bd-gone"><button type="button" class="dlink" data-act="gone">${[nc ? nc + ' cancelled' : '', na ? na + ' archived' : ''].filter(Boolean).join(' · ')}</button></p>`;
|
|
65
|
-
}
|
|
66
|
-
function openGone(from) {
|
|
67
|
-
const G = M().initiatives.gone || { cancelled: [], archived: [] };
|
|
68
|
-
const row = (r, k) => `<div class="bd-ar"><span class="t"><b>${esc(r.title)}</b><small>${esc(k === 'archived' ? (r.acts && r.acts.archived && (r.acts.archived.into ? 'Merged into ' + (r.acts.archived.intoTitle || r.acts.archived.into) : r.acts.archived.reason)) || 'Archived' : (r.acts && r.acts.reason) || 'Cancelled')}</small></span><button type="button" class="bd-btn" data-act="${k === 'archived' ? 'restore' : 'reopen'}" data-id="${esc(r.key)}">${k === 'archived' ? 'Restore' : 'Reopen'}</button></div>`;
|
|
69
|
-
panel('Cancelled and archived', (G.cancelled.length ? `<p class="bd-albl">Cancelled</p>${G.cancelled.map((r) => row(r, 'cancelled')).join('')}` : '') + (G.archived.length ? `<p class="bd-albl">Archived</p>${G.archived.map((r) => row(r, 'archived')).join('')}` : '') + (!G.cancelled.length && !G.archived.length ? '<p class="bd-amut">No initiative of this board is cancelled or archived.</p>' : '') + msg('goneM'), from);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* ── a row's actions: move, hold, resume, cancel, reopen, archive, restore, each with Undo ─────────────────────────── */
|
|
61
|
+
/* ── a row's actions (BdActions): the ⋯ menu ────────────────────────────────────────────────────────────────────── */
|
|
73
62
|
const life = (id, state, reason, back) => post('/api/lifecycle', { initiative_id: id, state, reason: reason || '', ...(back ? { back } : {}) });
|
|
74
63
|
const arch = (id, archived, reason) => post('/api/boards/archive', { board: M().board.id, id, archived, ...(reason ? { reason } : {}) });
|
|
75
|
-
const move = (id, to) => post('/api/boards/move', { board: M().board.id, id, to });
|
|
64
|
+
const move = (id, to, why) => post('/api/boards/move', { board: M().board.id, id, to, ...(why ? { why } : {}) });
|
|
76
65
|
const prevOf = (r) => ({ life: r.acts.life, reason: r.acts.reason, backDay: r.acts.backDay || null });
|
|
77
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'));
|
|
78
|
-
|
|
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) {
|
|
79
70
|
const a = r.acts || { stages: [], stage: '' }, cur = a.stages.indexOf(a.stage), out = [];
|
|
80
|
-
if (a.archived) return [['restore', 'Restore', 'Back in the lists, as it was']];
|
|
81
|
-
if (a.life === 'cancelled') return [['reopen', 'Reopen', 'Back to ' + (a.stage || 'its stage') + ', active again']];
|
|
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']];
|
|
82
73
|
if (!M().board.self && !a.life && cur >= 0) {
|
|
83
|
-
if (a.stages[cur + 1]) out.push(['mv:' + (cur + 1), 'Move to ' + a.stages[cur + 1],
|
|
84
|
-
if (cur > 0) out.push(['
|
|
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, '']);
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
out.push(['cancel', 'Cancel',
|
|
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, '']);
|
|
89
80
|
return out;
|
|
90
81
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
|
|
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>`;
|
|
94
97
|
}
|
|
95
98
|
async function runRow(r, k, btn) {
|
|
96
99
|
const a = r.acts, p = prevOf(r), m = $('#rowM');
|
|
97
|
-
if (k
|
|
98
|
-
|
|
99
|
-
const
|
|
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;
|
|
100
105
|
const w = Array.isArray(res.warnings) && res.warnings.length ? ' Warning: ' + res.warnings.join('; ') + '. Warnings never block.' : '';
|
|
101
|
-
await done(res, 'Moved to ' + to + '
|
|
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(); });
|
|
102
125
|
return;
|
|
103
126
|
}
|
|
104
|
-
if (k === 'hold') return formHold(r);
|
|
105
|
-
if (k === 'cancel') return formReason(r, 'cancel');
|
|
106
|
-
if (k === 'archive') return formReason(r, 'archive');
|
|
107
127
|
if (k === 'resume' || k === 'reopen') {
|
|
108
|
-
const res = await press(btn,
|
|
109
|
-
await done(res,
|
|
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);
|
|
110
131
|
return;
|
|
111
132
|
}
|
|
112
133
|
if (k === 'restore') {
|
|
113
|
-
const res = await press(btn,
|
|
114
|
-
await done(res,
|
|
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);
|
|
115
137
|
}
|
|
116
138
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
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' });
|
|
124
158
|
}
|
|
125
159
|
|
|
126
|
-
/* ──
|
|
127
|
-
let
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return
|
|
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 };
|
|
135
169
|
}
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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>` : '');
|
|
142
177
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const L = (A0 && A0.rows) || [];
|
|
147
|
-
panel('New asks', A0 == null || A0.missing ? '<p class="bd-amut">The new asks could not be read, so none is shown.</p>' : L.length ? L.map((a) => `<div class="bd-ask"><p class="bd-quote">“${esc(a.line)}”</p><small>${esc([a.source, a.by, a.at].filter(Boolean).join(' · '))}</small><div class="bd-arow"><button type="button" class="bd-btn solid" data-act="accept" data-id="${esc(a.id)}">Accept</button><button type="button" class="bd-btn" data-act="decline" data-id="${esc(a.id)}">Decline</button></div></div>`).join('') : '<p class="bd-amut">No new ask waits for triage.</p>', from);
|
|
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' });
|
|
148
181
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
182
|
+
function pickFind() {
|
|
183
|
+
const b = $$('#bdQr .bd-mi')[findAt]; if (b) b.click();
|
|
151
184
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
|
|
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>`;
|
|
159
196
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
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>`
|
|
173
|
-
+ `${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>`
|
|
174
|
-
+ `<p class="bd-amut">${esc(t.def || '')}</p>${weeks ? `<div class="bd-kv">${weeks}</div>` : ''}</details>`;
|
|
175
|
-
};
|
|
176
|
-
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>`;
|
|
177
|
-
if (m.pending) setTimeout(() => { if ($('#metW')) openMetrics(null, true); }, 3000);
|
|
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>`;
|
|
178
209
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
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>` : ''}`;
|
|
183
219
|
}
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
|
|
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' });
|
|
188
238
|
}
|
|
189
239
|
|
|
190
|
-
/* ──
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return
|
|
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;
|
|
198
248
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
+
}
|
|
209
291
|
}
|
|
210
292
|
async function issueDoc(key, btn) {
|
|
211
293
|
const D = M().docs || {}, d = (D.rows || []).find((x) => x.key === key); if (!d) return;
|
|
212
294
|
const r = await press(btn, $('#formM'), () => post('/api/core-docs/issue', { scope: D.scope, key: d.key, slot: d.slot }));
|
|
213
295
|
if (!r) return;
|
|
214
|
-
A.say('Issued. Nothing was sent to anyone.'); await A.load();
|
|
296
|
+
A.say('Issued. Nothing was sent to anyone.'); await A.load(); openDocPanel('core:' + key, null);
|
|
215
297
|
}
|
|
216
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).
|
|
217
299
|
* PMOS saves the title and the address on the board's record; it does not read or sync the linked page. */
|
|
218
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>`;
|
|
219
302
|
function openAddDoc(from) {
|
|
220
|
-
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);
|
|
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' });
|
|
221
304
|
const f = $('#peek form[data-form="adddoc"]'); if (f) f.kind.onchange = () => { f.url.disabled = f.kind.value === 'In PMOS'; };
|
|
222
305
|
}
|
|
223
|
-
|
|
224
|
-
/* ──
|
|
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
|
+
}
|
|
225
326
|
function openBell(from) {
|
|
226
327
|
const rows = (M().rows || []).filter((r) => r.track && r.track.you), na = (M().chips || {}).asks;
|
|
227
|
-
const list = rows.map((r) => `<button type="button" class="bd-
|
|
228
|
-
const asks = na ? `<button type="button" class="bd-
|
|
229
|
-
|
|
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' });
|
|
230
331
|
}
|
|
231
|
-
|
|
232
|
-
const
|
|
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
|
+
});
|
|
233
344
|
document.addEventListener('click', async (e) => {
|
|
234
|
-
|
|
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;
|
|
235
361
|
const k = b.dataset.act;
|
|
236
|
-
if (k === 'gone') { openGone(b); return; }
|
|
237
|
-
if (k === 'ini') { const r = A.rowOf(b.dataset.id); if (r && A.openIni) A.openIni(r); return; }
|
|
238
|
-
if (k === 'asks') { openAsks(b); return; }
|
|
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; }
|
|
239
365
|
if (k === 'adddoc') { openAddDoc(b); return; }
|
|
240
|
-
if (k === 'cdoc') { openCoreDoc(b.dataset.key, b); return; }
|
|
241
366
|
if (k === 'issue') { issueDoc(b.dataset.key, b); return; }
|
|
242
|
-
if (k === 'accept') { const a = askOf(b.dataset.id); if (a) openNew(null, a); return; }
|
|
243
|
-
if (k === 'decline') { const a = askOf(b.dataset.id); if (a) openDecline(a); return; }
|
|
244
|
-
if (k === 'fclear') { A.F.owners.clear(); A.F.lanes.clear(); $$('[data-flt]').forEach((x) => { x.checked = false; }); A.redraw(); return; }
|
|
245
|
-
if (k === 'row') { const r = A.rowOf(b.dataset.id); if (r) runRow(r, b.dataset.k, b); return; }
|
|
246
|
-
if (k === 'reopen' || k === 'restore') { const r = A.rowOf(b.dataset.id); if (r) runRow(r, k, b); return; }
|
|
247
367
|
if (k === 'draft') {
|
|
248
368
|
b.disabled = true;
|
|
249
369
|
const r = await pmPost('/api/core-docs/draft', { ws: M().board.ws, scope: M().docs.scope, key: b.dataset.key }).catch(() => null);
|
|
250
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)); }
|
|
251
371
|
}
|
|
252
372
|
});
|
|
253
|
-
document.addEventListener('change', (e) => {
|
|
254
|
-
const c = e.target.closest('[data-flt]'); if (!c || !A) return;
|
|
255
|
-
const S = A.F[c.dataset.flt]; if (c.checked) S.add(c.value); else S.delete(c.value); A.redraw();
|
|
256
|
-
});
|
|
257
373
|
document.addEventListener('submit', async (e) => {
|
|
258
|
-
const f = e.target.closest('form[data-form]'); if (!f || !A) return;
|
|
374
|
+
const f = e.target.closest('form[data-form="adddoc"]'); if (!f || !A) return;
|
|
259
375
|
e.preventDefault();
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (!ask) { const r0 = await post('/api/boards/asks/add', { board: M().board.id, line: title, source: 'New initiative, typed by you' }); if (!r0 || r0.ok !== true) return r0; ask = r0.ask && r0.ask.id; }
|
|
268
|
-
return post('/api/boards/asks/accept', { board: M().board.id, ask, title, lane, anchor });
|
|
269
|
-
});
|
|
270
|
-
if (res) await done(res, '“' + title + '” is ' + (askId ? 'accepted' : 'created') + ' in ' + (res.stage || 'the first stage') + ', anchored to ' + anchor + '.');
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (kind === 'adddoc') {
|
|
274
|
-
const title = val('title'), kd = val('kind'), url = val('url'), writer = (f.querySelector('input[name="writer"]:checked') || {}).value || 'drafts';
|
|
275
|
-
if (!title) { m.textContent = 'Give the document a title.'; return; }
|
|
276
|
-
if (kd !== 'In PMOS' && !url) { m.textContent = 'Paste the address of the ' + kd + ' page, or choose In PMOS.'; return; }
|
|
277
|
-
const body = { scope: M().docs.scope, title, writer, ...(kd !== 'In PMOS' ? { kind: kd, url } : {}) };
|
|
278
|
-
const res = await press(go, m, () => post('/api/custom-docs/add', body));
|
|
279
|
-
if (res) await done(res, '“' + title + '” is added to the board\'s documents.');
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (kind === 'decline') {
|
|
283
|
-
const why = val('why').replace(/\s+/g, ' '); if (!why) { m.textContent = 'Say why. A decline needs a reason.'; return; }
|
|
284
|
-
const res = await press(go, m, () => post('/api/boards/asks/decline', { board: M().board.id, ask: f.dataset.ask, why }));
|
|
285
|
-
if (res) await done(res, 'Ask declined. The reason is kept in the board ledger.');
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const r = A.rowOf(f.dataset.id); if (!r) return;
|
|
289
|
-
const p = prevOf(r);
|
|
290
|
-
if (kind === 'hold') {
|
|
291
|
-
const bk = BACK.find((q) => q[0] === val('back')) || BACK[1], day = bk[2] != null ? dayIso(bk[2]) : null;
|
|
292
|
-
const res = await press(go, m, () => life(r.id, 'on-hold', val('why'), day));
|
|
293
|
-
if (res) await done(res, r.title + ' is on hold. Recorded as a lifecycle line.', async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? r.title + ' is back as it was.' : errOf(u)); await A.load(); });
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
const why = val('why'); if (!why) { m.textContent = 'Pick a reason.'; return; }
|
|
297
|
-
const reason = why + (val('note') ? ': ' + val('note').replace(/\s+/g, ' ') : '');
|
|
298
|
-
if (kind === 'cancel') {
|
|
299
|
-
const res = await press(go, m, () => life(r.id, 'cancelled', reason));
|
|
300
|
-
if (res) await done(res, r.title + ' is cancelled. Recorded as a lifecycle line.', async () => { const u = await lifeBack(r, p); A.say(u && u.ok ? r.title + ' is back as it was.' : errOf(u)); await A.load(); });
|
|
301
|
-
} else if (kind === 'archive') {
|
|
302
|
-
const res = await press(go, m, () => arch(r.id, true, reason));
|
|
303
|
-
if (res) await done(res, r.title + ' is archived. Recorded in the board ledger.', async () => { const u = await arch(r.id, false); A.say(u && u.ok ? r.title + ' is restored.' : errOf(u)); await A.load(); });
|
|
304
|
-
}
|
|
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(); }
|
|
305
383
|
});
|