create-pmos 0.419.0 → 0.421.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +25 -30
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/lane-defs.js +14 -1
- package/payload/scripts/workflow-state.js +2 -2
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-board-test.js +9 -13
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/report-api/draft.json +2 -1
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/home.md +3 -0
- package/workspace/home-other-product-test.js +18 -0
- package/workspace/home-rows-test.js +14 -0
- package/workspace/lib/board-premium.js +13 -3
- package/workspace/lib/brief.js +5 -0
- package/workspace/lib/briefing-premium-agent.js +8 -0
- package/workspace/lib/engine/lane-defs.js +14 -1
- package/workspace/lib/engine/workflow-state.js +2 -2
- package/workspace/lib/first-input.js +13 -6
- package/workspace/lib/hold-spans.js +64 -0
- package/workspace/lib/mention-store.js +49 -13
- package/workspace/lib/plan-tree.js +1 -1
- package/workspace/lib/report-draft.js +6 -0
- package/workspace/lib/routes-boards.js +22 -6
- package/workspace/lib/source-reads.js +5 -0
- package/workspace/lib/transcript-read.js +29 -1
- package/workspace/lib/vendor/scripts/lane-defs.js +14 -1
- package/workspace/lib/vendor/scripts/workflow-state.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-viewer-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +49 -1
- package/workspace/public/pm/bd-ini-panel.js +15 -8
- package/workspace/public/pm/bd-next.js +119 -0
- package/workspace/public/pm/bd-prog.js +1 -1
- package/workspace/public/pm/bd-span.js +120 -22
- package/workspace/public/pm/bd-views.js +7 -5
- package/workspace/public/pm/cozy-board.css +54 -9
- package/workspace/public/pm/cozy-live-pill.js +1 -1
- package/workspace/public/pm/cozy-nav.js +1 -1
- package/workspace/public/pm/cozy-steps.js +1 -1
- package/workspace/public/pm/cozy-today.css +9 -0
- package/workspace/public/pm/cozy-viewer.js +7 -3
- package/workspace/public/pm/cozy-xv.js +1 -1
- package/workspace/public/pm/cozy.css +10 -0
- package/workspace/public/pm/home-app.js +39 -13
- package/workspace/public/pm/home-ask.js +7 -0
- package/workspace/public/pm/home-ini.js +44 -13
- package/workspace/public/pm/home-line.js +1 -1
- package/workspace/public/pm/home-list.js +22 -2
- package/workspace/public/pm/home-mentions.js +1 -1
- package/workspace/public/pm/home-today.js +13 -2
- package/workspace/public/pm/ini-tasks.js +363 -0
- package/workspace/public/pm/ini-view-model.js +19 -11
- package/workspace/public/pm/ini-view.css +160 -0
- package/workspace/public/pm/ini-view.js +40 -9
- package/workspace/public/pm/premium-board.js +54 -17
- package/workspace/public/pm/premium-insights.js +1 -1
- package/workspace/public/pm/premium-mtg-present.js +2 -2
- package/workspace/public/pm/premium-report-read.js +1 -1
- package/workspace/public/pm/premium-report-tab.js +1 -1
- package/workspace/public/pm/premium-viewer.js +3 -3
- package/workspace/public/pm/premium-vw-mtg.js +3 -1
- package/workspace/public/pm/premium-vw-open.js +1 -1
- package/workspace/public/pm/premium-vw-slides.js +1 -1
- package/workspace/public/pm/prog-order.js +1 -1
- package/workspace/public/pm/task-card.js +6 -0
- package/workspace/public/pm/tk-send.js +1 -1
- package/workspace/server.js +26 -2
- package/workspace/skills/day-check.skill +2 -2
- package/workspace/skills/morning-brief.skill +1 -1
- package/workspace/skills/sources-read.skill +8 -4
- package/workspace/task-press-test.js +120 -0
- package/workspace/task-views-test.js +245 -0
- package/workspace/test-lists/task-press.json +6 -0
- package/workspace/test-lists/task-views.json +6 -0
- package/workspace/test-lists/timeline-holds.json +6 -0
- package/workspace/timeline-holds-test.js +199 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/* pm/ini-tasks.js — the initiative's Tasks in three views, and a task's status and dates changed where it sits (feedback batch 9 item 5b;
|
|
2
|
+
* canvas In development, row "Tasks views": XtvAGrill, XtvA1Status, XtvA1bDone, XtvA2Dates, XtvA3Timeline, XtvA4Kanban, XtvA5PhoneKanban,
|
|
3
|
+
* XtvA6PhoneTimeline, XtvA7BoardPanel). pm/ini-view.js draws the Tasks header and the List; this file draws Timeline and Kanban from the
|
|
4
|
+
* same model (pm/ini-view-model.js) and owns the presses they share with the List. The Board's panel and Home's page are the same section.
|
|
5
|
+
*
|
|
6
|
+
* viewMode() / setViewMode(m) 'list' | 'timeline' | 'kanban': the last view, remembered for the PM across initiatives; first time List
|
|
7
|
+
* switchHtml(m) the icon-only segment List / Timeline / Kanban (Kanban is the Board's "By stage" icon)
|
|
8
|
+
* headExtraHtml(v, m) what the view adds to the header: Timeline's Weeks/Months/Quarters picker, Kanban's stage picker
|
|
9
|
+
* timelineHtml(v, o, isOpen) the stage groups of the List (the same folds), bars by start → due, a circle for a due day only, a dashed
|
|
10
|
+
* date press at today for a task with no dates, the Today line and the legend under it
|
|
11
|
+
* kanbanHtml(v, o, isOpen) one stage at a time; columns To do, In progress, Done; Won't do a folded strip; phone: one column a screen
|
|
12
|
+
* press(b, d, root, H) a press this file owns → true: the view switch, the pickers, the status caret, a date, a bar, a tab
|
|
13
|
+
* wireDrag(body) once per body: drag a bar (move, or an end), drag a card between columns, long-press a box on a phone
|
|
14
|
+
*
|
|
15
|
+
* The host's handlers (wireView's h): h.check(uid) the box's one-press Done (Undo in the host's toast), h.status(uid, state) and
|
|
16
|
+
* h.dates(uid, { start?, due? }) the quick changes (each with Undo), h.redraw(). A Jira ticket is read-only: the Jira mark, a plain date, no
|
|
17
|
+
* picker and no drag. Archived tasks show in no view here (the List folds them after Done). */
|
|
18
|
+
import { STATES, stateIcon, stateKey, datePickerHtml, cardStyle } from './task-card.js';
|
|
19
|
+
|
|
20
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
21
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
22
|
+
export const P = {
|
|
23
|
+
list: 'M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01', time: 'M4 6h9M8 12h11M6 18h7', kanban: 'M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z',
|
|
24
|
+
down: 'M7 10l5 5 5-5', right: 'M10 7l5 5-5 5', cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', jira: 'M12 3l9 9-9 9-9-9z', check: 'M5 12l5 5 9-10',
|
|
25
|
+
};
|
|
26
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
27
|
+
const VIEWS = [['list', 'List', P.list], ['timeline', 'Timeline', P.time], ['kanban', 'Kanban', P.kanban]];
|
|
28
|
+
const ZOOMS = [['week', 'Weeks', 14], ['month', 'Months', 4], ['quarter', 'Quarters', 1.6]];
|
|
29
|
+
const COLS = [['To do', 'To do'], ['In progress', 'In progress'], ['Done', 'Done']];
|
|
30
|
+
|
|
31
|
+
/* ── what the PM picked: the view and the zoom for the PM (this browser), the Kanban stage per initiative for the session ── */
|
|
32
|
+
const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch { /* private window: the session keeps it */ } } };
|
|
33
|
+
let VIEW = null, ZOOM = null;
|
|
34
|
+
const STAGE = new Map(); // initiative → the Kanban's stage key ('all' | a section key)
|
|
35
|
+
const SCROLL = new Map(); // initiative|zoom → the Timeline's scroll, so a redraw keeps the PM's place
|
|
36
|
+
export function viewMode() { if (!VIEW) { const v = store.get('pmos.tasks.view'); VIEW = v === 'timeline' || v === 'kanban' ? v : 'list'; } return VIEW; }
|
|
37
|
+
export function setViewMode(m) { VIEW = m === 'timeline' || m === 'kanban' ? m : 'list'; store.set('pmos.tasks.view', VIEW); }
|
|
38
|
+
const zoomOf = () => { if (!ZOOM) { const z = store.get('pmos.tasks.zoom'); ZOOM = ZOOMS.some((x) => x[0] === z) ? z : 'week'; } return ZOOM; };
|
|
39
|
+
/** For the tests: forget the PM's picks. */
|
|
40
|
+
export const resetViews = () => { VIEW = null; ZOOM = null; STAGE.clear(); SCROLL.clear(); };
|
|
41
|
+
|
|
42
|
+
/* ── days, as whole numbers (UTC, so a summer-time night never moves a bar) ── */
|
|
43
|
+
const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
44
|
+
const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
45
|
+
export const isoN = (n) => new Date(n * 864e5).toISOString().slice(0, 10);
|
|
46
|
+
const md = (n) => { const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
|
|
47
|
+
/** "Nov 4 → 13", "Nov 28 → Dec 3", "Nov 4": the tip while a bar drags, in the List's words. */
|
|
48
|
+
export function spanText(s, e) {
|
|
49
|
+
if (s == null && e == null) return '';
|
|
50
|
+
if (s == null || e == null || s === e) return md(s == null ? e : s);
|
|
51
|
+
const a = new Date(s * 864e5), b = new Date(e * 864e5);
|
|
52
|
+
return md(s) + ' → ' + (a.getUTCMonth() === b.getUTCMonth() && a.getUTCFullYear() === b.getUTCFullYear() ? b.getUTCDate() : md(e));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ── the header ── */
|
|
56
|
+
export function switchHtml(m) {
|
|
57
|
+
return `<div class="ivx-seg" role="group" aria-label="Tasks view">${VIEWS.map(([k, l, d]) => `<button type="button" class="ivx-sb" data-iv-view="${k}" aria-pressed="${m === k}" aria-label="${l}" title="${l}">${SVG(d, 17)}</button>`).join('')}</div>`;
|
|
58
|
+
}
|
|
59
|
+
/** The Kanban's stage choices: the current stage first, All stages, then the rest of the List's groups in their order, each with its count. */
|
|
60
|
+
export function stagesOf(v) {
|
|
61
|
+
const S = v.tasks.sections, now = S.find((s) => s.kind === 'stage' && s.status === 'now');
|
|
62
|
+
const name = (s) => (s.kind === 'later' ? 'Later stages' : s.kind === 'none' ? 'Not in a stage' : s.label || s.name);
|
|
63
|
+
const all = { key: 'all', label: 'All stages', count: v.tasks.open ? v.tasks.open + ' open' : v.tasks.count };
|
|
64
|
+
const rest = S.filter((s) => s !== now).map((s) => ({ key: s.key || '-', label: name(s), count: s.count }));
|
|
65
|
+
return now ? [{ key: now.key, label: now.name, count: now.count }, all, ...rest] : [all, ...rest];
|
|
66
|
+
}
|
|
67
|
+
const stageKeyOf = (v) => { const L = stagesOf(v), k = STAGE.get(v.id || v.key); return L.some((x) => x.key === k) ? k : L[0].key; };
|
|
68
|
+
export function headExtraHtml(v, m) {
|
|
69
|
+
if (m === 'timeline') {
|
|
70
|
+
const z = ZOOMS.find((x) => x[0] === zoomOf());
|
|
71
|
+
return `<button type="button" class="ivx-pick" data-iv-zoom aria-haspopup="menu" aria-label="Zoom: ${esc(z[1].toLowerCase())}. Change">${esc(z[1])}${SVG(P.down, 14, 2)}</button>`;
|
|
72
|
+
}
|
|
73
|
+
if (m === 'kanban') {
|
|
74
|
+
const L = stagesOf(v), k = stageKeyOf(v), x = L.find((y) => y.key === k);
|
|
75
|
+
return `<button type="button" class="ivx-pick on" data-iv-kstage aria-haspopup="menu" aria-label="Stage: ${esc(x.label)}. Change">${esc(x.label)}${SVG(P.down, 14, 2)}</button>`;
|
|
76
|
+
}
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ── the rows a group holds, flat: the List folds by work package; Timeline and Kanban do not ── */
|
|
81
|
+
const flat = (sec) => (sec.stages ? sec.stages.flatMap((s) => flat(s)) : [...sec.top, ...sec.groups.flatMap((g) => g.rows)]);
|
|
82
|
+
const flatDone = (sec) => (sec.stages ? sec.stages.flatMap((s) => flatDone(s)) : sec.done);
|
|
83
|
+
const jiraOf = (sec) => (sec.stages ? sec.stages.flatMap((s) => jiraOf(s)) : sec.jira ? sec.jira.open : []);
|
|
84
|
+
const box = (x, o) => {
|
|
85
|
+
const cls = ['iv-cb', x.done ? 'on' : '', x.prog ? 'pr' : '', x.wont ? 'wo' : ''].filter(Boolean).join(' ');
|
|
86
|
+
return `<span class="iv-bxw"><button type="button" class="${cls}" data-iv-check="${esc(x.uid)}" aria-pressed="${x.done}" aria-label="${esc((x.done ? 'Reopen: ' : 'Mark done: ') + x.title)}" title="${x.done ? 'Reopen' : 'Mark done'}">${x.done ? SVG(P.check, 12, 3) : ''}</button>`
|
|
87
|
+
+ (o.quick ? `<button type="button" class="iv-car" data-iv-stat="${esc(x.uid)}" data-st="${esc(x.status)}" aria-haspopup="dialog" aria-label="${esc('Change the status: ' + x.title)}" title="Status">${SVG(P.down, 10, 2.6)}</button>` : '') + '</span>';
|
|
88
|
+
};
|
|
89
|
+
const jmark = (k) => `<span class="iv-jm" role="img" aria-label="${esc('Jira ticket, ' + (k.status || 'To do') + '. Status and dates come from Jira')}" title="${esc('Jira · ' + (k.status || 'To do'))}">${SVG(P.jira, 14, 2)}</span>`;
|
|
90
|
+
const title = (x, o) => (o.openTask && x.uid ? `<button type="button" class="iv-tt" data-iv-task="${esc(x.uid)}">${esc(x.title)}</button>` : `<b class="iv-tt">${esc(x.title)}</b>`);
|
|
91
|
+
const ttitle = (k) => `<button type="button" class="iv-tt" data-iv-ticket="${esc(k.key)}"><em>${esc(k.key)}</em> ${esc(k.title)}</button>`;
|
|
92
|
+
/** The date press: the task card's start and due picker opens right under it. No dates: a calendar icon, shown on hover. */
|
|
93
|
+
export function dateBtn(x, o) {
|
|
94
|
+
if (!o.quick || !x.uid) return x.days ? `<span class="${x.late ? 'w' : ''}">${esc(x.days)}</span>` : '';
|
|
95
|
+
const a = `data-iv-date="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" title="Start and due"`;
|
|
96
|
+
return x.days ? `<button type="button" class="iv-dc${x.late ? ' w' : ''}" ${a} aria-label="${esc('Dates: ' + x.days + '. Change')}">${esc(x.days)}</button>`
|
|
97
|
+
: `<button type="button" class="iv-dc none" ${a} aria-label="${esc('Add dates: ' + x.title)}">${SVG(P.cal, 14)}</button>`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* ── Timeline ── */
|
|
101
|
+
const tone = (x) => (x.closed ? 'dn' : x.late ? 'lt' : x.prog ? 'pr' : '');
|
|
102
|
+
export function timelineHtml(v, o, isOpen) {
|
|
103
|
+
const today = dn(v.today) || Math.round(Date.now() / 864e5), z = ZOOMS.find((x) => x[0] === zoomOf()), px = z[2];
|
|
104
|
+
const S = v.tasks.sections;
|
|
105
|
+
// the range: the open tasks around today, a little air each side; never more than a few years
|
|
106
|
+
const ns = [];
|
|
107
|
+
for (const s of S) { for (const x of flat(s).concat(flatDone(s))) { const a = dn(x.start), b = dn(x.end); if (a != null) ns.push(a); if (b != null) ns.push(b); } for (const k of jiraOf(s)) { const b = dn(k.due); if (b != null) ns.push(b); } }
|
|
108
|
+
const lo = Math.max(today - 730, Math.min(today - 14, ...ns) - 4), hi = Math.min(today + 1095, Math.max(today + 42, ...ns) + 10);
|
|
109
|
+
const O = lo - ((new Date(lo * 864e5).getUTCDay() + 6) % 7); // start on a Monday
|
|
110
|
+
const W = Math.ceil((hi - O + 1) * px), X = (n) => Math.round((n - O) * px);
|
|
111
|
+
// the axis: Mondays (Weeks), the 1st (Months), the quarter's first day (Quarters)
|
|
112
|
+
const ticks = [];
|
|
113
|
+
for (let n = O; n <= hi; n++) {
|
|
114
|
+
const d = new Date(n * 864e5), m = d.getUTCMonth(), y = d.getUTCFullYear();
|
|
115
|
+
if (z[0] === 'week' && d.getUTCDay() === 1) ticks.push({ x: X(n), t: md(n), b: d.getUTCDate() <= 7 });
|
|
116
|
+
if (z[0] === 'month' && d.getUTCDate() === 1) ticks.push({ x: X(n), t: MON[m] + (m === 0 ? ' ' + y : ''), b: m === 0 });
|
|
117
|
+
if (z[0] === 'quarter' && d.getUTCDate() === 1 && m % 3 === 0) ticks.push({ x: X(n), t: 'Q' + (m / 3 + 1) + ' ' + y, b: m === 0 });
|
|
118
|
+
}
|
|
119
|
+
const drag = o.quick ? ' data-ivt-drag="1"' : '';
|
|
120
|
+
const barOf = (x) => {
|
|
121
|
+
const a = dn(x.start), b = dn(x.end), cls = tone(x), lbl = [x.days || 'No dates', x.owner && x.owner !== 'You' ? x.owner : '', x.closed ? x.status.toLowerCase() : x.late ? 'late' : x.prog ? 'in progress' : ''].filter(Boolean).join(', ');
|
|
122
|
+
const av = x.av ? `<span class="ivt-av" aria-hidden="true">${esc(x.av)}</span>` : '';
|
|
123
|
+
const at = `data-ivt-bar="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}"${o.quick && !x.closed ? drag : ''} aria-label="${esc(lbl + '. Change the dates')}"`;
|
|
124
|
+
if (a == null && b == null) return x.closed || !o.quick ? '' : `<button type="button" class="ivt-g" data-iv-date="${esc(x.uid)}" data-s="" data-e="" data-tlx="${X(today) - 18}" aria-label="${esc('No dates yet. Set dates: ' + x.title)}" title="Set dates">${SVG(P.cal, 13)}</button>`;
|
|
125
|
+
if (a == null) return `<button type="button" class="ivt-d ${cls}" ${at} data-only="due" data-tlx="${X(b) + Math.round(px / 2)}"></button>`;
|
|
126
|
+
const e = b == null ? a : Math.max(a, b);
|
|
127
|
+
return `<button type="button" class="ivt-b ${cls}" ${at} data-tlx="${X(a)}" data-tlw="${Math.max(10, X(e + 1) - X(a))}">`
|
|
128
|
+
+ (o.quick && !x.closed ? '<span class="ivt-gp l" data-grip="start" aria-hidden="true"></span><span class="ivt-gp r" data-grip="end" aria-hidden="true"></span>' : '') + av + '</button>';
|
|
129
|
+
};
|
|
130
|
+
const jbar = (k) => { const b = dn(k.due); return b == null ? '' : `<span class="ivt-d jr" role="img" data-tlx="${X(b) + Math.round(px / 2)}" aria-label="${esc('Due ' + md(b) + ' in Jira')}" title="${esc('Jira · ' + md(b))}"></span>`; };
|
|
131
|
+
const row = (n, c, cls = '') => `<div class="ivt-r${cls}"><div class="ivt-n">${n}</div><div class="ivt-c">${c}</div></div>`;
|
|
132
|
+
const band = (rs) => { const ds = rs.flatMap((x) => [dn(x.start), dn(x.end)]).filter((n) => n != null); if (!ds.length) return ''; const a = Math.min(...ds), b = Math.max(...ds); return `<span class="ivt-band" data-tlx="${X(a)}" data-tlw="${Math.max(8, X(b + 1) - X(a))}"></span>`; };
|
|
133
|
+
let h = '';
|
|
134
|
+
for (const sec of S) {
|
|
135
|
+
const key = 'sec:' + (sec.key || 'none'), op = isOpen(key, sec.open), rs = flat(sec), dn_ = flatDone(sec), jr = jiraOf(sec);
|
|
136
|
+
const has = rs.length || dn_.length || jr.length;
|
|
137
|
+
const head = `<button type="button" class="ivt-gh${sec.kind !== 'stage' && sec.kind !== 'none' ? ' mut' : ''}" ${has ? `data-iv-fold="${esc(key)}" aria-expanded="${op}"` : 'disabled'}>${o.mark(sec)}<b>${esc(sec.label || sec.name)}</b>${sec.count ? `<span class="n${sec.warn ? ' w' : ''}">${esc(sec.count)}</span>` : ''}${has ? `<span class="iv-cv" aria-hidden="true">${SVG(op ? P.down : P.right, 15, 2)}</span>` : ''}</button>`;
|
|
138
|
+
h += row(head, band(rs.concat(dn_)), ' g');
|
|
139
|
+
if (!op || !has) continue;
|
|
140
|
+
for (const k of jr) h += row(`${jmark(k)}${ttitle(k)}`, jbar(k), ' k');
|
|
141
|
+
for (const x of rs) h += row(`${box(x, o)}${title(x, o)}`, barOf(x), ' k');
|
|
142
|
+
if (dn_.length) {
|
|
143
|
+
const dk = (sec.key || 'none') + ':done', dop = isOpen(dk, false);
|
|
144
|
+
h += row(`<button type="button" class="ivt-df" data-iv-fold="${esc(dk)}" aria-expanded="${dop}">Done<span class="n">${dn_.length}</span><span class="iv-cv" aria-hidden="true">${SVG(dop ? P.down : P.right, 14, 2)}</span></button>`, dop ? '' : dn_.map(barOf).join(''), ' k');
|
|
145
|
+
if (dop) for (const x of dn_) h += row(`${box(x, o)}${title(x, o)}`, barOf(x), ' k x' + (x.wont ? ' wo' : ''));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const grid = ticks.map((t) => `<i data-tlx="${t.x}"></i>`).join('');
|
|
149
|
+
const axis = `<div class="ivt-r ax"><div class="ivt-n"></div><div class="ivt-c">${ticks.map((t) => `<span class="${t.b ? 'b' : ''}" data-tlx="${t.x}">${esc(t.t)}</span>`).join('')}</div></div>`;
|
|
150
|
+
const legend = `<div class="ivt-lg"><span><i class="to"></i>To do</span><span><i class="pr"></i>In progress</span><span><i class="lt"></i>Late</span><span><i class="dd"></i>Due only</span>`
|
|
151
|
+
+ `<span>${SVG(P.jira, 12, 2)}Jira, read only</span>${o.quick ? '<span class="h">Drag a bar to move it; drag an end to change start or due</span>' : ''}</div>`;
|
|
152
|
+
// it opens on today, moved left as far as the earliest open task's start, so a late bar is in view
|
|
153
|
+
const firstOpen = S.flatMap(flat).flatMap((x) => [dn(x.start), dn(x.end)]).filter((n) => n != null);
|
|
154
|
+
const first = firstOpen.length ? X(Math.min(...firstOpen)) : X(today);
|
|
155
|
+
return `<div class="ivt" data-ivt="${esc((v.id || v.key) + '|' + z[0])}" data-px="${px}" data-today="${X(today)}" data-first="${first}"><div class="ivt-sc"><div class="ivt-in" data-tlw="${W}">`
|
|
156
|
+
+ `<div class="ivt-grid" aria-hidden="true">${grid}</div>${axis}${h}<span class="ivt-today" data-tlx="${X(today) + Math.round(px / 2)}" aria-hidden="true"><i>Today</i></span></div></div></div>${legend}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The Timeline's geometry, set at run time as the layout's own custom properties (--tl-x, --tl-w; the stylesheet places them): every
|
|
160
|
+
* [data-tlx] / [data-tlw] under root. Called on each draw, before the paint. */
|
|
161
|
+
export function place(root) {
|
|
162
|
+
if (!root || !root.querySelectorAll) return;
|
|
163
|
+
for (const e of root.querySelectorAll('[data-tlx], [data-tlw]')) {
|
|
164
|
+
if (e.__tl) continue; // placed once: a drag moves it from there
|
|
165
|
+
e.__tl = true;
|
|
166
|
+
if (e.dataset.tlx != null) e.style.setProperty('--tl-x', e.dataset.tlx + 'px');
|
|
167
|
+
if (e.dataset.tlw != null) e.style.setProperty('--tl-w', e.dataset.tlw + 'px');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ── Kanban ── */
|
|
172
|
+
const colOf = (status) => (status === 'Done' ? 'Done' : status === "Won't do" ? "Won't do" : /progress|review/i.test(status || '') ? 'In progress' : 'To do');
|
|
173
|
+
export function kanbanHtml(v, o, isOpen) {
|
|
174
|
+
const S = v.tasks.sections, k = stageKeyOf(v);
|
|
175
|
+
const secs = k === 'all' ? S : S.filter((s) => (s.key || '-') === k);
|
|
176
|
+
const rs = secs.flatMap((s) => flat(s).concat(flatDone(s))), jr = secs.flatMap(jiraOf);
|
|
177
|
+
const by = { 'To do': [], 'In progress': [], Done: [], "Won't do": [] };
|
|
178
|
+
for (const x of rs) by[colOf(x.status)].push({ x });
|
|
179
|
+
for (const t of jr) by[colOf(t.status)].push({ t });
|
|
180
|
+
const card = (c) => {
|
|
181
|
+
if (c.t) {
|
|
182
|
+
const t = c.t, d = dn(t.due);
|
|
183
|
+
return `<div class="ivk-d jr">${jmark(t)}<div class="w">${ttitle(t)}<div class="ivk-m">${d != null ? `<span>${esc(md(d))}</span>` : ''}${t.av ? `<span class="ivt-av" aria-hidden="true">${esc(t.av)}</span>` : ''}</div></div></div>`;
|
|
184
|
+
}
|
|
185
|
+
const x = c.x;
|
|
186
|
+
return `<div class="ivk-d${x.closed ? ' x' : ''}${x.wont ? ' wo' : ''}"${o.quick && x.uid ? ` draggable="true" data-ivk-card="${esc(x.uid)}" data-st="${esc(x.status)}"` : ''}>${box(x, o)}<div class="w">${title(x, o)}`
|
|
187
|
+
+ `<div class="ivk-m">${dateBtn(x, o)}${x.av ? `<span class="ivt-av" aria-hidden="true">${esc(x.av)}</span>` : ''}</div></div></div>`;
|
|
188
|
+
};
|
|
189
|
+
const wop = isOpen('kb:wont', false), nW = by["Won't do"].length;
|
|
190
|
+
const col = ([st, lbl]) => `<section class="ivk-c" data-ivk-col="${esc(st)}" aria-label="${esc(lbl + ', ' + by[st].length)}"><h4>${esc(lbl)}${by[st].length ? `<span class="n">${by[st].length}</span>` : ''}</h4>${by[st].map(card).join('')}</section>`;
|
|
191
|
+
const wont = wop ? `<section class="ivk-c" data-ivk-col="Won't do" aria-label="${esc("Won't do, " + nW)}"><button type="button" class="ivk-wh" data-iv-fold="kb:wont" aria-expanded="true" aria-label="Fold Won't do">Won't do${nW ? `<span class="n">${nW}</span>` : ''}</button>${by["Won't do"].map(card).join('')}</section>`
|
|
192
|
+
: `<button type="button" class="ivk-w" data-iv-fold="kb:wont" data-ivk-col="Won't do" aria-expanded="false" aria-label="${esc("Show Won't do" + (nW ? ', ' + nW : ''))}"><span>Won't do${nW ? ' · ' + nW : ''}</span></button>`;
|
|
193
|
+
const tabs = `<div class="ivk-tabs" role="tablist">${COLS.map(([st, lbl], i) => `<button type="button" role="tab" data-ivk-tab="${i}" aria-selected="${i === 0}">${esc(lbl)}${by[st].length ? ` <span class="n">${by[st].length}</span>` : ''}</button>`).join('')}</div>`;
|
|
194
|
+
return `${tabs}<div class="ivk${wop ? ' w4' : ''}">${COLS.map(col).join('')}${wont}</div>`
|
|
195
|
+
+ (o.quick ? '<p class="iv-q ivk-h">Drag a card to change its status. A Jira card does not drag: Jira owns its status.</p>' : '');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* ── the popovers: the task card's own status segment and date picker, opened right under the press ── */
|
|
199
|
+
let POP = null;
|
|
200
|
+
function closePop() { if (!POP) return; const { el, anchor } = POP; POP = null; el.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
|
|
201
|
+
function openPop(anchor, html, onPress) {
|
|
202
|
+
closePop(); cardStyle();
|
|
203
|
+
const el = document.createElement('div');
|
|
204
|
+
el.className = 'tkc ivq'; el.dataset.escLayer = ''; el.innerHTML = html; document.body.appendChild(el); // data-esc-layer: Escape closes this first, not the Viewer
|
|
205
|
+
const r = anchor.getBoundingClientRect(), w = el.offsetWidth, h = el.offsetHeight;
|
|
206
|
+
const left = Math.max(8, Math.min(r.left, innerWidth - w - 8)), below = r.bottom + 6 + h <= innerHeight - 8;
|
|
207
|
+
el.style.setProperty('--tl-x', left + 'px'); el.style.setProperty('--tl-y', (below ? r.bottom + 6 : Math.max(8, r.top - 6 - h)) + 'px');
|
|
208
|
+
anchor.setAttribute('aria-expanded', 'true');
|
|
209
|
+
POP = { el, anchor, onPress };
|
|
210
|
+
const f = el.querySelector('[aria-checked="true"], button'); if (f) f.focus({ preventScroll: true });
|
|
211
|
+
return el;
|
|
212
|
+
}
|
|
213
|
+
if (typeof document !== 'undefined' && document.head) {
|
|
214
|
+
cardStyle(); // the task card's look, before the first press, so a picker opens at its own size
|
|
215
|
+
document.addEventListener('pointerdown', (e) => { if (POP && !POP.el.contains(e.target) && e.target !== POP.anchor) closePop(); }, true);
|
|
216
|
+
// a press inside the open picker (one listener on the document: the picker's own buttons are real buttons)
|
|
217
|
+
document.addEventListener('click', (e) => { if (!POP) return; const b = e.target.closest && e.target.closest('button'); if (b && POP.el.contains(b)) POP.onPress(b, e); });
|
|
218
|
+
// the drags and the long press, read on the document for every Tasks section (each section's body holds its handlers in __iv)
|
|
219
|
+
document.addEventListener('pointerdown', (e) => downOn(e));
|
|
220
|
+
document.addEventListener('pointerup', () => dragEnd());
|
|
221
|
+
document.addEventListener('pointercancel', () => { dragEnd(); longOff(); });
|
|
222
|
+
document.addEventListener('pointermove', (e) => dragMove(e));
|
|
223
|
+
document.addEventListener('keydown', (e) => { if (POP && e.key === 'Escape') { e.stopPropagation(); const a = POP.anchor; closePop(); if (a && a.isConnected) a.focus(); } }, true);
|
|
224
|
+
addEventListener('resize', () => closePop());
|
|
225
|
+
document.addEventListener('scroll', (e) => { if (POP && !POP.el.contains(e.target)) closePop(); }, true);
|
|
226
|
+
}
|
|
227
|
+
/** The five icons (To do, In progress, Done, Won't do | Archive), only the current one named: the task card's segment. */
|
|
228
|
+
export function statusPopHtml(status) {
|
|
229
|
+
const b = (s) => { const k = stateKey(s), on = s === status;
|
|
230
|
+
return `<button type="button" class="i-${k}${on ? ' on' : ''}" role="radio" aria-checked="${on}" data-ivq-state="${esc(s)}"${on ? '' : ` aria-label="${esc(s === 'Archived' ? 'Archive' : s)}"`} title="${esc(s === 'Archived' ? 'Archive' : s)}">${stateIcon(s)}${on ? esc(s) : ''}</button>`; };
|
|
231
|
+
return `<div class="tkc-pop ivq-st" role="dialog" aria-label="Status"><div class="seg" role="radiogroup" aria-label="Status">${STATES.slice(0, 4).map(b).join('')}<span class="vr" aria-hidden="true"></span>${b('Archived')}</div></div>`;
|
|
232
|
+
}
|
|
233
|
+
function statusPop(anchor, uid, status, H) {
|
|
234
|
+
openPop(anchor, statusPopHtml(status), (b) => { const s = b.dataset.ivqState; if (!s) return; closePop(); if (s !== status && H.status) H.status(uid, s); });
|
|
235
|
+
}
|
|
236
|
+
function datePop(anchor, uid, H) {
|
|
237
|
+
const t = { start: anchor.dataset.s || '', due: anchor.dataset.e || '' }, st = { field: 'due', month: '' };
|
|
238
|
+
const draw = () => { if (!POP || POP.anchor !== anchor) return; POP.el.innerHTML = datePickerHtml(t, st); };
|
|
239
|
+
openPop(anchor, datePickerHtml(t, st), (b) => {
|
|
240
|
+
const d = b.dataset;
|
|
241
|
+
if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
|
|
242
|
+
if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
|
|
243
|
+
if (d.tkcDay == null) return;
|
|
244
|
+
const iso = d.tkcDay, f = st.field, p = { [f]: iso };
|
|
245
|
+
if (iso && f === 'due' && t.start && iso < t.start) p.start = iso; // a due day before the start moves the start with it
|
|
246
|
+
if (iso && f === 'start' && t.due && iso > t.due) p.due = iso;
|
|
247
|
+
Object.assign(t, p);
|
|
248
|
+
if (H.dates) H.dates(uid, p);
|
|
249
|
+
// after the start, the next tap is the due day; after the due day the picker closes
|
|
250
|
+
if (f === 'start' && iso) { st.field = 'due'; st.month = ''; draw(); } else closePop();
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function menuPop(anchor, label, items, go) {
|
|
254
|
+
const html = `<div class="tkc-pop ivq-m" role="menu" aria-label="${esc(label)}">${items.map((x, i) => `<button type="button" role="menuitemradio" class="o${x.on ? ' hl' : ''}" aria-checked="${!!x.on}" data-ivq-i="${i}"><span class="ck" aria-hidden="true">${x.on ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(x.label)}</span>${x.count ? `<span class="k">${esc(x.count)}</span>` : ''}</button>`).join('')}</div>`;
|
|
255
|
+
openPop(anchor, html, (b) => { const i = b.dataset.ivqI; if (i == null) return; closePop(); go(items[+i]); });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* ── the presses ── */
|
|
259
|
+
let LONG = 0; // a long press opened the status picker: the click that follows is not a Done
|
|
260
|
+
/** A press inside the Tasks section that this file owns. → true when handled. */
|
|
261
|
+
export function press(b, d, root, H, e) {
|
|
262
|
+
const id = root.dataset.iv;
|
|
263
|
+
if (d.ivView) { setViewMode(d.ivView); closePop(); if (H.redraw) H.redraw(); return true; }
|
|
264
|
+
if ('ivZoom' in d) { menuPop(b, 'Zoom', ZOOMS.map(([k, l]) => ({ k, label: l, on: k === zoomOf() })), (x) => { ZOOM = x.k; store.set('pmos.tasks.zoom', x.k); if (H.redraw) H.redraw(); }); return true; }
|
|
265
|
+
if ('ivKstage' in d) {
|
|
266
|
+
const v = H.__v; if (!v) return true;
|
|
267
|
+
const cur = stageKeyOf(v);
|
|
268
|
+
menuPop(b, 'Stage', stagesOf(v).map((x) => ({ ...x, on: x.key === cur })), (x) => { STAGE.set(id, x.key); if (H.redraw) H.redraw(); });
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
if (d.ivStat) { statusPop(b, d.ivStat, d.st || 'To do', H); return true; }
|
|
272
|
+
if (d.ivDate) { datePop(b, d.ivDate, H); return true; }
|
|
273
|
+
if (d.ivtBar) { if (DRAGGED) { DRAGGED = false; return true; } datePop(b, d.ivtBar, H); return true; }
|
|
274
|
+
if (d.ivkTab != null) { const c = root.querySelectorAll('.ivk > .ivk-c')[+d.ivkTab]; if (c) c.scrollIntoView({ block: 'nearest', inline: 'start', behavior: 'smooth' }); return true; }
|
|
275
|
+
if (d.ivCheck && LONG && Date.now() - LONG < 900) { LONG = 0; e.preventDefault(); return true; }
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* ── the drags, and the long press ── */
|
|
280
|
+
let DRAGGED = false;
|
|
281
|
+
const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
282
|
+
export function wireDrag(body) {
|
|
283
|
+
if (!body || body.__ivtDrag) return;
|
|
284
|
+
body.__ivtDrag = true;
|
|
285
|
+
body.addEventListener('contextmenu', (e) => { if (e.target.closest && e.target.closest('[data-iv-check]') && coarse()) e.preventDefault(); });
|
|
286
|
+
// Kanban: drag a card to another column to change its status
|
|
287
|
+
body.addEventListener('dragstart', (e) => { const c = e.target.closest && e.target.closest('[data-ivk-card]'); if (!c) return; e.dataTransfer.setData('text/plain', c.dataset.ivkCard); e.dataTransfer.effectAllowed = 'move'; c.classList.add('drag'); body.__ivkFrom = c.dataset.st; });
|
|
288
|
+
body.addEventListener('dragend', (e) => { const c = e.target.closest && e.target.closest('[data-ivk-card]'); if (c) c.classList.remove('drag'); body.querySelectorAll('.ivk-over').forEach((n) => n.classList.remove('ivk-over')); });
|
|
289
|
+
body.addEventListener('dragover', (e) => { const z = e.target.closest && e.target.closest('[data-ivk-col]'); if (!z || !body.__ivkFrom) return; e.preventDefault(); body.querySelectorAll('.ivk-over').forEach((n) => { if (n !== z) n.classList.remove('ivk-over'); }); z.classList.add('ivk-over'); });
|
|
290
|
+
body.addEventListener('drop', (e) => {
|
|
291
|
+
const z = e.target.closest && e.target.closest('[data-ivk-col]'); if (!z) return;
|
|
292
|
+
e.preventDefault(); z.classList.remove('ivk-over');
|
|
293
|
+
const uid = e.dataTransfer.getData('text/plain'), to = z.dataset.ivkCol, from = body.__ivkFrom; body.__ivkFrom = null;
|
|
294
|
+
const H = body.__iv || {};
|
|
295
|
+
if (uid && to && colOf(from) !== to && H.status) H.status(uid, to);
|
|
296
|
+
});
|
|
297
|
+
// the Timeline keeps the PM's place over a redraw, and first opens on today
|
|
298
|
+
const settle = () => {
|
|
299
|
+
place(body);
|
|
300
|
+
for (const T of body.querySelectorAll('.ivt[data-ivt]')) {
|
|
301
|
+
const sc = T.querySelector('.ivt-sc'); if (!sc || sc.__settled) continue;
|
|
302
|
+
sc.__settled = true;
|
|
303
|
+
const k = T.dataset.ivt, nw = T.querySelector('.ivt-n') ? T.querySelector('.ivt-n').offsetWidth : 0;
|
|
304
|
+
sc.scrollLeft = SCROLL.has(k) ? SCROLL.get(k) : Math.max(0, Math.min((+T.dataset.today || 0) - Math.max(0, sc.clientWidth - nw) * 0.25, (+T.dataset.first || 0) - 16));
|
|
305
|
+
sc.addEventListener('scroll', () => SCROLL.set(k, sc.scrollLeft), { passive: true });
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
if (typeof MutationObserver === 'function') new MutationObserver(settle).observe(body, { childList: true, subtree: true });
|
|
309
|
+
settle();
|
|
310
|
+
}
|
|
311
|
+
/* Timeline: drag a bar to move it, an end to change its start or due; it snaps to days, a tip says the new dates, Undo is in the toast.
|
|
312
|
+
* A phone: a long press on a task's box opens its status picker under it. Read on the document (see above); the Tasks section's body
|
|
313
|
+
* (the element wireView wired, holding the host's handlers in __iv) is found from the press. */
|
|
314
|
+
let G = null, LP = null;
|
|
315
|
+
const hostOf = (n) => { for (let e = n; e; e = e.parentElement) if (e.__iv) return e.__iv; return {}; };
|
|
316
|
+
const num = (e, k) => parseFloat(e.dataset[k]) || 0;
|
|
317
|
+
function downOn(e) {
|
|
318
|
+
const t = e.target; if (!t || !t.closest) return;
|
|
319
|
+
const bar = t.closest('[data-ivt-drag]');
|
|
320
|
+
if (bar && e.button === 0 && e.pointerType !== 'touch' && !coarse()) {
|
|
321
|
+
const T = bar.closest('.ivt'); if (!T || T.offsetWidth < 520) return; // the phone's layout does not drag
|
|
322
|
+
const grip = t.closest('[data-grip]'), a = dn(bar.dataset.s), b = dn(bar.dataset.e);
|
|
323
|
+
G = { bar, uid: bar.dataset.ivtBar, mode: bar.dataset.only === 'due' ? 'due' : grip ? grip.dataset.grip : 'move', x0: e.clientX, a, b: b == null ? a : b, px: +T.dataset.px || 14, left: num(bar, 'tlx'), width: num(bar, 'tlw'), n: 0, moved: false };
|
|
324
|
+
bar.setPointerCapture(e.pointerId);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const cb = t.closest('[data-iv-check]');
|
|
328
|
+
if (cb && (e.pointerType === 'touch' || coarse())) {
|
|
329
|
+
longOff();
|
|
330
|
+
LP = { x: e.clientX, y: e.clientY, t: setTimeout(() => { LP = null; const c = cb.parentElement && cb.parentElement.querySelector('[data-iv-stat]'); LONG = Date.now(); statusPop(cb, cb.dataset.ivCheck, (c && c.dataset.st) || 'To do', hostOf(cb)); }, 500) };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function longOff() { if (LP) { clearTimeout(LP.t); LP = null; } }
|
|
334
|
+
function dragMove(e) {
|
|
335
|
+
if (LP && Math.abs(e.clientX - LP.x) + Math.abs(e.clientY - LP.y) > 10) longOff();
|
|
336
|
+
const g = G; if (!g) return;
|
|
337
|
+
const dx = e.clientX - g.x0; if (!g.moved && Math.abs(dx) < 4) return;
|
|
338
|
+
g.moved = true; g.n = Math.round(dx / g.px);
|
|
339
|
+
const [a, b] = shifted(g);
|
|
340
|
+
if (g.mode === 'due') g.bar.style.setProperty('--tl-x', g.left + g.n * g.px + 'px');
|
|
341
|
+
else { g.bar.style.setProperty('--tl-x', g.left + (a - g.a) * g.px + 'px'); g.bar.style.setProperty('--tl-w', Math.max(10, g.width + ((b - a) - (g.b - g.a)) * g.px) + 'px'); }
|
|
342
|
+
let tip = g.bar.querySelector('.ivt-tip'); if (!tip) { tip = document.createElement('span'); tip.className = 'ivt-tip'; g.bar.appendChild(tip); }
|
|
343
|
+
tip.textContent = g.mode === 'due' ? md(b) : spanText(a, b);
|
|
344
|
+
g.bar.classList.add('drag');
|
|
345
|
+
}
|
|
346
|
+
function dragEnd() {
|
|
347
|
+
longOff();
|
|
348
|
+
const x = G; G = null;
|
|
349
|
+
if (!x || !x.moved) return;
|
|
350
|
+
DRAGGED = true; setTimeout(() => { DRAGGED = false; }, 400);
|
|
351
|
+
x.bar.classList.remove('drag'); const tip = x.bar.querySelector('.ivt-tip'); if (tip) tip.remove();
|
|
352
|
+
if (!x.n) return;
|
|
353
|
+
const [a, b] = shifted(x), H = hostOf(x.bar);
|
|
354
|
+
const p = x.mode === 'due' ? { due: isoN(b) } : x.mode === 'start' ? { start: isoN(a) } : x.mode === 'end' ? { due: isoN(b) } : { start: isoN(a), due: isoN(b) };
|
|
355
|
+
if (H.dates) H.dates(x.uid, p);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** The days a drag lands on: a move shifts both; an end moves only itself and never past the other end. */
|
|
359
|
+
function shifted(g) {
|
|
360
|
+
if (g.mode === 'move') return [g.a + g.n, g.b + g.n];
|
|
361
|
+
if (g.mode === 'start') return [Math.min(g.b, g.a + g.n), g.b];
|
|
362
|
+
return [g.a, Math.max(g.a == null ? g.b + g.n : g.a, g.b + g.n)];
|
|
363
|
+
}
|
|
@@ -109,14 +109,18 @@ function rowOf(k, today) {
|
|
|
109
109
|
const days = k.start && k.end ? span(k.start, k.end, today) : k.start ? 'from ' + dateY(k.start, today) : d ? dateY(k.end, today) : '';
|
|
110
110
|
const due = days ? days + (late ? ', ' + plural(between(d, today), 'day', 'days') + ' late' : '') : '';
|
|
111
111
|
const who = ownerName(k.owner);
|
|
112
|
-
|
|
112
|
+
// the List's meta draws the dates as their own press (batch 9 item 5b): days is the dates alone, lateText what follows them
|
|
113
|
+
return { uid: k.uid, title: k.title, status: k.status || 'To do', closed, done: k.status === 'Done', wont: k.status === "Won't do", prog: k.status === 'In progress', late, due,
|
|
114
|
+
days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item,
|
|
115
|
+
start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
|
|
113
116
|
sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid, order: k.order };
|
|
114
117
|
}
|
|
115
118
|
const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999') || (a.order != null && b.order != null ? a.order - b.order : 0);
|
|
116
|
-
/** A section's rows: open ones first by urgency; past 5 open, the 3 most urgent then the rest folded by the next WBS level; done fold last
|
|
117
|
-
|
|
119
|
+
/** A section's rows: open ones first by urgency; past 5 open, the 3 most urgent then the rest folded by the next WBS level; done fold last
|
|
120
|
+
* (Won't do joins it), then the archived ones, which only the List draws, folded after Done (batch 9 item 5b). */
|
|
121
|
+
function bodyOf(rows, archived = []) {
|
|
118
122
|
const open = rows.filter((x) => !x.closed).sort(urgent), done = rows.filter((x) => x.closed);
|
|
119
|
-
if (open.length <= 5) return { top: open, groups: [], done };
|
|
123
|
+
if (open.length <= 5) return { top: open, groups: [], done, archived };
|
|
120
124
|
const top = open.slice(0, 3), rest = open.slice(3), by = new Map();
|
|
121
125
|
for (const x of rest) { const k = x.wbs ? x.wbs.top : ''; if (!by.has(k)) by.set(k, []); by.get(k).push(x); }
|
|
122
126
|
const heads = new Map(rows.filter((x) => x.wbs && x.wbs.head).map((x) => [x.wbs.top, x.title.replace(/^\d+(?:\.0)?\s+/, '')]));
|
|
@@ -127,7 +131,7 @@ function bodyOf(rows) {
|
|
|
127
131
|
});
|
|
128
132
|
// one group only says nothing the count does not: then it is "N more open"
|
|
129
133
|
if (groups.length === 1) groups[0].label = plural(rest.length, 'more open', 'more open');
|
|
130
|
-
return { top, groups, done };
|
|
134
|
+
return { top, groups, done, archived };
|
|
131
135
|
}
|
|
132
136
|
const countOf = (open, late, done) => (late && late === open ? late + ' late' : late ? late + ' late · ' + open + ' open' : open ? open + ' open' : done ? done + ' done' : '');
|
|
133
137
|
|
|
@@ -137,6 +141,9 @@ export function iniView(r, ctx = {}) {
|
|
|
137
141
|
const { list, cur } = stagesOf(r, ctx.steps);
|
|
138
142
|
const T = (r.tasks || []).filter((k) => k.status !== 'Archived');
|
|
139
143
|
const rows = T.map((k) => ({ ...rowOf(k, today), sec: sectionOf(k, list) }));
|
|
144
|
+
// archived tasks count nowhere and show in no view but the List's Archived fold (batch 9 item 5b)
|
|
145
|
+
const arch = (r.tasks || []).filter((k) => k.status === 'Archived').map((k) => ({ ...rowOf(k, today), sec: sectionOf(k, list) }));
|
|
146
|
+
const archOf = (keys) => arch.filter((x) => keys.includes(x.sec));
|
|
140
147
|
const open = rows.filter((x) => !x.closed), late = open.filter((x) => x.late);
|
|
141
148
|
const jira = !ownWf(r) && (t.key === 'build' || t.key === 'deliver') && (t.tickets || []).length > 0;
|
|
142
149
|
|
|
@@ -187,7 +194,7 @@ export function iniView(r, ctx = {}) {
|
|
|
187
194
|
else { const p = planOf(rs); if (p) { sub = 'Plan ' + dateY(p, today); if (dayOf(p) < today && op.length) { sub += ', missed'; subWarn = true; } } }
|
|
188
195
|
const h = headOf(rs); if (h) sub = [sub, h].filter(Boolean).join(' · ');
|
|
189
196
|
return { kind: 'stage', key: s.key, n: i + 1, name: s.name, ms: s.ms, status: s.status, sub, subWarn, count: countOf(op.length, lt.length, dn), warn: lt.length > 0,
|
|
190
|
-
open: s.status === 'now' || lt.length > 0, ...bodyOf(rs), jira: null, why };
|
|
197
|
+
open: s.status === 'now' || lt.length > 0, ...bodyOf(rs, archOf([s.key])), jira: null, why };
|
|
191
198
|
};
|
|
192
199
|
const anyTasks = rows.length > 0 || jira;
|
|
193
200
|
// past: a done or skipped stage folds into one line unless it holds a late task
|
|
@@ -199,7 +206,7 @@ export function iniView(r, ctx = {}) {
|
|
|
199
206
|
const from = past.map((i) => ran[i].from).filter(Boolean).sort()[0] || '', to = past.map((i) => ran[i].to).filter(Boolean).sort().pop() || (cur >= 0 ? ran[cur].from : '') || '';
|
|
200
207
|
const sk = skips.map((i) => list[i].name + ' skipped' + (list[i].why ? ': ' + list[i].why.replace(/\.$/, '').replace(/^./, (c) => c.toLowerCase()) : '')).join(' · ');
|
|
201
208
|
sections.push({ kind: 'past', key: 'past', label: a === b ? list[a - 1].name : 'Stages ' + a + '–' + b, sub: [span(from, to, today), sk].filter(Boolean).join(' · '),
|
|
202
|
-
count: rs.length ? rs.filter((x) => x.closed).length + ' done' : '', open: false, ...bodyOf(rs), stages: past.map((i) => one(list[i], i)) });
|
|
209
|
+
count: rs.length ? rs.filter((x) => x.closed).length + ' done' : '', open: false, ...bodyOf(rs, archOf(past.map((i) => list[i].key))), stages: past.map((i) => one(list[i], i)) });
|
|
203
210
|
}
|
|
204
211
|
// now and any past stage with a late task, in workflow order; later stages with a late task stay open, the rest fold into Later
|
|
205
212
|
const later = [];
|
|
@@ -209,7 +216,7 @@ export function iniView(r, ctx = {}) {
|
|
|
209
216
|
const x = one(s, i);
|
|
210
217
|
if (jira) {
|
|
211
218
|
const opn = tk.filter((k) => k.status !== 'Done').sort((a, b) => (b.blocked ? 1 : 0) - (a.blocked ? 1 : 0));
|
|
212
|
-
x.jira = { open: opn.map((k) => ({ key: k.key, title: k.title, epic: k.epic || '', sub: [k.blocked ? 'Blocked' + (k.reason ? ' by ' + String(k.reason).replace(/^Waiting on /i, '') : '') : k.status || 'To do', k.assignee || ''].filter(Boolean).join(' · '), warn: !!k.blocked })),
|
|
219
|
+
x.jira = { open: opn.map((k) => ({ key: k.key, title: k.title, epic: k.epic || '', status: k.status || 'To do', due: k.due || k.sprintEnd || '', av: initials(k.assignee), sub: [k.blocked ? 'Blocked' + (k.reason ? ' by ' + String(k.reason).replace(/^Waiting on /i, '') : '') : k.status || 'To do', k.assignee || ''].filter(Boolean).join(' · '), warn: !!k.blocked })),
|
|
213
220
|
done: tk.length - opn.length, total: tk.length, at: ctx.jiraAt || '' };
|
|
214
221
|
x.count = countOf(opn.length + x.top.length + x.groups.reduce((n, g) => n + g.n, 0), x.top.filter((y) => y.late).length, 0);
|
|
215
222
|
x.sub = x.sub + (x.sub ? ' · ' : '') + 'Jira tickets, by epic';
|
|
@@ -224,12 +231,12 @@ export function iniView(r, ctx = {}) {
|
|
|
224
231
|
const rs = later.flatMap((i) => secOf(list[i], i)), op = rs.filter((x) => !x.closed);
|
|
225
232
|
const ds = rs.map((x) => x.end).filter(Boolean).sort();
|
|
226
233
|
sections.push({ kind: 'later', key: 'later', label: 'Later: ' + later.map((i) => list[i].name).join(', '), sub: ds.length ? 'Plan ' + span(ds[0], ds[ds.length - 1], today) : '',
|
|
227
|
-
count: op.length ? op.length + ' to do' : '', open: false, ...bodyOf(rs), stages: later.map((i) => one(list[i], i)) });
|
|
234
|
+
count: op.length ? op.length + ' to do' : '', open: false, ...bodyOf(rs, archOf(later.map((i) => list[i].key))), stages: later.map((i) => one(list[i], i)) });
|
|
228
235
|
}
|
|
229
236
|
const loose = rows.filter((x) => !x.sec);
|
|
230
237
|
if (loose.length) {
|
|
231
238
|
const op = loose.filter((x) => !x.closed), lt = op.filter((x) => x.late);
|
|
232
|
-
sections.push({ kind: 'none', key: '', label: 'Not in a stage', sub: '', count: countOf(op.length, lt.length, loose.length - op.length), warn: lt.length > 0, open: op.length > 0, ...bodyOf(loose) });
|
|
239
|
+
sections.push({ kind: 'none', key: '', label: 'Not in a stage', sub: '', count: countOf(op.length, lt.length, loose.length - op.length), warn: lt.length > 0, open: op.length > 0, ...bodyOf(loose, archOf([''])) });
|
|
233
240
|
}
|
|
234
241
|
const nOpen = open.length + (jira ? tk.filter((k) => k.status !== 'Done').length : 0), nDone = rows.length - open.length + (jira ? tk.filter((k) => k.status === 'Done').length : 0);
|
|
235
242
|
const tasks = { open: nOpen, done: nDone, late: late.length, count: [nOpen ? nOpen + ' open' : '', nDone ? nDone + ' done' : ''].filter(Boolean).join(' · '), sections,
|
|
@@ -256,7 +263,8 @@ export function iniView(r, ctx = {}) {
|
|
|
256
263
|
summary.owner = r.owner ? { name: r.owner, av: initials(r.owner) } : null;
|
|
257
264
|
summary.wf = r.wf || { id: PF_ID, name: 'Product feature', icon: 'feature' };
|
|
258
265
|
summary.program = ctx.program || null;
|
|
259
|
-
|
|
266
|
+
const today2 = (n) => String(n).padStart(2, '0');
|
|
267
|
+
return { id: r.id || null, key: r.key, title: r.title, today: today.getFullYear() + '-' + today2(today.getMonth() + 1) + '-' + today2(today.getDate()), summary, stage, tasks, docs: ctx.docs != null ? ctx.docs : null, linked: linkedOf(r) };
|
|
260
268
|
}
|
|
261
269
|
/** What it links to, from its trail: the PRD (with its version), the rubric, the evaluation, the release notes, what it waits on, its epic. */
|
|
262
270
|
export function linkedOf(r) {
|