create-pmos 0.442.0 → 0.444.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/state/discoveries.md +1 -1
- package/workspace/briefing-premium-board-test.js +8 -2
- package/workspace/briefing-premium-insights-test.js +40 -38
- package/workspace/briefing-premium-test.js +2 -1
- package/workspace/changelog.json +24 -0
- package/workspace/goals-clear-ui-test.js +263 -0
- package/workspace/guide/home.md +12 -2
- package/workspace/guide/metric-drafts.md +8 -2
- package/workspace/home-railcard-test.js +193 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +16 -14
- package/workspace/lib/board-premium.js +1 -1
- package/workspace/lib/engine/boards.js +9 -2
- 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-boards.js +40 -1
- 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/live-pill-round-test.js +178 -0
- package/workspace/metric-drafts-ui-test.js +5 -2
- package/workspace/okr-goals-ui-test.js +27 -23
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +231 -0
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-item-test.js +10 -2
- package/workspace/premium-vw-jira-test.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/cozy-adler.js +21 -0
- package/workspace/public/pm/cozy-divider.css +32 -0
- package/workspace/public/pm/cozy-divider.js +45 -0
- package/workspace/public/pm/cozy-insights.css +96 -0
- package/workspace/public/pm/cozy-live-pill.css +16 -17
- package/workspace/public/pm/cozy-live-pill.js +28 -17
- package/workspace/public/pm/cozy-panels.css +59 -0
- package/workspace/public/pm/cozy-panels.js +524 -0
- package/workspace/public/pm/cozy-today.css +15 -0
- package/workspace/public/pm/cozy-viewer.js +173 -69
- package/workspace/public/pm/cozy-vw-shell.css +4 -0
- package/workspace/public/pm/goals-clear.js +265 -0
- package/workspace/public/pm/home-app.js +73 -14
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/home-today.js +55 -12
- package/workspace/public/pm/ini-edit.js +401 -0
- package/workspace/public/pm/ini-groups.js +14 -8
- package/workspace/public/pm/ini-tasks.js +84 -26
- package/workspace/public/pm/ini-versions.js +18 -4
- package/workspace/public/pm/ini-view-model.js +45 -18
- package/workspace/public/pm/ini-view.css +117 -5
- package/workspace/public/pm/ini-view.js +51 -17
- package/workspace/public/pm/metric-drafts.js +4 -1
- package/workspace/public/pm/mission.js +11 -7
- package/workspace/public/pm/premium-board.js +8 -6
- package/workspace/public/pm/premium-insights.js +375 -59
- package/workspace/public/pm/task-card.css +2 -0
- package/workspace/public/pm/task-card.js +4 -1
- package/workspace/server.js +6 -2
- package/workspace/skills/metric-read.skill +7 -5
- package/workspace/stage-card-tasks-test.js +396 -0
- package/workspace/stage-card-test.js +12 -4
- package/workspace/task-delete-test.js +9 -1
- package/workspace/task-milestones-test.js +3 -3
- package/workspace/task-press-test.js +12 -4
- package/workspace/task-views-test.js +198 -5
- package/workspace/test-lists/batch18-live-pill-round.json +10 -0
- package/workspace/test-lists/batch18-panels.json +9 -0
- package/workspace/test-lists/goals-clear.json +15 -0
- package/workspace/test-lists/home-railcard.json +9 -0
- package/workspace/test-lists/stage-card-tasks.json +6 -0
- package/workspace/tk-tasks-test.js +2 -2
|
@@ -39,6 +39,7 @@ import * as AD from './cozy-adler.js'; // Adler in Claude's ✦ line only, nev
|
|
|
39
39
|
import * as RL from './ready-lib.js'; // the ready-made reports of every program, product and initiative (batch 17 item 1, PbA6, PbG4)
|
|
40
40
|
import * as RI from './premium-report-intel.js'; // a report made from Intelligence (batch 15 item 4): the header icon, the ✦ proposals, the draft panel
|
|
41
41
|
import * as OK from './okr-list.js'; // Claude runs the OKRs (batch 16 item 6, 6-B): the goal list, its drafts, the ✦ line, ⋯ › Metrics, the notify choice
|
|
42
|
+
import * as GC from './goals-clear.js'; // goals made clear (batch 18 item 11, 11-B): the drafts table, the check panel, first readings, failed and held
|
|
42
43
|
|
|
43
44
|
let M = null; // the model
|
|
44
45
|
let BM = null, bmErr = ''; // the Board measures (Delivery trends)
|
|
@@ -386,8 +387,14 @@ const listGoals = () => (PF ? [] : M.goals.filter((g) => isOwnKr(g) && (g.role =
|
|
|
386
387
|
/** The ✦ line (GsM1–M5): the one thing that matters this week, from lib/goal-status.js (model.okr.line) or said from the goals and drafts. It is
|
|
387
388
|
* the strip's first item; the findings and the reports Claude proposes follow it. It never says "There is no insight yet". */
|
|
388
389
|
function okrLine() {
|
|
389
|
-
const run = DR && DR.run;
|
|
390
|
-
|
|
390
|
+
const run = DR && DR.run, running = !!(run && run.state === 'running');
|
|
391
|
+
const base = OK.lineOf({ okr: M.okr, goals: listGoals(), budgets: M.budgets || [], drafts: drAll(), running, failed: run && run.state === 'failed' ? (run.error || 'The run failed') : null, product: M.board.name });
|
|
392
|
+
if (running || base.tone === 'crit') return base;
|
|
393
|
+
// batch 18 item 11 (GcJ1aTable, GcJ2FirstMonday, GcR4Failed, GcR5Held): a held reading, a failed read or the first readings are the news; else
|
|
394
|
+
// the drafted metrics in the table say what Claude drafted. ✓✓ still keeps every open draft.
|
|
395
|
+
// A goal behind its line stays the news over the drafts; the drafts line replaces only a line about drafts or a calm one.
|
|
396
|
+
const news = GC.lineOf(listGoals(), M.board.name) || (base.tone === 'drafts' || base.tone === 'calm' ? GC.draftsLine(tableRows(), M.board.name) : null);
|
|
397
|
+
return news ? Object.assign({}, news, { keepAll: Math.max(news.keepAll || 0, base.keepAll || 0) }) : base;
|
|
391
398
|
}
|
|
392
399
|
function stripList() {
|
|
393
400
|
const I0 = M.insight || { none: true, text: '' };
|
|
@@ -454,32 +461,85 @@ async function pressMove(b) {
|
|
|
454
461
|
await load();
|
|
455
462
|
}
|
|
456
463
|
|
|
457
|
-
/* ── the North Star (
|
|
464
|
+
/* ── the North Star and its inputs (Iq8Overview; GcJ2FirstMonday while it has fewer than 3 readings): the KR metric record with role north-star,
|
|
465
|
+
* drawn as its number with the change against the span before it and its readings as a line; the records with role input (and guardrail) as a
|
|
466
|
+
* list beside it, each with its change over the same span. Every number is a reading. One reading is a starting point: the line waits in a dashed
|
|
467
|
+
* box for the 2nd, and the span buttons wait for a line. A read that failed or a held reading (GcR4Failed, GcR5Held) keeps the last good number
|
|
468
|
+
* and says so. The drafts that repair the North Star sit under its card. With no North Star the row is not drawn (zero is silence); a drafted
|
|
469
|
+
* North Star is a row of the drafts table, never a second North Star here. ── */
|
|
470
|
+
let nsSpan = '4';
|
|
471
|
+
const SPANS = [['4', '4 weeks', 28], ['12', '12 weeks', 84], ['q', 'This quarter vs last', null]];
|
|
458
472
|
const isOwnKr = (g) => !g.program && !g.initiative;
|
|
459
473
|
const nsGoal = () => (PF ? null : M.goals.find((g) => g.role === 'north-star' && isOwnKr(g)) || null);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const S = g.series || [];
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
const
|
|
469
|
-
|
|
474
|
+
const inputGoals = () => (PF ? [] : M.goals.filter((g) => (g.role === 'input' || g.role === 'guardrail') && isOwnKr(g)));
|
|
475
|
+
/** The reading at or before a day, from a goal's series; null when the series does not reach back that far. */
|
|
476
|
+
const atOrBefore = (g, t) => { const S = (g.series || []).filter((r) => day(r.at) <= t); return S.length ? S[S.length - 1] : null; };
|
|
477
|
+
/** The change of a goal over the span: the latest reading against the one a span before it (a quarter: the same day of the quarter before). */
|
|
478
|
+
function spanChange(g, span = nsSpan) {
|
|
479
|
+
const S = g.series || []; if (S.length < 2) return null;
|
|
480
|
+
const last = S[S.length - 1], tl = day(last.at), back = (SPANS.find((x) => x[0] === span) || SPANS[0])[2];
|
|
481
|
+
const t0 = back ? tl - back * DAY : (() => { const d = new Date(tl); return Date.UTC(d.getUTCFullYear(), d.getUTCMonth() - 3, d.getUTCDate()); })();
|
|
482
|
+
const prev = atOrBefore(g, t0); if (!prev || prev === last) return null;
|
|
483
|
+
const d = last.v - prev.v, pctd = prev.v ? d / Math.abs(prev.v) * 100 : null, better = d === 0 ? null : (g.direction === 'down' ? d < 0 : d > 0);
|
|
484
|
+
return { d, pct: pctd, prev, last, better, t0 };
|
|
485
|
+
}
|
|
486
|
+
const pctSay = (p) => (p === null ? '' : (p > 0 ? '+' : p < 0 ? '−' : '') + (Math.round(Math.abs(p) * 10) / 10) + '%');
|
|
487
|
+
/** The North Star's line: the readings of the span solid, the span before it dashed and laid under it, the latest a dot. Each reading has a
|
|
488
|
+
* title, so a hover says its value and day. */
|
|
489
|
+
function nsSvg(g, ch, W = 520, H = 120) {
|
|
490
|
+
const S = g.series || [], tl = day(S[S.length - 1].at), span = ch ? tl - ch.t0 : 28 * DAY;
|
|
491
|
+
const cur = S.filter((r) => day(r.at) >= tl - span), prev = S.filter((r) => day(r.at) >= tl - 2 * span && day(r.at) <= tl - span);
|
|
492
|
+
const ys = cur.concat(prev).map((r) => r.v), lo = Math.min(...ys), hi = Math.max(...ys), rg = hi - lo || 1, f = (n) => n.toFixed(1);
|
|
493
|
+
const x = (t) => 8 + (span ? (t - (tl - span)) / span : 1) * (W - 16), y = (v) => 10 + (1 - (v - lo) / rg) * (H - 26);
|
|
494
|
+
const path = (L, sh) => L.map((r, i) => (i ? 'L' : 'M') + f(x(day(r.at) + sh)) + ' ' + f(y(r.v))).join('');
|
|
495
|
+
const dots = cur.map((r) => `<circle class="pt" cx="${f(x(day(r.at)))}" cy="${f(y(r.v))}" r="3"><title>${esc(md(day(r.at)) + ' · ' + unitV(g, r.v))}</title></circle>`).join('');
|
|
496
|
+
const z = cur[cur.length - 1];
|
|
497
|
+
return `<svg class="ins-nsch" viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" role="img" aria-label="${esc(g.title + ': ' + cur.length + ' readings in the span' + (prev.length > 1 ? ', the span before it dashed' : ''))}">`
|
|
498
|
+
+ (prev.length > 1 ? `<path class="pv" d="${path(prev, span)}"/>` : '') + (cur.length > 1 ? `<path class="ar" d="${path(cur, 0)}L${f(x(tl))} ${H}L${f(x(day(cur[0].at)))} ${H}Z"/><path class="ln" d="${path(cur, 0)}"/>` : '')
|
|
499
|
+
+ dots + `<circle class="dt" cx="${f(x(day(z.at)))}" cy="${f(y(z.v))}" r="4.5"/></svg>`;
|
|
500
|
+
}
|
|
501
|
+
const RM = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
502
|
+
let nsCounted = false;
|
|
503
|
+
/** The North Star's number counts up once, on the first draw (principle 12 as amended for Intelligence: subtle, honest, reduced motion respected). */
|
|
504
|
+
function countUp(el, g) {
|
|
505
|
+
if (nsCounted || RM() || !el || g.now === null) { nsCounted = true; return; }
|
|
506
|
+
nsCounted = true;
|
|
507
|
+
const txt = g.nowTxt, m = /-?\d[\d,]*(\.\d+)?/.exec(txt || ''); if (!m) return;
|
|
508
|
+
const dec = (m[1] || '').length - (m[1] ? 1 : 0), to = Number(m[0].replace(/,/g, '')), t0 = performance.now();
|
|
509
|
+
const step = (t) => { const k = Math.min(1, (t - t0) / 900), e = 1 - Math.pow(1 - k, 3), v = (to * e).toFixed(Math.max(0, dec)); el.textContent = txt.replace(m[0], m[0].includes(',') ? Number(v).toLocaleString('en-US', { minimumFractionDigits: dec, maximumFractionDigits: dec }) : v); if (k < 1) requestAnimationFrame(step); else el.textContent = txt; };
|
|
510
|
+
requestAnimationFrame(step);
|
|
511
|
+
}
|
|
512
|
+
/** What the North Star's number is (said once, beside it): the last good reading after a failed read or a held one; the source and time of
|
|
513
|
+
* the first readings; else the source and how fresh it is. */
|
|
514
|
+
function nsNote(g) {
|
|
515
|
+
const good = GC.lastGoodSay(g); if (good) return good;
|
|
516
|
+
const F = GC.firstOf(g); if (F) return [F.source, GC.atTxt(F.at)].filter(Boolean).join(' · ');
|
|
517
|
+
const src = srcOf(g); return [src === 'Recorded' ? '' : src, freshOf(g)].filter(Boolean).join(' · ');
|
|
470
518
|
}
|
|
471
519
|
function drawNs() {
|
|
472
520
|
const box = $('#nsRow');
|
|
473
521
|
if (!M || PF) { box.hidden = true; box.innerHTML = ''; return; }
|
|
474
|
-
const g = nsGoal()
|
|
475
|
-
if (!g
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
522
|
+
const g = nsGoal();
|
|
523
|
+
if (!g) { box.hidden = true; box.innerHTML = ''; return; }
|
|
524
|
+
const F = GC.firstOf(g), line = !F || F.n >= 2, ch = line ? spanChange(g) : null, I0 = inputGoals(), bad = !!(g.failed || (g.held || []).length);
|
|
525
|
+
const pill = ch && ch.pct !== null && !bad ? `<span class="cz-pill ${ch.better === null ? 'q' : ch.better ? 'ok' : 'late'}">${esc(pctSay(ch.pct))}</span><span class="note">vs ${esc(unitV(g, ch.prev.v))} ${nsSpan === 'q' ? 'last quarter, same day' : 'the previous ' + (SPANS.find((x) => x[0] === nsSpan) || SPANS[0])[1]}</span>` : '';
|
|
526
|
+
const seg = line && (g.series || []).length > 1 ? `<div class="cz-seg ins-seg" role="group" aria-label="Compare">${SPANS.map(([k, l]) => `<button type="button" aria-pressed="${nsSpan === k}" data-span="${k}">${esc(l)}</button>`).join('')}</div>` : '';
|
|
527
|
+
const chart = !line ? GC.firstChart(g) : (g.series || []).length ? nsSvg(g, ch) : `<p class="note">${esc(nextReading(g))}</p>`;
|
|
528
|
+
const drafts = draftsFor(g.id).map(drHtml).join('');
|
|
529
|
+
const card = `<div class="ins-nsc${bad ? ' bad' : ''}" data-goal="${esc(g.id)}"><div class="ins-nsh"><span class="ins-lbl2">${OK.dotOf(g) === 'broken' ? OK.dotHtml('broken') + ' ' : ''}North Star <span>${esc(g.title)}</span></span>${seg}</div>`
|
|
530
|
+
+ `<div class="ins-nsv"><button type="button" class="ins-big" data-nsopen aria-label="Open ${esc(g.title)}"><b id="nsNum">${esc(nowOf(g))}</b></button>${pill}<span class="note ins-nsn">${esc(nsNote(g))}</span></div>`
|
|
531
|
+
+ chart + (drafts ? `<div class="ins-nsd">${drafts}</div>` : '') + '</div>';
|
|
532
|
+
const row = (x) => { const c = F ? null : spanChange(x), warn = gcSay(x); return `<button type="button" class="ins-inr" data-goal="${esc(x.id)}"><span class="nm">${esc(x.title)}${warn ? `<small class="note">${esc(warn)}</small>` : ''}</span><span class="v"><b>${esc(nowOf(x))}</b>${c && !warn ? `<span class="${c.better === null ? 'q' : c.better ? 'up' : 'dn'}">${esc(sgn(c.d, x.unit))}</span>` : ''}</span></button>`; };
|
|
533
|
+
const ins = I0.filter((x) => x.role === 'input'), grd = I0.filter((x) => x.role === 'guardrail');
|
|
534
|
+
const side = ins.length || grd.length ? `<div class="ins-nsi">${ins.length ? `<span class="ins-lbl2">Inputs <span>what moves the North Star</span></span>${ins.map(row).join('')}` : ''}${grd.length ? `<span class="ins-lbl2">Guardrails <span>must not get worse</span></span>${grd.map(row).join('')}` : ''}</div>` : '';
|
|
535
|
+
box.innerHTML = card + side; box.hidden = false; box.classList.toggle('one', !side);
|
|
536
|
+
countUp($('#nsNum'), g);
|
|
480
537
|
}
|
|
481
538
|
$('#nsRow').addEventListener('click', (e) => {
|
|
482
|
-
|
|
539
|
+
if (e.target.closest('.okr-dr')) return; // a draft under the North Star has its own presses
|
|
540
|
+
const s = e.target.closest('[data-span]'); if (s) { nsSpan = s.dataset.span; drawNs(); return; }
|
|
541
|
+
if (e.target.closest('[data-nsopen]')) { const g = nsGoal(); if (g) openGoalDetail(g.id); return; }
|
|
542
|
+
const r = e.target.closest('.ins-inr[data-goal]'); if (r) openGoalDetail(r.dataset.goal);
|
|
483
543
|
});
|
|
484
544
|
|
|
485
545
|
/* ── what Claude drafted (GsM1–M5; before it Iq8Suggest, Iq9Draft): GET /api/metric-drafts for this product. Each draft sits under the row it
|
|
@@ -497,7 +557,10 @@ async function draftsLoad() {
|
|
|
497
557
|
}
|
|
498
558
|
const drAll = () => OK.draftsOf(DR);
|
|
499
559
|
/** The drafts under one goal row. */
|
|
500
|
-
|
|
560
|
+
// a held reading's drafted ticket (GcR5Held) and a failed read's reconnect (GcR4Failed) are said in the goal's panel, with the reading they
|
|
561
|
+
// are about: not again under the row
|
|
562
|
+
const draftsFor = (id) => { const g = M && M.goals.find((x) => x.id === id), H = g && (g.held || [])[0]; const fx = g && g.failed && g.failed.fix && g.failed.fix.row;
|
|
563
|
+
return drAll().filter((r) => r.goal === id && !(H && r.kind === 'ticket' && (!H.ticket || H.ticket === r.id)) && !(fx && r.id === fx)); };
|
|
501
564
|
/** A draft with no goal on the list: a drafted North Star or key result is drawn as its own hollow row; inputs and guardrails sit in the North
|
|
502
565
|
* Star card; anything else in the loose box under the ✦ line. */
|
|
503
566
|
const looseDrafts = () => { const ids = new Set(M.goals.map((g) => g.id).concat((M.budgets || []).map((b) => b.id))); return drAll().filter((r) => !r.goal || !ids.has(r.goal)); };
|
|
@@ -520,9 +583,14 @@ function drawDrafts() {
|
|
|
520
583
|
if (!M || PF) { box.hidden = true; box.innerHTML = ''; return; }
|
|
521
584
|
const placed = new Set(['North Star', 'Inputs', 'Guardrails', 'Key results']);
|
|
522
585
|
const L = looseDrafts().filter((r) => !(r.kind === 'metric' && placed.has(r.group)));
|
|
523
|
-
|
|
524
|
-
|
|
586
|
+
// batch 18 item 11 (GcJ1aTable): the drafted metrics are ONE table, how each is counted and where and how often it is read; the other loose
|
|
587
|
+
// drafts follow it as before
|
|
588
|
+
const T = GC.tableHtml(tableRows(), { busy: tblBusy, sel: CHK && CHK.id });
|
|
589
|
+
box.innerHTML = T + (L.length ? `<div class="okr-card">${L.map((r) => `<div class="okr-row">${drHtml(r)}</div>`).join('')}</div>` : '');
|
|
590
|
+
box.hidden = !T && !L.length;
|
|
591
|
+
box.classList.toggle('gc-on', !!T);
|
|
525
592
|
if (M) { drawStrip(); drawNs(); drawGoals(); }
|
|
593
|
+
if (CHK) CHK.draw();
|
|
526
594
|
}
|
|
527
595
|
/** One press on a draft: keep (its act), drop, edit, save, cancel or undo; keep-all from the ✦ line; start asks Claude to draft the goals. */
|
|
528
596
|
async function draftPress(k, row, b) {
|
|
@@ -549,8 +617,9 @@ async function draftPress(k, row, b) {
|
|
|
549
617
|
const name = r0 ? r0.text : 'it';
|
|
550
618
|
// batch 18 item 4: say only what the server started. The run is in Sessions; the ✦ line follows it and says when it ends, or why it failed.
|
|
551
619
|
const said = k === 'start' ? (res.already ? 'I am already drafting them. The drafts show here when I finish.' : 'Drafting now. Follow it in Sessions; the drafts show here when I finish.')
|
|
552
|
-
|
|
553
|
-
|
|
620
|
+
// batch 18 item 11: "Kept" names the goal's own rhythm (the server's rhythm.txt, else the recipe), never "every morning"
|
|
621
|
+
: k === 'keep-all' ? (res.rhythm && res.rhythm.txt ? 'Kept ' + (res.kept || 'them all') + '. I read them ' + res.rhythm.txt + '.' : GC.keptSay(tableRows()).replace(/^Kept\. I read it /, 'Kept. I read them '))
|
|
622
|
+
: k === 'keep' ? (res.outbox ? (r0 && r0.kind === 'ticket' ? 'In the outbox for Jira.' : 'In the outbox. It goes as you.') : res.open === 'settings:connectors' ? 'Opening Connectors.' : GC.keptSay(r0 && r0.kind === 'metric' ? [r0] : [], res.rhythm && res.rhythm.txt ? 'Kept. I read it ' + res.rhythm.txt + '.' : null))
|
|
554
623
|
: k === 'drop' ? 'Not now: ' + name + '.' : k === 'undo' ? 'Undone.' : 'Done.';
|
|
555
624
|
toast(said, k === 'keep' || k === 'drop' ? { label: 'Undo', fn: async () => { await pmPost('/api/metric-drafts/undo', Object.assign({ row }, base)); await load(); await draftsLoad(); } } : undefined);
|
|
556
625
|
if (res.open === 'settings:connectors') import('./cozy-settings.js').then((S) => S.openSettings('connectors')).catch(() => {});
|
|
@@ -568,6 +637,114 @@ document.addEventListener('keydown', (e) => {
|
|
|
568
637
|
if (e.key === 'Escape') { e.preventDefault(); drEdit = null; drawDrafts(); }
|
|
569
638
|
});
|
|
570
639
|
|
|
640
|
+
/* ── goals made clear (batch 18 item 11, 11-B; frames Gc* on In development) ─────────────────────────────────────────────────────────
|
|
641
|
+
* The drafted metrics are one table (GcJ1aTable); a row opens its check panel in the Viewer card (GcJ1Drafts): how it is counted, the live read,
|
|
642
|
+
* Claude's checks, your number to compare (GcS3Differs), how often and the query, then ↗ ✎ ↻ and Keep. A kept goal with fewer than 3 readings says
|
|
643
|
+
* its reading with source and time and no pace yet (GcJ2FirstMonday); a read that failed or a reading that was held never shows as progress: the row
|
|
644
|
+
* keeps the last good reading and says what happened (GcR4Failed, GcR5Held). The reads are GET /api/metric-drafts and GET /api/insights-premium;
|
|
645
|
+
* the writes POST /api/goal-status/test, /read, /compare, /compare-pick and /file-held (lib/routes-goal-status.js), and the draft routes. */
|
|
646
|
+
const tableRows = () => (PF || !M ? [] : looseDrafts().filter((r) => r.kind === 'metric' && r.state === 'open' && ['North Star', 'Inputs', 'Guardrails', 'Key results'].includes(r.group)));
|
|
647
|
+
const tblBusy = new Set();
|
|
648
|
+
let CHK = null; // the check panel shown: { id, st, draw }
|
|
649
|
+
/** A goal row's look while its reading is not ordinary: a read that failed, a held reading, or the first readings (no pace, a grey dot). */
|
|
650
|
+
function rowLook(g) {
|
|
651
|
+
const base = () => OK.metaOf(g, today());
|
|
652
|
+
if (g.failed) return { meta: [base(), 'not read ' + GC.dayTxt(g.failed.at)].filter(Boolean).join(' · ') };
|
|
653
|
+
const H = (g.held || []).length; if (H) return { meta: [base(), H === 1 ? '1 reading held' : H + ' readings held'].join(' · ') };
|
|
654
|
+
if (GC.firstOf(g) && OK.dotOf(g) !== 'broken') return { meta: GC.firstMeta(g), dot: 'q' };
|
|
655
|
+
return {};
|
|
656
|
+
}
|
|
657
|
+
$('#draftBox').addEventListener('click', (e) => {
|
|
658
|
+
const b = e.target.closest('[data-gc]');
|
|
659
|
+
if (b) { e.stopPropagation(); if (!b.disabled) tablePress(b.dataset.gc, b.dataset.row, b); return; }
|
|
660
|
+
const r = e.target.closest('[data-gc-row]'); if (r) openCheck(r.dataset.gcRow);
|
|
661
|
+
});
|
|
662
|
+
$('#draftBox').addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches && e.target.matches('[data-gc-row]')) { e.preventDefault(); openCheck(e.target.dataset.gcRow); } });
|
|
663
|
+
async function tablePress(k, row, b) {
|
|
664
|
+
if (k !== 'keep' && k !== 'drop') return;
|
|
665
|
+
tblBusy.add(row); drawDrafts();
|
|
666
|
+
await draftPress(k, row, null);
|
|
667
|
+
tblBusy.delete(row); drawDrafts();
|
|
668
|
+
if (CHK && CHK.id === row && !drAll().some((x) => x.id === row && x.state === 'open')) closeViewer();
|
|
669
|
+
}
|
|
670
|
+
/** Reads the drafts again every 3 s until `until()` holds, at most `n` times: a live read or a compare is a run that ends on its own. */
|
|
671
|
+
async function followDrafts(until, n = 20) {
|
|
672
|
+
for (let i = 0; i < n; i++) { await new Promise((ok) => setTimeout(ok, 3000)); if (!CHK) return false; await draftsLoad(); if (until()) return true; }
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
/** The number the PM typed: "39k", "44,100", "94.1", "1.2m". NaN when it is not one. */
|
|
676
|
+
const typedNum = (raw) => { const m = /^([\d.,]+)\s*([kKmM%]?)$/.exec(String(raw || '').replace(/\s+/g, '')); return m ? Number(m[1].replace(/,/g, '')) * ({ k: 1e3, K: 1e3, m: 1e6, M: 1e6 }[m[2]] || 1) : NaN; };
|
|
677
|
+
/** The check panel of one drafted metric (GcJ1Drafts; GcS3Differs once a number was typed). */
|
|
678
|
+
function openCheck(id) {
|
|
679
|
+
const r0 = drAll().find((x) => x.id === id); if (!r0 || !M.board.ws) return;
|
|
680
|
+
const st = { compare: '', busy: false, msg: '', back: false, edit: false };
|
|
681
|
+
const rowOf = () => drAll().find((x) => x.id === id) || r0;
|
|
682
|
+
const base = { ws: M.board.ws, scope: 'product', id: M.board.ws };
|
|
683
|
+
let el = null;
|
|
684
|
+
const editHtml = (r) => `<form class="gc-ed" data-gc-ed><label class="ins-fl">Name<input class="ins-inp" name="name" maxlength="120" value="${esc(r.name)}"></label>`
|
|
685
|
+
+ (r.raw && r.raw.type !== 'Done or not' ? `<label class="ins-fl">Target<input class="ins-inp" name="target" inputmode="decimal" maxlength="20" value="${esc(r.raw && r.raw.target != null ? String(r.raw.target) : '')}"></label>` : '')
|
|
686
|
+
+ `<label class="ins-fl">Measured by<input class="ins-inp" name="source" maxlength="40" value="${esc(r.source || '')}"></label><div class="gc-foot"><a class="cz-ib sm" href="${esc(homeAsk('insights', 'Change how ' + r.name + ' is counted: '))}" aria-label="Ask Claude in Home to change how it is counted" title="Ask in Home">${SV('M4 5h16v11H9l-5 4z')}</a><span class="gc-sp"></span>`
|
|
687
|
+
+ `<button type="button" class="cz-ib sm" data-gc="edit-x" aria-label="Cancel the edit" title="Cancel">${SV(I.x)}</button><button type="submit" class="cz-ib sm solid" aria-label="Save" title="Save">${SV(I.chk)}</button></div></form>`;
|
|
688
|
+
const draw = () => { if (!el || !document.contains(el)) return; const r = rowOf(), top = el.scrollTop; el.innerHTML = st.edit ? editHtml(r) : GC.checkHtml(r, st); el.scrollTop = top; };
|
|
689
|
+
CHK = { id, st, draw };
|
|
690
|
+
const post = (path, body) => pmPost(path, Object.assign({ ws: M.board.ws }, body)).catch(() => null);
|
|
691
|
+
const live = () => { const r = rowOf(); return r.raw && r.raw.live; };
|
|
692
|
+
const press = async (k) => {
|
|
693
|
+
const r = rowOf();
|
|
694
|
+
if (k === 'edit') { st.edit = true; draw(); const f = el.querySelector('[name="name"]'); if (f) f.focus(); return; }
|
|
695
|
+
if (k === 'edit-x') { st.edit = false; draw(); return; }
|
|
696
|
+
if (k === 'keep') { st.busy = true; draw(); await draftPress('keep', id, null); st.busy = false; if (!drAll().some((x) => x.id === id && x.state === 'open')) closeViewer(); else draw(); return; }
|
|
697
|
+
if (k === 'test') {
|
|
698
|
+
st.busy = true; st.msg = 'Reading it now. Nothing is kept until you keep it.'; draw();
|
|
699
|
+
const was = live() ? live().at : null, res = await post('/api/goal-status/test', { rows: [id] });
|
|
700
|
+
st.busy = false;
|
|
701
|
+
if (!res || res.ok !== true) { st.msg = (res && res.error) || 'It could not be read. Nothing changed.'; draw(); return; }
|
|
702
|
+
draw();
|
|
703
|
+
const got = await followDrafts(() => !!(live() && live().at && live().at !== was));
|
|
704
|
+
st.msg = got ? '' : 'Still reading. Follow it in Sessions; the number shows here when it lands.'; draw(); return;
|
|
705
|
+
}
|
|
706
|
+
if (k === 'pick' || k === 'pick-other') {
|
|
707
|
+
const sg = r.raw && r.raw.compare && r.raw.compare.suggest, want = sg && sg.keep === 'yours' ? 'yours' : 'mine';
|
|
708
|
+
const pick = k === 'pick' ? want : want === 'yours' ? 'mine' : 'yours';
|
|
709
|
+
st.busy = true; draw();
|
|
710
|
+
const res = await post('/api/goal-status/compare-pick', { goal: id, pick });
|
|
711
|
+
st.busy = false;
|
|
712
|
+
if (!res || res.ok !== true) { st.msg = (res && res.error) || 'It could not be saved. Nothing changed.'; draw(); return; }
|
|
713
|
+
st.back = true; st.compare = ''; st.msg = '';
|
|
714
|
+
toast(pick === 'yours' ? 'Done. “How it is counted” says it your way now.' : 'Done. I keep counting it my way.'); await draftsLoad();
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
const wire = (body) => {
|
|
718
|
+
el = body; el.classList.add('ins-vbody', 'gc-panel'); draw();
|
|
719
|
+
el.onclick = (e) => { const b = e.target.closest('[data-gc]'); if (b && !b.disabled) { e.preventDefault(); press(b.dataset.gc); } };
|
|
720
|
+
el.onsubmit = async (e) => {
|
|
721
|
+
e.preventDefault(); const f = e.target;
|
|
722
|
+
if (f.matches('[data-gc-ed]')) {
|
|
723
|
+
const body = { row: id, name: f.name.value, source: f.source.value }; if (f.target) body.target = f.target.value;
|
|
724
|
+
st.busy = true; const res = await pmPost('/api/metric-drafts/edit', Object.assign({}, base, body)).catch(() => null); st.busy = false;
|
|
725
|
+
if (!res || res.ok !== true) { toast((res && res.error) || 'It could not be saved. Nothing changed.'); return; }
|
|
726
|
+
st.edit = false; toast(res.changed === false ? 'Nothing changed.' : 'Saved. Keep it to read it as you wrote it.'); await draftsLoad(); return;
|
|
727
|
+
}
|
|
728
|
+
if (!f.matches('[data-gc-cmp]')) return;
|
|
729
|
+
const raw = String(f.v.value || '').trim(), v = typedNum(raw);
|
|
730
|
+
if (!Number.isFinite(v)) { st.msg = 'Type a number, for example 39k or 94.1.'; draw(); return; }
|
|
731
|
+
st.compare = raw; st.busy = true; st.back = false; st.msg = ''; draw();
|
|
732
|
+
const L = live();
|
|
733
|
+
const res = await post('/api/goal-status/compare', { goal: id, value: v, period: (L && L.period) || undefined });
|
|
734
|
+
st.busy = false;
|
|
735
|
+
if (!res || res.ok !== true) { st.msg = (res && res.error) || 'It could not be compared. Nothing changed.'; draw(); return; }
|
|
736
|
+
await draftsLoad();
|
|
737
|
+
const c = rowOf().raw && rowOf().raw.compare;
|
|
738
|
+
if (c && c.differs && !c.why) await followDrafts(() => { const x = rowOf().raw && rowOf().raw.compare; return !!(x && x.why); }, 10);
|
|
739
|
+
};
|
|
740
|
+
};
|
|
741
|
+
const body = vwOpen({ kind: 'Drafted metric', title: r0.name, sub: 'Check it before you keep it', icon: 'goal', id: 'draft:' + id,
|
|
742
|
+
more: [{ label: 'Not now', note: 'drop this draft', on: () => tablePress('drop', id, null) }],
|
|
743
|
+
onClose: () => { if (CHK && CHK.id === id) { CHK = null; drawDrafts(); } }, render: wire });
|
|
744
|
+
if (!body) { openSide({ kind: 'view', eye: 'Check it before you keep it', title: r0.name, body: '', note: '', go: null }); wire($('#sideBody')); }
|
|
745
|
+
drawDrafts();
|
|
746
|
+
}
|
|
747
|
+
|
|
571
748
|
/* ── Reports and dashboards (⋯; the old Library tab) in a side panel: Found in your work, requests from Home, the reports, then the dashboards ── */
|
|
572
749
|
let libBack = null;
|
|
573
750
|
function openLib() {
|
|
@@ -636,41 +813,148 @@ function bandSvg(pts, lim, ceil, tone, label, w = 210, h = 40) {
|
|
|
636
813
|
const line = L.length > 1 ? `<polygon points="${L[0].split(',')[0]},${h} ${L.join(' ')} ${last[0]},${h}" class="ar"/><polyline points="${L.join(' ')}" class="ln"/>` : '';
|
|
637
814
|
return `<svg class="ins-spark" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" role="img" aria-label="${esc(label)}">${band}${line}<circle cx="${last[0]}" cy="${last[1]}" r="3.6" class="dt" style="fill:${TONE_BAR[tone] || TONE_BAR.q}"/></svg>`;
|
|
638
815
|
}
|
|
639
|
-
/* the
|
|
640
|
-
*
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const
|
|
816
|
+
/* ── the key results (Iq8Overview, GcJ2FirstMonday): one table, Key results · Now, of target · So far · By its date · Moved by, by objective,
|
|
817
|
+
* then Health budgets. A goal with fewer than 3 readings shows its reading, a grey dot for So far and "Known after 3 readings" for By its date;
|
|
818
|
+
* a read that failed or a held reading keeps the last good reading and says what happened under it (GcR4Failed, GcR5Held). The drafts that
|
|
819
|
+
* repair a goal sit under its row. On a phone each goal is a card (Iq8Phone). ── */
|
|
820
|
+
const COLS = 'ins-cols';
|
|
821
|
+
function barHtml(g, cls = '') {
|
|
822
|
+
return `<div class="ins-bar1${cls}" role="img" aria-label="${g.done === null ? 'No progress to read' : Math.round(g.done * 100) + '% of the way to the target'}${g.timeGone == null ? '' : ', ' + Math.round(g.timeGone * 100) + '% of its time gone'}"><i style="width:${g.done === null ? 0 : Math.round(g.done * 100)}%;background:${TONE_BAR[g.tone] || TONE_BAR.q}"></i>${g.timeGone == null ? '' : `<span class="today" title="today" style="left:${Math.round(g.timeGone * 100)}%"></span>`}</div>`;
|
|
823
|
+
}
|
|
824
|
+
/** The so-far sparkline: the readings at their dates across the goal's span, the target dashed, and the pace carried to the date, dashed. */
|
|
825
|
+
function sparkHtml(g, w = 210, h = 40) {
|
|
826
|
+
const c = g.key ? byKey(g.key) : null;
|
|
827
|
+
if (!c) return g.readings ? `<span class="ins-one"><span class="note">${g.readings === 1 ? '1 reading' : g.readings + ' readings'}</span><span class="cz-pill ins-dash">No trend yet</span></span>` : '<span class="note">No reading yet</span>'; // IsMenus: the one value, never a flat line
|
|
828
|
+
const t0 = day(c.pts[0].at), tl = day(c.pts[c.pts.length - 1].at), t1 = Math.max(tl, day(g.byAt) || tl);
|
|
829
|
+
const ys = c.pts.map((p) => p.v).concat(g.target !== null ? [g.target] : [], g.proj ? [g.proj.atDue] : []), lo = Math.min(...ys), hi = Math.max(...ys), rg = hi - lo || 1;
|
|
830
|
+
const x = (t) => 5 + (t1 > t0 ? (t - t0) / (t1 - t0) : 1) * (w - 10), y = (v) => 4 + (1 - (v - lo) / rg) * (h - 8);
|
|
831
|
+
const pts = c.pts.map((p) => x(day(p.at)).toFixed(1) + ',' + y(p.v).toFixed(1)), last = pts[pts.length - 1].split(',');
|
|
832
|
+
const fill = `${x(t0).toFixed(1)},${h} ${pts.join(' ')} ${last[0]},${h}`;
|
|
833
|
+
const proj = g.proj && day(g.byAt) > tl ? `<polyline points="${last.join(',')} ${x(day(g.byAt)).toFixed(1)},${y(g.proj.atDue).toFixed(1)}" class="pj"/>` : '';
|
|
834
|
+
return `<svg class="ins-spark" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" role="img" aria-label="${esc(g.title + ': ' + c.pts.length + ' readings' + (g.targetTxt ? ', target ' + g.targetTxt : ''))}"><polygon points="${fill}" class="ar"/>${g.target !== null ? `<line x1="0" x2="${w}" y1="${y(g.target).toFixed(1)}" y2="${y(g.target).toFixed(1)}" class="tg"/>` : ''}${proj}<polyline points="${pts.join(' ')}" class="ln"/><circle cx="${last[0]}" cy="${last[1]}" r="3.6" class="dt" style="fill:${TONE_BAR[g.tone]}"/></svg>`;
|
|
835
|
+
}
|
|
836
|
+
/** A Count goal with a small whole target is drawn as blocks: one per unit of the target, the ones reached filled. */
|
|
837
|
+
const isBlocks = (g) => g.type === 'Count' && Number.isInteger(g.target) && g.target >= 1 && g.target <= 12 && Number.isInteger(g.now) && g.now >= 0;
|
|
838
|
+
const blocksHtml = (g, w, names = true) => `<div class="ins-blocks" style="width:${w}px" role="img" aria-label="${esc(g.now + ' of ' + g.target)}">${Array.from({ length: g.target }, (_, i) => `<i class="${i < g.now ? 'on' : ''}"></i>`).join('')}</div>`
|
|
839
|
+
+ (names && g.items && g.items.length ? `<div class="note ins-items">${esc(g.items.slice(0, g.now).join(', '))}</div>` : ''); // the reached items, when the goal records them
|
|
840
|
+
/** The grey dot of So far while a goal has fewer than 3 readings (GcJ2FirstMonday): one reading is a starting point, not a trend. */
|
|
841
|
+
const firstDot = (g) => `<span class="ins-dot1" role="img" aria-label="${esc((GC.firstOf(g) || {}).n === 1 ? '1 reading, no trend yet' : '2 readings, no trend yet')}"></span>`;
|
|
842
|
+
function soFarHtml(g, w = 210) {
|
|
843
|
+
if (g.type === 'Done or not') return g.steps && g.steps.length ? stepsHtml(g) : '<span class="note">No steps recorded</span>';
|
|
844
|
+
if (GC.firstOf(g)) return firstDot(g);
|
|
845
|
+
if (g.type === 'Stay within' && g.target !== null && g.series && g.series.length) {
|
|
846
|
+
return bandSvg(g.series, g.target, g.limit !== 'floor', g.pace && g.pace.tone !== 'q' ? g.pace.tone : g.tone, g.title + ': ' + g.series.length + (g.series.length === 1 ? ' reading' : ' readings') + ', the green band is inside the budget', w);
|
|
847
|
+
}
|
|
848
|
+
if (isBlocks(g)) return blocksHtml(g, w);
|
|
849
|
+
return sparkHtml(g, w);
|
|
850
|
+
}
|
|
851
|
+
const PACE_C = { ok: 'var(--cz-ok)', late: 'var(--cz-late)', risk: 'var(--cz-risk)', q: 'var(--cz-ink3)' };
|
|
852
|
+
const GAP_DAYS = { hourly: 1 / 24, daily: 1, weekly: 7, monthly: 30 };
|
|
853
|
+
/** When the pace of a goal with fewer than 3 readings is known: the day of its 3rd reading, from its next read and its rhythm. */
|
|
854
|
+
function knownAt(g) {
|
|
855
|
+
const F = GC.firstOf(g); if (!F || !F.next) return '';
|
|
856
|
+
const c = (g.rhythm && g.rhythm.cadence) || (g.recipe && g.recipe.cadence), gap = GAP_DAYS[c];
|
|
857
|
+
const t = Date.parse(F.next); if (!Number.isFinite(t)) return '';
|
|
858
|
+
return GC.dayTxt(new Date(t + Math.max(0, 2 - F.n) * (gap || 0) * DAY).toISOString());
|
|
859
|
+
}
|
|
860
|
+
/** The pace column: "≈16.5% by Dec 31" with its words; "Known after 3 readings" and the day it will be while the line is too short. */
|
|
861
|
+
function paceHtml(g) {
|
|
862
|
+
if (GC.firstOf(g)) { const k = knownAt(g); return `<div class="pace" role="cell"><span>Known after 3 readings</span>${k ? `<div class="note">${esc(k)}</div>` : ''}</div>`; }
|
|
863
|
+
return `<div class="pace" role="cell"><b style="color:${PACE_C[g.pace.tone]}">${esc(g.pace.head)}</b><div class="note">${esc(g.pace.sub)}</div></div>`;
|
|
864
|
+
}
|
|
865
|
+
/** What happened to a goal's last reading, said once under its number: "not read Mon 16 Nov", "1 reading held". */
|
|
866
|
+
const gcSay = (g) => (g.failed ? 'not read ' + GC.dayTxt(g.failed.at) : (g.held || []).length ? ((g.held.length === 1 ? '1 reading' : g.held.length + ' readings') + ' held') : '');
|
|
867
|
+
function goalSub(g) {
|
|
868
|
+
const by = day(g.byAt), late = per && by !== null && by > per.to && per.key !== 'y' && per.key !== 'c';
|
|
869
|
+
if (g.type === 'Done or not') return [g.steps && g.steps.length ? g.steps.filter((x) => x.done).length + ' of ' + g.steps.length + ' steps' : '', by !== null ? 'due ' + md(by) : ''].filter(Boolean).join(' · ');
|
|
870
|
+
if (g.type === 'Stay within') return [g.dirTxt + ' ' + (g.targetTxt || ''), g.alwaysOn ? 'always on' : by !== null ? 'until ' + md(by) : ''].filter(Boolean).join(' · ');
|
|
871
|
+
const from = g.baseTxt ? 'from ' + g.baseTxt + (g.fromAt && (g.type === 'Percentage' || g.type === 'Amount') ? ' on ' + md(day(g.fromAt)) : '') : '';
|
|
872
|
+
const cp = late ? (g.checkpoints || []).find((c) => day(c.by) >= per.from && day(c.by) <= per.to) : null;
|
|
873
|
+
return [g.dirTxt, from, late ? 'due ' + md(by) + ' ' + new Date(by).getUTCFullYear() + ' · ' + (cp ? per.short + ' checkpoint ' + unitV(g, cp.target) : 'no ' + per.short + ' checkpoint recorded') : ''].filter(Boolean).join(' · ');
|
|
874
|
+
}
|
|
875
|
+
/** The drafts that repair a goal or a budget, as one full row under it (zero is silence). */
|
|
876
|
+
const draftsRow = (id) => { const D = PF ? [] : draftsFor(id); return D.length ? `<div class="ins-drr" role="row" data-drafts-for="${esc(id)}"><div role="cell">${D.map(drHtml).join('')}</div></div>` : ''; };
|
|
877
|
+
/** The number a row shows: after a failed read or a held reading it is the last good one (GcR4Failed, GcR5Held), never the held value. */
|
|
878
|
+
const nowOf = (g) => ((g.failed || (g.held || []).length) && g.lastRead && g.lastRead.txt ? g.lastRead.txt : g.nowTxt) || '—';
|
|
879
|
+
function goalRow(g) {
|
|
880
|
+
const sel = selecting && picked.includes(g.id), warn = gcSay(g), crit = OK.dotOf(g) === 'broken';
|
|
881
|
+
return `<div class="ins-tr ins-row ${COLS}${sel ? ' sel' : ''}${crit ? ' crit' : ''}" role="row" data-goal="${esc(g.id)}" tabindex="0" aria-label="${esc(g.title)}"${selecting ? ` aria-selected="${sel}"` : ''}>`
|
|
882
|
+
+ `<div class="nm" role="cell">${crit ? OK.dotHtml('broken') : ''}<span><b>${markHtml(g.title)}</b><small><span class="cz-pill q ins-type">${esc(g.type)}</span><span class="ins-sub" title="${esc(goalSub(g))}">${esc(PF && g.prod ? [g.prod, goalSub(g)].filter(Boolean).join(' · ') : goalSub(g))}</span></small></span></div>`
|
|
883
|
+
+ `<div class="val" role="cell"><b>${esc(nowOf(g))}</b> <span class="note">${esc(g.targetTxt ? 'of ' + g.targetTxt : 'no target')}</span>${warn ? `<div class="note ins-warn">${esc(warn)}</div>` : GC.firstOf(g) ? '' : barHtml(g)}</div>`
|
|
884
|
+
+ `<div class="sofar" role="cell">${soFarHtml(g)}</div>`
|
|
885
|
+
+ paceHtml(g)
|
|
886
|
+
+ `<div class="mv" role="cell">${g.moves.length ? g.moves.slice(0, 3).map((r) => initRow(r)).join('') + (g.moves.length > 3 ? `<span class="note">and ${g.moves.length - 3} more</span>` : '') : `<span class="note">${M.initiativesRead ? 'No initiative anchors to it' : 'The initiatives are not read yet'}</span>`}</div>`
|
|
887
|
+
+ '</div>' + draftsRow(g.id);
|
|
888
|
+
}
|
|
889
|
+
/** A health budget (D59): always on. Its reading is its share of the board's open initiatives, against its quarterly cap (planning/okrs/health-budgets.md). */
|
|
890
|
+
const pct = (v) => Math.round(v * 100) + '%';
|
|
891
|
+
function budgetRow(b) {
|
|
892
|
+
const R = b.reading, cap = b.cap;
|
|
893
|
+
const val = R ? `<b>${R.n}</b> <span class="note">of ${R.total} open initiatives</span>` : '<b>—</b> <span class="note">' + (b.declared ? 'the initiatives are not read' : 'not in the budget registry') + '</span>';
|
|
894
|
+
const scale = R && R.share !== null && cap !== null ? Math.max(cap * 1.5, R.share) || 1 : 1;
|
|
895
|
+
const bar = R && R.share !== null && cap !== null ? `<div class="ins-bar1" role="img" aria-label="${esc(pct(R.share) + ' of open initiatives, cap ' + pct(cap))}"><i style="width:${Math.round(R.share / scale * 100)}%;background:${R.over ? TONE_BAR.late : TONE_BAR.ok}"></i><span class="today" title="cap" style="left:${Math.round(cap / scale * 100)}%"></span></div>` : barHtml({ done: null, timeGone: null, tone: 'q' });
|
|
896
|
+
const pace = !R || R.share === null ? ['var(--cz-ink3)', '—', b.declared ? 'no open initiative to share' : 'add it to health-budgets.md to give it a cap']
|
|
897
|
+
: R.over ? ['var(--cz-late)', 'Over its ' + pct(cap) + ' cap', pct(R.share) + ' of open initiatives'] : ['var(--cz-ok)', 'Within its ' + pct(cap) + ' cap', pct(R.share) + ' of open initiatives'];
|
|
898
|
+
return `<div class="ins-tr ins-row ${COLS} ins-budget${R && R.over ? ' crit' : ''}" role="row" data-budget="${esc(b.id)}" tabindex="0" aria-label="${esc(b.title)}">`
|
|
899
|
+
+ `<div class="nm" role="cell">${R && R.over ? OK.dotHtml('broken') : ''}<span><b>${markHtml(b.title)}</b><small><span class="cz-pill q ins-type">Stay within</span><span class="ins-sub">always on${cap !== null ? ' · cap ' + pct(cap) + ' of a quarter' : ''}</span></small></span></div>`
|
|
900
|
+
+ `<div class="val" role="cell">${val}${bar}</div>`
|
|
901
|
+
+ `<div class="sofar" role="cell">${R && R.share !== null && cap !== null ? bandSvg([{ at: M.today || iso(today()), v: R.share * 100 }], cap * 100, true, R.over ? 'late' : 'ok', b.title + ': ' + pct(R.share) + ' of open initiatives, the green band is inside its ' + pct(cap) + ' cap') : ''}<span class="note">${esc(b.covers ? 'Covers ' + b.covers : 'What it covers is not declared')}</span></div>`
|
|
902
|
+
+ `<div class="pace" role="cell"><b style="color:${pace[0]}">${esc(pace[1])}</b><div class="note">${esc(pace[2])}</div></div>`
|
|
903
|
+
+ `<div class="mv" role="cell">${b.moves.length ? b.moves.slice(0, 3).map((r) => initRow(r)).join('') : '<span class="note">No initiative anchors to it</span>'}</div></div>` + draftsRow(b.id);
|
|
904
|
+
}
|
|
905
|
+
const GRP_PILL = (L) => {
|
|
906
|
+
const scored = L.filter((g) => g.tone !== 'q'), bad = scored.filter((g) => g.tone === 'late' || g.tone === 'red').length;
|
|
907
|
+
return !scored.length ? '' : bad ? `<span class="cz-pill late">${bad} of ${L.length} behind</span>` : '<span class="cz-pill ok">on track</span>';
|
|
908
|
+
};
|
|
644
909
|
function drawGoals() {
|
|
645
910
|
const G = goalsShown(), T = $('#goalTbl');
|
|
646
911
|
document.body.classList.toggle('ins-trv', dash === TRENDS);
|
|
647
|
-
T.
|
|
648
|
-
$('
|
|
649
|
-
if (dash === TRENDS) { T.innerHTML = bmHtml(true); return; }
|
|
912
|
+
if (dash === TRENDS) { T.innerHTML = bmHtml(true); $('#goalCards').innerHTML = ''; return; }
|
|
913
|
+
const head = `<div class="ins-tr ins-th ${COLS}" role="row"><div role="columnheader">Key results <span>${G.length} · ${esc(per ? per.label : '')}</span></div><div role="columnheader">Now, of target <span class="ins-lg"><span><i class="ins-tdk"></i>today</span></span></div><div role="columnheader">So far</div><div role="columnheader">By its date</div><div role="columnheader" class="ins-mvh">Moved by <span class="ins-lg"><span><i class="ins-trk"><i class="k"></i></i>Skipped</span><span><i class="ins-trk"><i class="p m"></i></i>Milestone</span></span></div></div>`;
|
|
650
914
|
const D = curDash();
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
T.
|
|
656
|
-
return;
|
|
915
|
+
if (!M.goals.filter(isKr).length) {
|
|
916
|
+
// the drafts table above says what is drafted: no empty card under it (zero is silence)
|
|
917
|
+
const B = budgetsHtml(D);
|
|
918
|
+
T.innerHTML = PF || !tableRows().length ? '<div class="ins-empty"><b>No key result is recorded for this workspace.</b> A key result is a metric with a target and a date. Press + to add one.</div>' + B : B;
|
|
919
|
+
T.hidden = !T.innerHTML; drawCards([]); return;
|
|
657
920
|
}
|
|
658
|
-
|
|
921
|
+
T.hidden = false;
|
|
922
|
+
/* by objective; Portfolio groups by product, each product's objectives said in its rows */
|
|
659
923
|
const keyOf = (g) => (PF ? g.prod : g.pillar || '');
|
|
660
924
|
const by = new Map(); for (const g of G) { const k = keyOf(g); if (!by.has(k)) by.set(k, []); by.get(k).push(g); }
|
|
661
925
|
const objs = [...new Set(M.goals.filter(isKr).map((g) => g.pillar || ''))];
|
|
662
|
-
const
|
|
663
|
-
const groups = [...by.entries()].map(([k, L]) =>
|
|
664
|
-
|
|
665
|
-
|
|
926
|
+
const head1 = (k) => (PF ? esc(k || 'A product') : k ? 'Objective ' + (objs.indexOf(k) + 1) + ' · ' + esc(k) : 'No objective');
|
|
927
|
+
const groups = [...by.entries()].map(([k, L]) => `<div class="ins-grp" role="row"><span role="cell">${head1(k)}</span> <span class="q">${esc(per ? per.label : '')}</span>${GRP_PILL(L)}</div>` + L.map(goalRow).join('')).join('');
|
|
928
|
+
T.innerHTML = head + (G.length ? groups : `<div class="ins-empty">No goal matches${find ? ' “' + esc(find) + '”' : ''}${noFilter() ? '' : ' this filter'} in ${esc(per.label)}. <button type="button" class="lk" id="goalsAll">Show every goal</button></div>`) + budgetsHtml(D);
|
|
929
|
+
drawCards(G);
|
|
666
930
|
}
|
|
667
|
-
const pct = (v) => Math.round(v * 100) + '%';
|
|
668
931
|
function budgetsHtml(D) {
|
|
669
932
|
if (PF || D.saved || D.id.startsWith('p:') || (!M.initiativesRead && !(M.budgets || []).length) || (filt.kind.length && !filt.kind.includes('budgets'))) return '';
|
|
670
933
|
const B = (M.budgets || []).filter((b) => hit(b.title, ...b.moves.map((m) => m.title)) && ownerHit(b.moves.map((m) => m.owner).filter(Boolean)) && (!filt.status.length || filt.status.includes(budgetStatus(b))));
|
|
671
934
|
if (!B.length) return ''; // zero is silence
|
|
672
|
-
return
|
|
935
|
+
return '<div class="ins-grp" role="row"><span role="cell">Health budgets</span> <span class="q">always on, judged every week</span></div>' + B.map(budgetRow).join('');
|
|
673
936
|
}
|
|
937
|
+
/* the phone (Iq8Phone): one card per goal, its status at the top right, its value, its so-far, its bar and the first initiative that moves it */
|
|
938
|
+
function cardPill(g) {
|
|
939
|
+
if (g.failed) return ['risk', 'Not read'];
|
|
940
|
+
if ((g.held || []).length) return ['risk', 'Held'];
|
|
941
|
+
if (GC.firstOf(g)) return null;
|
|
942
|
+
const t = g.pace && g.pace.tone !== 'q' ? g.pace.tone : g.tone;
|
|
943
|
+
if (t === 'late' || t === 'red') return ['late', 'Behind'];
|
|
944
|
+
if (t === 'ok') return g.done !== null && g.timeGone != null && g.done > g.timeGone ? ['ok', 'Ahead'] : ['ok', 'On track'];
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
function drawCards(G) {
|
|
948
|
+
$('#goalCards').innerHTML = G.map((g) => {
|
|
949
|
+
const p = cardPill(g), tg = g.targetTxt ? (g.type === 'Count' ? 'of ' : 'target ') + g.targetTxt + (g.byAt ? ' by ' + md(day(g.byAt)) : '') : 'no target', first = GC.firstOf(g);
|
|
950
|
+
const gr = first ? `<span class="note">${esc(GC.firstMeta(g).split(' · ').slice(1).join(' · '))}</span>` : isBlocks(g) ? blocksHtml(g, 190, false) : g.type === 'Stay within' && g.series.length && g.target !== null ? bandSvg(g.series, g.target, g.limit !== 'floor', g.tone, g.title, 190, 30) : g.key ? sparkHtml(g, 190, 30) : '';
|
|
951
|
+
return `<div class="ins-card" role="listitem" data-goal="${esc(g.id)}" tabindex="0" aria-label="${esc(g.title)}"><div class="ins-ch"><b>${esc(g.title)}</b>${p ? `<span class="cz-pill ${p[0]}">${p[1]}</span>` : ''}</div>`
|
|
952
|
+
+ `<div class="ins-cs"><span class="cz-pill q ins-type">${esc(g.type)}</span><span class="note">${esc(tg)}</span></div>`
|
|
953
|
+
+ `<div class="ins-cv"><b>${esc(nowOf(g))}</b><span class="ins-cg">${gr}</span></div>${first || gcSay(g) ? '' : barHtml(g, ' ins-wide')}`
|
|
954
|
+
+ (g.moves[0] ? `<div class="ins-c1">${initRow(g.moves[0], false)}</div>` : '') + '</div>' + (PF ? '' : draftsFor(g.id).map(drHtml).join(''));
|
|
955
|
+
}).join('') || (M.goals.filter(isKr).length ? '<p class="note">No goal in this period.</p>' : '');
|
|
956
|
+
}
|
|
957
|
+
$('#goalCards').addEventListener('click', (e) => { if (e.target.closest('a, .okr-dr')) return; const c = e.target.closest('[data-goal]'); if (c) pressGoal(c.dataset.goal); });
|
|
674
958
|
$('#goalTbl').addEventListener('click', (e) => {
|
|
675
959
|
if (e.target.closest('#goalsAll')) { find = ''; $('#findIn').value = ''; clearFilter(); per = periods()[3]; redraw(); return; }
|
|
676
960
|
if (e.target.closest('a')) return;
|
|
@@ -679,7 +963,7 @@ $('#goalTbl').addEventListener('click', (e) => {
|
|
|
679
963
|
const bu = e.target.closest('[data-budget]'); if (bu) { openBudget(bu.dataset.budget); return; }
|
|
680
964
|
const r = e.target.closest('[data-goal]'); if (r) pressGoal(r.dataset.goal);
|
|
681
965
|
});
|
|
682
|
-
$('#goalTbl').addEventListener('keydown', (e) => { if (e.key !== 'Enter' && e.key !== ' ') return; const r = e.target.closest && e.target.closest('.
|
|
966
|
+
$('#goalTbl').addEventListener('keydown', (e) => { if (e.key !== 'Enter' && e.key !== ' ') return; const r = e.target.closest && e.target.closest('.ins-row, [data-tile]'); if (!r || e.target !== r) return; e.preventDefault(); r.click(); });
|
|
683
967
|
/** A goal press: picks it while New dashboard is open; opens Edit chart on a saved dashboard (AgInsChart); otherwise the goal's detail (IsGoal). */
|
|
684
968
|
function pressGoal(id) {
|
|
685
969
|
if (selecting) { picked = picked.includes(id) ? picked.filter((x) => x !== id) : picked.concat(id); drawGoals(); drawDashSide(); return; }
|
|
@@ -706,8 +990,12 @@ function detailSvg(g, c, W = 490, H = 150) {
|
|
|
706
990
|
const x = (t) => 12 + (t1 > t0 ? (t - t0) / (t1 - t0) : 1) * (W - 24), y = (v) => 26 + (1 - (v - lo) / rg) * (H - 56), f = (n) => n.toFixed(1);
|
|
707
991
|
let out = '';
|
|
708
992
|
if (g.target !== null) { const ty = y(g.target); out += `<path class="tg" d="M0 ${f(ty)}H${W}"/><text class="tgl" x="${W - 2}" y="${f(ty < 18 ? ty + 14 : ty - 6)}" text-anchor="end">Target ${esc(g.targetTxt)}</text>`; }
|
|
709
|
-
|
|
710
|
-
|
|
993
|
+
// the labels at the foot never overlap: the first milestone label (Deliver, Evaluate) keeps the bottom line, and a milestone or release label
|
|
994
|
+
// that would touch one moves up a line (7.5 units a character is the bold label font, a little over; a line is 17 units)
|
|
995
|
+
const lanes = [], laneOf = (a, b) => { let i = 0; while ((lanes[i] || []).some(([p, q]) => a < q + 6 && b > p - 6)) i++; (lanes[i] = lanes[i] || []).push([a, b]); return i; };
|
|
996
|
+
const span = (px, end, label) => { const w = String(label).length * 7.5; return end ? [px - w, px] : [px, px + w]; };
|
|
997
|
+
for (const m of marks) { const mx = x(m.t), end = mx > W - 120, lx = end ? mx - 9 : mx + 9; const [a, b] = span(lx, end, m.label), ly = H - 5 - 17 * laneOf(Math.min(a, mx - 6), Math.max(b, mx + 6)); out += `<path class="msr" d="M${f(mx)} 14V${H - 16}"/><path class="msd" d="M${f(mx)} ${H - 14}l5 5-5 5-5-5z"/><text class="msl" x="${f(lx)}" y="${ly}"${end ? ' text-anchor="end"' : ''}>${esc(m.label)}</text>`; }
|
|
998
|
+
for (const s of shipsOf(g)) { if (s.t < t0 || s.t > t1) continue; const sx = x(s.t), end = sx > W - 160, lx = end ? sx - 4 : sx + 4, ly = H - 5 - 17 * laneOf(...span(lx, end, s.label)); out += `<path class="ship" d="M${f(sx)} 20V${H - 10}"/><text class="shipl" x="${f(lx)}" y="${ly}"${end ? ' text-anchor="end"' : ''}>${esc(s.label)}</text>`; }
|
|
711
999
|
const L = pts.map((p) => f(x(day(p.at))) + ' ' + f(y(p.v))), last = L[L.length - 1];
|
|
712
1000
|
out += `<path class="ln" d="M${L.join('L')}"/>` + (proj ? `<path class="pj" d="M${last}L${f(x(proj.t))} ${f(y(proj.v))}"/>` : '');
|
|
713
1001
|
out += `<circle class="pt now" cx="${f(x(day(pts[pts.length - 1].at)))}" cy="${f(y(pts[pts.length - 1].v))}" r="3.5"/>`;
|
|
@@ -784,23 +1072,32 @@ const historyHtml = (g) => ((g.history || []).length ? (g.history || []).slice()
|
|
|
784
1072
|
* folds: How I read it, What it counts and History. On dashboards folds under them when the PM keeps a saved dashboard. */
|
|
785
1073
|
function goalBodyHtml(g, o) {
|
|
786
1074
|
const c = g.key ? byKey(g.key) : null, phone = isPhone(), steps = g.type === 'Done or not' && g.steps && g.steps.length;
|
|
787
|
-
|
|
788
|
-
const
|
|
789
|
-
const
|
|
1075
|
+
// batch 18 item 11 (GcJ2FirstMonday): one reading is a starting point: the chart waits for the 2nd, and no pace is said before the 3rd
|
|
1076
|
+
const first = GC.firstOf(g), wait = first ? GC.firstChart(g) : '';
|
|
1077
|
+
const chart = steps ? stepsHtml(g) : c ? detailSvg(g, c, phone ? 330 : 470, phone ? 140 : 160) : wait || emptyTrend(g, o.own);
|
|
1078
|
+
const lk = PF ? {} : rowLook(g), d = lk.dot || OK.dotOf(g), R = g.reading || {}, prog = R.txt || OK.progressOf(g);
|
|
1079
|
+
// a failed read or a held reading (GcR4Failed, GcR5Held): the number is the last good one, and it says so
|
|
1080
|
+
const good = GC.lastGoodSay(g);
|
|
1081
|
+
const line = good || (first && d === 'q' ? [first.source, GC.atTxt(first.at)].filter(Boolean).join(' · ') + ' · pace known after 3 readings' : R.line || (d === 'behind' && g.pace && g.pace.sub ? g.pace.sub : ''));
|
|
790
1082
|
const head = `<div class="okr-vh">${OK.dotHtml(d)}<b>${esc(prog || OK.DOT_SAY[d])}</b>${line ? `<span class="note">${esc(line)}</span>` : ''}${PF && g.prod ? `<span class="note">${esc(g.prod)}</span>` : ''}<span class="okr-sp"></span>${OK.avHtml(OK.whoOf(g))}</div>`;
|
|
791
1083
|
const form = !steps && o.adding ? `<form class="ins-mf ins-box" data-rdf><div class="ins-2"><label class="ins-fl">Date<input class="ins-inp" type="date" name="at" value="${esc(M.today || '')}"></label><label class="ins-fl">Value${g.unit ? ' (' + esc(g.unit) + ')' : ''}<input class="ins-inp" name="v" inputmode="decimal" maxlength="16"></label></div><div class="ins-mact"><button type="submit" class="ins-btn sm dark">Add reading</button><button type="button" class="ins-btn sm ghost" data-gx="cancel">Cancel</button><span class="note" data-msg role="status"></span></div></form>` : '';
|
|
792
1084
|
const why = whyOf(g), moves = g.moves || [];
|
|
793
1085
|
const whyCard = why || moves.length ? `<div class="okr-why"><span class="sp" aria-hidden="true">${SV(I.spark)}</span><div>${why ? `<p>${esc(why)}</p>` : ''}${moves.length ? `<div class="ins-mvl">${moves.map(moveRow).join('')}</div>` : ''}</div></div>` : '';
|
|
794
1086
|
const onDash = savedDash().filter((D) => D.charts.includes(g.id)).length;
|
|
795
1087
|
const R0 = g.recipe;
|
|
1088
|
+
// batch 18 item 11 (GcR3Goal): how it is counted, where it is read from, how often and the last read are said ONCE, above the chart; the
|
|
1089
|
+
// Readings fold keeps the list, and What it counts folds away when the counts say it
|
|
1090
|
+
const kr = PF ? '' : GC.krHtml(g, { ticket: heldTicket(g) }), said = !!kr && !!(R0 && R0.connector);
|
|
796
1091
|
const rows = [
|
|
797
|
-
{ id: 'read', title: '
|
|
798
|
-
|
|
1092
|
+
said ? { id: 'read', title: 'Readings', count: (g.series || []).length || '', open: o.open === 'read', render: () => readingsHtml(g, o) }
|
|
1093
|
+
: { id: 'read', title: 'How I read it', count: R0 && R0.connector ? R0.connector : srcOf(g) === 'Recorded' ? 'typed in' : srcOf(g), open: o.open === 'read', render: () => readHtml(g, o) },
|
|
1094
|
+
g.counts && (g.counts.what || g.counts.num_label) ? null : { id: 'counts', title: 'What it counts', count: g.defn ? '' : 'not written yet', render: () => `<p class="note">${esc(g.defn || 'No definition is written for it yet. I write one with how I read it, and you keep it.')}</p>` },
|
|
799
1095
|
{ id: 'hist', title: 'History', count: (g.history || []).length || '', render: () => historyHtml(g) },
|
|
800
1096
|
o.own && savedDash().length ? { id: 'dash', title: 'On dashboards', count: onDash, render: () => dashSwitches(g) } : null,
|
|
801
1097
|
];
|
|
802
1098
|
const ask = `<form class="ins-askf" data-askf><input name="q" maxlength="300" autocomplete="off" placeholder="Ask about this goal" aria-label="Ask about this goal"><button type="submit" class="cz-ib sm solid" aria-label="Ask in Home" title="Ask in Home">${SV(I.up)}</button></form>`;
|
|
803
|
-
|
|
1099
|
+
// GcR3Goal: the panel leads with the number and how it is counted, never with its chart; the chart follows the words
|
|
1100
|
+
return head + form + kr + `<div class="ins-gbig">${chart}</div>` + whyCard + window.czViewer.czSections(rows.filter(Boolean), { key: 'goal' }) + '<p class="note ins-gmsg" data-gmsg role="status"></p>' + ask;
|
|
804
1101
|
}
|
|
805
1102
|
/** The goal as plain text, for Copy as text. */
|
|
806
1103
|
function goalText(g) {
|
|
@@ -819,6 +1116,8 @@ async function setNotify(g, k) {
|
|
|
819
1116
|
toast(say, { label: 'Undo', fn: async () => { await pmPost('/api/goals/notify', { ws: goalWs(g), id: goalRid(g), notify: was }); await load(); } });
|
|
820
1117
|
await load();
|
|
821
1118
|
}
|
|
1119
|
+
/** The drafted Jira ticket of a goal's held reading (GcR5Held): the row the reading engine named, else an open ticket draft under the goal. */
|
|
1120
|
+
const heldTicket = (g) => { const H = (g.held || [])[0]; if (!H) return null; const D = drAll(); return (H.ticket && D.find((r) => r.id === H.ticket)) || D.find((r) => r.goal === g.id && r.kind === 'ticket' && r.state === 'open') || null; };
|
|
822
1121
|
let ovCss = false;
|
|
823
1122
|
function openGoalDetail(id, open0) {
|
|
824
1123
|
let g = goalById(id); if (!g) return;
|
|
@@ -826,10 +1125,12 @@ function openGoalDetail(id, open0) {
|
|
|
826
1125
|
const own = goalWs(g) === M.board.ws, st = { open: open0 || '', more: false, adding: false, own };
|
|
827
1126
|
const kr = krId(g);
|
|
828
1127
|
const more = [], stepsGoal = g.type === 'Done or not' && g.steps && g.steps.length;
|
|
829
|
-
|
|
1128
|
+
// ↻ Read now (batch 18 item 11, GcR3Goal): in the header, any time; it files a normal reading and does not move the next scheduled read
|
|
1129
|
+
const readNow = async () => {
|
|
830
1130
|
const r = await pmPost('/api/goal-status/read', { ws: goalWs(g), id: goalRid(g) });
|
|
831
|
-
toast(r && r.ok === true ? '
|
|
832
|
-
|
|
1131
|
+
toast(r && r.ok === true ? 'Reading it now. The goal shows the new reading when it lands; the next read stays ' + ((GC.rhythmOf(g) || {}).long || 'as it was') + '.' : (r && r.error) || 'It could not be read. Nothing changed.');
|
|
1132
|
+
if (r && r.ok === true) setTimeout(() => { load(); }, 4000);
|
|
1133
|
+
};
|
|
833
1134
|
if (own && !stepsGoal) more.push({ label: 'Add a reading', on: () => { const el = window.czViewer && window.czViewer.body(); st.adding = true; if (el) { el.innerHTML = goalBodyHtml(g, st); const f = el.querySelector('[data-rdf] [name="v"]'); if (f) f.focus(); } } });
|
|
834
1135
|
if (own && M.goals.some((x) => x.id === g.id)) more.push({ label: 'Edit chart', on: () => openChartEdit(g.id) });
|
|
835
1136
|
if (more.length) more.push({ sep: true });
|
|
@@ -841,14 +1142,29 @@ function openGoalDetail(id, open0) {
|
|
|
841
1142
|
const moreOf = () => notifyItems().concat(more);
|
|
842
1143
|
const rp = own && !PF ? RI.viewerPress('goal:' + id) : null; // RfA1: a key result's panel makes a report too
|
|
843
1144
|
const subOf = () => [kr, g.targetTxt ? g.targetTxt + (g.byAt ? ' by ' + md(day(g.byAt)) : '') : ''].filter(Boolean).join(' · ');
|
|
1145
|
+
const presses = (own && g.recipe && g.recipe.connector ? [{ act: 'gc-read', label: 'Read it now', icon: 'M20 12a8 8 0 1 1-2.3-5.6M20 4v5h-5' }] : []).concat(rp ? [rp] : []);
|
|
844
1146
|
const body = vwOpen({ kind: 'Goal', title: g.title, sub: subOf(), icon: 'goal', id: 'goal:' + id, more: moreOf,
|
|
845
|
-
discuss: true, presses:
|
|
1147
|
+
discuss: true, presses: presses.length ? presses : null, onPress: (act) => { if (act === 'gc-read') readNow(); else if (rp && act === rp.act) rp.run(); },
|
|
846
1148
|
render: (el) => {
|
|
847
1149
|
el.classList.add('ins-vbody', 'ins-xv');
|
|
848
1150
|
const draw = () => { const top = el.scrollTop; el.innerHTML = goalBodyHtml(g, st); el.scrollTop = top; };
|
|
849
1151
|
const fresh = async (said) => { toast(said); await load(); if (PF) await openPortfolio(); g = goalById(id); if (g) draw(); };
|
|
850
1152
|
draw();
|
|
851
1153
|
el.onclick = async (e) => {
|
|
1154
|
+
// batch 18 item 11: a failed read's one fix (reconnect), a held reading's (file it, or its drafted ticket)
|
|
1155
|
+
const gx = e.target.closest('[data-gc], [data-okd]');
|
|
1156
|
+
if (gx && !gx.disabled) {
|
|
1157
|
+
const k = gx.dataset.gc || gx.dataset.okd;
|
|
1158
|
+
if (k === 'reconnect') { if (gx.dataset.row) await draftPress('keep', gx.dataset.row, gx); else import('./cozy-settings.js').then((S) => S.openSettings('connectors')).catch(() => {}); return; }
|
|
1159
|
+
if (k === 'file-held') {
|
|
1160
|
+
gx.disabled = true;
|
|
1161
|
+
const r = await pmPost('/api/goal-status/file-held', { ws: goalWs(g), id: goalRid(g), held: gx.dataset.row });
|
|
1162
|
+
if (!r || r.ok !== true) { gx.disabled = false; toast((r && r.error) || 'It could not be filed. Nothing changed.'); return; }
|
|
1163
|
+
await fresh('Filed. It counts as a reading now.'); return;
|
|
1164
|
+
}
|
|
1165
|
+
if (k === 'keep') { await draftPress('keep', gx.dataset.row, gx); g = goalById(id); if (g) draw(); return; }
|
|
1166
|
+
if (k === 'edit') { const t = heldTicket(g); location.assign(homeAsk('goal', 'Change the drafted ticket for ' + g.title + (t ? ' (“' + t.text + '”)' : '') + ': ')); return; }
|
|
1167
|
+
}
|
|
852
1168
|
const x = e.target.closest('[data-gx], [data-czs-act]'); if (!x || x.disabled) return;
|
|
853
1169
|
const k = x.dataset.gx || x.dataset.czsAct, msg = el.querySelector('[data-gmsg]');
|
|
854
1170
|
if (k === 'all') { st.more = true; st.open = 'read'; draw(); }
|