create-pmos 0.647.0 → 0.649.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 +27 -27
- 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/changelog.json +26 -0
- package/workspace/guide/layout.md +11 -0
- package/workspace/lib/engine/boards.js +7 -2
- package/workspace/lib/routes-backlog.js +37 -3
- package/workspace/lib/sprint-now.js +96 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog-ds.js +176 -0
- package/workspace/public/pm/bd-backlog.js +130 -10
- package/workspace/public/pm/bd-sprint-ds.js +115 -0
- package/workspace/public/pm/bd-sprint.js +71 -56
- package/workspace/public/pm/bd-stands.js +4 -4
- package/workspace/public/pm/bd-work-ds.css +59 -0
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
* with Undo where the route has one. The words say PMOS, never the model's name. pm/premium-board.js calls sync() after each read of the board. */
|
|
16
16
|
import * as BM from './bk-model.js';
|
|
17
17
|
import { productName } from './scope-chip.js'; // the product's display name ("IDPF"), never its folder id
|
|
18
|
-
import * as SP from './bd-sprint.js';
|
|
18
|
+
import * as SP from './bd-sprint.js';
|
|
19
|
+
import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
|
|
19
20
|
|
|
20
21
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
21
22
|
const SV = (d, n) => `<svg viewBox="0 0 24 24"${n ? ` width="${n}" height="${n}"` : ''} aria-hidden="true"><path d="${d}"/></svg>`;
|
|
22
23
|
const I = {
|
|
23
24
|
chev: 'M9 6l6 6-6 6', down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7', x: 'M6 6l12 12M18 6L6 18', more: 'M5 12h.01M12 12h.01M19 12h.01',
|
|
24
25
|
undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', jira: 'M12 3l9 9-9 9-9-9z', task: 'M6 6h12v12H6z', ms: 'M12 4l8 8-8 8-8-8z', back: 'M15 6l-6 6 6 6',
|
|
25
|
-
ext: 'M14 4h6v6M20 4l-9 9M10 6H5v13h13v-5', ret: 'M20 5v7a4 4 0 0 1-4 4H5M9 12l-4 4 4 4',
|
|
26
|
+
ext: 'M14 4h6v6M20 4l-9 9M10 6H5v13h13v-5', eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z', ret: 'M20 5v7a4 4 0 0 1-4 4H5M9 12l-4 4 4 4',
|
|
26
27
|
};
|
|
27
28
|
const SPARK = '✦';
|
|
28
29
|
const KEY = 'pmos.backlog.view';
|
|
@@ -41,10 +42,14 @@ let SEL = new Set(); // ticked rows: ws|board|id
|
|
|
41
42
|
let host = null, sw = null;
|
|
42
43
|
let iniApplied = false; // ?ini= is read once
|
|
43
44
|
let SAID = null; // the one line after a Yes: { text, undo }
|
|
45
|
+
// the Backlog tab (WorkBacklogDS): its tab, its group, the Group menu, the pulls the PM said no to (kept in this browser)
|
|
46
|
+
let BMENU = false;
|
|
47
|
+
const PULLNO = 'pmos.backlog.pullno';
|
|
44
48
|
|
|
45
49
|
const box = () => { try { return typeof localStorage !== 'undefined' ? localStorage : null; } catch { return null; } };
|
|
46
50
|
const get = (k, d) => { try { const s = box(); const v = s ? JSON.parse(s.getItem(k) || 'null') : null; return v == null ? d : v; } catch { return d; } };
|
|
47
51
|
const put = (k, v) => { try { const s = box(); if (s) s.setItem(k, JSON.stringify(v)); } catch { /* a private window keeps it for this page */ } };
|
|
52
|
+
const BV = (() => { const v = get('pmos.work.backlog', {}) || {}; return { tab: BD.TABS.some(([k]) => k === v.tab) ? v.tab : 'all', group: BD.GROUPS.some(([k]) => k === v.group) ? v.group : 'ini' }; })();
|
|
48
53
|
const scopeKey = () => (A ? A.scope().map((s) => s.ws + '|' + (s.board || '')).sort().join(',') : '');
|
|
49
54
|
const uidOf = (t) => t.ws + '|' + t.board + '|' + t.id;
|
|
50
55
|
|
|
@@ -86,7 +91,9 @@ export async function load() {
|
|
|
86
91
|
const ok = got.filter(Boolean);
|
|
87
92
|
// the oldest Jira read of the pick (the sprint band says when Jira was last read) and the PM's edits of each sprint's overview
|
|
88
93
|
const reads = ok.map((r) => r.readAt).filter(Boolean).sort();
|
|
89
|
-
DATA = { readAt: reads[0] || null, hist: ok.map((r) => ({ ws: r.ws, board: r.board, list: r.sprintList || [], trend: r.sprintTrend || null })),
|
|
94
|
+
DATA = { readAt: reads[0] || null, hist: ok.map((r) => ({ ws: r.ws, board: r.board, list: r.sprintList || [], trend: r.sprintTrend || null })),
|
|
95
|
+
rank: ok.flatMap((r) => r.backlogRank || []), next: (ok.find((r) => r.sprintNext) || {}).sprintNext || null, today: (ok[0] || {}).today || '',
|
|
96
|
+
now: ok.flatMap((r) => (r.sprintNow || []).map((n) => ({ ...n, ws: r.ws, board: r.board, rows: (n.rows || []).map((x) => ({ ...x, ws: r.ws, board: r.board })) }))), notes: Object.fromEntries(ok.map((r) => [r.ws + '|' + r.board, r.sprintNotes || {}])), tasks: ok.flatMap((r) => r.tasks || []), modes: ok.map((r) => ({ product: productName(r.ws, r.product), mode: r.mode, label: r.modeLabel, kinds: r.kinds || null })), inis: ok.flatMap((r) => (r.inis || []).map((x) => ({ ...x, ws: r.ws, board: r.board, product: productName(r.ws, r.product) }))),
|
|
90
97
|
err: ok.length ? (ok.length < S.length ? 'One product could not be read; its tasks are not here.' : '') : 'The tasks could not be read. Try again in a moment.', many: S.length > 1 };
|
|
91
98
|
// ?ini=<initiative id> (the initiative popup's "Open in Backlog"): the Initiative facet starts on that initiative, once
|
|
92
99
|
if (!iniApplied) {
|
|
@@ -132,7 +139,17 @@ function draw() {
|
|
|
132
139
|
const said = SAID ? `<p class="bk-said" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="bk-lnk" data-bksaid>Undo</button>' : ''}</p>` : '';
|
|
133
140
|
const sh = BM.showingLine(T, { chips: CHIPS, pick: PICK, partB: partB() });
|
|
134
141
|
const showing = sh ? `<p class="bk-show">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="bk-lnk" data-bkall>Show all</button></p>` : '';
|
|
135
|
-
|
|
142
|
+
if (tabOf() === 'bk') { drawBk(); return; }
|
|
143
|
+
// This sprint (WorkSprintDS): the Summary card and the Tasks Table, both pm/bd-sprint.js; a past sprint keeps its frozen view and list
|
|
144
|
+
if (tabOf() === 'sp') {
|
|
145
|
+
const card = SP.bandHtml({ tasks: T.filter(BM.isOpen), all: T, inis: DATA.inis, readAt: DATA.readAt, notes: DATA.notes, hist: DATA.hist, now: DATA.now }, spDeps());
|
|
146
|
+
const list = SP.pastOn() ? SP.pastListHtml() : SP.tasksNowHtml();
|
|
147
|
+
host.innerHTML = (DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : '') + (SAID ? `<p class="bk-said" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="bk-lnk" data-bksaid>Undo</button>' : ''}</p>` : '')
|
|
148
|
+
+ (card || list ? card + list : '<section class="pm-block"><p class="pm-meta">No sprint is active. When Jira has one, its work shows here, with the tasks outside Jira in its dates.</p></section>');
|
|
149
|
+
drawBar();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const band = CHIPS.has('sprint') ? SP.bandHtml({ tasks: T.filter(BM.isOpen), all: T, inis: DATA.inis, readAt: DATA.readAt, notes: DATA.notes, hist: DATA.hist, now: DATA.now }, spDeps()) : '';
|
|
136
153
|
const th = band ? SP.themeOf() : null;
|
|
137
154
|
// a theme pressed in the band: the list is its tickets only, in one group with "Show all" (board SpA2)
|
|
138
155
|
const G = th ? [{ k: 'theme', n: th.name, sub: '', open: true, total: th.total,
|
|
@@ -147,6 +164,98 @@ function draw() {
|
|
|
147
164
|
+ (past != null ? past : `<div class="bk" role="table" aria-label="Backlog" style="--bk-cols: ${colsCss(cols)}">${head}${body}</div>`);
|
|
148
165
|
drawBar();
|
|
149
166
|
}
|
|
167
|
+
/* ── the Backlog tab (WorkBacklogDS): Where it stands with one Suggestion, then the Backlog block ───────────────────────── */
|
|
168
|
+
let ORDER = []; // the backlog in rank order, as drawn last
|
|
169
|
+
const backlogOf = () => DATA.tasks.filter(BD.inBacklog).filter((t) => BM.keeps(t, new Set(), PICK, partB()));
|
|
170
|
+
function pullFor(order) {
|
|
171
|
+
const p = BD.pullOf(order, DATA.next);
|
|
172
|
+
if (!p) return null;
|
|
173
|
+
const no = get(PULLNO, []) || [];
|
|
174
|
+
return no.includes(pullSig(p)) ? null : p;
|
|
175
|
+
}
|
|
176
|
+
const pullSig = (p) => (DATA.next ? DATA.next.name : '') + ':' + p.ids.concat(p.keys).join(',');
|
|
177
|
+
function drawBk() {
|
|
178
|
+
const B = backlogOf(), order = BD.ranked(B, DATA.rank, DATA.inis);
|
|
179
|
+
ORDER = order;
|
|
180
|
+
const rank = new Map(order.map((t, i) => [t.id, i]));
|
|
181
|
+
const sh = BM.showingLine(DATA.tasks, { chips: new Set(), pick: PICK, partB: partB() });
|
|
182
|
+
const showing = sh ? `<p class="pm-meta">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="wk-sa" data-bkall>Show all</button></p>` : '';
|
|
183
|
+
const said = SAID ? `<p class="pm-meta" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="wk-sa" data-bksaid>Undo</button>' : ''}</p>` : '';
|
|
184
|
+
const ml = BM.modeLine(DATA.modes);
|
|
185
|
+
const mode = ml ? `<p class="pm-meta">${esc(ml.lead)}<b>${esc(ml.label)}</b>${esc(ml.tail)}: ${esc(ml.what)} <button type="button" class="wk-sa" data-bkmode aria-haspopup="dialog">Change</button></p>` : '';
|
|
186
|
+
const pmosGroups = (R) => BM.groupsOf(R, { partB: partB(), sort: SORT }).map((g) => {
|
|
187
|
+
const can = yesRows(g, g.rows);
|
|
188
|
+
return { k: g.k, n: g.n, sub: g.sub, rows: g.rows, yes: can.length ? ` <button type="button" class="pm-btn" data-bkyes="${g.k}" aria-label="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}" title="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}">${SV(I.ok, 16)}</button>` : '' };
|
|
189
|
+
});
|
|
190
|
+
host.innerHTML = (DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : '')
|
|
191
|
+
+ BD.standsHtml(B, { today: DATA.today, next: DATA.next, pull: pullFor(order) })
|
|
192
|
+
+ BD.tableHtml(order, { tab: BV.tab, group: BV.group, menu: BMENU, today: DATA.today, rank, sel: SEL, picking: host.classList.contains('picking'),
|
|
193
|
+
act: (t) => actHtml(t, BM.groupOf(t, partB())), stateOf: (t) => { if (!t.agent) return null; const x = BM.stateOf(t); return { text: x.text, tone: x.tone, title: x.text + (x.note ? ' · ' + x.note : '') }; },
|
|
194
|
+
groupsPmos: pmosGroups, said: showing + said, mode });
|
|
195
|
+
drawBar();
|
|
196
|
+
}
|
|
197
|
+
const saveBv = () => put('pmos.work.backlog', BV);
|
|
198
|
+
/** A press only the Backlog tab has. → true when it was one. */
|
|
199
|
+
async function bkPress(e) {
|
|
200
|
+
const t0 = e.target, hit = (a) => t0.closest('[' + a + ']');
|
|
201
|
+
let b;
|
|
202
|
+
if ((b = hit('data-bktab'))) { BV.tab = b.dataset.bktab; saveBv(); draw(); const n = host.querySelector(`[data-bktab="${BV.tab}"]`); if (n) n.focus(); return true; }
|
|
203
|
+
if (hit('data-bkgroup')) { BMENU = !BMENU; draw(); const n = host.querySelector('[data-bkgrp][aria-checked="true"]'); if (BMENU && n) n.focus(); return true; }
|
|
204
|
+
if ((b = hit('data-bkgrp'))) { BV.group = b.dataset.bkgrp; BMENU = false; saveBv(); draw(); const n = host.querySelector('[data-bkgroup]'); if (n) n.focus(); return true; }
|
|
205
|
+
if (BMENU) { BMENU = false; draw(); }
|
|
206
|
+
if ((b = hit('data-bktune'))) { if (pop && pop.classList.contains('bk-tune')) closePop(); else tune(b); return true; }
|
|
207
|
+
if ((b = hit('data-bksug'))) {
|
|
208
|
+
const p = pullFor(ORDER); if (!p) return true;
|
|
209
|
+
const k = b.dataset.bksug, T = p.ids.map((id) => DATA.tasks.find((t) => t.id === id)).filter(Boolean);
|
|
210
|
+
if (k === 'no') { const no = get(PULLNO, []) || []; no.push(pullSig(p)); put(PULLNO, no.slice(-50)); AP().say('PMOS will not suggest this again.', () => { put(PULLNO, (get(PULLNO, []) || []).filter((x) => x !== pullSig(p))); draw(); }); draw(); return true; }
|
|
211
|
+
if (k === 'edit') { BV.tab = 'ready'; saveBv(); for (const t of T) SEL.add(uidOf(t)); draw(); AP().say(`Ticked ${T.length === 1 ? 'the item' : 'the ' + T.length + ' items'}. Change the ticks, then Set date.`); return true; }
|
|
212
|
+
await editMany(T, { start: DATA.next.start, due: DATA.next.end }, 'Into ' + (DATA.next.label || DATA.next.name) + (p.keys.length ? '. Add ' + p.keys.join(', ') + ' in Jira' : ''));
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
/** The capture: one line into the backlog, in the initiative it names, else the closest by its words, else PMOS asks. */
|
|
218
|
+
async function capture(inp) {
|
|
219
|
+
const line = inp.value.trim(); if (!line) return;
|
|
220
|
+
const L = DATA.inis || [], c = BD.captureOf(line, L);
|
|
221
|
+
const add = async (ini) => {
|
|
222
|
+
const x = L.find((y) => y.id === ini); if (!x) return;
|
|
223
|
+
const r = await post('/api/boards/tasks/add', { ws: x.ws, board: x.board, title: c.title.slice(0, 200), initiative: ini });
|
|
224
|
+
if (!r || r.ok === false || !r.item) { AP().say((r && r.error) || 'The task was not added.'); return; }
|
|
225
|
+
inp.value = '';
|
|
226
|
+
AP().say(`Added to ${x.title}: ${c.title}.`, async () => { await post('/api/boards/tasks/delete', { ws: x.ws, board: x.board, task: r.item.uid }); AP().say('Taken out.'); load(); AP().reload(); });
|
|
227
|
+
load(); AP().reload();
|
|
228
|
+
};
|
|
229
|
+
if (c.ini) { await add(c.ini); return; }
|
|
230
|
+
pickPop(inp, 'Which initiative?', L.map((x) => [x.id, x.title]), add);
|
|
231
|
+
}
|
|
232
|
+
/** A drag in the Backlog block: the row moves before the row it is dropped on, in the one rank; the board's order is written with Undo. */
|
|
233
|
+
let DRAG = '';
|
|
234
|
+
function dragWire() {
|
|
235
|
+
host.addEventListener('dragstart', (e) => { const r = e.target.closest && e.target.closest('tr.wk-br[draggable]'); if (!r) return; DRAG = r.dataset.bkid; r.classList.add('drag'); try { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', DRAG); } catch { /* old browser */ } });
|
|
236
|
+
host.addEventListener('dragend', () => { DRAG = ''; for (const n of host.querySelectorAll('.drag, .drop')) n.classList.remove('drag', 'drop'); });
|
|
237
|
+
host.addEventListener('dragover', (e) => { if (!DRAG) return; const r = e.target.closest('tr.wk-br'); if (!r) return; e.preventDefault(); for (const n of host.querySelectorAll('.drop')) if (n !== r) n.classList.remove('drop'); r.classList.add('drop'); });
|
|
238
|
+
host.addEventListener('drop', async (e) => {
|
|
239
|
+
const r = e.target.closest('tr.wk-br'); if (!DRAG || !r) return;
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
const id = DRAG, before = r.dataset.bkid; DRAG = '';
|
|
242
|
+
if (id === before) { draw(); return; }
|
|
243
|
+
await rerank(BD.moved(ORDER.map((t) => t.id), id, before), ORDER.find((t) => t.id === id));
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async function rerank(ids, t) {
|
|
247
|
+
if (!t) return;
|
|
248
|
+
const by = byBoard(ORDER), back = [];
|
|
249
|
+
for (const [, ts] of by) {
|
|
250
|
+
const mine = new Set(ts.map((x) => x.id));
|
|
251
|
+
const r = await post('/api/backlog/rank', { ws: ts[0].ws, board: ts[0].board, order: ids.filter((x) => mine.has(x)) });
|
|
252
|
+
if (!r || r.ok === false) { AP().say((r && r.error) || 'The rank was not changed.'); break; }
|
|
253
|
+
back.push({ ws: ts[0].ws, board: ts[0].board, from: r.from || [] });
|
|
254
|
+
}
|
|
255
|
+
if (back.length) AP().say('Reranked: ' + t.title + '.', async () => { for (const x of back) await post('/api/backlog/rank', { ws: x.ws, board: x.board, order: x.from }); AP().say('Put back.'); load(); });
|
|
256
|
+
DATA.rank = ids; draw(); load();
|
|
257
|
+
}
|
|
258
|
+
|
|
150
259
|
/* ── the columns: Task first and the actions last, always; the ones between are a list, so the initiative popup can leave Initiative out ── */
|
|
151
260
|
export const COLS = ['jira', 'epic', 'ini', 'who', 'state'];
|
|
152
261
|
const COL = { jira: ['Jira ticket', '104px'], epic: ['Epic', 'minmax(80px, 130px)'], ini: ['Initiative', 'minmax(110px, 160px)'], who: ['Who', '76px'], due: ['Due', 'minmax(80px, 150px)'], state: ['State', 'minmax(200px, 290px)'] };
|
|
@@ -182,6 +291,16 @@ function whoHtml(t) {
|
|
|
182
291
|
if (t.agent && t.agent.state !== 'failed') return `<span class="bk-pm">${SPARK} PMOS</span>`;
|
|
183
292
|
return t.who ? esc(t.who) : '<span class="q">None</span>';
|
|
184
293
|
}
|
|
294
|
+
/** The row's action, by its group: Review, ⋯ (PMOS is working), ✓ ✕ (PMOS can take it, or PMOS proposes a home), Undo (done today). */
|
|
295
|
+
function actHtml(t, gk) {
|
|
296
|
+
const u = uidOf(t);
|
|
297
|
+
let act = '';
|
|
298
|
+
if (gk === 'review') act = `<button type="button" class="bk-ib" data-bkrev="${esc(u)}" aria-label="Review what PMOS made: ${esc(t.title)}" title="Review">${SV(I.eye)}</button>`;
|
|
299
|
+
else if (gk === 'working') act = `<button type="button" class="bk-ib" data-bkmenu="${esc(u)}" aria-label="More for ${esc(t.title)}" title="More">${SV(I.more)}</button>`;
|
|
300
|
+
else if (gk === 'take' || (gk === 'nohome' && t.propose)) act = `<span class="bk-two"><button type="button" class="bk-ib" data-bkok="${esc(u)}" aria-label="${gk === 'take' ? 'Give to PMOS' : 'Put it in ' + esc(t.propose.title)}" title="${gk === 'take' ? 'Give to PMOS' : 'Put it there'}">${SV(I.ok)}</button><button type="button" class="bk-ib" data-bkno="${esc(u)}" aria-label="${gk === 'take' ? 'Not for PMOS' : 'Not there'}" title="${gk === 'take' ? 'Not for PMOS' : 'Not there'}">${SV(I.x)}</button></span>`;
|
|
301
|
+
else if (gk === 'done') act = `<button type="button" class="bk-ib" data-bkundo="${esc(u)}" aria-label="Undo: open ${esc(t.title)} again" title="Undo">${SV(I.undo)}</button>`;
|
|
302
|
+
return act;
|
|
303
|
+
}
|
|
185
304
|
function rowHtml(t, gk, cols = COLS) {
|
|
186
305
|
const u = uidOf(t), ck = SEL.has(u), s = BM.stateOf(t, gk, { noLate: cols.includes('due') });
|
|
187
306
|
const icon = t.milestone ? `<i class="bk-ic ms" title="Milestone">${SV(I.ms)}</i>` : `<i class="bk-ic" title="Task">${SV(I.task)}</i>`;
|
|
@@ -189,11 +308,7 @@ function rowHtml(t, gk, cols = COLS) {
|
|
|
189
308
|
const epic = t.src === 'jira' ? (t.epic ? `<span title="${esc(t.epic.name ? t.epic.name + ' (' + t.epic.key + ')' : t.epic.key)}">${esc(t.epic.name || t.epic.key)}</span>` : '<span class="q">No epic</span>') : '';
|
|
190
309
|
const ini = t.ini ? `<span title="${esc(t.iniTitle)}">${esc(t.iniTitle)}</span>`
|
|
191
310
|
: t.propose ? `<span class="bk-pm" title="${esc('PMOS proposes it: ' + t.propose.why)}">${SPARK} ${esc(t.propose.title)}</span>` : ''; // No home says it once, in its head
|
|
192
|
-
|
|
193
|
-
if (gk === 'review') act = `<button type="button" class="bk-rvb" data-bkrev="${esc(u)}">Review</button>`;
|
|
194
|
-
else if (gk === 'working') act = `<button type="button" class="bk-ib" data-bkmenu="${esc(u)}" aria-label="More for ${esc(t.title)}" title="More">${SV(I.more)}</button>`;
|
|
195
|
-
else if (gk === 'take' || (gk === 'nohome' && t.propose)) act = `<span class="bk-two"><button type="button" class="bk-ib" data-bkok="${esc(u)}" aria-label="${gk === 'take' ? 'Give to PMOS' : 'Put it in ' + esc(t.propose.title)}" title="${gk === 'take' ? 'Give to PMOS' : 'Put it there'}">${SV(I.ok)}</button><button type="button" class="bk-ib" data-bkno="${esc(u)}" aria-label="${gk === 'take' ? 'Not for PMOS' : 'Not there'}" title="${gk === 'take' ? 'Not for PMOS' : 'Not there'}">${SV(I.x)}</button></span>`;
|
|
196
|
-
else if (gk === 'done') act = `<button type="button" class="bk-ib" data-bkundo="${esc(u)}" aria-label="Undo: open ${esc(t.title)} again" title="Undo">${SV(I.undo)}</button>`;
|
|
311
|
+
const act = actHtml(t, gk);
|
|
197
312
|
const cell = {
|
|
198
313
|
due: `<span class="c-due${t.late ? ' lt' : ''}">${t.due ? esc(dueText(t.due) + (t.late ? ' · ' + t.late + (t.late === 1 ? ' day late' : ' days late') : '')) : '<span class="q">No date</span>'}</span>`,
|
|
199
314
|
jira: `<span class="c-jira">${jira}</span>`, epic: `<span class="c-epic">${epic}</span>`, ini: `<span class="c-ini">${ini}</span>`, who: `<span class="c-who">${whoHtml(t)}</span>`,
|
|
@@ -208,6 +323,8 @@ function rowHtml(t, gk, cols = COLS) {
|
|
|
208
323
|
|
|
209
324
|
/** What the sprint band (pm/bd-sprint.js) needs from the Backlog and its page. */
|
|
210
325
|
const spDeps = () => ({ post, tasks: () => (DATA ? DATA.tasks.filter(BM.isOpen) : []), say: (m, u) => AP().say(m, u), draw, load, reload: () => AP().reload(), taskOf,
|
|
326
|
+
openTask: (t, from) => AP().openTask(t, from),
|
|
327
|
+
pickIni: (at, p, done) => pickPop(at, 'Put them in', (DATA.inis || []).filter((x) => x.ws === p.ws && x.board === p.board).map((x) => [x.id, x.title]), (id) => done(id, ((DATA.inis || []).find((x) => x.id === id) || {}).title || id)),
|
|
211
328
|
readJira: A && A.readJira ? () => A.readJira() : null, newInitiative: A && A.newInitiative ? (name, from) => A.newInitiative(name, from) : null });
|
|
212
329
|
|
|
213
330
|
/* ── the bar under ticked rows (board BkSelect) ───────────────────────────────────────────────────────────────── */
|
|
@@ -418,7 +535,8 @@ function closeRv() { if (rv) { rv.remove(); rv = null; } }
|
|
|
418
535
|
const taskOf = (u) => (SC ? SC.tasks() : DATA ? DATA.tasks : []).find((t) => uidOf(t) === u) || null;
|
|
419
536
|
async function press(e, emb) {
|
|
420
537
|
const t0 = e.target;
|
|
421
|
-
if (!emb && t0.closest('.sbo-band, .bk-past, [data-spall]') && await SP.press(e, spDeps())) return;
|
|
538
|
+
if (!emb && t0.closest('.sbo-band, .bk-past, [data-spall], .wk-sp, .wk-spt') && await SP.press(e, spDeps())) return;
|
|
539
|
+
if (!emb && tabOf() === 'bk' && await bkPress(e)) return;
|
|
422
540
|
const chip = t0.closest('[data-bkchip]');
|
|
423
541
|
if (chip) { const k = chip.dataset.bkchip; if (k === 'all') CHIPS.clear(); else if (CHIPS.has(k)) CHIPS.delete(k); else CHIPS.add(k); draw(); const n = host.querySelector(`[data-bkchip="${k}"]`); if (n) n.focus(); return; }
|
|
424
542
|
if (t0.closest('[data-bkall]')) { CHIPS.clear(); PICK = {}; SP.clearTheme(); draw(); return; }
|
|
@@ -544,6 +662,8 @@ export function sync(api) {
|
|
|
544
662
|
ib.insertAdjacentElement('afterend', host);
|
|
545
663
|
host.addEventListener('click', (e) => { press(e); });
|
|
546
664
|
host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
|
|
665
|
+
host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
|
|
666
|
+
dragWire();
|
|
547
667
|
// a phone shows no tick boxes until a long press on a row (design check 1 h): the press ticks that row and shows the boxes
|
|
548
668
|
let lp = null;
|
|
549
669
|
const lpEnd = () => { if (lp) { clearTimeout(lp); lp = null; } };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* pm/bd-sprint-ds.js — This sprint built from the design system's parts (initiative work-ds-sprint; Exploring 3 page "work", board
|
|
2
|
+
* WorkSprintDS). Pure: HTML from data, no state and no fetch. pm/bd-sprint.js keeps the state (the tab, the group, the goal being edited)
|
|
3
|
+
* and the presses.
|
|
4
|
+
*
|
|
5
|
+
* · cardHtml(N, o): the one Summary card. The sprint, its end and what it holds ("21 Jira tickets and 7 tasks outside Jira"), "11 of 28
|
|
6
|
+
* done" with a bar, then four columns: Sprint goal (o.goal, editable), In progress, To do and Done, each with its count and top tasks;
|
|
7
|
+
* then one Suggestion (o.sug). No other metric: Wawan was not confident in them.
|
|
8
|
+
* · tasksHtml(N, o): the Tasks Table. Tabs All / To do / In progress / Done (no Late tab), the Group menu (Initiative by default, Who,
|
|
9
|
+
* State, Theme, none), columns Task, Who, State, Source (the Jira key, or "Not in Jira") and Due. Late = the due date has passed and the
|
|
10
|
+
* task is not done: a red badge after the date. "Moved twice" is a plain badge.
|
|
11
|
+
* N is one sprint of GET /api/backlog's sprintNow (lib/sprint-now.js): all work in the sprint's dates, Jira and not. */
|
|
12
|
+
import { sugHtml } from './bd-stands.js';
|
|
13
|
+
|
|
14
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
15
|
+
const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
16
|
+
const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16z', read: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7',
|
|
17
|
+
down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18' };
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
export const dayText = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
20
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
21
|
+
|
|
22
|
+
export const TABS = [['all', 'All'], ['todo', 'To do'], ['doing', 'In progress'], ['done', 'Done']];
|
|
23
|
+
export const GROUPS = [['ini', 'Initiative'], ['who', 'Who'], ['state', 'State'], ['theme', 'Theme'], ['none', 'None']];
|
|
24
|
+
const tabOfRow = (r) => (r.state === 'Done' ? 'done' : r.state === 'To do' ? 'todo' : 'doing');
|
|
25
|
+
/** The rows of one tab. */
|
|
26
|
+
export const rowsOf = (N, tab) => (N ? N.rows : []).filter((r) => tab === 'all' || !tab || tabOfRow(r) === tab);
|
|
27
|
+
export const countsOf = (N) => { const c = { all: 0, todo: 0, doing: 0, done: 0 }; for (const r of N ? N.rows : []) { c.all++; c[tabOfRow(r)]++; } return c; };
|
|
28
|
+
/** "moved twice" and on: the ticket was in two sprints before this one. */
|
|
29
|
+
export const movedText = (n) => (n >= 3 ? `moved ${n} times` : n === 2 ? 'moved twice' : '');
|
|
30
|
+
const lateText = (n) => plural(n, 'day late', 'days late');
|
|
31
|
+
/** What the sprint holds, in words: "21 Jira tickets and 7 tasks outside Jira". Zero is silence. */
|
|
32
|
+
export function holdsText(N) {
|
|
33
|
+
const a = N.jira ? plural(N.jira, 'Jira ticket', 'Jira tickets') : '', b = N.other ? plural(N.other, 'task outside Jira', 'tasks outside Jira') : '';
|
|
34
|
+
return [a, b].filter(Boolean).join(' and ');
|
|
35
|
+
}
|
|
36
|
+
/** Due first (no date last), then the title. */
|
|
37
|
+
const byDue = (a, b) => (a.due || '9999').localeCompare(b.due || '9999') || a.title.localeCompare(b.title);
|
|
38
|
+
|
|
39
|
+
/** The Summary card. o: { label (the sprint's name or its picker), goal: { lines: [text], mine, editing, edit (the textarea's html),
|
|
40
|
+
* newer (html) }, read: { old, title }, sug: the Suggestion's html } */
|
|
41
|
+
export function cardHtml(N, o = {}) {
|
|
42
|
+
const c = countsOf(N), pct = c.all ? Math.round((c.done / c.all) * 1000) / 10 : 0;
|
|
43
|
+
const meta = [o.label || esc(N.label || N.name), N.end ? 'ends ' + dayText(N.end) : '', esc(holdsText(N))].filter(Boolean).join(' · ');
|
|
44
|
+
const read = o.read ? `<button type="button" class="pm-btn wk-rd${o.read.old ? ' old' : ''}" data-spread aria-label="Read Jira again" title="${esc(o.read.title || 'Read Jira again')}">${SV(I.read)}</button>` : '';
|
|
45
|
+
const head = `<div class="head"><h2 class="pm-h-sm pm-row">${SV(I.star).replace('pm-ic', 'pm-ic pm-star')}This sprint</h2><span class="sp"></span><span class="pm-meta wk-spm">${meta}</span>${read}</div>`;
|
|
46
|
+
const done = c.all ? `<div class="pm-row wk-spd"><b>${c.done} of ${c.all} done</b><div class="wk-spbar" role="progressbar" aria-label="${c.done} of ${c.all} done" aria-valuenow="${c.done}" aria-valuemin="0" aria-valuemax="${c.all}"><span style="width:${pct}%"></span></div></div>` : '';
|
|
47
|
+
const g = o.goal || { lines: [] };
|
|
48
|
+
const goal = `<div class="wk-spc1"><div class="pm-row wk-sph"><b>Sprint goal</b><button type="button" class="pm-btn" data-spedit="goals" aria-label="Edit Sprint goal" title="Edit Sprint goal">${SV(I.pen)}</button></div>`
|
|
49
|
+
+ (g.editing ? g.edit : g.lines.length ? `<ul>${g.lines.map((t) => `<li>${esc(t)}</li>`).join('')}</ul>` : '<p class="pm-meta">No goal yet. Write one; it can name work outside Jira.</p>')
|
|
50
|
+
+ (g.editing ? '' : g.newer || (!g.mine && g.lines.length ? '<p class="pm-meta">Drafted from the sprint\'s work. Edit to make it yours.</p>' : '')) + '</div>';
|
|
51
|
+
const col = (tab, name) => {
|
|
52
|
+
const R = rowsOf(N, tab).slice().sort(byDue).slice(0, 3);
|
|
53
|
+
if (!c[tab]) return `<div class="wk-spc1"><div class="pm-row wk-sph"><b>${name}</b></div></div>`;
|
|
54
|
+
return `<div class="wk-spc1"><div class="pm-row wk-sph"><b>${name} <span class="pm-meta">${c[tab]}</span></b></div><ul>${R.map((r) => `<li>${esc(r.title)}${movedText(r.moved) ? ` <span class="pm-badge">${movedText(r.moved)}</span>` : ''}</li>`).join('')}</ul></div>`;
|
|
55
|
+
};
|
|
56
|
+
return `<section class="pm-block wk-sp" aria-label="This sprint">${head}${done}<div class="wk-spcols">${goal}${col('doing', 'In progress')}${col('todo', 'To do')}${col('done', 'Done')}</div>${o.sug || ''}</section>`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The Suggestion of one sprint proposal (pm/bk-sprint.js proposalsOf): Why, PMOS will, What changes, Based on. */
|
|
60
|
+
export function sugOfProp(p, label) {
|
|
61
|
+
if (!p) return '';
|
|
62
|
+
const n = p.uids.length, tk = plural(n, 'ticket', 'tickets');
|
|
63
|
+
const why = p.kind === 'link' ? `Their parent ticket is already in ${p.iniTitle}, so they belong there too.`
|
|
64
|
+
: p.kind === 'place' ? `The ${p.theme} tickets have no initiative, and ${p.iniTitle} has the same name.`
|
|
65
|
+
: `${n} ${p.theme} tickets in ${label || 'this sprint'} have no initiative, so nobody reports on them.`;
|
|
66
|
+
const will = p.kind === 'home' ? [`Open New initiative named ${p.theme}`, 'Place its tickets once you save it'] : [`Put ${n === 1 ? 'the ticket' : 'the ' + n + ' tickets'} in ${p.iniTitle}`];
|
|
67
|
+
const changes = p.kind === 'home' ? 'Nothing changes until you save the initiative. Nothing is sent to anyone.' : `The ${tk} show under ${p.iniTitle} here and on the initiative. Jira is not changed.`;
|
|
68
|
+
const basis = p.kind === 'link' ? 'The parent ticket in Jira' : 'The ticket titles' + (p.kind === 'place' ? ' and the initiative\'s name' : '');
|
|
69
|
+
return sugHtml({ title: p.text, why, will, changes, basis }, `data-pid="${esc(p.id)}"`, 'data-spsug');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The Group menu's groups, in order. o: { group, themes: [{ id, name, uids }] } → [{ k, name, rows }] */
|
|
73
|
+
export function groupsOf(rows, o = {}) {
|
|
74
|
+
const G = o.group || 'ini';
|
|
75
|
+
if (G === 'none') return [{ k: '', name: '', rows: rows.slice().sort(byDue) }];
|
|
76
|
+
const m = new Map(), add = (k, name, r) => { if (!m.has(k)) m.set(k, { k, name, rows: [] }); m.get(k).rows.push(r); };
|
|
77
|
+
const th = new Map(); for (const t of o.themes || []) for (const u of t.uids || []) th.set(u, t);
|
|
78
|
+
for (const r of rows) {
|
|
79
|
+
if (G === 'who') add(r.who || '~', r.who || 'No one', r);
|
|
80
|
+
else if (G === 'state') add(r.state, r.state, r);
|
|
81
|
+
else if (G === 'theme') { const t = th.get(r.uid); add(t ? t.name : '~', t ? t.name : 'Other work', r); }
|
|
82
|
+
else add(r.ini || '~', r.ini ? r.iniTitle || r.ini : 'No initiative yet', r);
|
|
83
|
+
}
|
|
84
|
+
const ST = ['In progress', 'In review', 'To do', 'Done'];
|
|
85
|
+
return [...m.values()].sort((a, b) => (G === 'state' ? ST.indexOf(a.k) - ST.indexOf(b.k) : (a.k === '~') - (b.k === '~') || a.name.localeCompare(b.name)))
|
|
86
|
+
.map((g) => ({ ...g, rows: g.rows.slice().sort((a, b) => (a.state === 'Done') - (b.state === 'Done') || byDue(a, b)) }));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const badgeOf = (s) => `<span class="pm-badge${s === 'In progress' || s === 'In review' ? ' blue' : ''}">${esc(s)}</span>`;
|
|
90
|
+
function rowHtml(r, nest) {
|
|
91
|
+
const t = r.open ? `<button type="button" class="wk-tt" data-spopen="${esc(r.uid)}">${esc(r.title)}</button>`
|
|
92
|
+
: r.url ? `<a class="wk-tt" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title)}</a>` : esc(r.title);
|
|
93
|
+
const src = r.key ? `<span class="pm-meta code">${esc(r.key)}</span>` : '<span class="pm-chip">Not in Jira</span>';
|
|
94
|
+
const due = `<span class="pm-row wk-due">${r.due ? `<span class="pm-meta code">${dayText(r.due)}</span>` : ''}${r.late ? `<span class="pm-badge alert">${lateText(r.late)}</span>` : ''}${movedText(r.moved) ? `<span class="pm-badge">${movedText(r.moved).replace(/^m/, 'M')}</span>` : ''}</span>`;
|
|
95
|
+
return `<tr class="wk-sr${r.state === 'Done' ? ' wk-dn' : ''}" data-sp="${esc(r.uid)}"><td class="${nest ? 'wk-nest' : ''}"><b>${t}</b></td><td>${esc(r.who) || '<span class="pm-meta">No one</span>'}</td><td>${badgeOf(r.state)}</td><td>${src}</td><td>${due}</td></tr>`;
|
|
96
|
+
}
|
|
97
|
+
/** The Tasks block. o: { tab, group, menu (the Group menu is open), themes } */
|
|
98
|
+
export function tasksHtml(N, o = {}) {
|
|
99
|
+
const c = countsOf(N), tab = o.tab || 'all', group = o.group || 'ini';
|
|
100
|
+
const tabs = `<div class="pm-tabs" role="tablist" aria-label="Show">${TABS.filter(([k]) => k === 'all' || c[k] || k === tab).map(([k, n]) => `<button type="button" class="pm-tab" role="tab" aria-selected="${k === tab}" data-sptab="${k}">${n} <span class="pm-meta">${c[k]}</span></button>`).join('')}</div>`;
|
|
101
|
+
const G = GROUPS.filter(([k]) => k !== 'theme' || (o.themes || []).length);
|
|
102
|
+
const gname = (G.find(([k]) => k === group) || G[0])[1];
|
|
103
|
+
const menu = `<span class="wk-mw"><button type="button" class="pm-tab wk-gb" data-spgroup aria-haspopup="menu" aria-expanded="${!!o.menu}">Group: ${gname}${SV(I.down, 14)}</button>`
|
|
104
|
+
+ (o.menu ? `<div class="pm-menu wk-gm" role="menu" aria-label="Group">${G.map(([k, n]) => `<button type="button" role="menuitemradio" aria-checked="${k === group}" data-spgrp="${k}">${n}</button>`).join('')}</div>` : '') + '</span>';
|
|
105
|
+
const R = rowsOf(N, tab), GG = groupsOf(R, { group, themes: o.themes });
|
|
106
|
+
const all = groupsOf(N.rows, { group, themes: o.themes });
|
|
107
|
+
const body = GG.map((g) => {
|
|
108
|
+
const whole = all.find((x) => x.k === g.k) || g;
|
|
109
|
+
const head = g.name ? `<tr class="wk-g"><td colspan="5"><div class="pm-group"><b>${esc(g.name)}</b> <span class="pm-meta">${whole.rows.filter((r) => r.state === 'Done').length} of ${whole.rows.length} done</span></div></td></tr>` : '';
|
|
110
|
+
return head + g.rows.map((r) => rowHtml(r, !!g.name)).join('');
|
|
111
|
+
}).join('');
|
|
112
|
+
const table = R.length ? `<table class="pm-table wk-spx"><thead><tr><th>Task</th><th>Who</th><th>State</th><th>Source</th><th>Due</th></tr></thead><tbody>${body}</tbody></table>`
|
|
113
|
+
: '<p class="pm-meta">Nothing here.</p>';
|
|
114
|
+
return `<section class="pm-block wk-blk wk-spt" aria-label="Sprint tasks"><div class="head"><h2 class="pm-h">Tasks</h2><span class="sp"></span>${tabs}${menu}</div>${table}</section>`;
|
|
115
|
+
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* pm/bd-backlog.js calls bandHtml() while the chip is on, themeOf() for the list, pastOn()/pastListHtml() for a past sprint's list, and
|
|
20
20
|
* press() first on each press in the Backlog. */
|
|
21
21
|
import * as SK from './bk-sprint.js';
|
|
22
|
+
import * as DS from './bd-sprint-ds.js'; // This sprint from the system's parts (WorkSprintDS)
|
|
22
23
|
|
|
23
24
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
24
25
|
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
@@ -27,7 +28,7 @@ const I = { ok: 'M5 12.5l4.5 4.5L19 7', x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4
|
|
|
27
28
|
const SPARK = '✦';
|
|
28
29
|
const OLD_MS = 36 * 3600000; // the Board's own line for an old Jira read (pm/premium-board.js jMood)
|
|
29
30
|
const MON3 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
30
|
-
const BLOCK = { goals: 'Sprint
|
|
31
|
+
const BLOCK = { goals: 'Sprint goal', doing: 'Doing now', next: 'Planned next' };
|
|
31
32
|
|
|
32
33
|
let PICK = ''; // the sprint shown (its id), when there are more than one
|
|
33
34
|
let THEME = ''; // the theme pressed (its id): the list below shows only its tickets
|
|
@@ -42,6 +43,10 @@ const DET = new Map(); // 'ws|board|name' → { state: pending|ready|failed, d
|
|
|
42
43
|
const FILLING = new Set(); // sprints being read from Jira now (SpH3)
|
|
43
44
|
const SHOWN = 8; // past sprints the picker shows before "N older sprints"
|
|
44
45
|
const DR = new Map(); // sprint id → { sig, state: pending|ready|failed, d, again }
|
|
46
|
+
const VKEY = 'pmos.work.sprint';
|
|
47
|
+
const VIEW = (() => { try { const v = JSON.parse(localStorage.getItem(VKEY) || 'null'); if (v && typeof v === 'object') return { tab: DS.TABS.some(([k]) => k === v.tab) ? v.tab : 'all', group: DS.GROUPS.some(([k]) => k === v.group) ? v.group : 'ini' }; } catch { /* a private window */ } return { tab: 'all', group: 'ini' }; })();
|
|
48
|
+
const saveView = () => { try { localStorage.setItem(VKEY, JSON.stringify(VIEW)); } catch { /* kept for this page */ } };
|
|
49
|
+
let GMENU = false; // the Group menu is open
|
|
45
50
|
|
|
46
51
|
const sigOf = (T) => T.map((t) => t.key + (SK.isMoving(t) ? 'm' : 't')).sort().join(',');
|
|
47
52
|
const dayOf = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : d.getDate() + ' ' + MON3[d.getMonth()]; };
|
|
@@ -77,7 +82,7 @@ export function bandHtml(o, deps) {
|
|
|
77
82
|
if (PAST) { CUR = null; return pastHtml(o, H, past.find((x) => x.name === PAST), deps); }
|
|
78
83
|
CURP = null;
|
|
79
84
|
const sp = S.find((x) => x.id === PICK) || S[0];
|
|
80
|
-
const T = sp.tasks
|
|
85
|
+
const T = sp.tasks;
|
|
81
86
|
const dr = ask(sp, deps);
|
|
82
87
|
const written = dr.state === 'ready' ? SK.fromDraft(T, dr.d) : null;
|
|
83
88
|
const themes = written ? written.themes : SK.themesOf(T);
|
|
@@ -87,37 +92,32 @@ export function bandHtml(o, deps) {
|
|
|
87
92
|
const props = SK.proposalsOf(T, o.all, o.inis, themes, note.dismissed);
|
|
88
93
|
CUR = { sp, themes, draft, props, note };
|
|
89
94
|
|
|
90
|
-
const pct = (a, b) => (b ? Math.round((a / b) * 1000) / 10 : 0);
|
|
91
95
|
const old = !o.readAt || Date.now() - Date.parse(o.readAt) > OLD_MS;
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
+ `<span class="bk-two"><button type="button" class="bk-ib" data-spok="${esc(p.id)}" aria-label="Yes: ${esc(p.text)}" title="Yes">${SV(I.ok)}</button><button type="button" class="bk-ib" data-spno="${esc(p.id)}" aria-label="No: ${esc(p.text)}" title="No">${SV(I.x)}</button></span></div>`).join('')}</div>` : '';
|
|
105
|
-
return `<section class="sbo-band" aria-label="Sprint overview"><div class="sbo-top">${sum}${th}</div><div class="sbo-pl">${blocks}</div>${pr}</section>`;
|
|
96
|
+
// all work in the sprint's dates, Jira and not (lib/sprint-now.js); before the server's answer, the sprint's open tickets
|
|
97
|
+
const N = (o.now || []).find((n) => n.ws === sp.ws && n.board === sp.board && n.name === sp.name) || nowOf(sp);
|
|
98
|
+
CUR.now = N;
|
|
99
|
+
const pick = S.length > 1 ? `<span class="pm-tabs" role="group" aria-label="Sprint">${S.map((x) => `<button type="button" class="pm-tab" aria-pressed="${x.id === sp.id}" aria-selected="${x.id === sp.id}" data-sppick="${esc(x.id)}">${esc(x.label)}</button>`).join('')}</span>` : '';
|
|
100
|
+
const label = pick || (H && past.length ? pickerHtml(H, sp.name, sp.label) : `<b title="${esc(sp.name)}">${esc(sp.label)}</b>`);
|
|
101
|
+
const b = SK.blockOf(note.goals, draft.goals || []);
|
|
102
|
+
const goal = { lines: b.lines.map((l) => l.text), mine: !!b.mine, editing: EDIT === 'goals',
|
|
103
|
+
edit: `<textarea class="pm-input wk-ta" data-spta="goals" rows="${Math.max(3, b.lines.length + 1)}" aria-label="Sprint goal, one point a line">${esc(b.lines.map((l) => l.text).join('\n'))}</textarea>`
|
|
104
|
+
+ `<div class="pm-row wk-ed"><button type="button" class="pm-btn primary" data-spsave="goals" aria-label="Save the sprint goal" title="Save">${SV(I.ok)}</button><button type="button" class="pm-btn" data-spcancel aria-label="Cancel" title="Cancel">${SV(I.x)}</button></div>`,
|
|
105
|
+
newer: b.newer ? `<div class="pm-sug"><span class="say">PMOS has a newer draft from the sprint's work.</span><button type="button" class="pm-btn" data-spnew="goals" aria-label="Use PMOS's newer draft of the sprint goal" title="Use it">${SV(I.ok)}</button><button type="button" class="pm-btn" data-spkeep="goals" aria-label="Keep yours" title="Keep yours">${SV(I.x)}</button></div>` : '' };
|
|
106
|
+
const read = { old, title: old ? 'Jira was last read ' + (o.readAt ? dayOf(o.readAt) : 'a while ago') + '. Read it again' : 'Read Jira again' + (o.readAt ? ' (last read ' + dayOf(o.readAt) + ')' : '') };
|
|
107
|
+
return DS.cardHtml(N, { label, goal, read, sug: DS.sugOfProp(props[0], sp.label) });
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
: k === 'goals' && !b.mine && L.length ? `<p class="sbo-meta">Drafted from the ${st.all} tickets, not from the goal set in Jira. Edit to make it yours.</p>` : '';
|
|
120
|
-
return `<div class="sbo-b">${head}${ul}${foot}</div>`;
|
|
110
|
+
/** The sprint's open tickets as This sprint's rows, until GET /api/backlog answers with sprintNow. */
|
|
111
|
+
function nowOf(sp) {
|
|
112
|
+
const rows = sp.tasks.map((t) => ({ uid: SK.uidOf(t), id: t.id, src: t.src, key: t.key || '', title: t.title, ini: t.ini || null, iniTitle: t.iniTitle || '', who: t.who || '', state: t.state, due: t.due || null, late: t.late || 0, moved: 0, url: t.url || null, open: true }));
|
|
113
|
+
const jira = rows.filter((r) => r.key).length;
|
|
114
|
+
return { name: sp.name, label: sp.label, start: null, end: null, rows, jira, other: rows.length - jira, done: 0, total: rows.length };
|
|
115
|
+
}
|
|
116
|
+
/** The Tasks block of the sprint shown (WorkSprintDS); '' when a past sprint shows (its list is pastListHtml). */
|
|
117
|
+
export function tasksNowHtml() {
|
|
118
|
+
if (!CUR || !CUR.now || CURP) return '';
|
|
119
|
+
const themes = (CUR.themes || []).filter((t) => !t.spare && (t.uids || []).length).map((t) => ({ id: t.id, name: t.name, uids: t.uids }));
|
|
120
|
+
return DS.tasksHtml(CUR.now, { tab: VIEW.tab, group: VIEW.group === 'theme' && !themes.length ? 'ini' : VIEW.group, menu: GMENU, themes });
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/* ── past sprints (initiative sprint-snapshots) ───────────────────────────────────────────────────────────── */
|
|
@@ -311,35 +311,50 @@ export async function press(e, deps) {
|
|
|
311
311
|
deps.say(use ? BLOCK[k] + ': PMOS\'s newer draft.' : BLOCK[k] + ': yours kept.', () => back(deps, at, k, r.was));
|
|
312
312
|
await deps.load(); return true;
|
|
313
313
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if ((b = hit('data-spok'))) {
|
|
322
|
-
const p = CUR.props.find((x) => x.id === b.dataset.spok); if (!p) return true;
|
|
323
|
-
if (p.kind === 'home') {
|
|
324
|
-
if (deps.newInitiative) deps.newInitiative(p.theme, b); else deps.say('Make the initiative with New initiative, then place the tickets.');
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
const done = [];
|
|
328
|
-
for (const u of p.uids) {
|
|
329
|
-
const t = deps.taskOf(u); if (!t) continue;
|
|
330
|
-
const r = await deps.post('/api/backlog/place', { ws: t.ws, board: t.board, key: t.id, to: p.ini });
|
|
331
|
-
if (r && r.ok) done.push({ t, from: r.from || '' }); else { deps.say((r && r.error) || 'Nothing was placed.'); break; }
|
|
332
|
-
}
|
|
333
|
-
if (done.length) {
|
|
334
|
-
deps.say(`Placed ${done.length === 1 ? done[0].t.title : done.length + ' tickets'} in ${p.iniTitle}.`, async () => {
|
|
335
|
-
for (const x of done) await deps.post('/api/backlog/place', { ws: x.t.ws, board: x.t.board, key: x.t.id, to: x.from });
|
|
336
|
-
deps.say('Put back.'); deps.load(); deps.reload();
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
await deps.load(); deps.reload(); return true;
|
|
314
|
+
// the Suggestion (WorkSprintDS): Yes is the old ✓, No the old ✕; the pencil picks another initiative before it places the tickets
|
|
315
|
+
if ((b = hit('data-spsug'))) {
|
|
316
|
+
const k = b.dataset.spsug, p = CUR.props.find((x) => x.id === b.dataset.pid); if (!p) return true;
|
|
317
|
+
if (k === 'no') return dismiss(p, at, deps);
|
|
318
|
+
if (k === 'yes' || p.kind === 'home' || !deps.pickIni) return accept(p, b, deps);
|
|
319
|
+
deps.pickIni(b, p, (id, title) => accept({ ...p, ini: id, iniTitle: title }, b, deps));
|
|
320
|
+
return true;
|
|
340
321
|
}
|
|
322
|
+
if ((b = hit('data-sptab'))) { VIEW.tab = b.dataset.sptab; saveView(); deps.draw(); const n = document.querySelector(`[data-sptab="${VIEW.tab}"]`); if (n) n.focus(); return true; }
|
|
323
|
+
if (hit('data-spgroup')) { GMENU = !GMENU; deps.draw(); const n = document.querySelector('[data-spgrp][aria-checked="true"]'); if (GMENU && n) n.focus(); return true; }
|
|
324
|
+
if ((b = hit('data-spgrp'))) { VIEW.group = b.dataset.spgrp; GMENU = false; saveView(); deps.draw(); const n = document.querySelector('[data-spgroup]'); if (n) n.focus(); return true; }
|
|
325
|
+
if (GMENU) { GMENU = false; deps.draw(); }
|
|
326
|
+
if ((b = hit('data-spopen'))) { const t = deps.taskOf(b.dataset.spopen); if (t && deps.openTask) deps.openTask(t, b); return true; }
|
|
327
|
+
if ((b = hit('data-spno'))) { const p = CUR.props.find((x) => x.id === b.dataset.spno); return p ? dismiss(p, at, deps) : true; }
|
|
328
|
+
if ((b = hit('data-spok'))) { const p = CUR.props.find((x) => x.id === b.dataset.spok); return p ? accept(p, b, deps) : true; }
|
|
341
329
|
return false;
|
|
342
330
|
}
|
|
331
|
+
/** No on a proposal: not now, with Undo. */
|
|
332
|
+
async function dismiss(p, at, deps) {
|
|
333
|
+
const r = await deps.post('/api/backlog/sprint-note', { ...at, ev: 'dismiss', id: p.id });
|
|
334
|
+
if (!r || r.ok === false) { deps.say((r && r.error) || 'Nothing was changed.'); return true; }
|
|
335
|
+
deps.say('Not now: ' + p.text + '.', async () => { await deps.post('/api/backlog/sprint-note', { ...at, ev: 'undismiss', id: p.id }); deps.load(); });
|
|
336
|
+
await deps.load(); return true;
|
|
337
|
+
}
|
|
338
|
+
/** Yes on a proposal: place its tickets in the initiative (a ticket-move line; Jira is not written to), or open New initiative. */
|
|
339
|
+
async function accept(p, b, deps) {
|
|
340
|
+
if (p.kind === 'home') {
|
|
341
|
+
if (deps.newInitiative) deps.newInitiative(p.theme, b); else deps.say('Make the initiative with New initiative, then place the tickets.');
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
const done = [];
|
|
345
|
+
for (const u of p.uids) {
|
|
346
|
+
const t = deps.taskOf(u); if (!t) continue;
|
|
347
|
+
const r = await deps.post('/api/backlog/place', { ws: t.ws, board: t.board, key: t.id, to: p.ini });
|
|
348
|
+
if (r && r.ok) done.push({ t, from: r.from || '' }); else { deps.say((r && r.error) || 'Nothing was placed.'); break; }
|
|
349
|
+
}
|
|
350
|
+
if (done.length) {
|
|
351
|
+
deps.say(`Placed ${done.length === 1 ? done[0].t.title : done.length + ' tickets'} in ${p.iniTitle}.`, async () => {
|
|
352
|
+
for (const x of done) await deps.post('/api/backlog/place', { ws: x.t.ws, board: x.t.board, key: x.t.id, to: x.from });
|
|
353
|
+
deps.say('Put back.'); deps.load(); deps.reload();
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
await deps.load(); deps.reload(); return true;
|
|
357
|
+
}
|
|
343
358
|
/** Undo of an edit: the block as it was (the PM's earlier words, or PMOS's draft). */
|
|
344
359
|
async function back(deps, at, k, was) {
|
|
345
360
|
await deps.post('/api/backlog/sprint-note', was ? { ...at, ev: 'note', block: k, text: was.text, base: was.base } : { ...at, ev: 'clear', block: k });
|
|
@@ -97,15 +97,15 @@ export function sugOf(r, p, now = new Date()) {
|
|
|
97
97
|
return { title: title + (title && !title.includes(r.title) ? ` (${r.title})` : ''), why: String(p.why || '').trim(), will: title === will[0] && will.length === 1 ? [] : will, changes, basis };
|
|
98
98
|
}
|
|
99
99
|
/** The expanded Suggestion (pm-sug x). s: sugOf(); data: the attributes its answers carry (the page knows which proposal). */
|
|
100
|
-
export function sugHtml(s, data = '') {
|
|
100
|
+
export function sugHtml(s, data = '', at = 'data-wksug') {
|
|
101
101
|
if (!s || !s.title) return '';
|
|
102
102
|
const row = (k, v, cls = '') => (v ? `<dt>${k}</dt><dd${cls ? ` class="${cls}"` : ''}>${v}</dd>` : '');
|
|
103
103
|
return `<div class="pm-sug x" role="group" aria-label="PMOS suggests">`
|
|
104
104
|
+ `<div class="ttl">${SV(I.star)}<b class="say">${esc(s.title)}</b></div>`
|
|
105
105
|
+ `<dl>${row('Why', esc(s.why))}${row('PMOS will', s.will.length ? `<ul>${s.will.map((w) => `<li>${esc(w)}</li>`).join('')}</ul>` : '')}${row('What changes', esc(s.changes))}${row('Based on', esc(s.basis), 'src')}</dl>`
|
|
106
|
-
+ `<div class="ans"><button type="button" class="pm-btn"
|
|
107
|
-
+ `<button type="button" class="pm-btn primary"
|
|
108
|
-
+ `<button type="button" class="pm-btn outline"
|
|
106
|
+
+ `<div class="ans"><button type="button" class="pm-btn" ${at}="edit" ${data} aria-label="Change it first" title="Change it first">${SV(I.pen)}</button>`
|
|
107
|
+
+ `<button type="button" class="pm-btn primary" ${at}="yes" ${data} aria-label="Yes, do it" title="Yes, do it">${SV(I.ok)}</button>`
|
|
108
|
+
+ `<button type="button" class="pm-btn outline" ${at}="no" ${data} aria-label="No" title="No">${SV(I.x)}</button></div></div>`;
|
|
109
109
|
}
|
|
110
110
|
/** The Where it stands block: the sentences, then one Suggestion. Nothing to say and nothing suggested: no block. */
|
|
111
111
|
export function standsHtml(rows, o = {}) {
|