create-pmos 0.422.0 → 0.424.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +25 -25
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/board-programs-test.js +28 -0
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +12 -10
- package/workspace/briefing-premium-initiative-test.js +30 -38
- package/workspace/briefing-premium-products-test.js +16 -3
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/claude-proposes.md +37 -0
- package/workspace/guide/home.md +9 -2
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/programs.md +1 -0
- package/workspace/guide/workflows.md +5 -1
- package/workspace/home-pill-test.js +138 -0
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/board-premium.js +3 -2
- package/workspace/lib/custom-docs.js +65 -3
- package/workspace/lib/engine/boards.js +25 -2
- package/workspace/lib/headless.js +14 -1
- package/workspace/lib/initiative-writer.js +63 -1
- package/workspace/lib/plan-items.js +36 -5
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/programs.js +11 -3
- package/workspace/lib/proposal-runs.js +148 -0
- package/workspace/lib/proposals.js +370 -0
- package/workspace/lib/propose-cli.js +96 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-board-premium.js +33 -0
- package/workspace/lib/routes-boards.js +50 -10
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-proposals.js +325 -0
- package/workspace/lib/routes-task-links.js +336 -0
- package/workspace/lib/split-merge-suggest.js +162 -0
- package/workspace/lib/split-merge.js +379 -0
- package/workspace/lib/task-cli.js +58 -5
- package/workspace/lib/task-items.js +14 -2
- package/workspace/lib/task-links.js +422 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +4 -4
- package/workspace/premium-core-doc-issue-test.js +2 -2
- package/workspace/premium-vw-backlog-test.js +3 -3
- package/workspace/premium-vw-item-test.js +3 -3
- package/workspace/premium-vw-jira-test.js +6 -6
- package/workspace/product-lane-test.js +165 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-asks.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +16 -6
- package/workspace/public/pm/bd-prog.js +6 -1
- package/workspace/public/pm/bd-span.js +69 -15
- package/workspace/public/pm/bd-views.js +3 -2
- package/workspace/public/pm/cozy-board.css +10 -0
- package/workspace/public/pm/cozy-today.css +23 -0
- package/workspace/public/pm/cozy-viewer.js +14 -3
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/home-app.js +45 -14
- package/workspace/public/pm/home-ini-model.js +0 -34
- package/workspace/public/pm/home-ini.js +72 -204
- package/workspace/public/pm/home-task.js +2 -1
- package/workspace/public/pm/home-today.js +66 -16
- package/workspace/public/pm/ini-groups.js +253 -0
- package/workspace/public/pm/ini-links.js +519 -0
- package/workspace/public/pm/ini-props.js +218 -0
- package/workspace/public/pm/ini-tasks.js +58 -22
- package/workspace/public/pm/ini-versions.js +14 -9
- package/workspace/public/pm/ini-view-model.js +93 -4
- package/workspace/public/pm/ini-view.css +306 -18
- package/workspace/public/pm/ini-view.js +161 -36
- package/workspace/public/pm/premium-board.js +54 -6
- package/workspace/public/pm/premium-vw-item.js +2 -1
- package/workspace/public/pm/split-merge.css +77 -0
- package/workspace/public/pm/split-merge.js +265 -0
- package/workspace/public/pm/stage-line.js +414 -0
- package/workspace/public/pm/task-card.css +13 -0
- package/workspace/public/pm/task-card.js +42 -5
- package/workspace/public/pm/wf-page.css +2 -0
- package/workspace/public/pm/wf-page.js +2 -0
- package/workspace/public/pm/wf-stage.js +2 -1
- package/workspace/server.js +52 -3
- package/workspace/skills/initiative-propose.skill +45 -0
- package/workspace/split-merge-ui-test.js +175 -0
- package/workspace/stage-card-test.js +13 -12
- package/workspace/task-card-test.js +3 -2
- package/workspace/task-delete-test.js +126 -0
- package/workspace/task-links-test.js +239 -0
- package/workspace/task-milestones-test.js +1 -1
- package/workspace/task-plans-test.js +6 -0
- package/workspace/task-views-test.js +1 -1
- package/workspace/test-lists/bd-ini-panel.json +8 -2
- package/workspace/test-lists/claude-proposes.json +5 -0
- package/workspace/test-lists/home-sessions-pill.json +6 -0
- package/workspace/test-lists/product-lane.json +6 -0
- package/workspace/test-lists/split-merge.json +15 -0
- package/workspace/test-lists/task-delete.json +5 -0
- package/workspace/test-lists/task-links.json +6 -0
- package/workspace/tk-tasks-test.js +186 -57
- package/workspace/workflows-setup-test.js +4 -3
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/* pm/stage-line.js — the stage card's one line (feedback batch 11 item 21, agreed A; canvas In development: ScxAGrill, ScxA1Desk,
|
|
2
|
+
* ScxA2Phone, ScxA3States, ScxA4Board and the sctRules sticky). It replaced the equal stage bars and the dates line of the stage card in the
|
|
3
|
+
* ONE initiative view (pm/ini-view.js), so the Board's panel, Home's initiative page and the phone draw the same line. Pure: no DOM, no
|
|
4
|
+
* reads. pm/ini-view-model.js builds the model, pm/ini-view.js draws it and wires its presses; stage-line.test.js checks both halves.
|
|
5
|
+
*
|
|
6
|
+
* lineOf(r, o) → the model. r: the initiative row as GET /api/board-premium sends it (start, end, holds, gaps, plan, draft, track.forecast,
|
|
7
|
+
* status); o: { list, cur } (ini-view-model.js stagesOf), ran (the dates each stage ran, from its board moves), rows (its
|
|
8
|
+
* task rows, each with its section), today (a Date at midnight), deps (the trail's), ready (every task of the stage is done)
|
|
9
|
+
* lineHtml(L, o) → the markup. o: { open: what is unfolded under the line ('' | 'list' | 'ms:<i>' | 'gap:<i>' | 'hold:<i>'), hold (the host
|
|
10
|
+
* can set a return date), ini (the host opens another initiative) }
|
|
11
|
+
*
|
|
12
|
+
* THE RULES (sctRules, the Board's own rules from bd-span.js and lib/hold-spans.js):
|
|
13
|
+
* 1 one line, the height and colours of the Board row line (10 px). Each stage is a part of it on its own dates, with a 2 px notch between
|
|
14
|
+
* parts: done parts grey, the current part blue, later parts light. No numbers. Hover names the stage and its dates; a click goes to that
|
|
15
|
+
* stage in Tasks.
|
|
16
|
+
* 2 the dates of a stage: a done stage ran from its move into it to its move out (the board moves), else the days of its tasks; the current
|
|
17
|
+
* stage from its move into it to its latest task due date; a later stage the days of its tasks. With none on record the part is dashed
|
|
18
|
+
* and shares the room between its neighbours evenly. A date is never invented.
|
|
19
|
+
* 3 the milestone tasks are ◇ on the line, the Board's shapes: done filled, late orange, the end ◇ bigger. Its name above (cut at 24
|
|
20
|
+
* characters, the whole name on hover), its date below. A name that would run into the next one aligns its right edge to its own ◇.
|
|
21
|
+
* Milestones closer than about 4% of the line merge into one counted ◇ (mergeClose); a click lists them. A click on a ◇ opens that task.
|
|
22
|
+
* 4 the start date at the left; the end date and "N days left" at the right; the Today tick dark, as on the Board.
|
|
23
|
+
* 5 the phone names only the next open milestone and shows the start and end dates only; a tap on the line lists the stages and milestones in
|
|
24
|
+
* date order, the earlier done stages folded into one line.
|
|
25
|
+
* States (ScxA3States, ScxA4Board): every task done and the next stage waits → the → turns blue (ini-view.js); no dates at all → even dashed
|
|
26
|
+
* parts and the calendar; a skipped stage between two dated ones → »; on hold → a dotted gap, ⏸ where the work stopped and "back Dec 1"
|
|
27
|
+
* where it starts, the chip replaces the clock; no return date → dotted to Today, the rest faded, the calendar sets it; the return date
|
|
28
|
+
* passed → the gap orange; back after the end → the end ◇ orange and "Nov 4 · back Nov 10" (no date moves); no activity for 2 weeks or more
|
|
29
|
+
* → a hairline, a click says "No activity" or "Nothing planned" with + for a task on those dates; past the end → hatched to Today, "N days
|
|
30
|
+
* over"; a later Jira forecast → dashed to it; a saved plan → a thin dark line under the line where it differs and the slip; a draft only →
|
|
31
|
+
* everything dashed and a chip with its name; waits on another initiative → "after <initiative>" at the start; done → all grey, the end ◇
|
|
32
|
+
* filled, no clock and no →. */
|
|
33
|
+
import { mergeClose } from './program-model.js';
|
|
34
|
+
|
|
35
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
36
|
+
const DAY = 864e5;
|
|
37
|
+
const day = (v) => { if (v instanceof Date) return new Date(v.getFullYear(), v.getMonth(), v.getDate()); const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
38
|
+
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
39
|
+
const days = (a, b) => Math.round((b - a) / DAY);
|
|
40
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
41
|
+
const iso = (d) => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
|
|
42
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
43
|
+
const SVG = (d, w = 14, sw = 2) => `<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>`;
|
|
44
|
+
const I = { pause: 'M9 6v12M15 6v12', skip: 'M6 7l5 5-5 5M13 7l5 5-5 5', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1', plus: 'M12 5v14M5 12h14', down: 'M7 10l5 5 5-5' };
|
|
45
|
+
export const NAME_MAX = 24;
|
|
46
|
+
const MIN_PART = 3; // % of the line an undated part keeps, so it is never a hairline
|
|
47
|
+
const MIN_DATED = 1.5; // % a dated part of a day or two keeps, so it can be seen and pressed
|
|
48
|
+
const NEAR = 4;
|
|
49
|
+
const LINE_PX = 900; // a desktop line's usual width, for a first guess at the room a label takes (fitLine measures the real one) // % of the line within which milestones merge into one counted ◇
|
|
50
|
+
/** "Oct 9"; "Feb 3, 2027" when it is not this year. */
|
|
51
|
+
export const md = (d, today) => (d ? MON[d.getMonth()] + ' ' + d.getDate() + (today && d.getFullYear() !== today.getFullYear() ? ', ' + d.getFullYear() : '') : '');
|
|
52
|
+
const range = (a, b, t) => (a && b ? (+a === +b ? md(a, t) : md(a, t) + ' to ' + md(b, t)) : a ? 'from ' + md(a, t) : b ? 'to ' + md(b, t) : '');
|
|
53
|
+
export const cut = (s, n = NAME_MAX) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
54
|
+
|
|
55
|
+
/** The dates a stage's tasks cover: [first start, last due] (a task with one date counts that day). */
|
|
56
|
+
function taskSpan(rs) {
|
|
57
|
+
let a = null, b = null;
|
|
58
|
+
for (const x of rs) {
|
|
59
|
+
const s = day(x.start) || day(x.end), e = day(x.end) || day(x.start);
|
|
60
|
+
if (s && (!a || s < a)) a = s;
|
|
61
|
+
if (e && (!b || e > b)) b = e;
|
|
62
|
+
}
|
|
63
|
+
return [a, b];
|
|
64
|
+
}
|
|
65
|
+
/** A hold's words (bd-span.js holdWords): "On hold, Oct 12 to Dec 1, waits on the vendor". */
|
|
66
|
+
function holdWords(x, t) {
|
|
67
|
+
const h = x.h, why = h.reason ? ', ' + String(h.reason).replace(/\.$/, '').replace(/^./, (c) => c.toLowerCase()) : '';
|
|
68
|
+
const span = md(day(h.from), t) + (day(h.to || h.back) ? ' to ' + md(day(h.to || h.back), t) : '');
|
|
69
|
+
if (x.kind === 'past') return 'Was on hold, ' + span + why;
|
|
70
|
+
if (x.kind === 'none') return 'On hold since ' + md(day(h.from), t) + ', no return date' + why;
|
|
71
|
+
if (x.kind === 'over') { const n = days(day(h.back), t); return 'On hold, ' + span + why + '. The return date passed ' + plural(n, 'day', 'days') + ' ago'; }
|
|
72
|
+
return 'On hold, ' + span + why;
|
|
73
|
+
}
|
|
74
|
+
/** A gap's words (bd-span.js gapWords): "No activity, Jun 12 to Jul 9 · 4 wk" before today, "Nothing planned, …" after it. */
|
|
75
|
+
function gapWords(a, b, t) {
|
|
76
|
+
const p = addDays(a, 1), q = addDays(b, -1), len = (u, v) => { const n = days(u, v) + 1; return n < 7 ? plural(n, 'day', 'days') : Math.round(n / 7) + ' wk'; };
|
|
77
|
+
const say = (w, u, v) => w + ', ' + md(u, t) + ' to ' + md(v, t) + ' · ' + len(u, v);
|
|
78
|
+
if (q < t) return [say('No activity', p, q)];
|
|
79
|
+
if (p >= t) return [say('Nothing planned', p, q)];
|
|
80
|
+
return [say('No activity', p, addDays(t, -1)), say('Nothing planned', t, q)];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The » of a skipped stage between two parts (bd-span.js skipsOf): on the joint; one at either end of the line is not drawn. B: the parts' left edges in %. */
|
|
84
|
+
function skipsOf(parts, P, B) {
|
|
85
|
+
const skips = [];
|
|
86
|
+
for (let i = 0; i < parts.length; i++) {
|
|
87
|
+
if (parts[i].cls !== 'skip') continue;
|
|
88
|
+
const before = parts.slice(0, i).filter((p) => p.cls !== 'skip'), after = parts.slice(i + 1).filter((p) => p.cls !== 'skip');
|
|
89
|
+
if (!before.length || !after.length) continue;
|
|
90
|
+
const k = P.indexOf(after[0]), x = B[k];
|
|
91
|
+
const words = parts[i].name + ' skipped' + (parts[i].why ? ': ' + parts[i].why.replace(/\.$/, '').replace(/^./, (c) => c.toLowerCase()) : '');
|
|
92
|
+
const same = skips.find((s) => Math.abs(s.x - x) < 0.01);
|
|
93
|
+
if (same) same.words += '. ' + words; else skips.push({ x, words });
|
|
94
|
+
}
|
|
95
|
+
return skips;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The model of the line. See the head of this file. */
|
|
99
|
+
export function lineOf(r, o = {}) {
|
|
100
|
+
const t = day(o.today) || day(new Date()), list = o.list || [], ran = o.ran || [], rows = o.rows || [];
|
|
101
|
+
const finished = r.status === 'done', ended = finished || !!r.ended || r.status === 'cancelled';
|
|
102
|
+
const s0 = day(r.start), e0 = day(r.end), fc0 = r.track && day(r.track.forecast);
|
|
103
|
+
const draft = !s0 && !e0 && r.draft && day(r.draft.start) ? { name: r.draft.name || 'Draft', a: day(r.draft.start), b: day(r.draft.end) || day(r.draft.start) } : null;
|
|
104
|
+
const S = draft ? draft.a : s0, E = draft ? draft.b : e0;
|
|
105
|
+
|
|
106
|
+
// 1 each stage's dates, from the record only (rule 2)
|
|
107
|
+
const parts = list.map((s, i) => {
|
|
108
|
+
const [ta, tb] = taskSpan(rows.filter((x) => x.sec === s.key && !x.wont));
|
|
109
|
+
const rn = ran[i] || {};
|
|
110
|
+
let a = null, b = null;
|
|
111
|
+
if (s.status === 'done') { a = day(rn.from) || ta; b = day(rn.to) || tb; }
|
|
112
|
+
else if (s.status === 'now') { a = day(rn.from) || ta; b = tb && (!a || tb >= a) ? tb : null; }
|
|
113
|
+
else if (s.status !== 'skip') { a = ta; b = tb; }
|
|
114
|
+
if (a && b && b < a) b = a;
|
|
115
|
+
return { key: s.key, name: s.name, ms: !!s.ms, cls: finished ? 'done' : s.status, why: s.why || '', a, b, dated: !!(a || b) };
|
|
116
|
+
});
|
|
117
|
+
const P = parts.filter((p) => p.cls !== 'skip');
|
|
118
|
+
|
|
119
|
+
// 2 the milestone tasks (batch 11 item 3): flagged ◇, with a due date, not Won't do
|
|
120
|
+
const MS = rows.filter((x) => x.ms && day(x.end) && !x.wont).map((x) => ({ id: x.uid, name: x.title, date: String(x.end).slice(0, 10), d: day(x.end), done: !!x.done, late: !x.done && day(x.end) < t, sec: x.sec, ago: !x.done && day(x.end) < t ? days(day(x.end), t) : 0 }))
|
|
121
|
+
.sort((p, q) => p.d - q.d);
|
|
122
|
+
|
|
123
|
+
// 3 the holds (lib/hold-spans.js): past, open (the return date ahead), over (it passed), none (no return date)
|
|
124
|
+
const H = [];
|
|
125
|
+
(Array.isArray(r.holds) ? r.holds : []).forEach((h, i) => {
|
|
126
|
+
const a = day(h.from); if (!a) return;
|
|
127
|
+
const to = day(h.to), back = day(h.back);
|
|
128
|
+
const kind = to ? 'past' : !back ? 'none' : back < t ? 'over' : 'open';
|
|
129
|
+
const b = to || (kind === 'open' ? back : t);
|
|
130
|
+
if (b <= a || (S && b <= S) || (E && a >= E && kind === 'past')) return;
|
|
131
|
+
H.push({ a: S && a < S ? S : a, b, kind, h, i });
|
|
132
|
+
});
|
|
133
|
+
const openHold = H.find((x) => x.kind !== 'past') || null;
|
|
134
|
+
|
|
135
|
+
// 4 the stretch of the line: every date on record, and today while the work runs past its end or is held with no return date
|
|
136
|
+
const over = !!(E && !draft && E < t && !ended);
|
|
137
|
+
const fc = fc0 && E && fc0 > E && !ended ? fc0 : null;
|
|
138
|
+
const plan = r.plan && day(r.plan.start) && day(r.plan.end) && !(r.plan.start === r.start && r.plan.end === r.end) ? { a: day(r.plan.start), b: day(r.plan.end), name: r.plan.name || 'Plan' } : null;
|
|
139
|
+
const ds = [S, E, fc, over ? t : null].concat(parts.flatMap((p) => [p.a, p.b]), MS.map((m) => m.d), H.flatMap((x) => [x.a, x.b]), plan ? [plan.a, plan.b] : []).filter(Boolean);
|
|
140
|
+
const dep = ((o.deps || []).find((d) => d && d.known && !d.done)) || null;
|
|
141
|
+
const base = { finished, ended, draft: draft ? { name: draft.name } : null, dep: dep ? { id: dep.id, title: dep.title || dep.id } : null, today: null };
|
|
142
|
+
|
|
143
|
+
// the clock's place: a hold says when it comes back (the clock stops), done says when it ended, a draft names itself
|
|
144
|
+
let chip = null;
|
|
145
|
+
if (finished) chip = { text: E ? 'Done ' + md(E, t) : 'Done', tone: 'q' };
|
|
146
|
+
else if (openHold && openHold.kind === 'over') chip = { text: 'Back ' + md(day(openHold.h.back), t) + ' · ' + plural(days(day(openHold.h.back), t), 'day', 'days') + ' late', tone: 'late', pause: true };
|
|
147
|
+
else if (openHold && openHold.kind === 'open') chip = { text: 'Back ' + md(openHold.b, t), tone: 'q', pause: true };
|
|
148
|
+
else if (openHold) chip = { text: 'On hold', tone: 'q', pause: true };
|
|
149
|
+
else if (draft) chip = { text: draft.name, tone: 'draft' };
|
|
150
|
+
|
|
151
|
+
// 5 no date on record at all (state 2): even parts, dashed but the done ones, the calendar sets the dates
|
|
152
|
+
if (!ds.length) {
|
|
153
|
+
const n = P.length || 1;
|
|
154
|
+
return { ...base, chip, empty: true, cal: ended ? null : 'dates',
|
|
155
|
+
parts: P.map((p, k) => ({ key: p.key, name: p.name, cls: p.cls, l: (k * 100) / n, w: 100 / n, dash: p.cls !== 'done', fade: false, tip: (p.ms ? '◆ ' : '') + p.name + ' · no dates yet' + (p.cls === 'done' ? ' · done' : p.cls === 'now' ? ' · now' : '') })),
|
|
156
|
+
pieces: [], marks: [], ms: [], gaps: [], holds: [], skips: skipsOf(parts, P, P.map((_, k) => (k * 100) / n)), labels: null, sheet: sheetOf(parts, [], t, 0) };
|
|
157
|
+
}
|
|
158
|
+
let D0 = new Date(Math.min(...ds)), D1 = new Date(Math.max(...ds));
|
|
159
|
+
if (+D1 === +D0) D1 = addDays(D0, 1);
|
|
160
|
+
const X0 = (d) => Math.max(0, Math.min(100, ((d - D0) / (D1 - D0)) * 100));
|
|
161
|
+
|
|
162
|
+
// 6 the boundaries between the parts, in % of the line: a part starts on its own start, else where the one before it ended; the gaps
|
|
163
|
+
// between known boundaries are shared evenly by the undated parts in them
|
|
164
|
+
const n = P.length, bnd = new Array(n + 1).fill(null);
|
|
165
|
+
if (n) {
|
|
166
|
+
bnd[0] = P[0].a ? X0(P[0].a) : S ? X0(S) : null;
|
|
167
|
+
for (let k = 1; k < n; k++) bnd[k] = P[k].a ? X0(P[k].a) : P[k - 1].b ? X0(P[k - 1].b) : null;
|
|
168
|
+
bnd[n] = P[n - 1].b ? Math.max(X0(P[n - 1].b), E ? X0(E) : 0) : E ? X0(E) : null;
|
|
169
|
+
if (bnd[0] == null) bnd[0] = 0;
|
|
170
|
+
if (bnd[n] == null) bnd[n] = 100;
|
|
171
|
+
for (let k = 1; k < n; k++) {
|
|
172
|
+
if (bnd[k] != null) continue;
|
|
173
|
+
let j = k; while (bnd[j] == null) j++;
|
|
174
|
+
const lo = bnd[k - 1], hi = bnd[j];
|
|
175
|
+
for (let m = k; m < j; m++) bnd[m] = lo + ((hi - lo) * (m - k + 1)) / (j - k + 1);
|
|
176
|
+
}
|
|
177
|
+
for (let k = 1; k <= n; k++) if (bnd[k] < bnd[k - 1]) bnd[k] = bnd[k - 1];
|
|
178
|
+
}
|
|
179
|
+
// an undated part that got almost no room keeps MIN_PART of the line; the rest of the line shrinks to make room (one map for every mark)
|
|
180
|
+
const knots = [0].concat(n ? bnd : [], [100]);
|
|
181
|
+
const small = new Set();
|
|
182
|
+
for (let k = 0; k < n; k++) if (bnd[k + 1] - bnd[k] < (P[k].dated ? MIN_DATED : MIN_PART)) small.add(k + 1); // the segment between knots k+1 and k+2
|
|
183
|
+
const seg = knots.slice(1).map((x, j) => x - knots[j]);
|
|
184
|
+
const sw = [...small].reduce((m, j) => m + seg[j], 0), want = [...small].reduce((m, j) => m + (P[j - 1] && P[j - 1].dated ? MIN_DATED : MIN_PART), 0);
|
|
185
|
+
const f = small.size ? Math.max(0.2, (100 - want) / Math.max(1e-6, 100 - sw)) : 1;
|
|
186
|
+
const minOf = (j) => (P[j - 1] && P[j - 1].dated ? MIN_DATED : MIN_PART);
|
|
187
|
+
const nseg = seg.map((w, j) => (small.has(j) ? minOf(j) : w * f)), tot = nseg.reduce((m, w) => m + w, 0) || 1;
|
|
188
|
+
const nk = [0]; for (const w of nseg) nk.push(nk[nk.length - 1] + (w * 100) / tot);
|
|
189
|
+
// a date maps through the segment it falls in; one on a knot shared by parts of no width goes to the right end of the last of them (a
|
|
190
|
+
// milestone on a one-day stage sits at that stage's end, the end ◇ at the line's end)
|
|
191
|
+
const map = (x) => {
|
|
192
|
+
let j = -1;
|
|
193
|
+
for (let q = 0; q < knots.length - 1; q++) if (x >= knots[q] && x <= knots[q + 1]) j = q;
|
|
194
|
+
if (j < 0) return x <= 0 ? 0 : 100;
|
|
195
|
+
const span = knots[j + 1] - knots[j];
|
|
196
|
+
return span <= 0 ? nk[j + 1] : nk[j] + ((x - knots[j]) / span) * (nk[j + 1] - nk[j]);
|
|
197
|
+
};
|
|
198
|
+
const X = (d) => map(X0(d));
|
|
199
|
+
const B = n ? bnd.map((_, k) => nk[k + 1]) : [];
|
|
200
|
+
|
|
201
|
+
// 7 the cuts: a hold's dotted gap wins for its dates; a stretch of 2 weeks or more with no dated work is a hairline
|
|
202
|
+
const holds = H.filter((x) => x.kind !== 'past' || X(x.b) - X(x.a) >= 0.8).map((x) => ({ i: x.i, kind: x.kind, l: X(x.a), w: Math.max(0.6, X(x.b) - X(x.a)), words: holdWords(x, t),
|
|
203
|
+
back: x.kind === 'open' && (!E || x.b < E) ? md(x.b, t) : x.kind === 'over' ? md(day(x.h.back), t) : '' }));
|
|
204
|
+
const gaps = [];
|
|
205
|
+
if (S && E && !draft) {
|
|
206
|
+
for (const g of Array.isArray(r.gaps) ? r.gaps : []) {
|
|
207
|
+
let segs = [[day(g.from), day(g.to)]]; if (!segs[0][0] || !segs[0][1]) continue;
|
|
208
|
+
for (const x of H) segs = segs.flatMap(([a, b]) => (x.a < b && x.b > a ? [[a, x.a], [x.b, b]].filter(([p, q]) => q > p) : [[a, b]]));
|
|
209
|
+
for (const [a0, b0] of segs) {
|
|
210
|
+
const a = a0 < S ? S : a0, b = b0 > E ? E : b0;
|
|
211
|
+
if (b <= a || X(b) - X(a) < 0.8) continue;
|
|
212
|
+
gaps.push({ l: X(a), w: X(b) - X(a), from: iso(addDays(a, 1)), to: iso(addDays(b, -1)), ahead: addDays(b, -1) >= t, words: gapWords(a, b, t) });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const cuts = holds.map((x) => [x.l, x.l + x.w, x.kind]).concat(gaps.map((g) => [g.l, g.l + g.w, 'gap'])).sort((p, q) => p[0] - q[0]);
|
|
217
|
+
const fadeAt = (() => { const x = holds.find((y) => y.kind === 'none'); return x ? x.l + x.w : null; })();
|
|
218
|
+
// each part, less the cuts: its pieces carry the stage (a click goes to it in Tasks)
|
|
219
|
+
const pieces = [];
|
|
220
|
+
P.forEach((p, k) => {
|
|
221
|
+
let segs = [[B[k], B[k + 1]]];
|
|
222
|
+
for (const [a, b] of cuts) segs = segs.flatMap(([u, v]) => (a < v && b > u ? [[u, a], [b, v]].filter(([x, y]) => y - x > 0.05) : [[u, v]]));
|
|
223
|
+
const tip = (p.ms ? '◆ ' : '') + p.name + (p.dated ? ' · ' + range(p.a, p.b, t) : ' · no dates yet') + (p.cls === 'done' && !finished ? ' · done' : p.cls === 'now' ? ' · now' : '');
|
|
224
|
+
for (const [u, v] of segs) pieces.push({ key: p.key, name: p.name, cls: p.cls, l: u, w: v - u, dash: !p.dated || !!draft, fade: fadeAt != null && u >= fadeAt - 0.01, tip,
|
|
225
|
+
first: u <= B[k] + 0.01, last: v >= B[k + 1] - 0.01 });
|
|
226
|
+
});
|
|
227
|
+
const skips = skipsOf(parts, P, B);
|
|
228
|
+
|
|
229
|
+
// 8 the ◇s: the end ◇ is the committed end (a milestone task on that day, or the latest one in the workflow's last ◆ stage, IS it); the
|
|
230
|
+
// others merge when they are within NEAR % of each other
|
|
231
|
+
const lastMs = (list.filter((s) => s.ms).slice(-1)[0] || {}).key;
|
|
232
|
+
const inLast = lastMs ? MS.filter((m) => m.sec === lastMs) : [];
|
|
233
|
+
const endTask = E && !draft ? (MS.filter((m) => +m.d === +E).slice(-1)[0] || inLast.slice(-1)[0] || null) : null;
|
|
234
|
+
const clash = openHold && openHold.kind === 'open' && E && openHold.b > E ? md(openHold.b, t) : '';
|
|
235
|
+
const L = MS.filter((m) => !endTask || m.id !== endTask.id);
|
|
236
|
+
const reach = Math.max(1, Math.round(((D1 - D0) / DAY) * (NEAR / 100)));
|
|
237
|
+
const C = mergeClose(L.map((m) => ({ ...m })), reach).map((c) => ({ x: X(day(c.date)), n: c.n, items: c.items.map((m) => ({ id: m.id, name: m.name, date: md(m.d, t), done: m.done, late: m.late, ago: m.ago })),
|
|
238
|
+
name: c.n > 1 ? plural(c.n, 'milestone', 'milestones') : c.first.name, date: md(day(c.date), t), done: c.done, late: c.late, dash: !!draft }));
|
|
239
|
+
const ms = C.slice();
|
|
240
|
+
if (E && !draft) {
|
|
241
|
+
ms.push({ x: X(E), n: 1, end: true, items: endTask ? [{ id: endTask.id, name: endTask.name, date: md(E, t), done: endTask.done, late: endTask.late, ago: endTask.ago }] : [],
|
|
242
|
+
name: endTask ? endTask.name : '', date: md(E, t), done: finished || !!(endTask && endTask.done), late: !finished && (over || !!clash || !!(endTask && endTask.late)) });
|
|
243
|
+
} else if (draft && E) ms.push({ x: X(E), n: 1, end: true, items: [], name: '', date: md(E, t), done: false, late: false, dash: true });
|
|
244
|
+
ms.sort((p, q) => p.x - q.x);
|
|
245
|
+
// the names, right to left (rule 3): centred on the ◇; one that would run into the next name aligns its right edge to its own ◇; one
|
|
246
|
+
// that still does not fit keeps its ◇ and says its name on hover. Widths are a first guess here; fitLine checks them on the page.
|
|
247
|
+
const wOf = (txt) => (String(txt).length * 6.6 + 8) / LINE_PX * 100;
|
|
248
|
+
let limit = 103;
|
|
249
|
+
for (let i = ms.length - 1; i >= 0; i--) {
|
|
250
|
+
const m = ms[i]; m.short = cut(m.name); if (!m.short) continue;
|
|
251
|
+
const w = wOf(m.short), c = [m.x - w / 2, m.x + w / 2], rr = [m.x - w + 1.5, m.x + 1.5], ll = [m.x - 1.5, m.x - 1.5 + w];
|
|
252
|
+
if (c[0] >= 0 && c[1] <= limit) { m.align = 'c'; limit = c[0]; }
|
|
253
|
+
else if (rr[0] >= 0 && rr[1] <= limit) { m.align = 'r'; limit = rr[0]; }
|
|
254
|
+
else if (ll[1] <= limit && ll[0] >= 0) { m.align = 'l'; limit = ll[0]; }
|
|
255
|
+
else if (c[0] < 0 && ll[1] <= limit) { m.align = 'l'; limit = ll[0]; }
|
|
256
|
+
else { m.align = 'r'; m.hide = true; }
|
|
257
|
+
}
|
|
258
|
+
// the next open milestone: the only one a phone names
|
|
259
|
+
const nxt = ms.find((m) => !m.done && m.name); if (nxt) nxt.next = true;
|
|
260
|
+
|
|
261
|
+
// 9 the labels under the line: the start, the ◇ dates (a date that would run into a corner label is left to the ◇'s hover), the end
|
|
262
|
+
const start = S ? md(S, t) : B.length && P[0].a ? md(P[0].a, t) : '';
|
|
263
|
+
let end = null;
|
|
264
|
+
if (E) {
|
|
265
|
+
const words = [], late = [];
|
|
266
|
+
if (finished) {} // the chip says when it ended
|
|
267
|
+
else if (draft) {}
|
|
268
|
+
else if (clash) late.push('back ' + clash);
|
|
269
|
+
else if (over) late.push(plural(days(E, t), 'day', 'days') + ' over');
|
|
270
|
+
else if (fc) words.push('Jira forecast ' + md(fc, t));
|
|
271
|
+
else words.push(+E === +t ? 'ends today' : plural(days(t, E), 'day', 'days') + ' left');
|
|
272
|
+
const slip = r.plan && r.plan.slip ? (r.plan.slip > 0 ? '+' + r.plan.slip : '−' + -r.plan.slip) + 'd' : '';
|
|
273
|
+
end = { date: over && !clash ? '' : md(E, t), words: words.join(' · '), late: late.join(' · '), slip, slipLate: !!(r.plan && r.plan.slip > 0) };
|
|
274
|
+
}
|
|
275
|
+
// the ◇ dates under the line, right to left between the start and the end labels (fitLine checks them as drawn)
|
|
276
|
+
{
|
|
277
|
+
const endTxt = end ? [end.date, end.late, end.words, end.slip].filter(Boolean).join(' · ') : '';
|
|
278
|
+
let lim = 100 - (endTxt ? wOf(endTxt) * 0.6 : 0);
|
|
279
|
+
for (let i = ms.length - 1; i >= 0; i--) {
|
|
280
|
+
const m = ms[i]; if (m.end && !(over && !clash && !finished)) continue; // past its end: the end ◇ stands left of the corner, its date under it
|
|
281
|
+
const w = wOf(m.date) * 0.6;
|
|
282
|
+
if (m.x + w / 2 <= lim) { m.showDate = true; lim = m.x - w / 2; }
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const tx = !ended && t >= D0 && t <= D1 ? X(t) : null;
|
|
286
|
+
return { ...base, chip, empty: false, cal: openHold && openHold.kind === 'none' && !ended ? 'back' : null, holdAt: openHold ? openHold.i : null,
|
|
287
|
+
parts: P.map((p, k) => ({ key: p.key, name: p.name, cls: p.cls, l: B[k], w: B[k + 1] - B[k], dash: !p.dated })),
|
|
288
|
+
pieces, holds, gaps, skips, ms, today: tx,
|
|
289
|
+
over: over ? { l: X(E), w: Math.max(0.4, X(t) - X(E)) } : null,
|
|
290
|
+
fc: fc ? { l: X(E), w: X(fc) - X(E), words: 'Jira forecast ' + md(fc, t) } : null,
|
|
291
|
+
plan: plan ? { l: X(plan.a), w: Math.max(0.3, X(plan.b) - X(plan.a)), words: 'Plan · ' + plan.name + ' · ' + md(plan.a, t) + ' to ' + md(plan.b, t) } : null,
|
|
292
|
+
labels: { start, end }, sheet: sheetOf(parts, MS, t, finished ? 0 : parts.filter((p) => p.cls === 'done').length) };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** The phone's list (ScxA2Phone): the stages and the milestones in date order (a milestone after the stage it falls in), the earlier done
|
|
296
|
+
* stages folded into one line (all but the last done one). */
|
|
297
|
+
function sheetOf(parts, MS, t, nDone) {
|
|
298
|
+
const out = [];
|
|
299
|
+
const left = MS.slice();
|
|
300
|
+
for (const p of parts) {
|
|
301
|
+
if (p.cls === 'skip') { out.push({ kind: 'stage', key: p.key, name: p.name, when: 'skipped', cls: 'skip' }); continue; }
|
|
302
|
+
out.push({ kind: 'stage', key: p.key, name: p.name, when: p.dated ? range(p.a, p.b, t) : 'no dates yet', cls: p.cls });
|
|
303
|
+
const end = p.b || p.a;
|
|
304
|
+
for (let i = 0; i < left.length;) {
|
|
305
|
+
const m = left[i];
|
|
306
|
+
if (m.sec === p.key || (end && m.d <= end && !parts.some((q) => q.key === m.sec))) { out.push({ kind: 'ms', id: m.id, name: m.name, when: md(m.d, t) + (m.late ? ' · late' : ''), done: m.done, late: m.late }); left.splice(i, 1); } else i++;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for (const m of left) out.push({ kind: 'ms', id: m.id, name: m.name, when: md(m.d, t) + (m.late ? ' · late' : ''), done: m.done, late: m.late });
|
|
310
|
+
const fold = Math.max(0, nDone - 1);
|
|
311
|
+
return { items: out, fold };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* ── the markup ── */
|
|
315
|
+
const P = (x) => (+x).toFixed(2) + '%';
|
|
316
|
+
const pos = (l, w) => `left:${P(l)}` + (w != null ? `;width:${P(w)}` : '');
|
|
317
|
+
|
|
318
|
+
/** The line, its marks and its labels. See the head of this file. */
|
|
319
|
+
export function lineHtml(L, o = {}) {
|
|
320
|
+
if (!L) return '';
|
|
321
|
+
const open = o.open || '';
|
|
322
|
+
const dep = L.dep ? `<button type="button" class="iv-tl-dep" data-iv-ini="${esc(L.dep.id)}" title="${esc('Waits on ' + L.dep.title + '. Open it')}">${SVG(I.link, 12)}after ${esc(L.dep.title)}</button>` : '';
|
|
323
|
+
const pc = (x) => ['iv-tlp', x.cls, x.dash ? 'dash' : '', x.fade ? 'fd' : '', x.first === false ? 'xl' : '', x.last === false ? 'xr' : ''].filter(Boolean).join(' ');
|
|
324
|
+
// a 2 px notch between two parts: each part gives 1 px at a side it shares with another part (a cut keeps its own edge)
|
|
325
|
+
const ppos = (x) => { const a = x.first === false ? 0 : 1, b = x.last === false ? 0 : 1; return `left:calc(${P(x.l)} + ${a}px);width:max(2px, calc(${P(x.w)} - ${a + b}px))`; };
|
|
326
|
+
const parts = (L.empty ? L.parts : L.pieces).map((x) => `<button type="button" class="${pc(x)}" data-iv-stage="${esc(x.key)}" style="${ppos(x)}" title="${esc(x.tip)}" aria-label="${esc(x.tip + '. Show it in Tasks')}"></button>`).join('');
|
|
327
|
+
let marks = '';
|
|
328
|
+
for (const g of L.gaps || []) marks += `<button type="button" class="iv-tl-ng" data-iv-gap="${(L.gaps || []).indexOf(g)}" style="${pos(g.l, g.w)}" title="${esc(g.words.join('\n'))}" aria-label="${esc(g.words.join('. '))}" aria-expanded="${open === 'gap:' + L.gaps.indexOf(g)}"></button>`;
|
|
329
|
+
for (const s of L.skips || []) marks += `<span class="iv-tl-sk" style="${pos(s.x)}" role="img" aria-label="${esc(s.words)}" title="${esc(s.words)}">${SVG(I.skip, 10, 2.4)}</span>`;
|
|
330
|
+
for (const h of L.holds || []) {
|
|
331
|
+
marks += `<span class="iv-tl-ho${h.kind === 'over' ? ' late' : ''}" style="${pos(h.l, h.w)}" aria-hidden="true"></span>`;
|
|
332
|
+
marks += o.hold ? `<button type="button" class="iv-tl-pz${h.kind === 'over' ? ' late' : ''}" data-iv-hold="${h.i}" style="left:calc(${P(h.l)} + 11px)" title="${esc(h.words)}" aria-label="${esc(h.words + (h.kind === 'none' ? '. Set a return date' : '. Open the hold'))}">${SVG(I.pause, 11, 2.4)}</button>`
|
|
333
|
+
: `<span class="iv-tl-pz${h.kind === 'over' ? ' late' : ''}" style="left:calc(${P(h.l)} + 11px)" role="img" aria-label="${esc(h.words)}" title="${esc(h.words)}">${SVG(I.pause, 11, 2.4)}</span>`;
|
|
334
|
+
}
|
|
335
|
+
if (L.over) marks += `<span class="iv-tl-over" style="${pos(L.over.l, L.over.w)}" aria-hidden="true"></span>`;
|
|
336
|
+
if (L.fc) marks += `<span class="iv-tl-fc" style="${pos(L.fc.l, L.fc.w)}" title="${esc(L.fc.words)}" aria-hidden="true"></span>`;
|
|
337
|
+
if (L.plan) marks += `<span class="iv-tl-pl" style="${pos(L.plan.l, L.plan.w)}" role="img" aria-label="${esc(L.plan.words)}" title="${esc(L.plan.words)}"></span>`;
|
|
338
|
+
if (L.today != null) marks += `<i class="iv-tl-td" style="${pos(L.today)}" aria-hidden="true"></i>`;
|
|
339
|
+
// the ◇s, with the name above and the date below (a phone keeps the next open one's name only)
|
|
340
|
+
let names = '', dates = '';
|
|
341
|
+
(L.ms || []).forEach((m, i) => {
|
|
342
|
+
const cls = ['iv-tlm', m.end ? 'end' : '', m.done ? 'dn' : '', m.late ? 'late' : '', m.dash ? 'dash' : '', m.n > 1 ? 'n' : ''].filter(Boolean).join(' ');
|
|
343
|
+
const words = m.n > 1 ? m.items.map((x) => x.name + ' · ' + x.date + (x.late ? ' · late' : x.done ? ' · done' : '')).join('\n')
|
|
344
|
+
: (m.name ? m.name + ' · due ' + m.date : (L.finished ? 'Ended ' : 'Ends ') + m.date) + (m.late && m.items[0] && m.items[0].late ? ' · ' + lateBy(m.items[0]) : m.late ? ' · late' : m.done ? ' · done' : '');
|
|
345
|
+
const one = m.n === 1 && m.items[0];
|
|
346
|
+
marks += m.n > 1
|
|
347
|
+
? `<button type="button" class="${cls}" data-iv-msc="${i}" style="${pos(m.x)}" title="${esc(words)}" aria-label="${esc(m.n + ' milestones: ' + m.items.map((x) => x.name).join(', ') + '. List them')}" aria-expanded="${open === 'ms:' + i}"><b aria-hidden="true">${m.n}</b></button>`
|
|
348
|
+
: one ? `<button type="button" class="${cls}" data-iv-ms="${esc(one.id)}" style="${pos(m.x)}" title="${esc(words + ' · open in Tasks')}" aria-label="${esc('Milestone ' + words + '. Open it in Tasks')}"></button>`
|
|
349
|
+
: `<span class="${cls}" style="${pos(m.x)}" role="img" aria-label="${esc(words)}" title="${esc(words)}"></span>`;
|
|
350
|
+
if (m.name && (!m.hide || m.next)) names += `<span class="iv-tln ${m.align}${m.late ? ' late' : ''}${m.next ? ' nx' : ''}${m.hide ? ' oph' : ''}" style="${pos(m.x)}" title="${esc(m.name)}">${esc(m.short)}</span>`;
|
|
351
|
+
if (m.showDate) dates += `<span class="iv-tld${m.late ? ' late' : ''}" style="${pos(m.x)}">${esc(m.date)}</span>`;
|
|
352
|
+
});
|
|
353
|
+
// the holds' return dates: "back Dec 1" over the line where the work starts again
|
|
354
|
+
for (const h of L.holds || []) if (h.back && h.kind === 'open') names += `<span class="iv-tln c" style="${pos(h.l + h.w)}">back ${esc(h.back)}</span>`;
|
|
355
|
+
const lb = L.labels;
|
|
356
|
+
const endLab = lb && lb.end ? `<span class="iv-tle${lb.end.late && !lb.end.date ? ' late' : ''}">${lb.end.date ? `<b class="${L.ms.some((m) => m.end && m.late) ? 'late' : ''}">${esc(lb.end.date)}</b>` : ''}${lb.end.late ? `<span class="late">${lb.end.date ? ' · ' : ''}${esc(lb.end.late)}</span>` : ''}${lb.end.words ? ' · ' + esc(lb.end.words) : ''}${lb.end.slip ? ` <b class="iv-tl-slip${lb.end.slipLate ? ' late' : ''}">${esc(lb.end.slip)}</b>` : ''}</span>` : '';
|
|
357
|
+
const foot = lb ? `<div class="iv-tl-dt"><span class="iv-tls">${esc(lb.start)}</span>${dates}${endLab}</div>` : '';
|
|
358
|
+
const aria = L.empty ? 'No dates yet. Set them in Tasks' : 'Stages and milestones on a line. Tap for the list';
|
|
359
|
+
return `<div class="iv-tl${L.draft ? ' dr' : ''}${L.finished ? ' fin' : ''}${L.empty ? ' empty' : ''}${names ? '' : ' nonames'}${L.plan ? ' pl' : ''}">${dep}`
|
|
360
|
+
+ `<div class="iv-tl-nm" aria-hidden="true">${names}</div>`
|
|
361
|
+
+ `<div class="iv-tl-ln" role="group" aria-label="${esc(aria)}" data-iv-line>${parts}${marks}</div>`
|
|
362
|
+
+ foot + belowHtml(L, open) + '</div>';
|
|
363
|
+
}
|
|
364
|
+
const lateBy = (x) => (x.ago ? plural(x.ago, 'day', 'days') + ' late' : 'late');
|
|
365
|
+
/** What a press unfolds under the line: the counted ◇'s list, a gap's card, a hold's card, the phone's list. */
|
|
366
|
+
function belowHtml(L, open) {
|
|
367
|
+
if (!open) return '';
|
|
368
|
+
const msRow = (x) => `<button type="button" class="iv-tlx-r" data-iv-ms="${esc(x.id)}"><i class="iv-tlx-d${x.done ? ' dn' : ''}${x.late ? ' late' : ''}" aria-hidden="true"></i><span>${esc(x.name)}</span><em class="${x.late ? 'late' : ''}">${esc(x.when || x.date)}</em></button>`;
|
|
369
|
+
if (open.startsWith('ms:')) { const m = L.ms[+open.slice(3)]; return m ? `<div class="iv-tlx" role="list">${m.items.map((x) => msRow({ ...x, when: x.date + (x.late ? ' · late' : '') })).join('')}</div>` : ''; }
|
|
370
|
+
if (open.startsWith('gap:')) {
|
|
371
|
+
const g = (L.gaps || [])[+open.slice(4)]; if (!g) return '';
|
|
372
|
+
return `<div class="iv-tlx gap"><p>${g.words.map(esc).join('<br>')}</p>${g.ahead ? `<button type="button" class="iv-ib" data-iv-gapadd="${esc(g.from)} ${esc(g.to)}" aria-label="New task on these dates" title="New task on these dates">${SVG(I.plus, 16, 2.2)}</button>` : ''}</div>`;
|
|
373
|
+
}
|
|
374
|
+
if (open === 'list' || open === 'list+') {
|
|
375
|
+
const S = L.sheet || { items: [], fold: 0 }, all = open === 'list+';
|
|
376
|
+
let k = 0, head = '';
|
|
377
|
+
const rows = [];
|
|
378
|
+
for (const x of S.items) {
|
|
379
|
+
if (!all && x.kind === 'stage' && x.cls === 'done' && k < S.fold) { k++; continue; }
|
|
380
|
+
rows.push(x.kind === 'ms' ? msRow(x) : `<button type="button" class="iv-tlx-r st ${esc(x.cls)}" data-iv-stage="${esc(x.key)}"><i class="iv-tlx-s ${esc(x.cls)}" aria-hidden="true"></i><span>${esc(x.name)}</span><em>${esc(x.when)}</em></button>`);
|
|
381
|
+
}
|
|
382
|
+
if (S.fold) head = `<button type="button" class="iv-tlx-h" data-iv-tlall aria-expanded="${all}">${esc(plural(S.fold, 'earlier stage done', 'earlier stages done'))}${SVG(I.down, 12, 2.4)}</button>`;
|
|
383
|
+
return `<div class="iv-tlx list">${head}${rows.join('')}</div>`;
|
|
384
|
+
}
|
|
385
|
+
return '';
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** On the page, after a draw: the labels as drawn. Right to left, a ◇ name that runs into the one after it aligns its right edge to its own
|
|
389
|
+
* ◇, and one that still does not fit is hidden (its ◇ says it on hover); a ◇ date that runs into its neighbour or a corner label is hidden.
|
|
390
|
+
* root: any element holding stage lines. */
|
|
391
|
+
export function fitLine(root) {
|
|
392
|
+
if (!root || !root.querySelectorAll) return;
|
|
393
|
+
for (const tl of root.querySelectorAll('.iv-tl')) {
|
|
394
|
+
const box = tl.querySelector('.iv-tl-ln'); if (!box || !box.offsetWidth) continue;
|
|
395
|
+
const W = box.getBoundingClientRect();
|
|
396
|
+
const fit = (els, right, left) => {
|
|
397
|
+
let lim = right;
|
|
398
|
+
for (const el of els.slice().reverse()) {
|
|
399
|
+
el.classList.remove('cut');
|
|
400
|
+
const tries = el.classList.contains('iv-tln') ? ['c', 'r', 'l'] : ['c'];
|
|
401
|
+
let ok = false;
|
|
402
|
+
for (const a of tries) {
|
|
403
|
+
if (el.classList.contains('iv-tln')) { el.classList.remove('c', 'r', 'l'); el.classList.add(a); }
|
|
404
|
+
const r = el.getBoundingClientRect();
|
|
405
|
+
if (r.right <= lim + 0.5 && r.left >= left - 0.5) { lim = r.left - 6; ok = true; break; }
|
|
406
|
+
}
|
|
407
|
+
if (!ok) el.classList.add('cut');
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
fit([...tl.querySelectorAll('.iv-tl-nm .iv-tln')], W.right + 8, W.left - 8);
|
|
411
|
+
const s = tl.querySelector('.iv-tls'), e = tl.querySelector('.iv-tle');
|
|
412
|
+
fit([...tl.querySelectorAll('.iv-tld')], e ? e.getBoundingClientRect().left - 6 : W.right, s && s.textContent ? s.getBoundingClientRect().right + 6 : W.left);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
@@ -84,3 +84,16 @@
|
|
|
84
84
|
/* the ◇ milestone toggle after a divider (feedback batch 11 item 3, canvas XmlA2Flag) */
|
|
85
85
|
.tkc .seg .vr { width: 1px; height: 20px; background: var(--cz-hair); margin: 0 3px; align-self: center; }
|
|
86
86
|
.tkc .seg .ivq-ms.on { width: auto; padding: 0 12px 0 9px; gap: 6px; background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
87
|
+
/* History (batch 12 items 2 and 3, canvas TpA6): what Claude changed with the PM's ✓; folded, hidden at zero */
|
|
88
|
+
.tkc .tkc-h { padding-top: 4px; }
|
|
89
|
+
.tkc .tkc-hh { display: flex; align-items: center; gap: 6px; width: 100%; font: inherit; background: none; border: 0; padding: 6px 0; color: var(--cz-ink); cursor: pointer; text-align: left; }
|
|
90
|
+
.tkc .tkc-hh b { font-size: 13px; font-weight: 800; }
|
|
91
|
+
.tkc .tkc-hh .n { font-size: 12px; font-weight: 700; color: var(--cz-ink3); }
|
|
92
|
+
.tkc .tkc-hh svg { margin-left: auto; color: var(--cz-ink3); }
|
|
93
|
+
.tkc .tkc-h ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
94
|
+
.tkc .tkc-h li { display: flex; align-items: flex-start; gap: 8px; }
|
|
95
|
+
.tkc .tkc-h li .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
|
96
|
+
.tkc .tkc-h li b { font-size: 13px; font-weight: 700; }
|
|
97
|
+
.tkc .tkc-h li small { font-size: 12px; color: var(--cz-ink3); line-height: 1.4; }
|
|
98
|
+
.tkc .tkc-hu { width: 30px; height: 30px; border-radius: 999px; border: 0; background: none; color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
|
|
99
|
+
.tkc .tkc-hu:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* Notes the PM's words, edited in place;
|
|
9
9
|
* where it sits one row: initiative › section › breakdown item. The row opens the initiative; the move icon beside it changes the
|
|
10
10
|
* section (the workflow stage the task sits in), the PM's group, or the initiative.
|
|
11
|
+
* History N what Claude changed with the PM's ✓ (batch 12 items 2 and 3, canvas TpA6): field, before → after, why and where it read
|
|
12
|
+
* it; Undo on a change of the last 7 days. Folded; hidden at zero. h.history: { load() → [entry], undo(batch) → { ok } }
|
|
11
13
|
* Every change saves at once and says so in a toast with Undo. A Jira ticket is not drawn here: it opens the ticket Viewer (tk-view.js).
|
|
12
14
|
* cardHtml(t, o) → markup pure, for a node test: t is a task (taskOf), o the open picker and its lists
|
|
13
15
|
* taskOf(row, extra) → t a row of /api/boards/items or of the initiative model, in one shape
|
|
@@ -181,7 +183,22 @@ export function cardHtml(t, o = {}) {
|
|
|
181
183
|
const move = canMove(t, o) ? `<span class="anc"><button type="button" class="ovmv${mOpen ? ' open' : ''}" data-tkc="move" aria-label="Move it: section, group or initiative" title="Move it" aria-expanded="${mOpen}" aria-haspopup="menu">${ico(I.drag, 17)}</button>${mOpen ? movePop(t, o) : ''}</span>` : '';
|
|
182
184
|
const where = t.ini ? `<div class="ovw tk-ini"><button type="button" class="go" data-tkc="ini" aria-label="Open ${esc(t.iniTitle || t.ini)}"><span class="tl" aria-hidden="true">${ico(I.flag, 15)}</span>`
|
|
183
185
|
+ `<span class="tx"><b>${esc(t.iniTitle || t.ini)}</b>${path.length ? `<small>${path.join('<span class="sep" aria-hidden="true">›</span>')}</small>` : ''}</span><span class="cv">${ico(I.chev, 15)}</span></button>${move}</div>` : '';
|
|
184
|
-
return `<div class="tkc s-${sk}">${facts}${notes}${where}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
|
|
186
|
+
return `<div class="tkc s-${sk}">${facts}${notes}${where}${historyHtml(o.hist, o.histOpen, now)}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** History (canvas TpA6): Claude's approved changes to the task, newest first (lib/proposals.js historyOf). Zero is silence. */
|
|
190
|
+
const FIELD = { due: 'Due', status: 'Status', name: 'Name', notes: 'Notes', add: 'Added' };
|
|
191
|
+
const valOf = (f, v) => (v == null || v === '' ? '—' : typeof v === 'object' ? [short(v.start), short(v.due)].filter(Boolean).join(' – ') || '—' : f === 'notes' ? 'edited' : String(v));
|
|
192
|
+
export function historyHtml(hist, open, now = Date.now()) {
|
|
193
|
+
const L = (hist || []).filter((x) => x && !x.undone);
|
|
194
|
+
if (!L.length) return '';
|
|
195
|
+
const rows = L.map((x) => {
|
|
196
|
+
const recent = now - (Date.parse(x.at) || 0) < 7 * 864e5;
|
|
197
|
+
const what = x.field === 'add' ? 'Added from ' + (x.source || 'your sources') : (FIELD[x.field] || x.field) + ': ' + valOf(x.field, x.from) + ' → ' + valOf(x.field, x.to);
|
|
198
|
+
return `<li><span class="w"><b>${esc(what)}</b><small>${esc(['Claude, kept by you ' + short(String(x.at).slice(0, 10)), x.why, x.field !== 'add' && x.source ? x.source : ''].filter(Boolean).join(' · '))}</small></span>`
|
|
199
|
+
+ (recent && x.batch ? `<button type="button" class="tkc-hu" data-tkc-hundo="${esc(x.batch)}" aria-label="Undo this change" title="Undo">${ico('<path d="M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3"/>', 15)}</button>` : '') + '</li>';
|
|
200
|
+
}).join('');
|
|
201
|
+
return `<div class="ovb tkc-h"><button type="button" class="tkc-hh" data-tkc-hist aria-expanded="${!!open}"><b>History</b><span class="n">${L.length}</span>${ico(open ? '<path d="M6 9l6 6 6-6"/>' : I.chev, 14)}</button>${open ? `<ul>${rows}</ul>` : ''}</div>`;
|
|
185
202
|
}
|
|
186
203
|
|
|
187
204
|
/* ── the page: one card, every change saved at once with Undo ── */
|
|
@@ -209,7 +226,7 @@ export function mountCard(el, t, h) {
|
|
|
209
226
|
const draw = () => {
|
|
210
227
|
const keep = document.activeElement && el.contains(document.activeElement) && document.activeElement.matches('[data-tkc-notes]');
|
|
211
228
|
if (keep) return; // never redraw under the PM's typing
|
|
212
|
-
el.innerHTML = cardHtml(t, { ...st, ...lists(), now: h.now ? h.now() : Date.now() });
|
|
229
|
+
el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, now: h.now ? h.now() : Date.now() });
|
|
213
230
|
const f = el.querySelector('.tkc-new input'); if (f && (st.open === 'owner' || st.open === 'group')) f.focus();
|
|
214
231
|
};
|
|
215
232
|
const word = (kind) => (WORDS[kind] || (() => 'Saved'))(t, h);
|
|
@@ -237,6 +254,12 @@ export function mountCard(el, t, h) {
|
|
|
237
254
|
el.onclick = (e) => {
|
|
238
255
|
const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
|
|
239
256
|
const d = b.dataset;
|
|
257
|
+
if ('tkcHist' in d) { st.histOpen = !st.histOpen; draw(); return; }
|
|
258
|
+
if (d.tkcHundo && h.history) {
|
|
259
|
+
b.disabled = true;
|
|
260
|
+
Promise.resolve(h.history.undo(d.tkcHundo)).catch(() => null).then((r) => { st.msg = r && r.ok !== false ? '' : (r && r.error) || 'The undo did not land.'; loadHist(); if (h.changed) h.changed(t); });
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
240
263
|
if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
|
|
241
264
|
if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
|
|
242
265
|
if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
|
|
@@ -272,7 +295,9 @@ export function mountCard(el, t, h) {
|
|
|
272
295
|
// a press outside an open picker closes it (a popover opens under its control and leaves the same way)
|
|
273
296
|
const away = (e) => { if (!el.isConnected) { document.removeEventListener('pointerdown', away, true); return; } if (st.open && !e.target.closest('.anc')) { st.open = null; draw(); } };
|
|
274
297
|
document.addEventListener('pointerdown', away, true);
|
|
298
|
+
const loadHist = () => { if (h.history) Promise.resolve(h.history.load()).catch(() => null).then((L) => { st.hist = Array.isArray(L) ? L : []; draw(); }); };
|
|
275
299
|
draw();
|
|
300
|
+
loadHist();
|
|
276
301
|
return { draw, setStatus: (s) => change('status', { status: s }), task: t };
|
|
277
302
|
}
|
|
278
303
|
|
|
@@ -283,11 +308,13 @@ export const stateKey = (s) => SKEY[s] || 'todo';
|
|
|
283
308
|
export const datePickerHtml = (t, o = {}, now = Date.now()) => picker(t, o, now);
|
|
284
309
|
|
|
285
310
|
/** The page's toast with Undo, in the shape Home draws (home-app.js toastUndo): #toast with one .undo press, kept 8 seconds. */
|
|
286
|
-
/**
|
|
287
|
-
|
|
311
|
+
/** A task PMOS can delete (batch 11 item 16): a Board task (task-…) or a breakdown item (<initiative>.<10 characters>). Never a Jira ticket. */
|
|
312
|
+
export const canDelete = (t) => !!t && !t.jira && (/^task-/.test(String(t.uid || '')) || /^[a-z0-9][a-z0-9-]*\.[0-9a-z]{10}$/.test(String(t.uid || '')));
|
|
313
|
+
/** The ⋯ menu's Delete for a PMOS task (batch 7 item 5; breakdown items too since batch 11 item 16), or null for a Jira ticket.
|
|
314
|
+
* o: { ws, board, t, post(path, body), toast(msg, undo), done() — the Viewer closes and the list re-reads }. Undo restores it. */
|
|
288
315
|
export function deleteEntry(o) {
|
|
289
316
|
const { ws, board, t, post } = o;
|
|
290
|
-
if (!
|
|
317
|
+
if (!canDelete(t)) return null;
|
|
291
318
|
return { label: 'Delete', danger: true, on: async () => {
|
|
292
319
|
const r = await post('/api/boards/tasks/delete', { ws, board, task: t.uid });
|
|
293
320
|
if (!r || !r.ok) { o.toast((r && r.error) || 'The task was not deleted.'); return; }
|
|
@@ -303,6 +330,16 @@ export function toastUndo(msg, undo) {
|
|
|
303
330
|
clearTimeout(toastUndo.t); toastUndo.t = setTimeout(() => el.classList.remove('on', 'act'), undo ? 8000 : 4200);
|
|
304
331
|
}
|
|
305
332
|
|
|
333
|
+
/** h.history for a board task: GET /api/proposals/history and POST /api/proposals/undo (lib/routes-proposals.js). o: { ws, board, t, post } */
|
|
334
|
+
export function historyFor(o) {
|
|
335
|
+
const { ws, board, t, post } = o;
|
|
336
|
+
if (!t || t.jira || !t.uid || !board) return null;
|
|
337
|
+
return {
|
|
338
|
+
load: () => fetch('/api/proposals/history?board=' + encodeURIComponent(board) + (ws ? '&ws=' + encodeURIComponent(ws) : '') + '&task=' + encodeURIComponent(t.uid), { credentials: 'same-origin' })
|
|
339
|
+
.then((r) => r.json()).then((j) => (j && j.ok ? j.history : [])).catch(() => []),
|
|
340
|
+
undo: (batch) => post('/api/proposals/undo', { ws, board, batch }),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
306
343
|
/** The board's routes behind h.save. o: { ws, board, t, post(path, body) → Promise<json> } */
|
|
307
344
|
export function boardSaver(o) {
|
|
308
345
|
const { ws, board, t, post } = o;
|
|
@@ -96,6 +96,8 @@ body.wf-page { min-height: 100vh; overflow: hidden; font-family: var(--cz-sans);
|
|
|
96
96
|
.wf-chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--cz-hair2, var(--cz-hair)); background: var(--cz-card); font-size: 12.5px; font-weight: 700; color: var(--cz-ink2); cursor: pointer; }
|
|
97
97
|
.wf-chip.on { background: var(--cz-bluebg); border-color: var(--cz-blue); color: var(--cz-blueink); }
|
|
98
98
|
.wf-chip:disabled { cursor: default; }
|
|
99
|
+
/* a workflow that ships with PMOS: its controls read as settled, not as presses that fail */
|
|
100
|
+
.wf-chip:disabled, .wf-sw:disabled, .wf-pick:disabled { cursor: default; opacity: .55; }
|
|
99
101
|
.wf-fin { padding: 4px 8px 4px 10px; display: flex; flex-direction: column; }
|
|
100
102
|
.wf-fi { display: flex; align-items: center; gap: 6px; }
|
|
101
103
|
.wf-addi { padding: 6px 0; font-size: 12.5px; }
|
|
@@ -223,6 +223,8 @@ function stageCtx() {
|
|
|
223
223
|
return {
|
|
224
224
|
wf: () => cur(), readOnly: () => readOnly(cur()), save: (next) => edit(next), remove: (wf, key) => removeStage(wf, key),
|
|
225
225
|
toast, label: (wf, key) => E.label(wf, key),
|
|
226
|
+
// the read-only panel's "Copy it": the copy opens on the same stage, ready to change
|
|
227
|
+
copy: async (key) => { await copy(cur()); const wf = cur(); if (wf && !readOnly(wf)) openStage(wf, key); },
|
|
226
228
|
};
|
|
227
229
|
}
|
|
228
230
|
function openKey(key, o = {}) { const wf = cur(); if (wf) openStage(wf, key, o); }
|
|
@@ -50,7 +50,7 @@ function bodyHtml(wf, s, ro) {
|
|
|
50
50
|
+ sw(s.milestone, 'milestone', 'Milestone', 'a ◆ checkpoint with a date', ro)
|
|
51
51
|
+ sw(s.auto, 'auto', 'Moves on by itself', 'when every item is done', ro);
|
|
52
52
|
return `<p class="wf-lbl">${esc(wf.name)} · stage ${n} of ${wf.stages.length}</p>`
|
|
53
|
-
+ (ro ? `<p class="wf-box wf-small">${esc(wf.name)} ships with PMOS. Copy it to change a stage.</p>` : '')
|
|
53
|
+
+ (ro ? `<p class="wf-box wf-small">${esc(wf.name)} ships with PMOS. <button type="button" class="wf-link" data-st-copy>Copy it</button> to change a stage.</p>` : '')
|
|
54
54
|
+ `<div class="wf-sgrid"><div class="wf-scol">${left}</div><div class="wf-scol">${right}</div></div><p class="wf-small" role="status" id="wfStMsg"></p>`;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -93,6 +93,7 @@ function draw(b, key) {
|
|
|
93
93
|
function press(e, key) {
|
|
94
94
|
const t = e.target.closest('button'); if (!t || t.disabled) return;
|
|
95
95
|
const d = t.dataset, s = fresh().stages.find((x) => x.key === key);
|
|
96
|
+
if ('stCopy' in d) { H.copy(key); return; }
|
|
96
97
|
if (d.stCat) { save(E.setStage(fresh(), key, { cat: d.stCat })); return; }
|
|
97
98
|
if (d.stKind) { save(E.setStage(fresh(), key, { output: { kind: d.stKind } })); return; }
|
|
98
99
|
if (d.stWhen) {
|