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
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/* pm/bd-asks.js — new asks, New initiative and its first questions (initiative premium-uncovered-features, Board: BdAsks, BdNew, BdGrill, BdPhone).
|
|
2
|
+
* New asks (BdAsks) a popover (a bottom sheet on a phone) under the chip: each ask with who sent it and where, the product it is for and why,
|
|
3
|
+
* the kind PMOS suggests, its anchor, the initiative it is close to and an earlier rejection. Accept to Triage
|
|
4
|
+
* POST /api/boards/asks/accept (Undo archives what it made); Add to <initiative> and Decline POST /api/boards/asks/decline
|
|
5
|
+
* with the reason. An ask the record gives two products for sits under "Not sure which product".
|
|
6
|
+
* New initiative (BdNew) the side panel: name, why, material (links and files), no lane field (PMOS leans on the intake draft and names the
|
|
7
|
+
* kind in Triage), what it counts toward, the product. A name close to an earlier rejection or to an open initiative
|
|
8
|
+
* says so. Create: POST /api/boards/asks/add then /asks/accept (it starts in the first stage), then POST /api/board-grill/start
|
|
9
|
+
* and /file for the material.
|
|
10
|
+
* First questions (BdGrill) the same panel, right after: what PMOS took from the Why and the material, then only the open questions, one at a
|
|
11
|
+
* time (POST /api/board-grill/answer). Later (POST /api/board-grill/later) keeps them as the initiative's next step.
|
|
12
|
+
* Nothing is sent to anyone: a decline keeps its reason in the board ledger. */
|
|
13
|
+
import { pmPost } from './http.js';
|
|
14
|
+
import { $, $$, esc } from './premium-shell.js';
|
|
15
|
+
import * as Pop from './bd-pop.js';
|
|
16
|
+
import { avatar } from './bd-views.js';
|
|
17
|
+
|
|
18
|
+
let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), rowOf(key), openIni(r), openDoc(path), anchors() }
|
|
19
|
+
export function init(api) { A = api; }
|
|
20
|
+
const M = () => A.M();
|
|
21
|
+
const post = (p, body) => pmPost(p, { ws: M().board.ws, ...body });
|
|
22
|
+
const errOf = (r) => (r && r.error) || 'Nothing was recorded. The server did not say why.';
|
|
23
|
+
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
24
|
+
const I = { x: 'M6 6l12 12M18 6L6 18', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1', file: 'M7 3h7l5 5v13H7zM14 3v5h5', up: 'M12 16V4M7 9l5-5 5 5M5 20h14', info: 'M12 8v5M12 16h.01M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18', chev: 'M7 10l5 5 5-5', next: 'M9 6l6 6-6 6' };
|
|
25
|
+
const cap = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : '');
|
|
26
|
+
const krShort = (a) => { const s = String(a || ''); if (!s) return ''; if (/^health:/.test(s)) return 'Health budget'; const m = /:o(\d+):kr(\d+)/i.exec(s); return m ? 'KR ' + m[1] + '.' + m[2] : s; };
|
|
27
|
+
const WHY_NOT = ['Out of scope', 'Already planned', 'Not now', 'Other'];
|
|
28
|
+
|
|
29
|
+
/* ── New asks (BdAsks, BdPhone) ─────────────────────────────────────────────────────────────────────────────────── */
|
|
30
|
+
let declining = null, expanded = null, picked = {};
|
|
31
|
+
const asksOf = () => ((M().asks && M().asks.rows) || []);
|
|
32
|
+
function askCard(a, i, phone) {
|
|
33
|
+
if (phone && i > 0 && expanded !== a.id) return `<button type="button" class="bd-acard row" data-askopen="${esc(a.id)}">${avatar(a.by || a.source)}<span class="tx"><b>${esc(a.by || a.source || 'Someone')}</b> · “${esc(a.line)}”</span>${SV(I.next)}</button>`;
|
|
34
|
+
const who = `<div class="bd-awho">${avatar(a.by || a.source)}<b>${esc(a.by || a.source || 'Someone')}</b><span class="bd-amut">${esc([a.by ? a.source : '', a.at].filter(Boolean).map((x) => '· ' + x).join(' '))}</span></div>`;
|
|
35
|
+
const prod = picked[a.id] || a.product;
|
|
36
|
+
const product = prod && prod.name ? `<div class="bd-aprod"><span class="bd-chip sm"><b>${esc(prod.name)}</b></span><span class="bd-amut">Why: ${esc(prod.why || '')}</span></div>` : '';
|
|
37
|
+
const pills = [a.draft.lane ? `<span class="bd-pill">Suggest: ${esc(cap(a.draft.lane))}</span>` : '', a.draft.anchor ? `<span class="bd-pill">${esc(krShort(a.draft.anchor))}</span>` : '', a.close ? `<span class="bd-pill w">Close to: ${esc(a.close.title)}</span>` : ''].join('');
|
|
38
|
+
const prior = (a.prior || []).length ? `<p class="bd-warn sm">Close to something you declined: “${esc(a.prior[0].title)}”.</p>` : '';
|
|
39
|
+
if (declining === a.id) {
|
|
40
|
+
return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}<p class="bd-lbl">Why not</p><div class="bd-chips" role="radiogroup" aria-label="Why not">${WHY_NOT.map((w, j) => `<button type="button" class="bd-chip${j === 0 ? ' on' : ''}" role="radio" aria-checked="${j === 0}" data-whynot="${esc(w)}">${esc(w)}</button>`).join('')}</div>`
|
|
41
|
+
+ `<input class="bd-inp sm" name="why" maxlength="400" placeholder="Say a little more, optional" aria-label="Why not, in your words"><p class="bd-amsg" role="status"></p>`
|
|
42
|
+
+ `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="decline-go" data-id="${esc(a.id)}">Decline</button><button type="button" class="bd-btn sm ghost" data-askact="back">Back</button><span class="bd-amut bd-push">The reason is kept with the ask</span></div></div>`;
|
|
43
|
+
}
|
|
44
|
+
const btns = phone
|
|
45
|
+
? `<button type="button" class="bd-btn solid wide" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage())}</button><div class="bd-arow two">${a.close ? `<button type="button" class="bd-btn" data-askact="add" data-id="${esc(a.id)}">Add to existing</button>` : ''}<button type="button" class="bd-btn ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`
|
|
46
|
+
: `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage())}</button>${a.close ? `<button type="button" class="bd-btn sm" data-askact="add" data-id="${esc(a.id)}">Add to ${esc(a.close.title)}</button>` : ''}<button type="button" class="bd-btn sm ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`;
|
|
47
|
+
return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}${pills ? `<div class="bd-pills">${pills}</div>` : ''}${prior}${btns}<p class="bd-amsg" role="status"></p></div>`;
|
|
48
|
+
}
|
|
49
|
+
const firstStage = () => (M().board.stages || [])[0] || 'Triage';
|
|
50
|
+
function unsureHtml(L) {
|
|
51
|
+
if (!L.length) return '';
|
|
52
|
+
return `<div class="bd-unsure"><p class="bd-lbl">Not sure which product · ${L.length}</p>${L.map((a) => `<div class="bd-un1"><p class="sm">${esc(a.by || 'Someone')}${a.source ? ' by ' + esc(a.source.toLowerCase()) : ''}: “${esc(a.line)}”</p><p class="bd-amut">Could be ${a.products.map((p) => esc(p.name) + (p.why ? ' (' + esc(p.why) + ')' : '')).join(' or ')}.</p><div class="bd-chips">${a.products.map((p) => `<button type="button" class="bd-chip" data-pickprod="${esc(a.id)}" data-prod="${esc(p.id)}">${esc(p.name)}</button>`).join('')}</div></div>`).join('')}<p class="bd-amut bd-hr">PMOS picks the product from where the ask came from and what it talks about. When both point the same way, it shows the product with its reason. When they disagree, it asks you.</p></div>`;
|
|
53
|
+
}
|
|
54
|
+
function asksHtml() {
|
|
55
|
+
const L = asksOf(), phone = matchMedia('(max-width: 720px)').matches;
|
|
56
|
+
if (M().board.self) return '<p class="bd-h3">New asks</p><p class="bd-amut">PMOS-self has no ask source. New work starts at the pmos-router skill.</p>';
|
|
57
|
+
if (M().asks == null || M().asks.missing) return '<p class="bd-h3">New asks</p><p class="bd-amut">The new asks could not be read, so none is shown.</p>';
|
|
58
|
+
const sure = L.filter((a) => !(a.products || []).length || picked[a.id]), unsure = L.filter((a) => (a.products || []).length && !picked[a.id]);
|
|
59
|
+
const src = [...new Set(L.map((a) => a.source).filter(Boolean))];
|
|
60
|
+
const head = `<div class="bd-phead"><p class="bd-h3" id="hAsks">${L.length} new ${L.length === 1 ? 'ask' : 'asks'}</p>${src.length ? `<span class="bd-amut">For ${esc(M().board.name || 'this board')} · from ${esc(src.slice(0, 3).join(', ').toLowerCase())}</span>` : ''}</div>`;
|
|
61
|
+
if (!L.length) return head + '<p class="bd-amut">No new ask waits for triage.</p>';
|
|
62
|
+
return head + `<div class="bd-acards">${sure.map((a, i) => askCard(a, i, phone)).join('')}</div>` + unsureHtml(unsure);
|
|
63
|
+
}
|
|
64
|
+
export function openAsks(btn) {
|
|
65
|
+
declining = null; expanded = null;
|
|
66
|
+
Pop.open(asksHtml(), btn, { label: 'New asks', width: 520, cls: 'bd-asks' });
|
|
67
|
+
}
|
|
68
|
+
const redrawAsks = () => Pop.redraw(asksHtml());
|
|
69
|
+
async function acceptAsk(a, btn) {
|
|
70
|
+
const d = a.draft || {};
|
|
71
|
+
if (!d.anchor) { Pop.close(false); openNew(null, a); return; } // no anchor yet: the New initiative panel asks for one
|
|
72
|
+
btn.disabled = true;
|
|
73
|
+
const r = await post('/api/boards/asks/accept', { board: M().board.id, ask: a.id, title: d.title, lane: d.lane || 'feature', anchor: d.anchor, intent: a.line.slice(0, 400) }).catch(() => null);
|
|
74
|
+
if (!r || !r.ok) { btn.disabled = false; const m = btn.closest('.bd-acard').querySelector('.bd-amsg'); if (m) m.textContent = errOf(r); return; }
|
|
75
|
+
Pop.close(false);
|
|
76
|
+
const id = r.initiative && r.initiative.id;
|
|
77
|
+
A.say('Accepted to ' + (r.stage || firstStage()) + ' · ' + d.title, id ? async () => { const u = await post('/api/boards/archive', { board: M().board.id, id, archived: true, reason: 'Accepted by mistake: undone' }).catch(() => null); A.say(u && u.ok ? d.title + ' is undone. It is archived, and nothing else changed.' : errOf(u)); await A.load(); } : null);
|
|
78
|
+
await A.load();
|
|
79
|
+
}
|
|
80
|
+
document.addEventListener('click', async (e) => {
|
|
81
|
+
if (!A || !Pop.isOpen() || !Pop.el().contains(e.target)) return;
|
|
82
|
+
const op = e.target.closest('[data-askopen]'); if (op) { expanded = op.dataset.askopen; redrawAsks(); return; }
|
|
83
|
+
const wn = e.target.closest('[data-whynot]'); if (wn) { $$('[data-whynot]', Pop.el()).forEach((b) => { const on = b === wn; b.classList.toggle('on', on); b.setAttribute('aria-checked', String(on)); }); return; }
|
|
84
|
+
const pp = e.target.closest('[data-pickprod]');
|
|
85
|
+
if (pp) {
|
|
86
|
+
const a = asksOf().find((x) => x.id === pp.dataset.pickprod), p = a && a.products.find((x) => x.id === pp.dataset.prod); if (!p) return;
|
|
87
|
+
if (p.name === M().board.name || p.id === M().board.id) { picked[a.id] = { name: p.name, why: 'you chose it' }; redrawAsks(); }
|
|
88
|
+
else A.say('Open the ' + p.name + ' Board to accept it there. This Board holds only ' + (M().board.name || 'its own') + ' work.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const b = e.target.closest('[data-askact]'); if (!b) return;
|
|
92
|
+
const k = b.dataset.askact, a = asksOf().find((x) => x.id === b.dataset.id);
|
|
93
|
+
if (k === 'back') { declining = null; redrawAsks(); return; }
|
|
94
|
+
if (!a) return;
|
|
95
|
+
if (k === 'decline') { declining = a.id; redrawAsks(); const f = Pop.el().querySelector('[data-whynot].on'); if (f) f.focus(); return; }
|
|
96
|
+
if (k === 'accept') { acceptAsk(a, b); return; }
|
|
97
|
+
const card = b.closest('.bd-acard'), m = card && card.querySelector('.bd-amsg');
|
|
98
|
+
let why;
|
|
99
|
+
if (k === 'add') why = 'Added to ' + a.close.title + ' (' + a.close.id + ')';
|
|
100
|
+
else { const c = Pop.el().querySelector('[data-whynot].on'), t = (card.querySelector('input[name="why"]') || {}).value || ''; why = ((c && c.dataset.whynot) || 'Other') + (t.trim() ? ': ' + t.trim().replace(/\s+/g, ' ') : ''); }
|
|
101
|
+
b.disabled = true;
|
|
102
|
+
const r = await post('/api/boards/asks/decline', { board: M().board.id, ask: a.id, why }).catch(() => null);
|
|
103
|
+
if (!r || !r.ok) { b.disabled = false; if (m) m.textContent = errOf(r); return; }
|
|
104
|
+
declining = null; Pop.close(false);
|
|
105
|
+
A.say(k === 'add' ? 'Added to ' + a.close.title + '. The ask is kept with the reason.' : 'Ask declined. The reason is kept in the board ledger.');
|
|
106
|
+
await A.load();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/* ── New initiative (BdNew) ────────────────────────────────────────────────────────────────────────────────────── */
|
|
110
|
+
let N = null; // the form: { ask, links: [{url,label}], files: [File], lean, prior, ack }
|
|
111
|
+
function materialChips() {
|
|
112
|
+
return N.links.map((k, i) => `<span class="bd-chip sm">${SV(I.link)}${esc(k.label)}<button type="button" class="bd-x0" data-rmlink="${i}" aria-label="Remove ${esc(k.label)}">${SV(I.x)}</button></span>`).join('')
|
|
113
|
+
+ N.files.map((f, i) => `<span class="bd-chip sm">${SV(I.file)}${esc(f.name)}<button type="button" class="bd-x0" data-rmfile="${i}" aria-label="Remove ${esc(f.name)}">${SV(I.x)}</button></span>`).join('');
|
|
114
|
+
}
|
|
115
|
+
function kindBox() {
|
|
116
|
+
const lean = N.lean ? cap(N.lean) : null;
|
|
117
|
+
return `<b>Kind of work · PMOS works it out</b><span>No need to choose now. It starts in ${esc(firstStage())}, and PMOS names the kind (feature, discovery, chore and so on) once the BRD or the first research makes it clear. It tells you in New for you, and you can change it.</span><span class="bd-amut">Now: ${lean ? 'not sure yet · leaning ' + esc(lean) + ', from the words of the name' : 'not sure yet'}</span>`;
|
|
118
|
+
}
|
|
119
|
+
function hintsHtml() {
|
|
120
|
+
const p = N.prior && N.prior[0] && !N.ack ? `<div class="bd-warn"><b>Close to something you declined</b><span>“${esc(N.prior[0].title)}” was set aside in ${esc(N.prior[0].file)}.</span><div class="bd-arow"><button type="button" class="bd-btn sm" data-newact="seewhy">See why</button><button type="button" class="bd-btn sm ghost" data-newact="ack">It is different</button></div></div>` : '';
|
|
121
|
+
const c = N.close ? `<div class="bd-need">${SV(I.info)}<span>Also close to <button type="button" class="bd-dlink" data-newact="close">${esc(N.close.title)}</button> in ${esc(N.close.stage || 'its stage')}. Add to it instead?</span></div>` : '';
|
|
122
|
+
return p + c;
|
|
123
|
+
}
|
|
124
|
+
/** The open initiative a new name is close to (the model's rule for asks, run on the page as the PM types). */
|
|
125
|
+
function closeOf(text) {
|
|
126
|
+
const STOP = new Set(['the', 'and', 'for', 'with', 'from', 'that', 'this', 'who', 'what', 'when', 'can', 'are', 'was', 'not', 'our', 'your', 'their', 'they', 'into', 'each', 'all', 'any', 'has', 'have', 'its']);
|
|
127
|
+
const sig = (s) => new Set(String(s || '').toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length >= 3 && !STOP.has(w)));
|
|
128
|
+
const want = sig(text); let best = null;
|
|
129
|
+
for (const r of M().initiatives.list.rows) { const have = sig(r.title), n = [...have].filter((w) => want.has(w)).length; if (have.size && (n >= 2 || (n >= 1 && n / have.size >= 0.5)) && (!best || n > best.n)) best = { n, r }; }
|
|
130
|
+
return best ? { key: best.r.key, title: best.r.title, stage: (best.r.track && best.r.track.label) || best.r.stage } : null;
|
|
131
|
+
}
|
|
132
|
+
export async function openNew(from, ask) {
|
|
133
|
+
const d = ask ? ask.draft || {} : {};
|
|
134
|
+
N = { ask: ask || null, links: [], files: [], lean: d.lane || null, prior: ask ? ask.prior || [] : [], ack: false, close: null };
|
|
135
|
+
const body = `<form class="bd-form bd-new" data-form="new2"${ask ? ` data-ask="${esc(ask.id)}"` : ''} novalidate>`
|
|
136
|
+
+ (ask ? `<p class="bd-quote">“${esc(ask.line)}”</p>` : '')
|
|
137
|
+
+ `<label class="bd-field">Name<input class="bd-inp" name="title" maxlength="120" value="${esc(d.title || '')}" placeholder="For example: Partner SSO audit trail" autocomplete="off"></label>`
|
|
138
|
+
+ `<label class="bd-field">Why<textarea class="bd-inp ta" name="why" rows="3" maxlength="400" placeholder="Who asks for it, and what it changes for them">${esc(ask ? ask.line : '')}</textarea></label>`
|
|
139
|
+
+ `<div class="bd-field"><span class="bd-flbl">Material · links or files</span><div class="bd-drop" id="nwDrop"><span class="bd-mchips" id="nwMat"></span><span class="bd-sp"></span><button type="button" class="bd-ib sm" data-newact="link" aria-label="Paste a link" title="Paste a link">${SV(I.link)}</button><button type="button" class="bd-ib sm" data-newact="file" aria-label="Upload a file" title="Upload a file">${SV(I.up)}</button><input type="file" id="nwFile" multiple hidden></div>`
|
|
140
|
+
+ `<div class="bd-linkin" id="nwLink" hidden><input class="bd-inp sm" name="link" maxlength="600" placeholder="https://" aria-label="A link"><button type="button" class="bd-btn sm" data-newact="addlink">Add</button></div><p class="bd-amut">Drop files here. PMOS reads them before it asks you anything.</p></div>`
|
|
141
|
+
+ `<div class="bd-box sm" id="nwKind">${kindBox()}</div>`
|
|
142
|
+
+ `<label class="bd-field">Counts toward<span id="anW"><select class="bd-inp" name="anchor" disabled><option>Reading the goals</option></select></span><span class="bd-amut">A goal, or a health budget for upkeep work.</span></label>`
|
|
143
|
+
+ `<div class="bd-field"><span class="bd-flbl">Product</span><span class="bd-inp ro">${esc(M().board.name || 'This board')}</span></div>`
|
|
144
|
+
+ `<div id="nwHints">${hintsHtml()}</div><p class="bd-amsg" id="formM" role="status"></p>`
|
|
145
|
+
+ `<div class="bd-arow bd-pfoot"><button type="submit" class="bd-btn solid">${ask ? 'Accept and start ' : 'Create and start '}${esc(firstStage())}</button><span class="bd-amut">PMOS asks a few questions next</span></div></form>`;
|
|
146
|
+
A.panel(`<div class="pk-h"><div class="pk-ht"><h2 id="pkTitle">${ask ? 'Accept ask' : 'New initiative'}</h2></div><div class="pk-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, 'pk-new');
|
|
147
|
+
const L = await A.anchors(), w = $('#anW'); if (!w) return;
|
|
148
|
+
w.innerHTML = L && L.length ? `<select class="bd-inp" name="anchor"><option value="">Choose a goal or a health budget</option>${L.map((x) => `<option value="${esc(x.value)}"${x.value === d.anchor ? ' selected' : ''}>${esc(x.label || x.value)}</option>`).join('')}</select>`
|
|
149
|
+
: `<input class="bd-inp" name="anchor" maxlength="120" value="${esc(d.anchor || '')}" placeholder="A KR id or health:<budget>">`;
|
|
150
|
+
if (d.title) lean(d.title);
|
|
151
|
+
}
|
|
152
|
+
let leanT = null;
|
|
153
|
+
/** The intake draft of the name (POST /api/intake/draft): the kind it leans to and an earlier rejection it is close to. Drafts only. */
|
|
154
|
+
function lean(text) {
|
|
155
|
+
clearTimeout(leanT);
|
|
156
|
+
leanT = setTimeout(async () => {
|
|
157
|
+
if (!N) return;
|
|
158
|
+
N.close = text.trim().length > 3 ? closeOf(text) : null;
|
|
159
|
+
const r = text.trim().length > 3 ? await pmPost('/api/intake/draft', { line: text.trim() }).catch(() => null) : null;
|
|
160
|
+
if (!N) return;
|
|
161
|
+
if (r && r.ok && r.draft) { N.lean = r.draft.lane || N.lean; if (!N.ask) N.prior = r.draft.prior_rejections || []; }
|
|
162
|
+
const k = $('#nwKind'), h = $('#nwHints'); if (k) k.innerHTML = kindBox(); if (h) h.innerHTML = hintsHtml();
|
|
163
|
+
}, 350);
|
|
164
|
+
}
|
|
165
|
+
const drawMat = () => { const m = $('#nwMat'); if (m) m.innerHTML = materialChips(); };
|
|
166
|
+
function addFiles(list) { for (const f of list || []) if (N && N.files.length < 10 && !N.files.some((x) => x.name === f.name)) N.files.push(f); drawMat(); }
|
|
167
|
+
document.addEventListener('input', (e) => { if (N && e.target.matches('form[data-form="new2"] input[name="title"]')) lean(e.target.value); });
|
|
168
|
+
document.addEventListener('change', (e) => { if (N && e.target.id === 'nwFile') { addFiles(e.target.files); e.target.value = ''; } });
|
|
169
|
+
document.addEventListener('dragover', (e) => { const d = e.target.closest && e.target.closest('#nwDrop'); if (d) { e.preventDefault(); d.classList.add('on'); } });
|
|
170
|
+
document.addEventListener('dragleave', (e) => { const d = e.target.closest && e.target.closest('#nwDrop'); if (d) d.classList.remove('on'); });
|
|
171
|
+
document.addEventListener('drop', (e) => { const d = e.target.closest && e.target.closest('#nwDrop'); if (!d || !N) return; e.preventDefault(); d.classList.remove('on'); addFiles(e.dataTransfer && e.dataTransfer.files); });
|
|
172
|
+
document.addEventListener('click', (e) => {
|
|
173
|
+
if (!N) return;
|
|
174
|
+
const rl = e.target.closest('[data-rmlink]'); if (rl) { N.links.splice(+rl.dataset.rmlink, 1); drawMat(); return; }
|
|
175
|
+
const rf = e.target.closest('[data-rmfile]'); if (rf) { N.files.splice(+rf.dataset.rmfile, 1); drawMat(); return; }
|
|
176
|
+
const b = e.target.closest('[data-newact]'); if (!b) return;
|
|
177
|
+
const k = b.dataset.newact;
|
|
178
|
+
if (k === 'file') $('#nwFile').click();
|
|
179
|
+
else if (k === 'link') { const l = $('#nwLink'); l.hidden = !l.hidden; if (!l.hidden) l.querySelector('input').focus(); }
|
|
180
|
+
else if (k === 'addlink') {
|
|
181
|
+
const i = $('#nwLink input'), u = i.value.trim();
|
|
182
|
+
if (!/^https?:\/\/\S{3,}$/i.test(u)) { $('#formM').textContent = 'A link must start with http or https.'; return; }
|
|
183
|
+
let label = u; try { const x = new URL(u); label = x.hostname.replace(/^www\./, '') + (x.pathname.length > 1 ? x.pathname.replace(/\/$/, '').split('/').slice(-1)[0].slice(0, 30).replace(/^/, ' · ') : ''); } catch { /* keep it */ }
|
|
184
|
+
N.links.push({ url: u, label }); i.value = ''; $('#nwLink').hidden = true; $('#formM').textContent = ''; drawMat();
|
|
185
|
+
} else if (k === 'ack') { N.ack = true; $('#nwHints').innerHTML = hintsHtml(); }
|
|
186
|
+
else if (k === 'seewhy' && N.prior[0]) A.openDoc(N.prior[0].file);
|
|
187
|
+
else if (k === 'close' && N.close) { const r = A.rowOf(N.close.key); if (r) A.openIni(r); }
|
|
188
|
+
});
|
|
189
|
+
document.addEventListener('keydown', (e) => { if (N && e.key === 'Enter' && e.target.matches('#nwLink input')) { e.preventDefault(); const b = document.querySelector('[data-newact="addlink"]'); if (b) b.click(); } });
|
|
190
|
+
const b64 = (file) => new Promise((res) => { const fr = new FileReader(); fr.onload = () => res(String(fr.result).split(',')[1] || ''); fr.onerror = () => res(''); fr.readAsDataURL(file); });
|
|
191
|
+
document.addEventListener('submit', async (e) => {
|
|
192
|
+
const f = e.target.closest('form[data-form="new2"]'); if (!f || !A || !N) return;
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
const m = $('#formM'), go = f.querySelector('[type="submit"]'), val = (n) => (f.elements[n] ? String(f.elements[n].value || '').trim() : '');
|
|
195
|
+
const title = val('title'), why = val('why').replace(/\s+/g, ' ').slice(0, 400), anchor = val('anchor'), askId = f.dataset.ask || null;
|
|
196
|
+
if (!title) { m.textContent = 'Give it a name.'; f.title.focus(); return; }
|
|
197
|
+
if (!anchor) { m.textContent = 'Choose what it counts toward. Unanchored work is rejected.'; return; }
|
|
198
|
+
go.disabled = true; m.textContent = '';
|
|
199
|
+
let ask = askId;
|
|
200
|
+
if (!ask) { const r0 = await post('/api/boards/asks/add', { board: M().board.id, line: title, source: 'New initiative, typed by you' }).catch(() => null); if (!r0 || r0.ok !== true) { go.disabled = false; m.textContent = errOf(r0); return; } ask = r0.ask && r0.ask.id; }
|
|
201
|
+
const res = await post('/api/boards/asks/accept', { board: M().board.id, ask, title, lane: N.lean || 'feature', anchor, ...(why ? { intent: why } : {}) }).catch(() => null);
|
|
202
|
+
if (!res || res.ok !== true) { go.disabled = false; m.textContent = errOf(res); return; }
|
|
203
|
+
const id = res.initiative && res.initiative.id, stage = res.stage || firstStage();
|
|
204
|
+
if (id) {
|
|
205
|
+
await post('/api/board-grill/start', { id, why, links: N.links }).catch(() => null);
|
|
206
|
+
for (const file of N.files) { if (file.size > 4 * 1024 * 1024) continue; await post('/api/board-grill/file', { id, name: file.name, type: file.type, data: await b64(file) }).catch(() => null); }
|
|
207
|
+
}
|
|
208
|
+
N = null;
|
|
209
|
+
A.say('“' + title + '” is ' + (askId ? 'accepted' : 'created') + ' in ' + stage + ', anchored to ' + anchor + '.');
|
|
210
|
+
A.load();
|
|
211
|
+
if (id) openGrill(id, title, stage, true); else A.close();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
/* ── the first questions (BdGrill) ─────────────────────────────────────────────────────────────────────────────── */
|
|
215
|
+
let Q = null; // { id, title, stage, fresh, data, at }
|
|
216
|
+
const gget = async (id) => { try { const r = await (await fetch('/api/board-grill?ws=' + encodeURIComponent(M().board.ws || '') + '&id=' + encodeURIComponent(id), { credentials: 'same-origin' })).json(); return r && r.ok ? r : null; } catch { return null; } };
|
|
217
|
+
function grillHtml() {
|
|
218
|
+
const g = Q.data, qs = g ? g.questions : [], cur = qs[Q.at] || null, open = qs.filter((x) => !x.answer).length;
|
|
219
|
+
const took = g && g.summary.took.length ? g.summary.took : ['Nothing yet: no Why and no material were given.'];
|
|
220
|
+
const names = g ? g.material.links.map((k) => k.label).concat(g.material.files.map((f) => f.name)) : [];
|
|
221
|
+
const card = (x, i) => (i === Q.at
|
|
222
|
+
? `<div class="bd-qc on" data-q="${esc(x.key)}"><span class="src">${x.n} of ${x.of} · ${esc(x.topic)}</span><b>${esc(x.q)}</b><span class="bd-amut">${esc(x.why)}</span>${x.chips.length ? `<div class="bd-chips" role="radiogroup" aria-label="${esc(x.topic)}">${x.chips.map((c) => `<button type="button" class="bd-chip${x.answer === c ? ' on' : ''}" role="radio" aria-checked="${x.answer === c}" data-qchip="${esc(c)}">${esc(c)}</button>`).join('')}</div>` : ''}<input class="bd-inp sm" name="qa" maxlength="500" value="${esc(x.answer && !x.chips.includes(x.answer) ? x.answer : '')}" placeholder="Or answer in your words…" aria-label="Your answer"></div>`
|
|
223
|
+
: `<button type="button" class="bd-qc off" data-qgo="${i}"><span class="src">${x.n} of ${x.of} · ${esc(x.topic)}${x.answer ? ' · answered' : ''}</span><span class="sm">${esc(x.answer ? x.q + ' ' + x.answer : x.q)}</span></button>`);
|
|
224
|
+
const last = Q.at >= qs.length - 1;
|
|
225
|
+
return `<div class="pk-h"><div class="pk-ht"><p class="pk-eye">${esc(Q.stage)} · ${Q.fresh ? 'just created' : 'open questions'}</p><h2 id="pkTitle">${esc(Q.title)}</h2></div><div class="pk-tools"><button type="button" class="bd-ib" data-grill="later" aria-label="Close. The questions stay as this initiative’s next step" title="Close">${SV(I.x)}</button></div></div>`
|
|
226
|
+
+ `<div class="pk-b bd-pl"><div class="bd-box sm"><b>What PMOS took from your material</b>${took.map((t) => `<span>${esc(t)}</span>`).join('')}${names.length ? `<span class="bd-amut">From ${esc(names.join(' and '))}</span>` : ''}</div>`
|
|
227
|
+
+ (qs.length ? `<div class="bd-qhd"><b>${qs.length} ${qs.length === 1 ? 'question' : 'questions'} before the BRD</b><span class="bd-amut">Only what the material does not answer</span></div>${qs.map(card).join('')}` : '<p class="bd-amut">Nothing is left to ask: the BRD can start from what you gave.</p>')
|
|
228
|
+
+ `<p class="bd-amsg" id="grM" role="status"></p><div class="bd-arow bd-pfoot">${qs.length ? `<button type="button" class="bd-btn solid" data-grill="next">${last ? 'Done' : 'Next question'}</button>` : ''}<button type="button" class="bd-btn ghost" data-grill="later">Later</button><span class="bd-amut bd-push">${open ? 'Later keeps them as the next step' : 'Every question is answered'}</span></div></div>`;
|
|
229
|
+
}
|
|
230
|
+
export async function openGrill(id, title, stage, fresh, from) {
|
|
231
|
+
Q = { id, title, stage, fresh: !!fresh, data: null, at: 0 };
|
|
232
|
+
A.panel(grillHtml(), from || null, 'pk-new');
|
|
233
|
+
const g = await gget(id); if (!Q || Q.id !== id) return;
|
|
234
|
+
Q.data = g; Q.at = Math.max(0, g ? g.questions.findIndex((x) => !x.answer) : 0);
|
|
235
|
+
A.panel(grillHtml(), null, 'pk-new');
|
|
236
|
+
}
|
|
237
|
+
async function saveCur() {
|
|
238
|
+
const cur = Q.data && Q.data.questions[Q.at]; if (!cur) return true;
|
|
239
|
+
const box = document.querySelector('#peek .bd-qc.on'); if (!box) return true;
|
|
240
|
+
const typed = (box.querySelector('input[name="qa"]') || {}).value || '', chip = box.querySelector('[data-qchip].on');
|
|
241
|
+
const answer = typed.trim() || (chip ? chip.dataset.qchip : '');
|
|
242
|
+
if (answer === (cur.answer || '')) return true;
|
|
243
|
+
const r = await post('/api/board-grill/answer', { id: Q.id, q: cur.key, answer }).catch(() => null);
|
|
244
|
+
if (!r || !r.ok) { $('#grM').textContent = errOf(r); return false; }
|
|
245
|
+
Q.data = r; return true;
|
|
246
|
+
}
|
|
247
|
+
document.addEventListener('click', async (e) => {
|
|
248
|
+
if (!Q || !e.target.closest('#peek')) return;
|
|
249
|
+
const c = e.target.closest('[data-qchip]'); if (c) { $$('#peek [data-qchip]').forEach((x) => { const on = x === c && !x.classList.contains('on'); x.classList.toggle('on', on); x.setAttribute('aria-checked', String(on)); }); return; }
|
|
250
|
+
const go = e.target.closest('[data-qgo]'); if (go) { if (await saveCur()) { Q.at = +go.dataset.qgo; A.panel(grillHtml(), null, 'pk-new'); } return; }
|
|
251
|
+
const b = e.target.closest('[data-grill]'); if (!b) return;
|
|
252
|
+
if (!(await saveCur())) return;
|
|
253
|
+
const open = Q.data ? Q.data.questions.filter((x) => !x.answer).length : 0, title = Q.title;
|
|
254
|
+
if (b.dataset.grill === 'next' && Q.at < ((Q.data && Q.data.questions.length) || 0) - 1) { Q.at++; A.panel(grillHtml(), null, 'pk-new'); const i = $('#peek .bd-qc.on input'); if (i) i.focus(); return; }
|
|
255
|
+
if (b.dataset.grill === 'later' && open) await post('/api/board-grill/later', { id: Q.id }).catch(() => null);
|
|
256
|
+
Q = null; A.close();
|
|
257
|
+
A.say(open ? 'Kept as the next step of ' + title + ': ' + open + ' open ' + (open === 1 ? 'question' : 'questions') + '.' : 'The answers are kept on ' + title + ' for its BRD.');
|
|
258
|
+
A.load();
|
|
259
|
+
});
|
|
260
|
+
export const grillOpen = () => !!Q;
|
|
261
|
+
export function dropGrill() { Q = null; N = null; }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* pm/bd-pop.js — the Board's popovers (initiative premium-uncovered-features, Board): one floating card under the button that opened it
|
|
2
|
+
* (BdActions' row menu, BdFilter's Filter and Find, BdSprint's sprints and releases, BdAsks' new asks, BdPanel's metric trend), and on a
|
|
3
|
+
* phone the same card as a bottom sheet over a scrim (BdPhone). One popover is open at a time; a press outside it, Escape or a second press
|
|
4
|
+
* on its button closes it, and the focus goes back to that button. */
|
|
5
|
+
import { $ } from './premium-shell.js';
|
|
6
|
+
|
|
7
|
+
let host = null, scrim = null, from = null, onClose = null;
|
|
8
|
+
const PHONE = matchMedia('(max-width: 720px)');
|
|
9
|
+
function ensure() {
|
|
10
|
+
if (host) return;
|
|
11
|
+
host = document.createElement('div'); host.className = 'bd-pp'; host.id = 'bdPop'; host.hidden = true; host.setAttribute('role', 'dialog');
|
|
12
|
+
scrim = document.createElement('div'); scrim.className = 'bd-scrim'; scrim.hidden = true;
|
|
13
|
+
const main = $('#stage') || document.body;
|
|
14
|
+
main.appendChild(scrim); main.appendChild(host);
|
|
15
|
+
scrim.addEventListener('click', () => close(true));
|
|
16
|
+
document.addEventListener('pointerdown', (e) => { if (!host.hidden && !host.contains(e.target) && !(from && from.contains(e.target)) && !e.target.closest('.bd-scrim')) close(false); }, true);
|
|
17
|
+
window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !host.hidden) { e.stopPropagation(); close(true); } }, true);
|
|
18
|
+
window.addEventListener('resize', () => { if (!host.hidden) place(); });
|
|
19
|
+
}
|
|
20
|
+
/** Where the card goes: under its button, kept inside the window; a phone puts it at the bottom as a sheet. */
|
|
21
|
+
function place() {
|
|
22
|
+
const sheet = PHONE.matches;
|
|
23
|
+
host.classList.toggle('sheet', sheet); scrim.hidden = !sheet;
|
|
24
|
+
if (sheet || !from) { host.style.left = host.style.top = ''; return; }
|
|
25
|
+
const b = from.getBoundingClientRect(), w = host.offsetWidth, h = host.offsetHeight;
|
|
26
|
+
let left = host.dataset.align === 'right' ? b.right - w : b.left;
|
|
27
|
+
left = Math.max(12, Math.min(left, innerWidth - w - 12));
|
|
28
|
+
let top = b.bottom + 8;
|
|
29
|
+
if (top + h > innerHeight - 12) top = Math.max(12, b.top - h - 8);
|
|
30
|
+
host.style.left = left + 'px'; host.style.top = top + 'px';
|
|
31
|
+
}
|
|
32
|
+
/** Opens `html` under `btn`. o: { label, cls, width, align: 'left'|'right', onClose, focus: selector } → the card. A second press on the same button closes it. */
|
|
33
|
+
export function open(html, btn, o = {}) {
|
|
34
|
+
ensure();
|
|
35
|
+
if (!host.hidden && btn && from === btn) { close(true); return null; }
|
|
36
|
+
if (!host.hidden) close(false);
|
|
37
|
+
host.className = 'bd-pp' + (o.cls ? ' ' + o.cls : '');
|
|
38
|
+
host.style.width = o.width ? o.width + 'px' : '';
|
|
39
|
+
host.dataset.align = o.align || 'left';
|
|
40
|
+
host.setAttribute('aria-label', o.label || 'Board');
|
|
41
|
+
host.setAttribute('role', o.role || 'dialog');
|
|
42
|
+
host.innerHTML = (PHONE.matches ? '<div class="bd-grab" aria-hidden="true"></div>' : '') + html;
|
|
43
|
+
host.hidden = false; from = btn || null; onClose = o.onClose || null;
|
|
44
|
+
if (from) from.setAttribute('aria-expanded', 'true');
|
|
45
|
+
place();
|
|
46
|
+
const f = (o.focus && host.querySelector(o.focus)) || host.querySelector('input, button, [tabindex="0"]');
|
|
47
|
+
if (f) f.focus({ preventScroll: true });
|
|
48
|
+
return host;
|
|
49
|
+
}
|
|
50
|
+
/** Draws the open card again with new markup, in place (a filter chip pressed, a decline opened). */
|
|
51
|
+
export function redraw(html) { if (!host || host.hidden) return; host.innerHTML = (PHONE.matches ? '<div class="bd-grab" aria-hidden="true"></div>' : '') + html; place(); }
|
|
52
|
+
export function close(back) {
|
|
53
|
+
if (!host || host.hidden) return;
|
|
54
|
+
host.hidden = true; scrim.hidden = true;
|
|
55
|
+
if (from) { from.setAttribute('aria-expanded', 'false'); if (back && document.contains(from)) from.focus({ preventScroll: true }); }
|
|
56
|
+
const cb = onClose; from = null; onClose = null; if (cb) cb();
|
|
57
|
+
}
|
|
58
|
+
export const isOpen = () => !!host && !host.hidden;
|
|
59
|
+
export const el = () => host;
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* the sprint band, the today line and the release line, with their labels under the axis. Monitor and Evaluate are hidden here.
|
|
5
5
|
* · Year: themes, with their initiatives as bars inside, coloured by theme.
|
|
6
6
|
* · 5 yr: themes only, as one phase each from the dates on record; past 18 months is directional.
|
|
7
|
-
* · Sprint,
|
|
7
|
+
* · Sprint (BdSpans, initiative premium-uncovered-features): the sprint's working days, each initiative with its tickets in the sprint as rows,
|
|
8
|
+
* who has each one, the release sign-off and "Push tickets" as ◆, and the backlog row. Half is the Year view over six months; 2 yr is the
|
|
9
|
+
* 5 yr view over two years (themes as phases).
|
|
8
10
|
* Themes come from GET /api/board-trail (lib/board-trail.js): one per objective, named by the PRD's theme: key, else the objective's title. The Group
|
|
9
11
|
* control groups the long spans by theme, lane or owner. Milestones: a release's sign-off (◆ with its name), "Push tickets" where drafted tickets
|
|
10
12
|
* wait on the Commit, and "after <initiative>" where a dependency is not done. A bar is drawn only from dates a record holds. Pure: rows and the
|
|
@@ -17,11 +19,10 @@ export const md = (d) => MON[d.getMonth()] + ' ' + d.getDate();
|
|
|
17
19
|
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
18
20
|
const addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
19
21
|
export const SPANS = [['sprint', 'Sprint'], ['quarter', 'Quarter'], ['half', 'Half'], ['year', 'Year'], ['y2', '2 yr'], ['y5', '5 yr']];
|
|
20
|
-
/** The spans
|
|
21
|
-
export const DRAWN = new Set([
|
|
22
|
+
/** The spans a design draws: every one since the uncovered-features build. */
|
|
23
|
+
export const DRAWN = new Set(SPANS.map(([k]) => k));
|
|
22
24
|
/** The trail's theme tones (lib/board-trail.js TONES), in THEME_TONES order. */
|
|
23
25
|
const TONE_KEYS = ['grey', 'blue', 'green', 'amber', 'violet', 'teal'];
|
|
24
|
-
const WTAG = '<span class="bd-wtag" title="This span has no Agreed design yet. It works as a plain version until it has one.">Waiting for design</span>';
|
|
25
26
|
export const GROUPS = [['theme', 'Theme'], ['lane', 'Lane'], ['owner', 'Owner']];
|
|
26
27
|
/** Theme colours, in the order the Agreed design's themes take them (grey, blue, green, amber, then two more). */
|
|
27
28
|
export const THEME_TONES = ['var(--cz-c-8c929b)', 'var(--cz-c-4894ea)', 'var(--cz-c-5e9c6a)', 'var(--cz-c-d4a13a)', 'var(--cz-c-b07cc6)', 'var(--cz-c-d9773f)'];
|
|
@@ -134,8 +135,42 @@ function quarter(rows, M, o) {
|
|
|
134
135
|
const body = list.map((r) => `<div class="tg-r${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}"><b>${esc(r.title)}</b><small>${esc([r.owner, r.track ? r.track.label : r.stage].filter(Boolean).join(' · '))}</small></button><div class="tg-p">${ov}${qBar(r, X, now, false)}</div></div>`).join('');
|
|
135
136
|
const axis = `<div class="tg-ax"><span></span><div class="tg-p">${now > W.from && now < W.to ? `<span class="tg-axl td" style="left:${P(X(now))}">Today</span>` : ''}${sa && sb && sb > W.from && sa < W.to ? `<span class="tg-axl sb" style="left:${P(X(sa))}">Jira ${esc(sprint.name.toLowerCase())} · ${esc(md(sa))} – ${esc(md(sb))}</span>` : ''}${ra && ra > W.from && ra < W.to ? `<span class="tg-axl rl" style="left:${P(X(ra))}">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}</div></div>`;
|
|
136
137
|
const foot = `<div class="tg-ft">${none.length ? `<span class="tg-none"><b>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(none.slice(0, 4).map((r) => r.title).join(', '))}${none.length > 4 ? ' and ' + (none.length - 4) + ' more' : ''}</span>${askBtn}</span>` : '<span></span>'}${o.hiddenCount ? `<span class="tg-hid">Monitor and Evaluate hidden · ${o.hiddenCount}</span>` : ''}</div>`;
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
return { html: `<div class="tg tg-q" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tg-body">${lgd}${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${axis}${foot}</div>`, none };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Sprint (BdSpans): the sprint's working days as columns; per initiative with work in the sprint, its row (the release sign-off ◆, "Push
|
|
142
|
+
* tickets" ◆ where drafted tickets wait on the Commit) and one row per ticket with its state and who has it. A Jira reading holds no dates per
|
|
143
|
+
* ticket, so a bar runs from the sprint's first day to today; a drafted ticket runs from today to the sprint's end, dashed. The backlog row counts
|
|
144
|
+
* the open tickets in no sprint and opens the backlog. o: { now, sel, avatar(name) } */
|
|
145
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
146
|
+
const TB = (k) => (k.blocked ? 'r' : k.status === 'Done' ? 'k' : k.status === 'In review' ? 'y' : '');
|
|
147
|
+
function sprintSpan(rows, M, o) {
|
|
148
|
+
const now = o.now, J = M.jira || {}, sp = J.sprint, W = windowOf('sprint', now, false, sp);
|
|
149
|
+
const days = []; for (let d = W.from; d < W.to; d = addDays(d, 1)) if (d.getDay() % 6) days.push(d);
|
|
150
|
+
const n = days.length || 1, same = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
151
|
+
const idx = (d) => { if (!d) return -1; const i = days.findIndex((x) => same(x, d) || x > d); return i < 0 ? (d >= W.to ? n : -1) : i; };
|
|
152
|
+
const ti = Math.min(n, Math.max(0, idx(now))), at = (i) => P((i / n) * 100);
|
|
153
|
+
const head = `<div class="sp-r sp-h"><div class="sp-n">Initiative and ticket</div><div class="sp-g" style="--n:${n}">${days.map((d) => `<span${same(d, now) ? ' class="td"' : ''}>${WD[d.getDay()]} ${d.getDate()}</span>`).join('')}</div></div>`;
|
|
154
|
+
// the label sits right of the ◆, or left of it in the last third of the sprint so it stays inside the row
|
|
155
|
+
const dia = (i, label, cls) => `<i class="sp-dia${cls ? ' ' + cls : ''}" style="left:${at(i + 0.5)}"></i><span class="sp-dl${cls ? ' ' + cls : ''}" style="${i > n * 0.66 ? `right:calc(${P(100 - ((i + 0.5) / n) * 100)} + 14px)` : `left:calc(${at(i + 0.5)} + 14px)`}">${esc(label)}</span>`;
|
|
156
|
+
const groups = rows.map((r) => {
|
|
157
|
+
const t = r.track || {}, tk = (t.tickets || []).filter((k) => sp && k.sprint === sp.name), dr = ((r.trail && r.trail.drafted) || []).filter((x) => !x.key);
|
|
158
|
+
if (!tk.length && !dr.length) return '';
|
|
159
|
+
const ra = r.release && day(r.release.iso), ri = ra ? idx(ra) : -1;
|
|
160
|
+
const ms = (ri >= 0 && ri < n ? dia(ri, r.release.name + ' sign-off · ' + WD[ra.getDay()] + ' ' + ra.getDate(), '') : '') + (dr.length && ti < n ? dia(Math.min(n - 1, ti), 'Push tickets · ' + WD[(days[Math.min(n - 1, ti)] || now).getDay()], 'bl') : '');
|
|
161
|
+
const ini = `<div class="sp-r sp-i${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="sp-n ini2" data-key="${esc(r.key)}"><b>${esc(r.title)}</b></button><div class="sp-g sp-t" style="--n:${n}">${ms}</div></div>`;
|
|
162
|
+
const tks = tk.map((k) => {
|
|
163
|
+
const w = Math.max(1, ti + (k.status === 'Done' ? 0 : 1)), word = k.blocked ? 'Blocked' + (k.reason ? ' · ' + k.reason.replace(/^Waiting on /i, 'waits on ') : '') : k.status === 'In progress' ? 'Doing' : k.status;
|
|
164
|
+
return `<div class="sp-r"><button type="button" class="sp-n sp-k" data-tk="${esc(k.key)}" data-ini="${esc(r.key)}">${esc(k.key)} · ${esc(k.title)}</button><div class="sp-g sp-t" style="--n:${n}"><span class="sp-b ${TB(k)}" style="left:0;width:${at(Math.min(n, w))}"><span>${esc(word)}</span>${k.assignee && o.avatar ? o.avatar(k.assignee) : ''}</span></div></div>`;
|
|
165
|
+
}).join('');
|
|
166
|
+
const drafted = dr.length ? `<div class="sp-r"><span class="sp-n sp-k">${esc(dr.length === 1 ? (dr[0].id || 'A ticket') : (dr[0].id && dr[dr.length - 1].id ? dr[0].id + ' to ' + dr[dr.length - 1].id : dr.length + ' tickets'))} · drafted</span><div class="sp-g sp-t" style="--n:${n}"><span class="sp-b d" style="left:${at(Math.max(0, n - Math.max(3, n - ti)))};width:${at(Math.min(n, Math.max(3, n - ti)))}"><span>Draft · not pushed · waits on your Commit</span></span></div></div>` : '';
|
|
167
|
+
return ini + tks + drafted;
|
|
168
|
+
}).join('');
|
|
169
|
+
const bl = (J.backlog || []).length;
|
|
170
|
+
const back = `<div class="sp-r sp-bk"><span class="sp-n">Backlog · ${bl} not in ${sp ? esc(sp.name) : 'a sprint'}</span><div class="sp-g sp-bkg"><button type="button" class="bd-btn sm" data-backlog${bl ? '' : ' disabled'}>Show backlog</button></div></div>`;
|
|
171
|
+
const cap = sp ? `${esc(sp.name)} · ${esc(String(days[0] ? days[0].getDate() : ''))} to ${esc(days.length ? days[n - 1].getDate() + ' ' + MON[days[n - 1].getMonth()] : '')} · tickets with who has them` : 'No sprint is in the Jira reading. These are the next two weeks.';
|
|
172
|
+
const empty = `<p class="tg-empty">${sp ? 'No initiative on screen has a ticket in ' + esc(sp.name) + '.' : 'Read Jira to see the sprint\'s tickets here.'}</p>`;
|
|
173
|
+
return { html: `<p class="sp-cap"><span>${cap}</span><span class="bd-sp"></span><span>Group: Initiative</span></p><div class="sp" data-span="sprint">${head}<div class="sp-body">${groups || empty}</div>${back}</div><p class="tg-note">Jira holds no dates for each ticket, so a bar runs from the sprint's first day to today.</p>`, none: [] };
|
|
139
174
|
}
|
|
140
175
|
|
|
141
176
|
/** The groups of the long spans. By theme (default): the trail's themes (one per objective; the PRD's theme: names it, theme_note: says what it
|
|
@@ -175,7 +210,7 @@ function releasesOf(rows) {
|
|
|
175
210
|
|
|
176
211
|
/** Year: themes with their initiatives as bars inside. */
|
|
177
212
|
function year(rows, o) {
|
|
178
|
-
const sp = o.span === 'half'
|
|
213
|
+
const sp = o.span === 'half' ? 'half' : 'year';
|
|
179
214
|
const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows, o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
|
|
180
215
|
const tn = now > W.from && now < W.to ? X(now) : null;
|
|
181
216
|
const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>${T.length} ${T.length === 1 ? G.toLowerCase() : G.toLowerCase() + 's'} · ${rows.length} ${rows.length === 1 ? 'initiative' : 'initiatives'}</small></button><div class="tg-p">${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b>${k.sub ? `<small>${esc(k.sub)}</small>` : ''}</span>`).join('')}</div></div>`;
|
|
@@ -189,13 +224,13 @@ function year(rows, o) {
|
|
|
189
224
|
return `<div class="tg-r tg-th">${themeCell(t, false)}<div class="tg-p tg-stack">${grid}${lines || '<span class="tg-nod">No dates on record</span>'}</div></div>`;
|
|
190
225
|
}).join('');
|
|
191
226
|
const pill = tn != null ? `<span class="tg-today" style="left:calc(230px + (100% - 230px) * ${(tn / 100).toFixed(4)})">Today · ${esc(md(now))}</span>` : '';
|
|
192
|
-
|
|
193
|
-
return { html: `${tag}<div class="tg tg-y" data-span="${sp}">${head}<div class="tg-body">${pill}${body || '<p class="tg-empty">No initiative is on screen.</p>'}</div><div class="tg-ft"><span>Bars show initiatives inside their ${G.toLowerCase()}. The darker part is done. <i class="cz-ms" aria-hidden="true"></i> is a milestone.</span><button type="button" class="tg-go" data-span-go="quarter">Switch to Quarter to see one row per initiative</button></div></div>`, none: [] };
|
|
227
|
+
return { html: `<div class="tg tg-y" data-span="${sp}">${head}<div class="tg-body">${pill}${body || '<p class="tg-empty">No initiative is on screen.</p>'}</div><div class="tg-ft"><span>Bars show initiatives inside their ${G.toLowerCase()}. The darker part is done. <i class="cz-ms" aria-hidden="true"></i> is a milestone.</span><button type="button" class="tg-go" data-span-go="quarter">Switch to Quarter to see one row per initiative</button></div></div>`, none: [] };
|
|
194
228
|
}
|
|
195
229
|
|
|
196
230
|
/** 5 yr: themes only, as one phase each from the earliest date on record to the latest; past 18 months is directional (dashed). */
|
|
197
231
|
function fiveYear(rows, o) {
|
|
198
|
-
const
|
|
232
|
+
const sp = o.span === 'y2' ? 'y2' : 'y5';
|
|
233
|
+
const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows, o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
|
|
199
234
|
const far = addMonths(now, 18), fx = X(far), tn = now > W.from && now < W.to ? X(now) : null;
|
|
200
235
|
const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>what each ${G.toLowerCase()} is for</small></button><div class="tg-p">${fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : ''}${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b><small>${esc(k.sub)}</small></span>`).join('')}</div></div>`;
|
|
201
236
|
const grid = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('') + (fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : '') + (tn != null ? `<u class="tg-td" style="left:${P(tn)}"></u>` : '');
|
|
@@ -211,14 +246,15 @@ function fiveYear(rows, o) {
|
|
|
211
246
|
}).join('');
|
|
212
247
|
const lab = (x) => `calc(230px + (100% - 230px) * ${(x / 100).toFixed(4)})`; // the 230 px theme column
|
|
213
248
|
const marks = (tn != null ? `<span class="tg-today" style="left:${lab(tn)}">Today</span>` : '') + (fx < 100 ? `<span class="tg-far" style="left:${lab(fx)}">Beyond 18 months · directional</span>` : '');
|
|
214
|
-
return { html: `<div class="tg tg-5y" data-span="
|
|
249
|
+
return { html: `<div class="tg tg-5y" data-span="${sp}">${head}<div class="tg-body">${marks}${body || '<p class="tg-empty">No initiative is on screen.</p>'}</div><div class="tg-ft"><span>Only themes and their phases at this span. Dashed means directional, not committed.</span><span class="tg-go2">Open a phase to see its initiatives</span></div></div>`, none: [] };
|
|
215
250
|
}
|
|
216
251
|
|
|
217
252
|
/** The timeline's markup for the rows on screen. → { html, none: [rows with no dates] } */
|
|
218
253
|
export function timelineHtml(rows, M, span, o = {}) {
|
|
219
254
|
const opt = { now: new Date(), phone: false, sel: null, status: () => ({ tone: 'q', text: '' }), hiddenCount: 0, askHref: () => '#', ...o };
|
|
220
255
|
opt.span = span;
|
|
221
|
-
if (span === 'year' || span === 'half'
|
|
222
|
-
if (span === 'y5') return fiveYear(rows, opt);
|
|
256
|
+
if (span === 'year' || span === 'half') return year(rows, opt);
|
|
257
|
+
if (span === 'y5' || span === 'y2') return fiveYear(rows, opt);
|
|
258
|
+
if (span === 'sprint' && !opt.phone) return sprintSpan(rows, M, opt);
|
|
223
259
|
return quarter(rows, M, opt);
|
|
224
260
|
}
|