create-pmos 0.421.0 → 0.423.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 +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/anchor-resolve.js +93 -15
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +87 -3
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +13 -11
- package/workspace/briefing-premium-initiative-test.js +30 -38
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/report-api/draft.json +2 -1
- package/workspace/guide/briefing-premium.md +2 -1
- package/workspace/guide/home.md +14 -4
- package/workspace/guide/programs.md +5 -3
- package/workspace/guide/workflows.md +5 -1
- package/workspace/home-other-product-test.js +55 -0
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/board-premium.js +21 -6
- package/workspace/lib/custom-docs.js +65 -3
- package/workspace/lib/doc-live-root.js +37 -0
- package/workspace/lib/engine/anchor-resolve.js +93 -15
- package/workspace/lib/engine/boards.js +30 -2
- package/workspace/lib/engine/intake.js +1 -1
- package/workspace/lib/hold-spans.js +24 -10
- package/workspace/lib/initiative-writer.js +63 -1
- package/workspace/lib/kg.js +1 -1
- package/workspace/lib/plan-items.js +36 -5
- package/workspace/lib/programs.js +11 -3
- package/workspace/lib/report-draft.js +3 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-board-premium.js +28 -0
- package/workspace/lib/routes-boards.js +92 -13
- package/workspace/lib/routes-doc-sheet.js +29 -1
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-programs.js +44 -5
- package/workspace/lib/routes-task-links.js +329 -0
- package/workspace/lib/routes-task-plans.js +333 -0
- package/workspace/lib/split-merge-suggest.js +162 -0
- package/workspace/lib/split-merge.js +379 -0
- package/workspace/lib/task-cli.js +73 -13
- package/workspace/lib/task-items.js +15 -3
- package/workspace/lib/task-links.js +422 -0
- package/workspace/lib/task-plans.js +232 -0
- package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
- package/workspace/lib/vendor/scripts/intake.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-core-doc-issue-test.js +2 -2
- package/workspace/premium-vw-backlog-test.js +3 -3
- package/workspace/premium-vw-doc-test.js +26 -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-leave-test.js +203 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +5 -2
- package/workspace/public/pm/bd-ini-panel.js +32 -9
- package/workspace/public/pm/bd-prog-panel.js +22 -7
- package/workspace/public/pm/bd-prog.js +6 -1
- package/workspace/public/pm/bd-span.js +234 -30
- package/workspace/public/pm/bd-views.js +3 -2
- package/workspace/public/pm/cozy-board.css +90 -0
- package/workspace/public/pm/cozy-home.css +3 -0
- package/workspace/public/pm/doc-follow.js +36 -0
- package/workspace/public/pm/home-app.js +62 -14
- package/workspace/public/pm/home-ini-model.js +0 -34
- package/workspace/public/pm/home-ini.js +81 -204
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-today.js +3 -1
- package/workspace/public/pm/ini-groups.js +228 -0
- package/workspace/public/pm/ini-links.js +561 -0
- package/workspace/public/pm/ini-tasks.js +131 -30
- package/workspace/public/pm/ini-versions.js +348 -0
- package/workspace/public/pm/ini-view-model.js +113 -43
- package/workspace/public/pm/ini-view.css +341 -18
- package/workspace/public/pm/ini-view.js +153 -38
- package/workspace/public/pm/premium-board.js +160 -21
- package/workspace/public/pm/premium-report-read.js +20 -1
- package/workspace/public/pm/premium-shell.js +29 -4
- package/workspace/public/pm/premium-vw-doc.js +46 -11
- package/workspace/public/pm/prog-move.js +69 -0
- 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 +3 -0
- package/workspace/public/pm/task-card.js +15 -6
- 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 +15 -1
- package/workspace/split-merge-ui-test.js +175 -0
- package/workspace/stage-card-test.js +12 -11
- package/workspace/task-card-test.js +3 -2
- package/workspace/task-delete-test.js +126 -0
- package/workspace/task-links-test.js +227 -0
- package/workspace/task-milestones-test.js +176 -0
- package/workspace/task-plans-test.js +181 -0
- package/workspace/task-views-test.js +3 -3
- package/workspace/test-lists/bd-ini-panel.json +8 -2
- package/workspace/test-lists/product-lane.json +6 -0
- package/workspace/test-lists/program-leave.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/test-lists/task-milestones.json +6 -0
- package/workspace/test-lists/task-plans.json +6 -0
- package/workspace/test-lists/viewer-live-file.json +9 -0
- package/workspace/timeline-holds-test.js +61 -4
- package/workspace/tk-tasks-test.js +173 -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
|
+
}
|
|
@@ -81,3 +81,6 @@
|
|
|
81
81
|
.tkc .ovf { column-gap: 12px; padding: 12px 14px; }
|
|
82
82
|
.tkc .ovf .tkc-dp { left: -64px; } /* the picker starts at the card's edge, so it stays on the screen */
|
|
83
83
|
}
|
|
84
|
+
/* the ◇ milestone toggle after a divider (feedback batch 11 item 3, canvas XmlA2Flag) */
|
|
85
|
+
.tkc .seg .vr { width: 1px; height: 20px; background: var(--cz-hair); margin: 0 3px; align-self: center; }
|
|
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); }
|
|
@@ -57,7 +57,7 @@ export function taskOf(row, extra = {}) {
|
|
|
57
57
|
uid: r.uid || '', key: r.key && /^task:/.test(r.key) ? r.key : 'task:' + (r.uid || r.key || ''), title: r.title || '', status: r.status || r.state || 'To do',
|
|
58
58
|
start: r.start || '', due: r.end || r.due || '', owner: r.owner || '', notes: r.notes || '', ini: r.ini || extra.ini || '',
|
|
59
59
|
iniTitle: extra.iniTitle || '', group: extra.group != null ? extra.group : '', board: r.board || extra.board || '',
|
|
60
|
-
section: typeof r.section === 'string' ? r.section : '', wbs: r.wbs && (r.wbs.title || r.wbs.id) ? { id: r.wbs.id || '', title: r.wbs.title || r.wbs.id } : null,
|
|
60
|
+
section: typeof r.section === 'string' ? r.section : '', milestone: !!r.milestone, wbs: r.wbs && (r.wbs.title || r.wbs.id) ? { id: r.wbs.id || '', title: r.wbs.title || r.wbs.id } : null,
|
|
61
61
|
jira: jira ? { key: r.ref || r.key || r.uid || '', readAt: r.readAt || extra.readAt || '' } : null,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -167,7 +167,10 @@ export function cardHtml(t, o = {}) {
|
|
|
167
167
|
const ownerBtn = t.owner
|
|
168
168
|
? `<button type="button" class="own-b${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Owner: ${esc(t.owner)}. Change" title="Owner" aria-expanded="${oOpen}"><span class="av">${esc(initials(t.owner))}</span>${esc(t.owner)}</button>`
|
|
169
169
|
: `<button type="button" class="own-b ghost${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Add an owner" title="Owner" aria-expanded="${oOpen}"><span class="av no"></span></button>`;
|
|
170
|
-
|
|
170
|
+
// after a divider, the ◇ toggle (feedback batch 11 item 3, canvas XmlA2Flag): its due date shows as ◇ on the Board and the timeline
|
|
171
|
+
const msOn = !!t.milestone, msTip = msOn ? 'A milestone. Press to make it a plain task' : 'Make it a milestone: its due date shows as ◇ on the Board and the timeline';
|
|
172
|
+
const msBtn = `<span class="vr" aria-hidden="true"></span><button type="button" class="ivq-ms${msOn ? ' on' : ''}" data-tkc-ms aria-pressed="${msOn}" aria-label="${msOn ? 'Milestone' : 'Make it a milestone'}" title="${msTip}">${ico(I.dia, 15)}${msOn ? 'Milestone' : ''}</button>`;
|
|
173
|
+
const facts = `<div class="ovf tkc-f"><span class="k">Status</span><div class="v"><div class="seg" role="radiogroup" aria-label="Status">${seg}${msBtn}</div></div>`
|
|
171
174
|
+ `<span class="k">Due</span><div class="v"><span class="anc">${dueBtn}${dOpen ? picker(t, o, now) : ''}</span>${late}</div>`
|
|
172
175
|
+ `<span class="k">Owner</span><div class="v"><span class="anc">${ownerBtn}${ownerPop}</span></div></div>`;
|
|
173
176
|
const notes = `<div class="ovb"><label class="ovl" for="tkcNotes">Notes</label><textarea class="nt" id="tkcNotes" data-tkc-notes rows="2" maxlength="4000" placeholder="Add notes">${esc(t.notes)}</textarea></div>`;
|
|
@@ -196,6 +199,7 @@ const WORDS = {
|
|
|
196
199
|
notes: () => 'Notes saved',
|
|
197
200
|
dates: (t) => (dueLine(t).text || 'No dates'),
|
|
198
201
|
initiative: (t) => 'Moved to ' + (t.iniTitle || t.ini),
|
|
202
|
+
milestone: (t) => (t.milestone ? 'Milestone' : 'Not a milestone'),
|
|
199
203
|
};
|
|
200
204
|
|
|
201
205
|
export function mountCard(el, t, h) {
|
|
@@ -234,6 +238,7 @@ export function mountCard(el, t, h) {
|
|
|
234
238
|
const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
|
|
235
239
|
const d = b.dataset;
|
|
236
240
|
if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
|
|
241
|
+
if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
|
|
237
242
|
if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
|
|
238
243
|
if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
|
|
239
244
|
if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
|
|
@@ -278,11 +283,13 @@ export const stateKey = (s) => SKEY[s] || 'todo';
|
|
|
278
283
|
export const datePickerHtml = (t, o = {}, now = Date.now()) => picker(t, o, now);
|
|
279
284
|
|
|
280
285
|
/** The page's toast with Undo, in the shape Home draws (home-app.js toastUndo): #toast with one .undo press, kept 8 seconds. */
|
|
281
|
-
/**
|
|
282
|
-
|
|
286
|
+
/** A task PMOS can delete (batch 11 item 16): a Board task (task-…) or a breakdown item (<initiative>.<10 characters>). Never a Jira ticket. */
|
|
287
|
+
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 || '')));
|
|
288
|
+
/** 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.
|
|
289
|
+
* o: { ws, board, t, post(path, body), toast(msg, undo), done() — the Viewer closes and the list re-reads }. Undo restores it. */
|
|
283
290
|
export function deleteEntry(o) {
|
|
284
291
|
const { ws, board, t, post } = o;
|
|
285
|
-
if (!
|
|
292
|
+
if (!canDelete(t)) return null;
|
|
286
293
|
return { label: 'Delete', danger: true, on: async () => {
|
|
287
294
|
const r = await post('/api/boards/tasks/delete', { ws, board, task: t.uid });
|
|
288
295
|
if (!r || !r.ok) { o.toast((r && r.error) || 'The task was not deleted.'); return; }
|
|
@@ -303,13 +310,15 @@ export function boardSaver(o) {
|
|
|
303
310
|
const { ws, board, t, post } = o;
|
|
304
311
|
return async (patch) => {
|
|
305
312
|
if (t.jira) {
|
|
313
|
+
// a Jira ticket takes the ◇ flag only (batch 11 item 3); its date stays Jira's
|
|
314
|
+
if (patch.milestone != null) return post('/api/boards/tasks/edit', { ws, board, task: t.jira.key, milestone: !!patch.milestone });
|
|
306
315
|
if (patch.notes == null) return { ok: false, error: 'Jira owns this. Change it in Jira.' };
|
|
307
316
|
return post('/api/boards/tickets/note', { ws, board, ref: t.jira.key, notes: patch.notes });
|
|
308
317
|
}
|
|
309
318
|
if (patch.status != null) return post('/api/boards/tasks/state', { ws, board, task: t.uid, state: patch.status });
|
|
310
319
|
if (patch.group != null) return post('/api/initiative-layout', { ws, kind: 'place', initiative: t.ini, task: t.key, group: patch.group });
|
|
311
320
|
const body = {};
|
|
312
|
-
for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative']) if (patch[k] != null) body[k] = patch[k];
|
|
321
|
+
for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative', 'milestone']) if (patch[k] != null) body[k] = patch[k];
|
|
313
322
|
return post('/api/boards/tasks/edit', { ws, board, task: t.uid, ...body });
|
|
314
323
|
};
|
|
315
324
|
}
|
|
@@ -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) {
|
package/workspace/server.js
CHANGED
|
@@ -1655,6 +1655,7 @@ function roleAndStem(rel, base) {
|
|
|
1655
1655
|
const dir = path.dirname(rel).split(path.sep).pop();
|
|
1656
1656
|
return { role: ROLE_BY_DIR[dir] || 'doc', stem };
|
|
1657
1657
|
}
|
|
1658
|
+
const recordStem = (base) => { const m = /^([A-Za-z0-9][\w.-]*)\.md$/.exec(base); return m && !/^(readme|index)$/i.test(m[1]) ? m[1] : null; };
|
|
1658
1659
|
function docMeta(root, full) {
|
|
1659
1660
|
let st;
|
|
1660
1661
|
try { st = fs.statSync(full); } catch { return null; }
|
|
@@ -1667,7 +1668,8 @@ function docMeta(root, full) {
|
|
|
1667
1668
|
const meta = {
|
|
1668
1669
|
mtimeMs: st.mtimeMs, path: rel, name: base, role,
|
|
1669
1670
|
// frontmatter wins; the filename convention is the fallback, never the override
|
|
1670
|
-
|
|
1671
|
+
// a record with no id: is named by its file, as the engine names it (scripts/workflow-state.js#listInitiatives)
|
|
1672
|
+
initiative: head.initiative || (role === 'record' ? head.recordId || recordStem(base) : null) || null,
|
|
1671
1673
|
also: role === 'record' ? [] : (head.also || []),
|
|
1672
1674
|
named: role === 'record' ? (head.named || []) : [],
|
|
1673
1675
|
stem, title: head.title || null,
|
|
@@ -10078,6 +10080,18 @@ async function handleRequest(req, res) {
|
|
|
10078
10080
|
structureDraftState: (w, id) => require('./lib/routes-report-structure.js').draftState(reportStructureCtx(), w, id),
|
|
10079
10081
|
skillPrompt: (skillId, w) => { const t = taskById(skillId, w ? w.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
|
|
10080
10082
|
stopSession: (id) => { const x = sessions.get(String(id || '')); if (x && x.child) stopHeadless(x); },
|
|
10083
|
+
// split or merge (batch 11 item 14, lib/split-merge.js): a merge takes the open chats of the closing initiative to the one that stays; its
|
|
10084
|
+
// Undo names them (`only`) and takes them back. A closed chat stays with the initiative it ran for. → the ids rebound
|
|
10085
|
+
rebindSessions: (wsId, from, to, only) => {
|
|
10086
|
+
const out = [];
|
|
10087
|
+
for (const x of sessions.values()) {
|
|
10088
|
+
if (!x || x.state === 'exited' || (x.ws || null) !== wsId || x.initiative !== from) continue;
|
|
10089
|
+
if (Array.isArray(only) && !only.includes(x.id)) continue;
|
|
10090
|
+
x.initiative = to; x.attributedBy = 'declared'; persist(x); out.push(x.id);
|
|
10091
|
+
}
|
|
10092
|
+
if (out.length) pushSessions();
|
|
10093
|
+
return out;
|
|
10094
|
+
},
|
|
10081
10095
|
// workspace-headless-jobs R6: is this session a headless run that is still working?
|
|
10082
10096
|
headlessBusy: (id) => { const x = sessions.get(String(id || '')); return !!(x && x.headless && x.child); },
|
|
10083
10097
|
// initiative my-work: every registered repository, the day runs, and the two presses that start sessions
|