create-pmos 0.442.0 → 0.443.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +12 -0
- package/workspace/goals-clear-ui-test.js +249 -0
- package/workspace/guide/home.md +7 -2
- package/workspace/guide/metric-drafts.md +8 -2
- package/workspace/home-railcard-test.js +193 -0
- package/workspace/intelligence-gaps-ui-test.js +16 -14
- package/workspace/lib/engine/records/index.js +9 -2
- package/workspace/lib/initiative-layout.js +3 -1
- package/workspace/lib/insights-premium.js +22 -1
- package/workspace/lib/metric-drafts.js +37 -10
- package/workspace/lib/metric-read-runs.js +20 -13
- package/workspace/lib/metric-reads.js +208 -23
- package/workspace/lib/metrics-cli.js +62 -5
- package/workspace/lib/routes-goal-status.js +89 -6
- package/workspace/lib/routes-insights-premium.js +1 -1
- package/workspace/lib/routes-metric-drafts.js +26 -3
- package/workspace/metric-drafts-ui-test.js +5 -2
- package/workspace/okr-goals-ui-test.js +7 -5
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/public/pm/cozy-insights.css +82 -0
- package/workspace/public/pm/cozy-live-pill.css +5 -0
- package/workspace/public/pm/cozy-today.css +15 -0
- package/workspace/public/pm/cozy-viewer.js +42 -14
- package/workspace/public/pm/cozy-vw-shell.css +4 -0
- package/workspace/public/pm/goals-clear.js +258 -0
- package/workspace/public/pm/home-app.js +51 -3
- package/workspace/public/pm/home-today.js +51 -10
- package/workspace/public/pm/ini-groups.js +14 -8
- package/workspace/public/pm/ini-tasks.js +47 -13
- package/workspace/public/pm/ini-view-model.js +37 -14
- package/workspace/public/pm/ini-view.css +29 -4
- package/workspace/public/pm/ini-view.js +9 -6
- package/workspace/public/pm/metric-drafts.js +4 -1
- package/workspace/public/pm/mission.js +11 -7
- package/workspace/public/pm/premium-insights.js +178 -24
- package/workspace/server.js +6 -2
- package/workspace/skills/metric-read.skill +7 -5
- package/workspace/stage-card-test.js +11 -3
- package/workspace/task-views-test.js +190 -1
- package/workspace/test-lists/goals-clear.json +15 -0
- package/workspace/test-lists/home-railcard.json +9 -0
- package/workspace/tk-tasks-test.js +2 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* pm/goals-clear.js — goals made clear on Intelligence (feedback batch 18 item 11, build 11-B; main canvas In development, frames Gc*). PURE: each
|
|
2
|
+
* function takes a drafted row (GET /api/metric-drafts, through okr-list.js draftsOf) or a goal of the Intelligence model (GET /api/insights-premium,
|
|
3
|
+
* with the fields lib/goal-status.js and the goals reading engine add) and returns words or markup. No read, no write, no clock of its own.
|
|
4
|
+
*
|
|
5
|
+
* rhythmOf(x) { short: "Every Monday", long: "every Monday 07:00" } | null the server's rhythm, else said from the recipe
|
|
6
|
+
* keptSay(rows) the "Kept" toast: "Kept. I read it every Monday 07:00." with the goal's own rhythm (never "every morning")
|
|
7
|
+
* tableHtml(rows, o) GcJ1aTable: the drafts table. Proposed metric · How it is counted · Now (read hh:mm) · Target · From, how often · ✕ ✓
|
|
8
|
+
* checkHtml(r, st) GcJ1Drafts: the check panel of one drafted metric; GcS3Differs once the PM typed a number that differs
|
|
9
|
+
* firstOf(g) { n, first, next } while a goal has fewer than 3 readings (GcJ2FirstMonday): no pace, no trend yet
|
|
10
|
+
* firstMeta(g) the row's second line then: "39.4k · Looker, Mon 2 Nov 07:02 · pace known after 3 readings"
|
|
11
|
+
* firstChart(g) the dashed box where the chart will be: "The line starts with the 2nd reading, Mon 9 Nov"
|
|
12
|
+
* krHtml(g, o) GcR3Goal, GcR4Failed, GcR5Held: the failed or held box, How it is counted, From … (said once), the checks, the query
|
|
13
|
+
* lineOf(goals, product) the ✦ line for a held reading, a failed read or the first readings; null when none of them is the news
|
|
14
|
+
*
|
|
15
|
+
* The rules of the frames: summary first; how often and the last read are said once, in "From, how often"; a held or failed reading never shows as
|
|
16
|
+
* progress (the row and the dot keep the last good reading); icon-only presses, with words in aria-label and title; Adler stays out of the table,
|
|
17
|
+
* the counts and the charts. Every field is optional: what the server did not send is not drawn (zero is silence). */
|
|
18
|
+
|
|
19
|
+
import { esc, SV, P, dotHtml } from './okr-list.js';
|
|
20
|
+
|
|
21
|
+
const WD = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
22
|
+
const WD3 = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
23
|
+
const DAYKEY = { sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 };
|
|
24
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
25
|
+
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
26
|
+
const when = (iso) => { const t = Date.parse(String(iso || '')); return Number.isFinite(t) ? new Date(t) : null; };
|
|
27
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
28
|
+
/** "07:02" in the PM's own time. A day with no time ("2026-11-02") has none. */
|
|
29
|
+
export const hm = (iso) => { const d = /T\d/.test(String(iso || '')) ? when(iso) : null; return d ? pad(d.getHours()) + ':' + pad(d.getMinutes()) : ''; };
|
|
30
|
+
/** "Mon 2 Nov" (a date) and "Mon 2 Nov, 07:02" (a date with its time). */
|
|
31
|
+
export const dayTxt = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return ''; const d = /T\d/.test(iso) ? when(iso) : new Date(+m[1], +m[2] - 1, +m[3]); return d ? WD3[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()] : ''; };
|
|
32
|
+
export const atTxt = (iso) => [dayTxt(iso), hm(iso)].filter(Boolean).join(', ');
|
|
33
|
+
const big = (v) => (fin(v) ? (Math.abs(v) >= 1000 ? v.toLocaleString('en-US', { maximumFractionDigits: 0 }) : String(Math.round(v * 100) / 100)) : '');
|
|
34
|
+
const icon = (d, s = 16) => SV(d, s);
|
|
35
|
+
const I = Object.assign({}, P, { open: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5', redo: 'M20 12a8 8 0 1 1-2.3-5.6M20 4v5h-5', warn: 'M12 4l9 16H3zM12 10v4M12 17v.5' });
|
|
36
|
+
const ib = (o) => `<button type="button" class="cz-ib sm${o.solid ? ' solid' : ''}" data-gc="${esc(o.act)}"${o.row ? ` data-row="${esc(o.row)}"` : ''} aria-label="${esc(o.label)}" title="${esc(o.title || o.label)}"${o.busy ? ' disabled' : ''}>${icon(o.icon, o.solid ? 18 : 16)}</button>`;
|
|
37
|
+
|
|
38
|
+
/* ── the rhythm ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
39
|
+
/** How often a goal is read, in two lengths: the table's short one and the long one the panel and the toast say. The server's rhythm wins
|
|
40
|
+
* ({ txt, short }); else it is said from the recipe's cadence, at and day. null when the goal has no way to be read. */
|
|
41
|
+
export function rhythmOf(x) {
|
|
42
|
+
const R = (x && x.rhythm) || (x && x.raw && x.raw.rhythm), rc = (x && x.recipe) || (x && x.raw && x.raw.recipe) || null;
|
|
43
|
+
const rat = R && typeof R === 'object' ? (/^\d{1,2}:\d{2}$/.test(String(R.at || '')) ? String(R.at) : (/(\d{1,2}:\d{2})$/.exec(String(R.txt || '')) || [])[1] || '') : '';
|
|
44
|
+
if (R && typeof R === 'object' && R.cadence === 'daily' && rat) return { short: 'Every day, ' + rat.padStart(5, '0'), long: String(R.txt || 'every day ' + rat).replace(/^./, (c) => c.toLowerCase()) };
|
|
45
|
+
if (R && typeof R === 'object' && (R.txt || R.short)) { const long = String(R.txt || R.short); return { short: String(R.short || long.replace(/^./, (c) => c.toUpperCase()).replace(/ \d{2}:\d{2}$/, '')), long: long.replace(/^./, (c) => c.toLowerCase()) }; }
|
|
46
|
+
if (typeof R === 'string' && R) return { short: R.replace(/^./, (c) => c.toUpperCase()), long: R.replace(/^./, (c) => c.toLowerCase()) };
|
|
47
|
+
const c = rc && rc.cadence; if (!c) return null;
|
|
48
|
+
const at = /^\d{1,2}:\d{2}$/.test(String(rc.at || '')) ? String(rc.at).padStart(5, '0') : '';
|
|
49
|
+
if (c === 'hourly') return { short: 'Every hour', long: 'every hour' + (rc.hours ? ', ' + rc.hours : '') };
|
|
50
|
+
if (c === 'daily') return { short: 'Every day' + (at ? ', ' + at : ''), long: 'every day' + (at ? ' ' + at : '') };
|
|
51
|
+
if (c === 'weekly') { const d = DAYKEY[String(rc.day || 'mon').slice(0, 3).toLowerCase()]; const w = WD[d === undefined ? 1 : d]; return { short: 'Every ' + w, long: 'every ' + w + (at ? ' ' + at : '') }; }
|
|
52
|
+
if (c === 'monthly') return { short: 'Every month', long: 'every month, the 1st' + (at ? ' ' + at : '') };
|
|
53
|
+
return { short: String(c), long: String(c) };
|
|
54
|
+
}
|
|
55
|
+
/** The "Kept" toast (AdM3Intel, now with the goal's own rhythm). rows: the drafts kept by this press. One rhythm for all: it says it; several:
|
|
56
|
+
* "each on its own rhythm". A server's said line (r.said) wins. */
|
|
57
|
+
export function keptSay(rows, said) {
|
|
58
|
+
if (said) return said;
|
|
59
|
+
const R = (rows || []).map(rhythmOf).filter(Boolean), longs = [...new Set(R.map((x) => x.long))];
|
|
60
|
+
if (!R.length) return 'Kept. I read it from now on.';
|
|
61
|
+
if (longs.length === 1) return 'Kept. I read ' + ((rows || []).length > 1 ? 'them ' : 'it ') + longs[0] + '.';
|
|
62
|
+
return 'Kept. I read each one on its own rhythm: the first reading within the hour.';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ── the drafts table (GcJ1aTable) ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
66
|
+
const GROUP_SAY = { 'North Star': 'the moment people get value', Inputs: 'what moves the North Star', Guardrails: 'must not get worse', 'Key results': 'this quarter' };
|
|
67
|
+
const TYPE_SAY = { 'Stay within': 'Stay within', Percentage: 'Percentage', Count: 'Count', Amount: 'Amount', Duration: 'Duration', 'Done or not': 'Done or not' };
|
|
68
|
+
const liveOf = (r) => { const L = r && r.raw && r.raw.live; return L && typeof L === 'object' ? L : null; };
|
|
69
|
+
const countsOf = (x) => { const c = (x && x.counts) || (x && x.raw && x.raw.counts); return c && typeof c === 'object' ? c : null; };
|
|
70
|
+
/** What the row says in "How it is counted": the plain sentence, else the two counts as "a ÷ b", else nothing. */
|
|
71
|
+
export function countedOf(x) {
|
|
72
|
+
const c = countsOf(x); if (!c) return '';
|
|
73
|
+
if (c.what) return String(c.what);
|
|
74
|
+
return [c.num_label, c.den_label].filter(Boolean).join(' ÷ ');
|
|
75
|
+
}
|
|
76
|
+
/** The source and the rhythm as the table says them: the source with its dot (green: it read; amber: it could not), then the short rhythm. */
|
|
77
|
+
function fromHtml(r) {
|
|
78
|
+
const rc = (r.raw && r.raw.recipe) || null, L = liveOf(r), src = (rc && rc.connector) || r.source || '';
|
|
79
|
+
const R = rhythmOf(r);
|
|
80
|
+
if (!src && !R) return '<span class="note">Not set yet</span>';
|
|
81
|
+
const dot = L ? (L.ok === false ? 'risk' : 'ok') : 'q';
|
|
82
|
+
return `<span class="gc-src"><i class="cz-dot ${dot}" aria-hidden="true"></i><b>${esc(src || 'You type it in')}</b></span>${R ? `<span class="note">${esc(R.short)}</span>` : ''}`;
|
|
83
|
+
}
|
|
84
|
+
const nowOf = (r) => { const L = liveOf(r); if (L && L.ok !== false) return L.txt || big(L.value) || r.nowTxt || '—'; if (L && L.ok === false) return '—'; return r.nowTxt || '—'; };
|
|
85
|
+
/** rows: the open metric drafts (okr-list.js draftsOf, kind metric) in the product's groups. o: { busy: Set of row ids, sel: row id }.
|
|
86
|
+
* The header's "read hh:mm" is the time of the newest live read; with none it is "Now". */
|
|
87
|
+
export function tableHtml(rows, o = {}) {
|
|
88
|
+
const R = (rows || []).filter((r) => r && r.kind === 'metric' && r.state === 'open'); if (!R.length) return '';
|
|
89
|
+
const lives = R.map(liveOf).filter((L) => L && L.ok !== false && L.at).map((L) => L.at).sort();
|
|
90
|
+
const t = lives.length ? hm(lives[lives.length - 1]) : '';
|
|
91
|
+
const groups = ['North Star', 'Inputs', 'Guardrails', 'Key results'];
|
|
92
|
+
const by = groups.map((g) => [g, R.filter((r) => r.group === g)]).concat([['', R.filter((r) => !groups.includes(r.group))]]).filter(([, L]) => L.length);
|
|
93
|
+
const busy = o.busy || new Set();
|
|
94
|
+
const row = (r) => {
|
|
95
|
+
const type = (r.raw && TYPE_SAY[r.raw.type]) || '';
|
|
96
|
+
return `<div class="gc-tr${o.sel === r.id ? ' sel' : ''}" role="row" data-gc-row="${esc(r.id)}" tabindex="0" aria-label="${esc('Check ' + r.name)}">`
|
|
97
|
+
+ `<span class="gc-nm" role="cell"><b>${esc(r.name)}</b>${type ? `<span class="gc-type">${esc(type)}</span>` : ''}</span>`
|
|
98
|
+
+ `<span class="gc-hw" role="cell">${esc(countedOf(r)) || '<span class="note">Not written yet</span>'}</span>`
|
|
99
|
+
+ `<span class="gc-now" role="cell"><b>${esc(nowOf(r))}</b></span>`
|
|
100
|
+
+ `<span class="gc-tg" role="cell"><b>${esc(r.targetTxt || '—')}</b></span>`
|
|
101
|
+
+ `<span class="gc-from" role="cell">${fromHtml(r)}</span>`
|
|
102
|
+
+ `<span class="gc-acts" role="cell">${ib({ act: 'drop', row: r.id, icon: I.x, label: 'Not now: ' + r.name, title: 'Not now', busy: busy.has(r.id) })}${ib({ act: 'keep', row: r.id, icon: I.chk, label: 'Keep: ' + r.name, title: 'Keep', solid: false, busy: busy.has(r.id) })}</span></div>`;
|
|
103
|
+
};
|
|
104
|
+
return `<div class="gc-tbl" role="table" aria-label="Proposed metrics"><div class="gc-th" role="row"><span role="columnheader">Proposed metric</span><span role="columnheader">How it is counted</span>`
|
|
105
|
+
+ `<span role="columnheader">Now${t ? ` <span class="note">read ${esc(t)}</span>` : ''}</span><span role="columnheader">Target</span><span role="columnheader">From, how often</span><span role="columnheader"><span class="vh">Not now or keep</span></span></div>`
|
|
106
|
+
+ by.map(([g, L]) => (g ? `<div class="gc-grp" role="row"><span role="cell"><b>${esc(g)}</b> <span class="note">${esc(GROUP_SAY[g] || '')}</span></span></div>` : '') + L.map(row).join('')).join('') + '</div>';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ── the check panel (GcJ1Drafts, GcS3Differs) ─────────────────────────────────────────────────────────────────────────────────── */
|
|
110
|
+
const checkRow = (c) => `<li class="${c.ok ? 'ok' : 'warn'}">${icon(c.ok ? I.chk : I.warn, 14)}<span>${esc(c.text)}</span></li>`;
|
|
111
|
+
const queryHtml = (rc, open) => (rc && rc.query ? `<details class="gc-q"${open ? ' open' : ''}><summary><b>The query</b> <span class="note">${esc([rc.connector, rc.where].filter(Boolean).join(' · '))}</span></summary><pre>${esc(rc.query)}</pre></details>` : '');
|
|
112
|
+
/** The counts as a fraction (GcR3Goal): "1,212 checkouts stopped at login" over "6,000 checkouts reached login", then "= 20.2%, week of 9 Nov".
|
|
113
|
+
* With a reading that failed, the counts are "?" and the result is "not known for this week". */
|
|
114
|
+
function fractionHtml(c, L, unknown) {
|
|
115
|
+
if (!c || !(c.num_label || c.den_label)) return '';
|
|
116
|
+
const n = unknown ? '?' : big(L && L.num), d = unknown ? '?' : big(L && L.den);
|
|
117
|
+
if (!unknown && !(n || d)) return '';
|
|
118
|
+
const res = unknown ? '= not known for this ' + (L && L.period && /^month/.test(L.period) ? 'month' : 'week') : '= ' + (L.txt || big(L.value)) + (L.period ? ', ' + L.period : '');
|
|
119
|
+
return `<div class="gc-frac">${c.num_label ? `<div class="n"><b>${esc(n)}</b><span>${esc(c.num_label)}</span></div>` : ''}${c.den_label ? `<div class="d"><b>${esc(d)}</b><span>${esc(c.den_label)}</span></div>` : ''}<div class="r">${esc(res)}</div></div>`;
|
|
120
|
+
}
|
|
121
|
+
/** st: { compare: the PM's number as typed, busy, msg }. The compare answer lives on the row (raw.compare) once the server has it. */
|
|
122
|
+
export function checkHtml(r, st = {}) {
|
|
123
|
+
const raw = r.raw || {}, L = liveOf(r), c = countsOf(r), rc = raw.recipe || null, R = rhythmOf(r), cmp = raw.compare && fin(raw.compare.value) ? raw.compare : null;
|
|
124
|
+
if (cmp && cmp.state !== 'picked' && !st.back) {
|
|
125
|
+
// GcS3Differs: mine beside yours, how far apart and why, then Claude's suggestion with ✕ / ✓
|
|
126
|
+
const sg = cmp.suggest || null, mine = cmp.oursTxt || (fin(cmp.ours) ? big(cmp.ours) : '') || (L && L.ok !== false ? (L.txt || big(L.value)) : r.nowTxt || '—');
|
|
127
|
+
const close = cmp.state === 'same' || (cmp.differs === false) || (cmp.differs === undefined && fin(cmp.pct) && Math.abs(cmp.pct) <= 2);
|
|
128
|
+
return `<div class="gc-two"><div class="gc-card"><span class="note">Mine</span><b>${esc(mine)}</b><span class="note">${esc(cmp.oursLabel || 'as I count it')}</span></div>`
|
|
129
|
+
+ `<div class="gc-card"><span class="note">${esc(cmp.label || 'Yours')}</span><b>${esc(cmp.txt || big(cmp.value))}</b><span class="note">you typed it</span></div></div>`
|
|
130
|
+
+ (close ? `<p class="gc-say"><b>Within 2%.</b> Your number and mine agree, so I keep counting it this way.</p>`
|
|
131
|
+
: `<p class="gc-say">${cmp.apart ? `<b>${esc(cmp.apart)} apart.</b> ` : ''}${cmp.why ? `<b>I found why:</b> ${esc(cmp.why)}` : 'I am looking for why. It shows here when I know.'}</p>`)
|
|
132
|
+
+ (sg && sg.text && !close ? `<div class="gc-sg"><span class="sp" aria-hidden="true">${icon(I.spark, 16)}</span><p>${esc(sg.text)} I write your pick into “How it is counted”.</p><span class="acts">${ib({ act: 'pick-other', row: r.id, icon: I.x, label: 'No, count it the other way', title: 'No', busy: st.busy })}${ib({ act: 'pick', row: r.id, icon: I.chk, label: 'Yes, count it as you suggest', title: 'Yes', solid: true, busy: st.busy })}</span></div>` : '')
|
|
133
|
+
+ `<p class="note gc-msg" role="status">${esc(st.msg || '')}</p>`;
|
|
134
|
+
}
|
|
135
|
+
const value = L && L.ok !== false ? (L.txt || big(L.value)) : '';
|
|
136
|
+
const head = L && L.ok === false
|
|
137
|
+
? `<div class="gc-warnbox"><b>${esc(atTxt(L.at) + ' · not read')}</b><p>${esc(L.error || 'The source did not answer.')} I did not guess a number.</p></div>`
|
|
138
|
+
: '';
|
|
139
|
+
const box = `<div class="gc-box"><span class="gc-k">How it is counted</span>${c && c.what ? `<p class="gc-what">${esc(c.what)}</p>` : '<p class="note">Not written yet. ✎ says it in your words.</p>'}`
|
|
140
|
+
+ (L && L.ok !== false && (L.num != null || L.den != null) ? fractionHtml(c, L) : '')
|
|
141
|
+
+ (value ? `<p class="gc-big"><b>${esc(value)}</b><span class="note">read ${esc(L.at && Date.now() - Date.parse(L.at) < 15 * 6e4 ? 'just now' : atTxt(L.at))}${L.period ? ', ' + esc(L.period) : ''}</span></p>`
|
|
142
|
+
: !L ? `<p class="note">Not read yet. ↻ reads it now, and nothing is kept until you keep it.</p>` : '') + '</div>';
|
|
143
|
+
const checks = (Array.isArray(raw.checks) ? raw.checks : []).filter((x) => x && x.text);
|
|
144
|
+
const cmpLine = { ok: false, text: 'No other number to compare yet: type yours' };
|
|
145
|
+
const list = checks.concat(cmp ? [] : [cmpLine]);
|
|
146
|
+
return head + box
|
|
147
|
+
+ `<div class="gc-sec"><b class="gc-k">My checks</b><ul class="gc-checks">${list.map(checkRow).join('')}</ul></div>`
|
|
148
|
+
+ `<form class="gc-cmp" data-gc-cmp><input name="v" inputmode="decimal" maxlength="24" autocomplete="off" placeholder="${esc('Your number for ' + (L && L.period ? L.period.replace(/^week of .*/, 'last week') : 'last week') + (value ? ', e.g. ' + value : ''))}" aria-label="Your number, to compare with mine" value="${esc(st.compare || '')}">`
|
|
149
|
+
+ `<button type="submit" class="cz-ib sm solid" aria-label="Compare with my number" title="Compare"${st.busy ? ' disabled' : ''}>${icon(I.chk, 18)}</button></form>`
|
|
150
|
+
+ (R ? `<p class="gc-line"><b>How often</b> ${esc(R.long)}</p>` : '')
|
|
151
|
+
+ queryHtml(rc, false)
|
|
152
|
+
+ `<div class="gc-foot">${rc && rc.url ? `<a class="cz-ib sm" href="${esc(rc.url)}" target="_blank" rel="noopener noreferrer" aria-label="Open in ${esc(rc.connector || 'the source')}" title="Open in ${esc(rc.connector || 'the source')}">${icon(I.open)}</a>` : ''}`
|
|
153
|
+
+ ib({ act: 'edit', row: r.id, icon: I.pen, label: 'Edit how it is counted, the target or the source', title: 'Edit', busy: st.busy })
|
|
154
|
+
+ ib({ act: 'test', row: r.id, icon: I.redo, label: 'Read it now', title: 'Read now', busy: st.busy })
|
|
155
|
+
+ `<span class="gc-sp"></span>${ib({ act: 'keep', row: r.id, icon: I.chk, label: 'Keep', title: 'Keep', solid: true, busy: st.busy })}</div>`
|
|
156
|
+
+ `<p class="note gc-msg" role="status">${esc(st.msg || '')}</p>`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* ── first readings (GcJ2FirstMonday) ──────────────────────────────────────────────────────────────────────────────────────────── */
|
|
160
|
+
const SEEN_UNTIL = 3;
|
|
161
|
+
/** While a goal has fewer than 3 readings: how many, the first one (with its source and time) and when the next one comes. null from the 3rd. */
|
|
162
|
+
export function firstOf(g) {
|
|
163
|
+
const S = (g && g.series) || [], n = S.length;
|
|
164
|
+
// Only goals Claude reads on a rhythm; a goal read by hand keeps its line from the first reading.
|
|
165
|
+
if (!g || !n || n >= SEEN_UNTIL || !g.recipe) return null;
|
|
166
|
+
const last = g.lastRead || null, z = S[n - 1];
|
|
167
|
+
return { n, txt: (last && last.txt) || g.nowTxt || big(z.v), source: (last && last.source) || (g.recipe && g.recipe.connector) || '', at: (last && last.at) || z.at, next: g.nextRead || null };
|
|
168
|
+
}
|
|
169
|
+
/** The row's second line while the line is not drawn yet. */
|
|
170
|
+
export function firstMeta(g) {
|
|
171
|
+
const F = firstOf(g); if (!F) return '';
|
|
172
|
+
return [F.txt, [F.source, atTxt(F.at)].filter(Boolean).join(', '), 'pace known after 3 readings'].filter(Boolean).join(' · ');
|
|
173
|
+
}
|
|
174
|
+
/** Where the chart goes: "The line starts with the 2nd reading, Mon 9 Nov". */
|
|
175
|
+
export function firstChart(g) {
|
|
176
|
+
const F = firstOf(g); if (!F || F.n >= 2) return '';
|
|
177
|
+
return `<div class="gc-wait" role="note">The line starts with the 2nd reading${F.next ? ', ' + esc(dayTxt(F.next)) : ''}</div>`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* ── a key result's panel (GcR3Goal), and its failed (GcR4Failed) and held (GcR5Held) states ───────────────────────────────────────── */
|
|
181
|
+
/** "From Looker, chart “Checkout funnel”, every Monday 07:00. Last Mon 16 Nov, next Mon 23 Nov." The last read and the next one, said once. */
|
|
182
|
+
export function fromLine(g) {
|
|
183
|
+
const rc = g.recipe || null, R = rhythmOf(g), L = g.lastRead || null, F = g.failed || null, H = (g.held || [])[0] || null;
|
|
184
|
+
if (!rc || !rc.connector) return '';
|
|
185
|
+
const lastAt = [L && L.at, F && F.at, H && H.at].filter(Boolean).sort().pop() || (rc.last && rc.last.at) || null;
|
|
186
|
+
const last = lastAt ? 'Last ' + dayTxt(lastAt) + (H && H.at === lastAt ? ' (held)' : '') : '';
|
|
187
|
+
const next = g.nextRead ? 'next ' + dayTxt(g.nextRead) : '';
|
|
188
|
+
return `<p class="gc-fl">From <b>${esc(rc.connector)}</b>${rc.where ? ', ' + esc(rc.where) : ''}${R ? ', ' + esc(R.long) : ''}.${last || next ? ' ' + esc([last, next].filter(Boolean).join(', ')) + '.' : ''}</p>`;
|
|
189
|
+
}
|
|
190
|
+
/** The amber box of a read that failed: the time, the reason, and its one fix (reconnect the source, then Claude reads it at once). */
|
|
191
|
+
function failedHtml(g) {
|
|
192
|
+
const F = g.failed; if (!F) return '';
|
|
193
|
+
const fx = F.fix || {}, src = fx.connector || (g.recipe && g.recipe.connector) || 'the source';
|
|
194
|
+
return `<div class="gc-warnbox" data-gc-failed><b>${esc(atTxt(F.at) + ' · not read')}</b><p>${esc(F.why || 'The source did not answer.')} I did not guess a number.</p>`
|
|
195
|
+
+ `<div class="gc-fix"><b>Reconnect ${esc(src)}, then I read it at once</b>${ib({ act: 'reconnect', row: fx.row || '', icon: I.plug, label: 'Reconnect ' + src, title: 'Reconnect', solid: true })}</div></div>`;
|
|
196
|
+
}
|
|
197
|
+
/** The amber box of a held reading: the time, the value it read, why it was held, its checks, the drafted Jira ticket (✎, ✓ send it) and ✓✓ file it
|
|
198
|
+
* anyway. ticket: the drafted ticket row (okr-list.js draftsOf) when the goal's held reading names one. */
|
|
199
|
+
function heldHtml(g, ticket) {
|
|
200
|
+
const H = (g.held || [])[0]; if (!H) return '';
|
|
201
|
+
// say it once: a check whose words are already the why is not listed again
|
|
202
|
+
const checks = (H.checks || []).filter((c) => c && c.text && !String(H.why || '').includes(c.text));
|
|
203
|
+
const tk = ticket && ticket.state === 'open' ? `<div class="gc-fix"><b>I drafted a Jira ticket: “${esc((ticket.raw && ticket.raw.ticket && ticket.raw.ticket.title) || ticket.text)}”</b><span class="acts"><button type="button" class="cz-ib sm" data-okd="edit" data-row="${esc(ticket.id)}" aria-label="Edit the ticket" title="Edit">${icon(I.pen)}</button><button type="button" class="cz-ib sm solid" data-okd="keep" data-row="${esc(ticket.id)}" aria-label="Send the ticket to Jira" title="Send to Jira">${icon(I.chk, 18)}</button></span></div>` : '';
|
|
204
|
+
return `<div class="gc-warnbox" data-gc-held><b>${esc(dayTxt(H.at) + (H.txt || fin(H.value) ? ' · read ' + (H.txt || big(H.value)) : '') + ' · held')}</b>${H.why ? `<p>${esc(H.why)}</p>` : ''}`
|
|
205
|
+
+ (checks.length ? `<ul class="gc-checks">${checks.map(checkRow).join('')}</ul>` : '') + tk
|
|
206
|
+
+ `<div class="gc-file">${ib({ act: 'file-held', row: H.at, icon: I.checks, label: 'It is right: file it as a reading', title: 'File it' })}</div></div>`;
|
|
207
|
+
}
|
|
208
|
+
/** The key result's panel body above its chart: the failed or held box, How it is counted with its counts, From … (said once), Last read with its
|
|
209
|
+
* checks, and the query. o: { ticket: the held reading's drafted ticket row }. '' when the goal has none of these fields. */
|
|
210
|
+
export function krHtml(g, o = {}) {
|
|
211
|
+
const c = countsOf(g), L = g.lastRead || null, failed = !!g.failed;
|
|
212
|
+
const frac = fractionHtml(c, L || {}, failed);
|
|
213
|
+
const box = c && (c.what || frac) ? `<div class="gc-box"><span class="gc-k">How it is counted</span>${frac || `<p class="gc-what">${esc(c.what)}</p>`}${frac && c.what ? `<p class="note">${esc(c.what)}</p>` : ''}</div>` : '';
|
|
214
|
+
const checks = (g.checks || []).filter((x) => x && x.text);
|
|
215
|
+
// a goal read by hand says when in its head line already; the last read is said here only for a goal Claude reads
|
|
216
|
+
const last = L && g.recipe && !failed && !(g.held || []).length ? `<div class="gc-sec"><p class="gc-line"><b>Last read</b> ${esc(atTxt(L.at))}</p>${checks.length ? `<ul class="gc-checks">${checks.map(checkRow).join('')}</ul>` : ''}</div>` : '';
|
|
217
|
+
const out = failedHtml(g) + heldHtml(g, o.ticket) + box + fromLine(g) + last + (failed ? '' : queryHtml(g.recipe, true));
|
|
218
|
+
return out ? `<div class="gc-kr">${out}</div>` : '';
|
|
219
|
+
}
|
|
220
|
+
/** The big number of a goal whose last reading was not good: the last good one, and from when (GcR4Failed, GcR5Held). */
|
|
221
|
+
export function lastGoodSay(g) {
|
|
222
|
+
if (!(g.failed || (g.held || []).length)) return '';
|
|
223
|
+
const L = g.lastRead; return L && L.at ? (g.failed ? 'from ' + dayTxt(L.at) + ', the last good reading' : 'the last good reading, ' + dayTxt(L.at)) : '';
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* ── the ✦ line ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
227
|
+
/** The news a reading brings, before the ordinary line: a held reading, then a failed read, then the first readings. null when none applies. */
|
|
228
|
+
export function lineOf(goals, product) {
|
|
229
|
+
const G = (goals || []).filter(Boolean);
|
|
230
|
+
const held = G.filter((g) => (g.held || []).length);
|
|
231
|
+
if (held.length) {
|
|
232
|
+
const g = held[0], H = g.held[0], role = g.role === 'north-star' ? 'the North Star' : g.title;
|
|
233
|
+
return { head: 'I held back one reading of ' + role + '.', sub: (H.short || (H.why ? String(H.why).split('. ')[0] : 'It did not pass my checks')).replace(/\.?$/, '.') + ' Check it in the side panel.', tone: 'behind', goal: g.id };
|
|
234
|
+
}
|
|
235
|
+
const failed = G.filter((g) => g.failed);
|
|
236
|
+
if (failed.length) {
|
|
237
|
+
const g = failed[0], F = g.failed, src = (F.fix && F.fix.connector) || (g.recipe && g.recipe.connector) || 'The source';
|
|
238
|
+
const d = when(F.at);
|
|
239
|
+
return { head: 'I couldn’t read ' + g.title + (d ? ' on ' + WD[d.getDay()] : '') + '.', sub: String(F.short || F.why || src + ' did not answer').replace(/\.?$/, '.') + ' Reconnect it and I read it straight away.', tone: 'behind', goal: g.id };
|
|
240
|
+
}
|
|
241
|
+
const read = G.filter((g) => (g.series || []).length);
|
|
242
|
+
if (read.length && read.every((g) => g.series.length === 1)) {
|
|
243
|
+
const hourly = read.filter((g) => { const r = g.recipe; return r && r.cadence === 'hourly'; });
|
|
244
|
+
const next = read.map((g) => g.nextRead).filter(Boolean).sort().pop();
|
|
245
|
+
return { head: 'The first readings are in' + (read.length === G.length ? ', all ' + G.length + ' goals.' : ', ' + read.length + ' of ' + G.length + ' goals.'),
|
|
246
|
+
sub: 'One reading is a starting point, not a trend.' + (hourly.length ? ' ' + hourly[0].title + ' reads every hour, so its line starts today' + (next ? '; the others from ' + dayTxt(next) : '') + '.' : next ? ' The lines start with the 2nd reading, ' + dayTxt(next) + '.' : ''), tone: 'calm' };
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
/** A drafted-metrics ✦ line (GcJ1aTable): "I drafted a North Star, 3 inputs and 2 guardrails for pmos-idpf." */
|
|
251
|
+
export function draftsLine(rows, product) {
|
|
252
|
+
const R = (rows || []).filter((r) => r && r.kind === 'metric' && r.state === 'open'); if (!R.length) return null;
|
|
253
|
+
const n = (g) => R.filter((r) => r.group === g).length;
|
|
254
|
+
const parts = [n('North Star') ? 'a North Star' : '', n('Inputs') ? n('Inputs') + (n('Inputs') === 1 ? ' input' : ' inputs') : '', n('Guardrails') ? n('Guardrails') + (n('Guardrails') === 1 ? ' guardrail' : ' guardrails') : '', n('Key results') ? n('Key results') + (n('Key results') === 1 ? ' key result' : ' key results') : ''].filter(Boolean);
|
|
255
|
+
const list = parts.length > 1 ? parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1] : parts[0] || R.length + ' metrics';
|
|
256
|
+
return { head: 'I drafted ' + list + (product ? ' for ' + product : '') + '.', sub: 'Keep them and I read each one on its own rhythm, first reading within the hour. Tap a row to check it.', tone: 'drafts', keepAll: R.length > 1 ? R.length : 0 };
|
|
257
|
+
}
|
|
258
|
+
export { dotHtml };
|
|
@@ -304,8 +304,10 @@ function homeListHtml() {
|
|
|
304
304
|
const R = L.reviewModel(S.D, NOW());
|
|
305
305
|
// a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
|
|
306
306
|
const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1);
|
|
307
|
+
const sel = S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null);
|
|
308
|
+
S.lo = { sel, ses: S.ses, restOpen: (k) => S.rest.has(k), pin: S.pin, phone: false }; // the folded rail's card draws Home's rows with these
|
|
307
309
|
return TD.listHtml(M, todayModel(), {
|
|
308
|
-
sel: S.
|
|
310
|
+
sel, selHead: S.head, ses: S.ses, pOpen, here: isPhone() ? null : TD.groupOfOpen(M, sel) || S.head, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
|
|
309
311
|
pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) + (S.impact ? IMP.rowHtml(S.impact.c, { esc, sel: S.sel === 'impact' }) : '') : '',
|
|
310
312
|
imFace: IM.faceHtml(S.im, { joy: S.imJoy }),
|
|
311
313
|
});
|
|
@@ -588,8 +590,41 @@ function drawList() {
|
|
|
588
590
|
if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
|
|
589
591
|
document.body.classList.toggle('hm-folded', S.folded && !isPhone());
|
|
590
592
|
document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
|
|
593
|
+
drawRailCard();
|
|
591
594
|
drawRecTop();
|
|
592
595
|
}
|
|
596
|
+
/* ── the folded rail's card (batch 18 item 14, FlA1–FlA5) ──
|
|
597
|
+
* With the Viewer wide, Home's list folds to a rail of group tiles (cozy-viewer.js). A tile's press opens a card beside it with that group's
|
|
598
|
+
* rows, Home's own (iniHtml): a row opens as on Home and the card closes, the rail and the Viewer's width stay; the pill lists the sessions
|
|
599
|
+
* in place. A second press on the tile, ×, Escape or a press outside closes it. The card sits in the rail, inside #hmList, so the list's
|
|
600
|
+
* own presses work in it. S.rc: the group whose card is open. */
|
|
601
|
+
function drawRailCard() {
|
|
602
|
+
const bar = $('#hmList > .cz-vw-railbar');
|
|
603
|
+
if (!bar || isPhone() || !VW.railOn() || !S.M || !S.M.groups.some((g) => g.key === S.rc)) S.rc = null;
|
|
604
|
+
let card = bar && bar.querySelector(':scope > .hv-rc');
|
|
605
|
+
if (!S.rc) { if (card) card.remove(); VW.railSync(null); return; }
|
|
606
|
+
if (!card) { card = document.createElement('div'); card.className = 'hv-rc'; card.setAttribute('role', 'dialog'); card.setAttribute('data-esc-layer', ''); bar.append(card); }
|
|
607
|
+
const g = S.M.groups.find((x) => x.key === S.rc);
|
|
608
|
+
card.setAttribute('aria-label', g.name);
|
|
609
|
+
const html = TD.railCardHtml(S.M, S.rc, S.lo);
|
|
610
|
+
if (card.__h !== html) { card.__h = html; card.innerHTML = html; }
|
|
611
|
+
VW.railSync(S.rc);
|
|
612
|
+
// beside the tile, its top with the tile's, kept inside the window
|
|
613
|
+
const t = bar.querySelector(`[data-cz-vw-rail="${CSS.escape(S.rc)}"]`);
|
|
614
|
+
if (!t) return;
|
|
615
|
+
const r = t.getBoundingClientRect();
|
|
616
|
+
card.style.left = Math.round(r.right + 12) + 'px';
|
|
617
|
+
card.style.top = Math.round(Math.max(12, Math.min(r.top - 10, innerHeight - card.offsetHeight - 12))) + 'px';
|
|
618
|
+
}
|
|
619
|
+
function railCard(key, o = {}) {
|
|
620
|
+
const was = S.rc;
|
|
621
|
+
S.rc = key || null; S.ses = null;
|
|
622
|
+
drawList();
|
|
623
|
+
if (S.rc) { const f = $('#hmList .hv-rc .hv-rcb .hm-rm, #hmList .hv-rc .hv-rcb .hv-fold'); if (f && o.focus !== false) f.focus({ preventScroll: true }); return; }
|
|
624
|
+
const t = was && o.back && $(`#hmList [data-cz-vw-rail="${CSS.escape(was)}"]`); if (t) t.focus();
|
|
625
|
+
}
|
|
626
|
+
VW.railCard((key) => railCard(S.rc === key ? null : key, { back: true }));
|
|
627
|
+
document.addEventListener('cz:vw-rail', (e) => { if (!e.detail.on && S.rc) S.rc = null; });
|
|
593
628
|
/* A phone chat has no floating menu, so while a meeting records its pill sits in the top bar (XcbOptions B, case 7): a red dot and the
|
|
594
629
|
* clock (home-rec-row.js ticks every [data-hr-clock]); a press opens the live meeting in place. No recording: no pill. */
|
|
595
630
|
function drawRecTop() {
|
|
@@ -1683,11 +1718,14 @@ $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(
|
|
|
1683
1718
|
$('#hmList').onclick = (e) => { // delegated: every press on the list is a <button>
|
|
1684
1719
|
const b = e.target.closest('button'); if (!b) return;
|
|
1685
1720
|
const d = b.dataset;
|
|
1721
|
+
if ('hmRcx' in d) { railCard(null, { back: true }); return; } // × on the folded rail's card
|
|
1722
|
+
// a pick in the rail's card: the card closes, the rail stays folded and the Viewer as wide (FlA4After)
|
|
1723
|
+
if (S.rc && b.closest('.hv-rc') && (d.hmSel || d.hmProg || d.hmProdopen || d.hmSesnew)) { S.rc = null; S.ses = null; VW.keepWide(); }
|
|
1686
1724
|
if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
|
|
1687
1725
|
if ('hmSesx' in d) { sesPill(null); return; }
|
|
1688
1726
|
if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
|
|
1689
1727
|
if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
|
|
1690
|
-
if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
|
|
1728
|
+
if (S.ses && !b.closest('.hv-spp, .hv-sps, .hv-rcs')) sesPill(null, false); // a press anywhere else in the list closes it
|
|
1691
1729
|
if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
|
|
1692
1730
|
if ('hrImpact' in d) { if (S.day) S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; } // Your impact: Home's own chat, on the weekly check
|
|
1693
1731
|
if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
|
|
@@ -1737,13 +1775,23 @@ function sesPill(id, back = true) {
|
|
|
1737
1775
|
const was = S.ses;
|
|
1738
1776
|
S.ses = id || null;
|
|
1739
1777
|
drawList();
|
|
1740
|
-
const f = id ? $('#hmList .hv-spp .hm-rm, #hmList .hv-sps .hm-rm') : back && was ? $(`#hmList [data-hm-ses="${CSS.escape(was)}"]`) : null;
|
|
1778
|
+
const f = id ? $('#hmList .hv-spp .hm-rm, #hmList .hv-sps .hm-rm, #hmList .hv-rcs .hm-rm') : back && was ? $(`#hmList [data-hm-ses="${CSS.escape(was)}"]`) : null;
|
|
1741
1779
|
if (f) f.focus();
|
|
1742
1780
|
}
|
|
1743
1781
|
// Escape closes it wherever the focus is (a redraw of the list can drop the focus to the page); a press outside the list closes it too
|
|
1744
1782
|
window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.ses && menuEl.hidden) { e.preventDefault(); e.stopPropagation(); sesPill(null); } }, true); // before the Viewer's own Escape
|
|
1745
1783
|
// a press outside the list (the chat, the Viewer) closes an open pill list too
|
|
1746
1784
|
document.addEventListener('pointerdown', (e) => { if (S.ses && !e.target.closest('#hmList')) sesPill(null, false); });
|
|
1785
|
+
// the rail's card: Escape closes it (after an open pill list) and gives the focus back to its tile; a press outside it closes it
|
|
1786
|
+
window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.rc && !e.defaultPrevented && menuEl.hidden) { e.preventDefault(); e.stopPropagation(); railCard(null, { back: true }); } }, true);
|
|
1787
|
+
document.addEventListener('pointerdown', (e) => { if (S.rc && !e.target.closest('.hv-rc, .cz-vw-railtile')) railCard(null); });
|
|
1788
|
+
// arrows move between the card's rows
|
|
1789
|
+
$('#hmList').addEventListener('keydown', (e) => {
|
|
1790
|
+
if ((e.key !== 'ArrowDown' && e.key !== 'ArrowUp') || !e.target.closest('.hv-rc')) return;
|
|
1791
|
+
const all = [...document.querySelectorAll('#hmList .hv-rc .hv-rcb .hm-rm, #hmList .hv-rc .hv-rcb .hv-fold, #hmList .hv-rc .hv-rcb [data-hm-sesnew]')];
|
|
1792
|
+
const i = all.indexOf(e.target.closest('button')); if (!all.length) return;
|
|
1793
|
+
e.preventDefault(); all[Math.max(0, Math.min(all.length - 1, i < 0 ? 0 : i + (e.key === 'ArrowDown' ? 1 : -1)))].focus();
|
|
1794
|
+
});
|
|
1747
1795
|
$('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
|
|
1748
1796
|
if (e.target.id !== 'hmCapF') return;
|
|
1749
1797
|
e.preventDefault();
|
|
@@ -147,10 +147,11 @@ export function sesSheetHtml(M, o) {
|
|
|
147
147
|
* the pill lists what is in it. On a desktop the list opens right under the pill; on a phone it is a sheet (sesSheetHtml). */
|
|
148
148
|
function iniHtml(r, o, po) {
|
|
149
149
|
const on = o.ses === sesKey(r, o) && !o.phone && r.kids.length;
|
|
150
|
-
|
|
150
|
+
// in the folded rail's card (batch 18 item 14, FlA2) the sessions open in place under the row, inside the card
|
|
151
|
+
const pop = !on ? '' : o.card ? `<div class="hv-rcs" role="group" aria-label="In ${esc(r.name)}">${sesListHtml(r, o)}</div>` : `<div class="hv-spp" data-esc-layer role="dialog" aria-label="In ${esc(r.name)}">${sesListHtml(r, o)}</div>`;
|
|
151
152
|
const t = track(r.at, r.stage, r.steps);
|
|
152
153
|
return `<div class="hm-r hv-r ini st-${esc(r.state)}${o.sel === r.id ? ' sel' : ''}${on ? ' sp-on' : ''}" data-id="${esc(r.id)}"${po ? ` data-po-id="${esc(r.ini || r.id)}"` : ''}>${po ? gripHtml(r.name) : ''}<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${o.sel === r.id ? ' aria-current="true"' : ''} title="${esc(r.hint)}">${markHtml(r.yours && r.state !== 'blocked' ? { state: 'needs' } : r)}`
|
|
153
|
-
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span></button>${pillHtml(r, o)}${t ? `<button type="button" class="hv-tk" data-hm-sel="${esc(r.id)}" tabindex="-1" aria-hidden="true">${t}</button>` : ''}${pop}</div
|
|
154
|
+
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span></button>${pillHtml(r, o)}${t ? `<button type="button" class="hv-tk" data-hm-sel="${esc(r.id)}" tabindex="-1" aria-hidden="true">${t}</button>` : ''}${o.card ? '' : pop}</div>${o.card ? pop : ''}`;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/* ── a group (HvAC .pg, .card; PgHomePhone .psub) ── */
|
|
@@ -163,10 +164,15 @@ function productHtml(g, o) {
|
|
|
163
164
|
const say = [g.name, open ? (g.goals && g.goals.n ? g.goals.text : '') : [plural(g.count, 'initiative', 'initiatives'), yoursWords(g)].filter(Boolean).join(', ')].filter(Boolean).join(', ');
|
|
164
165
|
// the name opens the product in the Viewer, with its own chat; the rest of the header folds the group (canvas HbCProduct)
|
|
165
166
|
const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
|
|
166
|
-
+ `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
|
|
167
|
+
+ `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
|
|
167
168
|
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(say)}. ${open ? 'Close' : 'Open'} the group">${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
|
|
168
169
|
const sec = `<section class="hm-pg hv-g" aria-label="${esc(g.name)}" data-po-id="${esc(prodKey(g.name))}">${SO.gripHtml(g.name)}`;
|
|
169
170
|
if (!open) return `${sec}${head}</section>`;
|
|
171
|
+
return `${sec}${head}<div class="hv-card">${productBody(g, o, true)}</div></section>`;
|
|
172
|
+
}
|
|
173
|
+
/** A product's rows: its tasks, its initiatives with the quiet ones folded to "N more", the open one always shown. po: the grip arranges
|
|
174
|
+
* them (the list); the folded rail's card shows the same rows without it. */
|
|
175
|
+
function productBody(g, o, po) {
|
|
170
176
|
const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
|
|
171
177
|
const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
|
|
172
178
|
const QUIET = 3;
|
|
@@ -175,10 +181,11 @@ function productHtml(g, o) {
|
|
|
175
181
|
const rest = restAll ? g.rest : g.rest.filter((r, i) => i < Math.max(0, QUIET - g.inis.length) || r.id === o.sel);
|
|
176
182
|
const more = g.rest.length - rest.length;
|
|
177
183
|
// the product's initiatives are one list the grip arranges, shared with the Board (batch 14 item 8)
|
|
178
|
-
const
|
|
184
|
+
const inis = g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key }, po)).join('');
|
|
185
|
+
const body = flat + (po ? `<div class="po-list" data-po-list="@${esc(prodKey(g.name))}">${inis}</div>` : inis)
|
|
179
186
|
+ (more > 0 ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="false" aria-label="${more} more ${more === 1 ? 'initiative' : 'initiatives'} with nothing today. Show"><span class="hv-mk"></span>${more} more${svg(P.chevD, 16)}</button>`
|
|
180
187
|
: restAll && g.rest.length > QUIET ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="true"><span class="hv-mk"></span>Fewer${svg(P.chevU, 16)}</button>` : '');
|
|
181
|
-
return
|
|
188
|
+
return g.inis.length + rest.length + g.flat.length ? body : `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`;
|
|
182
189
|
}
|
|
183
190
|
/** A program's group (canvas PgHomePhone, PgHomeDesk): above the products. Its header: the program tile, the name, the next milestone's
|
|
184
191
|
* diamond with its date and one small diamond per initiative it waits on (filled when that initiative is past the Deliver milestone), a chevron.
|
|
@@ -188,21 +195,55 @@ function productHtml(g, o) {
|
|
|
188
195
|
function programHtml(g, o) {
|
|
189
196
|
const open = o.pOpen(g);
|
|
190
197
|
const nx = g.st && g.st.next;
|
|
191
|
-
const ms =
|
|
192
|
-
|
|
198
|
+
const ms = msHtml(g);
|
|
199
|
+
const line = nx ? 'Next milestone ' + nx.name + (nx.day ? ', ' + nx.day : '') + (nx.late ? ', late' : '') + (nx.n ? ', ' + nx.ready + ' of ' + nx.n + (nx.n === 1 ? ' initiative' : ' initiatives') + ' ready' : '') : 'No open milestone';
|
|
193
200
|
const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
|
|
194
|
-
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
201
|
+
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
195
202
|
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
|
|
196
203
|
const sec = `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}" data-po-id="g:${esc(g.program.id)}">${SO.gripHtml(g.name)}`;
|
|
197
204
|
if (!open) return `${sec}${head}</section>`;
|
|
198
205
|
// the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
|
|
199
206
|
// a product's sub-heading only when the program's rows on Home come from two or more products (batch 12 item 6): one product repeated
|
|
200
207
|
// under every program said nothing
|
|
208
|
+
return `${sec}${head}<div class="hv-card">${programBody(g, o, true)}</div></section>`;
|
|
209
|
+
}
|
|
210
|
+
/** The next milestone in a program's header: its diamond and date, then one small diamond per initiative it waits on. */
|
|
211
|
+
function msHtml(g) {
|
|
212
|
+
const nx = g.st && g.st.next;
|
|
213
|
+
return nx ? `<span class="hv-msd${nx.late ? ' late' : ''}"><span class="hv-dm"></span>${esc(nx.day || nx.name)}${nx.n ? `<span class="hv-rd">${Array.from({ length: nx.n }, (_, i) => `<i${i < nx.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : ''}</span>` : '';
|
|
214
|
+
}
|
|
215
|
+
/** A program's rows: its milestone row first, then its initiatives, under a product sub-heading when they come from two or more products. */
|
|
216
|
+
function programBody(g, o, po) {
|
|
201
217
|
const many = g.subs.length > 1;
|
|
202
|
-
const body = g.subs.map((x) => `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}
|
|
218
|
+
const body = g.subs.map((x) => { const inis = x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, po)).join(''); return `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}${po ? `<div class="po-list" data-po-list="${esc(g.program.id)}">${inis}</div>` : inis}`; }).join('');
|
|
203
219
|
// the program's milestone changes that wait on the PM lead its card (batch 14 item 4: they were only in Your day, which a desktop no longer has)
|
|
204
220
|
const msr = g.msRow ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
|
|
205
|
-
return
|
|
221
|
+
return msr + (body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`);
|
|
222
|
+
}
|
|
223
|
+
/** Which group holds what is open (o.sel: a row id, or 'i:<initiative>'): the folded rail marks that group's tile (batch 18 item 14, FlA4After).
|
|
224
|
+
* Nothing in a group is open: null. */
|
|
225
|
+
export function groupOfOpen(M, sel) {
|
|
226
|
+
if (!M || !sel) return null;
|
|
227
|
+
const hit = (r) => r && (r.id === sel || (r.kids || []).some((k) => k.id === sel));
|
|
228
|
+
for (const g of M.groups || []) {
|
|
229
|
+
if (g.kind === 'loose') continue;
|
|
230
|
+
const rows = g.kind === 'program' ? [g.msRow].concat(...(g.subs || []).map((x) => x.inis)) : (g.flat || []).concat(g.inis || [], g.rest || []);
|
|
231
|
+
if (rows.some(hit)) return g.key;
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
/** The folded rail's card (batch 18 item 14, FlA1–FlA5): a group's tile, name and › (opens the program or product), a program's next
|
|
236
|
+
* milestone, ×; then Home's own rows for that group (the quiet ones folded, the open one shown), the pill's sessions in place. */
|
|
237
|
+
export function railCardHtml(M, key, o) {
|
|
238
|
+
const g = M && (M.groups || []).find((x) => x.key === key && x.kind !== 'loose');
|
|
239
|
+
if (!g) return '';
|
|
240
|
+
const prog = g.kind === 'program';
|
|
241
|
+
const tile = prog ? `<span class="hv-tl tp" aria-hidden="true">${svg(P.layers, 16)}</span>` : `<span class="hv-tl t${g.tone}" aria-hidden="true">${esc(g.initials)}</span>`;
|
|
242
|
+
const go = prog ? `data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"` : `data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"`;
|
|
243
|
+
const oc = { ...o, card: true };
|
|
244
|
+
return `<div class="hv-rch"><button type="button" class="hv-pt" ${go}>${tile}<b>${esc(g.name)}</b>${svg(P.chevR, 16)}</button>${prog ? msHtml(g) : ''}`
|
|
245
|
+
+ `<button type="button" class="ut-ib hv-ib" data-hm-rcx aria-label="Close" title="Close">${svg(P.x, 18)}</button></div>`
|
|
246
|
+
+ `<div class="hv-rcb">${prog ? programBody(g, oc, false) : productBody(g, oc, false)}</div>`;
|
|
206
247
|
}
|
|
207
248
|
/** "Not in an initiative" (HvAC .lh): a line under the groups. Folded it shows a blue dot when a row waits on you, an amber square when one
|
|
208
249
|
* of your own is late, and the count; open, the rows in a card. */
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* place, set), POST /api/jira/draft; reads: GET /api/initiative-layout, GET /api/jira/tickets. Every write is the PM's press, file mode. */
|
|
19
19
|
import { pmGet, pmPost } from './http.js';
|
|
20
20
|
import * as VW from './cozy-viewer.js';
|
|
21
|
-
import { groupBy, groupSections, GROUP_BY } from './ini-view-model.js';
|
|
21
|
+
import { groupBy, groupSections, GROUP_BY, linkRows, bodyOf } from './ini-view-model.js';
|
|
22
22
|
import { readLine } from './tk-model.js';
|
|
23
23
|
|
|
24
24
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -75,9 +75,15 @@ export function attach(body, H) {
|
|
|
75
75
|
const byOf = (id) => groupBy(LAY.get(id), TK.get(id));
|
|
76
76
|
|
|
77
77
|
/* ── the view ── */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
/** The tickets the drafted ones put in Jira, with their Jira status: a task whose title names one is linked to it (ini-view-model.js linkRows). */
|
|
79
|
+
const inJiraOf = (id) => { const T = TK.get(id); return T && T.ok === true ? (T.tickets || []).filter((t) => t && t.inJira && t.key).map((t) => ({ key: t.key, status: (t.jira && t.jira.status) || (t.jira && t.jira.category === 'done' ? 'Done' : t.jira && t.jira.category === 'doing' ? 'In progress' : 'To do') })) : []; };
|
|
80
|
+
// a row linked here takes Jira's status, so the section is split into open and done again
|
|
81
|
+
const relink = (S, tk) => S.map((s) => (s.stages ? { ...s, stages: relink(s.stages, tk) }
|
|
82
|
+
: s.top ? { ...s, ...bodyOf(linkRows([...s.top, ...(s.groups || []).flatMap((g) => g.rows), ...(s.done || [])], tk), linkRows(s.archived || [], tk)) } : s));
|
|
83
|
+
export function view(v0) {
|
|
84
|
+
const id = v0 && v0.id;
|
|
85
|
+
if (!idOk(id) || !v0.tasks || v0.tasks.empty) return v0;
|
|
86
|
+
const tk = inJiraOf(id), v = tk.length ? { ...v0, tasks: { ...v0.tasks, sections: relink(v0.tasks.sections || [], tk) } } : v0;
|
|
81
87
|
const by = byOf(id);
|
|
82
88
|
if (by === 'stage') return { ...v, tasks: { ...v.tasks, by } };
|
|
83
89
|
const f = ONLY.get(id), keep = f ? stagesOf(v.tasks.sections || [], f.key) : null;
|
|
@@ -103,7 +109,7 @@ export function headHtml(v) {
|
|
|
103
109
|
* (→ the write's promise), more(anchor) the full menu (Epic, Your groups, the sets, New group) under the view button. */
|
|
104
110
|
export function api(root, H) {
|
|
105
111
|
const id = root && root.dataset.iv;
|
|
106
|
-
return { ok: idOk(id), by: () => byOf(id), label: () => GROUP_BY[byOf(id)] || 'Stage', set: (k) => (byOf(id) === k ? null : lay(id, H, { kind: 'by',
|
|
112
|
+
return { ok: idOk(id), by: () => byOf(id), label: () => GROUP_BY[byOf(id)] || 'Stage', set: (k) => (byOf(id) === k ? null : lay(id, H, { kind: 'by', grouping: k })), more: (a) => groupMenu(a, id, H) };
|
|
107
113
|
}
|
|
108
114
|
export function sumHtml(v) {
|
|
109
115
|
const s = v && v.tasks && v.tasks.gsum; if (!s) return '';
|
|
@@ -192,11 +198,11 @@ function groupMenu(b, id, H) {
|
|
|
192
198
|
const epics = T && T.ok === true ? new Set((T.tickets || []).map((t) => t.epic || '')).size : 0;
|
|
193
199
|
const same = (n) => n.join('|').toLowerCase() === names.join('|').toLowerCase();
|
|
194
200
|
const sets = L.sets || [];
|
|
195
|
-
const newGroup = { label: 'New group', icon: P.plus, keep: true, go: (a) => ask(a, 'Name the group', '', async (v) => { if (await lay(id, H, { kind: 'groups', names: names.concat(v) })) if (by !== 'mine') lay(id, H, { kind: 'by',
|
|
201
|
+
const newGroup = { label: 'New group', icon: P.plus, keep: true, go: (a) => ask(a, 'Name the group', '', async (v) => { if (await lay(id, H, { kind: 'groups', names: names.concat(v) })) if (by !== 'mine') lay(id, H, { kind: 'by', grouping: 'mine' }); }) };
|
|
196
202
|
menu(b, [{ head: 'Group by' }, ...Object.entries(GROUP_BY).map(([k, l]) => ({ label: l, radio: true, on: by === k,
|
|
197
|
-
sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by',
|
|
203
|
+
sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by', grouping: k }) })),
|
|
198
204
|
{ hr: true }, ...(sets.length ? [{ head: 'Your group sets' }] : []),
|
|
199
|
-
...sets.map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : '', go: async () => { if (await lay(id, H, { kind: 'groups', names: s.names })) if (by !== 'mine') lay(id, H, { kind: 'by',
|
|
205
|
+
...sets.map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : '', go: async () => { if (await lay(id, H, { kind: 'groups', names: s.names })) if (by !== 'mine') lay(id, H, { kind: 'by', grouping: 'mine' }); } })),
|
|
200
206
|
...(names.length && !sets.some((s) => same(s.names)) ? [{ label: 'Save these groups as a set', icon: P.plus, go: () => lay(id, H, { kind: 'set', name: names.join(' · '), names }) }] : []),
|
|
201
207
|
newGroup], 'Group tasks by');
|
|
202
208
|
}
|