create-pmos 0.432.0 → 0.434.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-insights-test.js +63 -58
- package/workspace/changelog.json +24 -0
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/metric-drafts.md +21 -1
- package/workspace/guide/programs.md +1 -1
- package/workspace/guide/your-impact.md +58 -0
- package/workspace/impact-screens-test.js +149 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +13 -9
- package/workspace/lib/engine/outbox.js +1 -1
- package/workspace/lib/engine/records/index.js +11 -3
- package/workspace/lib/goal-status.js +199 -0
- package/workspace/lib/goal-watch.js +71 -0
- package/workspace/lib/headless.js +24 -2
- package/workspace/lib/impact-cli.js +72 -0
- package/workspace/lib/impact-runs.js +114 -0
- package/workspace/lib/impact.js +195 -0
- package/workspace/lib/insights-premium.js +43 -4
- package/workspace/lib/metric-draft-runs.js +33 -10
- package/workspace/lib/metric-drafts.js +118 -15
- package/workspace/lib/metric-read-runs.js +132 -0
- package/workspace/lib/metric-reads.js +129 -0
- package/workspace/lib/metrics-cli.js +100 -5
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-goal-status.js +111 -0
- package/workspace/lib/routes-impact-views.js +58 -0
- package/workspace/lib/routes-impact.js +91 -0
- package/workspace/lib/routes-insights-premium.js +20 -0
- package/workspace/lib/routes-metric-drafts.js +55 -4
- package/workspace/lib/routes-records.js +2 -0
- package/workspace/lib/settings-store.js +3 -0
- package/workspace/milestone-pins-test.js +8 -3
- package/workspace/okr-goals-ui-test.js +175 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/product-lane-test.js +5 -5
- package/workspace/public/pm/bd-ini-panel.js +10 -2
- package/workspace/public/pm/bd-span.js +5 -4
- package/workspace/public/pm/cozy-adler.css +5 -0
- package/workspace/public/pm/cozy-adler.js +17 -9
- package/workspace/public/pm/cozy-insights.css +84 -0
- package/workspace/public/pm/cozy-settings.js +11 -1
- package/workspace/public/pm/home-app.js +61 -8
- package/workspace/public/pm/home-impact.css +16 -0
- package/workspace/public/pm/home-impact.js +72 -0
- package/workspace/public/pm/home-today.js +4 -2
- package/workspace/public/pm/impact.css +37 -0
- package/workspace/public/pm/impact.js +201 -0
- package/workspace/public/pm/okr-list.js +249 -0
- package/workspace/public/pm/premium-insights.js +222 -238
- package/workspace/public/pm/premium-vw-mtg.js +4 -1
- package/workspace/public/pm/stage-line.js +4 -3
- package/workspace/public/premium-intelligence.html +3 -2
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +56 -2
- package/workspace/skills/impact-detect.skill +46 -0
- package/workspace/skills/metric-read.skill +32 -0
- package/workspace/task-milestones-test.js +4 -3
- package/workspace/test-lists/goal-watch.json +9 -0
- package/workspace/test-lists/impact-screens.json +5 -0
- package/workspace/test-lists/impact-ui.json +9 -0
- package/workspace/test-lists/impact.json +9 -0
- package/workspace/test-lists/okr-goals-ui.json +5 -0
|
@@ -38,6 +38,7 @@ import * as L from './home-list.js';
|
|
|
38
38
|
import * as TD from './home-today.js';
|
|
39
39
|
import * as YD from './home-day.js';
|
|
40
40
|
import * as AD from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2)
|
|
41
|
+
import * as OKL from './okr-list.js'; // the product page's Goals line (batch 16 item 6, GsProduct)
|
|
41
42
|
import { canDictate, dictate } from './home-dictate.js';
|
|
42
43
|
import { mountIni, iniList, iniOverview, iniPage, iniAddTask } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
|
|
43
44
|
import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
|
|
@@ -48,7 +49,9 @@ import * as PM from './prog-move.js'; // move an initiative out of its program
|
|
|
48
49
|
import * as CW from './ctx-wedge.js'; // how full a session's context is, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
|
|
49
50
|
import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
|
|
50
51
|
import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
|
|
52
|
+
import * as IMP from './home-impact.js'; // Your impact: the weekly check in Home's own chat (batch 16 item 7, GmP1Ledger)
|
|
51
53
|
import * as LPV from './loose-props.js'; // Claude's clean-up of "Not in an initiative": the ✦ on its header and the Viewer (batch 13 item 3)
|
|
54
|
+
import * as IM from './impact.js'; // Your impact (batch 16 item 7): Adler's sprout on the greeting, the week in the Viewer, the Friday chapter
|
|
52
55
|
import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
|
|
53
56
|
|
|
54
57
|
const $ = (s, r = document) => r.querySelector(s);
|
|
@@ -196,6 +199,8 @@ async function load() {
|
|
|
196
199
|
S.ready = true;
|
|
197
200
|
await loadIni();
|
|
198
201
|
draw();
|
|
202
|
+
loadImpact();
|
|
203
|
+
readImpact();
|
|
199
204
|
// the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
|
|
200
205
|
const others = await Promise.all(otherProducts(D).map((a) => getRetry('/api/board-premium?ws=' + encodeURIComponent(a.ws), 4).then((r) => (r && r.ok && r.model ? { ws: a.ws, name: a.name, model: r.model } : null))));
|
|
201
206
|
const got = others.filter(Boolean);
|
|
@@ -294,7 +299,8 @@ function homeListHtml() {
|
|
|
294
299
|
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);
|
|
295
300
|
return TD.listHtml(M, todayModel(), {
|
|
296
301
|
sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, ses: S.ses, pOpen, 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] : '',
|
|
297
|
-
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 }) : '',
|
|
302
|
+
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' }) : '') : '',
|
|
303
|
+
imFace: IM.faceHtml(S.im, { joy: S.imJoy }),
|
|
298
304
|
});
|
|
299
305
|
}
|
|
300
306
|
/** Your day (XvAPhDay): "Good morning" opens it in the Viewer on a phone and a desktop alike (batch 16, Wawan: the same press must lead to
|
|
@@ -310,6 +316,26 @@ function dayParts() {
|
|
|
310
316
|
function drawDayBody(body, P) {
|
|
311
317
|
const ph = isPhone() && PHC;
|
|
312
318
|
YD.drawDay(body, P, VW, ph ? (el) => { el.append(PHC.el); PHC.read(true); } : null);
|
|
319
|
+
// Your impact's chapter (batch 16 item 7, GmP4Chapter): on a Friday when a stage of one of these initiatives really closed this week
|
|
320
|
+
if (S.chap) body.insertAdjacentHTML('afterbegin', IM.chapterHtml(S.chap, { href: '/premium.html?ini=' + encodeURIComponent(S.chap.c.id) + (S.chap.c.ws ? '&ws=' + encodeURIComponent(S.chap.c.ws) : '') }));
|
|
321
|
+
}
|
|
322
|
+
/** Your impact (batch 16 item 7): the week's read gives Adler's sprout its leaves, celebrates once on a real event (a thanks says itself in
|
|
323
|
+
* the toast), and on a Friday finds the chapter for Your day. Nothing shows while the switch is off or the 9-of-10 gate is not passed. */
|
|
324
|
+
async function readImpact() {
|
|
325
|
+
const W = await IM.readWeek().catch(() => null);
|
|
326
|
+
const had = IM.shows(S.im) || !!S.chap;
|
|
327
|
+
S.im = W;
|
|
328
|
+
// nothing to show and nothing shown before: keep the rows as they are, so a click in flight still lands
|
|
329
|
+
if (!IM.shows(W)) { S.chap = null; if (had) drawList(); return; }
|
|
330
|
+
S.imJoy = !!IM.celebrate(W, { toast });
|
|
331
|
+
drawList();
|
|
332
|
+
if (S.imJoy) setTimeout(() => { S.imJoy = false; }, 1600); // the leaf grows once: the next draw is still
|
|
333
|
+
if (new Date(NOW()).getDay() === 5) {
|
|
334
|
+
const ch = await IM.readChapters().catch(() => []);
|
|
335
|
+
const all = H.boardRows(S.D).concat(...(S.D.others || []).map((o) => H.boardRows({ ...S.D, board: o.model })));
|
|
336
|
+
S.chap = IM.chapterToday(ch, (id) => ((all.find((r) => r.id === id) || {}).title || ''), NOW(), W);
|
|
337
|
+
redrawDay();
|
|
338
|
+
}
|
|
313
339
|
}
|
|
314
340
|
function day(on) {
|
|
315
341
|
S.day = !!on;
|
|
@@ -780,18 +806,30 @@ const productRename = (ws, name, vid) => (ws ? { value: name, max: 80, save: asy
|
|
|
780
806
|
/** The name Home shows for the board's own product: its group's name (the PM's name for the repository wins), else the board's. */
|
|
781
807
|
const ownProductName = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return (g && g.name) || H.productName(S.D); };
|
|
782
808
|
const productKey = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return g ? g.key : null; };
|
|
809
|
+
/** The product page's Goals (GsProduct, batch 16 item 6): one line from the goal status function (GET /api/goal-status, readings only), one dot
|
|
810
|
+
* per goal, that opens the Intelligence goal list. Build status leaves the goal block and stays on the Board. */
|
|
811
|
+
const intelHref = (ws) => '/premium-intelligence.html' + (ws ? '?ws=' + encodeURIComponent(ws) : '');
|
|
812
|
+
const goalsBlock = (ws) => `<section class="hi-pg" aria-label="Goals"><div class="hm-r hi-r"><a class="hm-rm" href="${esc(intelHref(ws))}" aria-label="Open goals in Intelligence"><span class="hm-tile">${SVG(I.chart, 14)}</span><span class="hm-rt"><b>Goals</b><em class="q" data-okr-line>Reading the goals</em></span><span class="okr-pld" data-okr-dots aria-hidden="true"></span></a></div></section>`;
|
|
813
|
+
async function fillGoals(b, ws) {
|
|
814
|
+
let r = null;
|
|
815
|
+
try { r = await pmGet('/api/goal-status' + (ws ? '?ws=' + encodeURIComponent(ws) : '')); } catch { r = null; }
|
|
816
|
+
const L = r && r.ok ? OKL.productLine(r) : null, line = b.querySelector('[data-okr-line]'), dots = b.querySelector('[data-okr-dots]');
|
|
817
|
+
if (!line) return;
|
|
818
|
+
line.textContent = L ? L.text : 'Open them in Intelligence';
|
|
819
|
+
if (dots) dots.innerHTML = L ? L.dots.map((d) => OKL.dotHtml(d)).join('') : '';
|
|
820
|
+
}
|
|
783
821
|
/** The product's page in the Viewer (HbCProduct): Goals, the KRs and budgets with what is at risk, and This week, the weekly update and the
|
|
784
822
|
* metrics review. A press opens that one; ← comes back to the page. */
|
|
785
823
|
function openProductPage() {
|
|
786
824
|
const name = ownProductName();
|
|
787
825
|
VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart', rename: productRename(boardWs(), name, 'product'),
|
|
788
826
|
render: (b) => {
|
|
789
|
-
const
|
|
790
|
-
const goals = C.items.map((x) => itemHtml({ kind: x.kind === 'ok' ? 'done' : 'risk', label: x.label })).join('') || '<p class="hm-none">No KR or budget is anchored on this board.</p>';
|
|
827
|
+
const U = H.weeklyUpdate(S.D, S.D.now), sent = (U.sent || []).some((x) => x.week === U.week.iso);
|
|
791
828
|
const row = (k, icon, t, sub) => `<div class="hm-r hi-r"><button type="button" class="hm-rm" data-hp="${k}"><span class="hm-tile">${SVG(icon, 14)}</span><span class="hm-rt"><b>${esc(t)}</b><em class="q">${esc(sub)}</em></span></button></div>`;
|
|
792
|
-
b.innerHTML = `<div class="hi-v hi-page"
|
|
829
|
+
b.innerHTML = `<div class="hi-v hi-page">${goalsBlock(boardWs())}`
|
|
793
830
|
+ `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div>${row('update', I.doc, 'Weekly update', sent ? 'Sent this week' : 'Ready to send')}${row('metrics', I.chart, 'Metrics review', 'With Strategist')}</section>`
|
|
794
831
|
+ (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
|
|
832
|
+
fillGoals(b, boardWs());
|
|
795
833
|
b.onclick = (e) => {
|
|
796
834
|
const t = e.target.closest('[data-hp]'); if (!t) return;
|
|
797
835
|
if (t.dataset.hp === 'update') { VW.drill(); openTarget(updateTarget()); openUpdateViewer(); }
|
|
@@ -852,8 +890,21 @@ function programTarget(id, task) {
|
|
|
852
890
|
}
|
|
853
891
|
function homeTarget() {
|
|
854
892
|
return { key: 'chat:main', ws: WS || undefined, title: 'Home', scope: { text: 'All work', icon: I.home }, rich: false, placeholder: 'Message Claude', role: CLAUDE,
|
|
855
|
-
empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null)
|
|
856
|
-
}
|
|
893
|
+
empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null),
|
|
894
|
+
intro: S.impact ? S.impact.intro : undefined };
|
|
895
|
+
}
|
|
896
|
+
/* Your impact (batch 16 item 7): when a finished week has items not checked yet, Home's own chat opens on Claude's check (GmP1Ledger).
|
|
897
|
+
* Off in Settings, or nothing to check: no card. Read after the list is drawn, so it never holds Home up. */
|
|
898
|
+
async function loadImpact() {
|
|
899
|
+
const c = await IMP.readCheck(pmGet).catch(() => null);
|
|
900
|
+
const was = !!S.impact;
|
|
901
|
+
S.impact = c ? { c, intro: IMP.checkIntro(c, { esc, pmPost, done: () => { S.impact = null; drawList(); } }) } : null;
|
|
902
|
+
const cur = chat.current && chat.current();
|
|
903
|
+
if ((was || S.impact) && cur && cur.key === 'chat:main') { chat.open(homeTarget()); }
|
|
904
|
+
if (was || S.impact) drawList();
|
|
905
|
+
}
|
|
906
|
+
// the switch in Settings › General (pm/cozy-settings.js) turns the check off and on at once
|
|
907
|
+
window.addEventListener('pmos:impact', () => { loadImpact(); readImpact(); }); // the switch: the weekly check row and Adler's sprout follow at once
|
|
857
908
|
function openTarget(t) {
|
|
858
909
|
S.cur = { title: t.title, ses: t.ses || null, sub: t.sub != null && t.sub !== '' ? t.sub : t.scope && t.scope.text !== t.title ? t.scope.text : '' };
|
|
859
910
|
chat.open(t); drawTop();
|
|
@@ -929,11 +980,11 @@ function goOtherProduct(g) {
|
|
|
929
980
|
const own = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
|
|
930
981
|
VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart', rename: productRename(ws, name, 'product:' + ws),
|
|
931
982
|
render: (b) => {
|
|
932
|
-
|
|
933
|
-
b.innerHTML = `<div class="hi-v hi-page"><section class="hi-pg" aria-label="Goals"><div class="hi-pgh"><b>Goals</b><span class="hi-n">${esc(C.of)}</span></div>${goals}</section>`
|
|
983
|
+
b.innerHTML = `<div class="hi-v hi-page">${goalsBlock(ws)}`
|
|
934
984
|
+ `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div><div class="hm-r hi-r"><a class="hm-rm" href="${esc(own)}" target="_blank" rel="noopener"><span class="hm-tile">${SVG(I.doc, 14)}</span><span class="hm-rt"><b>Weekly update and metrics review</b><em class="q">In ${esc(name)}'s own Home, in a new tab</em></span></a></div></section>`
|
|
935
985
|
+ (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
|
|
936
986
|
// a phone has no chat beside the page: its own chat is one press away, as on the board's own product (Wawan, 2026-10-25)
|
|
987
|
+
fillGoals(b, ws);
|
|
937
988
|
b.onclick = (e) => { const t = e.target.closest('[data-hp="talk"]'); if (t) talk(); };
|
|
938
989
|
} });
|
|
939
990
|
}
|
|
@@ -1553,7 +1604,9 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
|
|
|
1553
1604
|
if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
|
|
1554
1605
|
if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
|
|
1555
1606
|
if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
|
|
1607
|
+
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
|
|
1556
1608
|
if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
|
|
1609
|
+
if ('hmImpact' in d) { if (S.day) day(false); IM.openWeek(); return; }
|
|
1557
1610
|
if ('hmDay' in d) { day(!S.day); return; }
|
|
1558
1611
|
if ('hmDayx' in d) { day(false); return; }
|
|
1559
1612
|
if ('hmFlt' in d) { filterMenu(b); return; }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* pm/home-impact.css — the weekly check of Your impact in Home's chat (feedback batch 16 item 7, canvas GmP1Ledger). pm/home-impact.js. */
|
|
2
|
+
.im-card { clear: both; margin-top: 8px; padding: 4px 14px 8px; } /* under Claude's line, never beside it (the line floats on a desk) */
|
|
3
|
+
.im-list { list-style: none; margin: 0; padding: 0; }
|
|
4
|
+
.im-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--cz-hair); }
|
|
5
|
+
.im-row:first-child { border-top: 0; }
|
|
6
|
+
.im-row.im-off .im-t { color: var(--cz-ink3); text-decoration: line-through; }
|
|
7
|
+
.im-k { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--cz-well); color: var(--cz-ink2); }
|
|
8
|
+
.im-k.im-thanks { background: var(--cz-bluebg); color: var(--cz-blueink); }
|
|
9
|
+
.im-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
10
|
+
.im-t { font-size: var(--fs-4); overflow-wrap: anywhere; }
|
|
11
|
+
.im-src { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
|
|
12
|
+
.im-src:hover { text-decoration: underline; }
|
|
13
|
+
.im-src svg, .im-lock svg { flex: none; }
|
|
14
|
+
.im-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
|
|
15
|
+
.im-lock { flex: 1; display: inline-flex; align-items: center; gap: 6px; }
|
|
16
|
+
@media (prefers-reduced-motion: no-preference) { .im-row { transition: opacity .2s ease; } }
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* pm/home-impact.js — the weekly check of "Your impact" in Home's chat (feedback batch 16 item 7, Phase 1; canvas In development GmP1Ledger).
|
|
2
|
+
* After a week ends, Claude lists that week's items and asks whether each is real: ✕ or ✓ on each row, ✓✓ for every row not checked yet.
|
|
3
|
+
* Only ✓ items count. Each row links to its source. No number is shown. The card is Home's own chat intro while the check is due; it goes
|
|
4
|
+
* when every row is checked.
|
|
5
|
+
*
|
|
6
|
+
* readCheck(pmGet) → the GET /api/impact/check body when a check is due, else null
|
|
7
|
+
* checkIntro(c, { esc, pmPost, done }) → the intro of Home's chat: { role, text, card: { html, press } }
|
|
8
|
+
* rowHtml(c, { esc, sel }) → the one row under Mentions while the check is due: a tap opens Home's chat on it (on a phone too). No count.
|
|
9
|
+
* Writes: POST /api/impact/verdict { id, real }, /verdict-all { week }, /undo { id } (page presses). Nothing leaves PMOS. */
|
|
10
|
+
|
|
11
|
+
const SV = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
12
|
+
const P = {
|
|
13
|
+
thanks: 'M7 7h4v4c0 3-2 5-4 5M14 7h4v4c0 3-2 5-4 5',
|
|
14
|
+
unblock: 'M7 11V8a5 5 0 0 1 9.6-2M5 11h14v9H5z',
|
|
15
|
+
used: 'M12 3l8 9-8 9-8-9z',
|
|
16
|
+
kr: 'M4 17l6-6 4 4 6-7M15 8h5v5',
|
|
17
|
+
no: 'M6 6l12 12M18 6L6 18', yes: 'M5 12l5 5 9-10', all: 'M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16',
|
|
18
|
+
lock: 'M7 11V8a5 5 0 0 1 10 0v3M5 11h14v9H5z', open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
|
|
19
|
+
};
|
|
20
|
+
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
21
|
+
const dayName = (iso) => { const t = Date.parse(iso); return Number.isFinite(t) ? DAYS[new Date(t).getDay()] : ''; };
|
|
22
|
+
|
|
23
|
+
export async function readCheck(pmGet) {
|
|
24
|
+
const r = await pmGet('/api/impact/check');
|
|
25
|
+
return r && r.ok && r.on && r.due ? r : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function rowHtml(c, { esc, sel }) {
|
|
29
|
+
if (!c) return '';
|
|
30
|
+
return `<div class="hv-card hr-card hr-men-card"><div class="hm-r hv-r hr-men${sel ? ' sel' : ''}" data-id="impact">`
|
|
31
|
+
+ `<button type="button" class="hm-rm" data-hr-impact${sel ? ' aria-current="true"' : ''} aria-label="Your impact: ${esc(c.label.toLowerCase())} is ready to check">`
|
|
32
|
+
+ `<span class="hv-mk hr-at" aria-hidden="true">${SV(P.yes, 16)}</span><span class="hm-rt"><b>Your impact</b><small class="hr-sub">${esc(c.label)} is ready to check</small></span>`
|
|
33
|
+
+ '<span class="hv-xc" aria-hidden="true"></span></button></div></div>';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function checkIntro(c, { esc, pmPost, done }) {
|
|
37
|
+
const st = { c, msg: '' };
|
|
38
|
+
const left = () => st.c.items.filter((x) => x.real === null);
|
|
39
|
+
const row = (x) => {
|
|
40
|
+
const mark = x.real === null
|
|
41
|
+
? `<button type="button" class="ut-ib lg" data-im-v="no" data-im-id="${esc(x.id)}" aria-label="Not real, drop it" title="Not real, drop it">${SV(P.no)}</button>`
|
|
42
|
+
+ `<button type="button" class="ut-ib pri" data-im-v="yes" data-im-id="${esc(x.id)}" aria-label="Real, keep it" title="Real, keep it">${SV(P.yes)}</button>`
|
|
43
|
+
: `<button type="button" class="ut-ib lg on" data-im-undo="${esc(x.id)}" aria-pressed="true" aria-label="${x.real ? 'Kept as real. Undo' : 'Dropped. Undo'}" title="${x.real ? 'Kept as real. Undo' : 'Dropped. Undo'}">${SV(x.real ? P.yes : P.no)}</button>`;
|
|
44
|
+
return `<li class="im-row${x.real === false ? ' im-off' : ''}"><span class="im-k im-${esc(x.kind)}" aria-hidden="true">${SV(P[x.kind] || P.used)}</span>`
|
|
45
|
+
+ `<span class="im-tx"><span class="im-t">${esc(x.text)}</span><a class="ut-small ut-mut im-src" href="${esc(x.source.url)}" target="_blank" rel="noopener noreferrer">${esc(x.source.label)} · ${esc(dayName(x.at))} ${SV(P.open, 12)}</a></span>${mark}</li>`;
|
|
46
|
+
};
|
|
47
|
+
const html = () => {
|
|
48
|
+
const open = left();
|
|
49
|
+
return `<div class="ut-card im-card" role="group" aria-label="Your impact, ${esc(st.c.label.toLowerCase())}">`
|
|
50
|
+
+ `<ul class="im-list">${st.c.items.map(row).join('')}</ul>`
|
|
51
|
+
+ `<div class="im-foot"><span class="ut-small ut-mut im-lock">${SV(P.lock, 14)} Only you see this. Nothing leaves PMOS.</span>`
|
|
52
|
+
+ (open.length > 1 ? `<button type="button" class="ut-ib pri" data-im-all aria-label="All real, keep them all" title="All real, keep them all">${SV(P.all)}</button>` : '')
|
|
53
|
+
+ `</div><p class="ut-small ut-mut" role="status">${esc(st.msg)}</p></div>`;
|
|
54
|
+
};
|
|
55
|
+
const press = async (b) => {
|
|
56
|
+
const d = b.dataset;
|
|
57
|
+
let r = null;
|
|
58
|
+
if (d.imV) r = await pmPost('/api/impact/verdict', { id: d.imId, real: d.imV === 'yes' });
|
|
59
|
+
else if (d.imUndo) r = await pmPost('/api/impact/undo', { id: d.imUndo });
|
|
60
|
+
else if ('imAll' in d) r = await pmPost('/api/impact/verdict-all', { week: st.c.week });
|
|
61
|
+
else return false;
|
|
62
|
+
if (!r || !r.ok) { st.msg = (r && r.error) || 'Not saved.'; return true; }
|
|
63
|
+
if (d.imV) { const x = st.c.items.find((y) => y.id === d.imId); if (x) x.real = d.imV === 'yes'; }
|
|
64
|
+
else if (d.imUndo) { const x = st.c.items.find((y) => y.id === d.imUndo); if (x) x.real = null; }
|
|
65
|
+
else for (const x of st.c.items) if (x.real === null) x.real = true;
|
|
66
|
+
st.msg = left().length ? '' : 'Thank you. This week is checked.';
|
|
67
|
+
if (!left().length && done) done();
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
const short = c.gate === 'short' ? ' Too many of these were not real, so I keep your sprout and your log hidden for now.' : '';
|
|
71
|
+
return { role: { key: 'claude', name: 'Claude', initial: 'C' }, text: `Here’s what I’d count as your impact ${c.label === 'Last week' ? 'last week' : c.label.replace(/^Week of/, 'the week of')}. Is each one real? I read these from your sources. I don’t post anything anywhere.${short}`, card: { html, press } };
|
|
72
|
+
}
|
|
@@ -267,12 +267,14 @@ export function todayHtml(T, o) {
|
|
|
267
267
|
const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
268
268
|
const WEEKDAY = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
269
269
|
const MOMENT = new Set(['rec', 'soon', 'live', 'eod', 'review']);
|
|
270
|
-
/** M is homeList(); T todayCard(); o: { sel, ses (the initiative row whose pill is open), pOpen, restOpen, pin, avHtml, ready, err, pick (GET /api/briefing-premium/products), tones, review, phone, day (Your day is open), news (how many items are new for you) } */
|
|
270
|
+
/** M is homeList(); T todayCard(); o: { sel, ses (the initiative row whose pill is open), pOpen, restOpen, pin, avHtml, ready, err, pick (GET /api/briefing-premium/products), tones, review, phone, day (Your day is open), news (how many items are new for you), imFace (Your impact's face press, pm/impact.js) } */
|
|
271
271
|
export function listHtml(M, T, o) {
|
|
272
272
|
const flt = M.filter !== 'today' ? M.filters.find((f) => f.key === M.filter) : null;
|
|
273
273
|
// the blue dot after "Good morning": something is new for you, in Your day's New for you fold (feedback batch 16 item 5b, FmA4Desk)
|
|
274
274
|
const nw = o.news > 0 ? '. ' + o.news + ' new for you' : '';
|
|
275
|
-
|
|
275
|
+
// Your impact (batch 16 item 7, GmA1Home): with it on, the greeting's face is its own press, Adler with the week's leaves (pm/impact.js faceHtml)
|
|
276
|
+
const face = o.imFace && !o.err ? '' : AD.adler(o.err ? 'honest' : 'handled', 36, { label: false, cls: 'hv-ad' });
|
|
277
|
+
const head = `<div class="hm-hd hv-bar">${o.imFace && !o.err ? o.imFace : ''}<button type="button" class="hv-hi" data-hm-day aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}${nw}. Open your day">${face}<b>${esc(M.word || 'Today')}</b>${o.news > 0 ? '<i class="hv-nd" aria-hidden="true"></i>' : ''}${svg(P.chevD, 18)}</button>`
|
|
276
278
|
// the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
|
|
277
279
|
+ (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
|
|
278
280
|
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* impact.css — Your impact (feedback batch 16 item 7; pm/impact.js adds this sheet). Plain PM words on calm cards: no badge, no count, no
|
|
2
|
+
* leaf outside Adler's sprout. Colours are the --cz-* tokens of cozy.css, type is the var(--fs-N) scale. */
|
|
3
|
+
.im { display: flex; flex-direction: column; gap: 14px; font-family: var(--cz-sans); color: var(--cz-ink); }
|
|
4
|
+
.im-hd { display: flex; flex-direction: column; gap: 4px; }
|
|
5
|
+
.im-hd b { font-size: var(--fs-5); font-weight: 800; letter-spacing: -.01em; }
|
|
6
|
+
.im-hd span { font-size: var(--fs-4); color: var(--cz-ink2); }
|
|
7
|
+
.im-card { background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 18px; padding: 4px 16px; }
|
|
8
|
+
.im-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 0; border-top: 1px solid var(--cz-hair); }
|
|
9
|
+
.im-row:first-child { border-top: 0; }
|
|
10
|
+
.im-tile { width: 36px; height: 36px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--cz-well); color: var(--cz-ink2); }
|
|
11
|
+
.im-tile.b { background: var(--cz-bluebg); color: var(--cz-blue); }
|
|
12
|
+
.im-tile.g { background: var(--cz-okbg); color: var(--cz-ok); }
|
|
13
|
+
.im-av { width: 36px; height: 36px; border-radius: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--fs-3); background: var(--cz-well); color: var(--cz-ink); }
|
|
14
|
+
.im-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
15
|
+
.im-t { font-size: var(--fs-4); font-weight: 400; }
|
|
16
|
+
b.im-t { font-weight: 700; }
|
|
17
|
+
.im-s { font-size: var(--fs-3); color: var(--cz-ink2); }
|
|
18
|
+
.im-ib { width: 44px; height: 44px; border-radius: 22px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--cz-well); color: var(--cz-ink2); text-decoration: none; }
|
|
19
|
+
.im-lock { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-3); color: var(--cz-ink2); }
|
|
20
|
+
.im-wk { display: flex; flex-direction: column; gap: 8px; }
|
|
21
|
+
.im-wk.quiet { flex-direction: row; align-items: baseline; gap: 10px; padding: 4px 0; }
|
|
22
|
+
.im-wl { font-size: var(--fs-2); font-weight: 800; letter-spacing: .02em; color: var(--cz-ink2); flex: none; }
|
|
23
|
+
.im-row .im-wl { width: 64px; }
|
|
24
|
+
.im-wk summary { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; border-radius: 12px; }
|
|
25
|
+
.im-wk summary::-webkit-details-marker { display: none; }
|
|
26
|
+
.im-wk summary .im-s { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
27
|
+
.im-wk[open] summary svg { transform: rotate(180deg); }
|
|
28
|
+
.im-log { display: flex; justify-content: center; padding: 4px 0; }
|
|
29
|
+
.im-first, .im-mh { display: flex; align-items: center; gap: 12px; }
|
|
30
|
+
.im-first { background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 18px; padding: 14px; }
|
|
31
|
+
.im-made { margin-top: 18px; }
|
|
32
|
+
.im-ch { margin: 12px 0; }
|
|
33
|
+
.im-mt { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: var(--fs-3); color: var(--cz-ink2); }
|
|
34
|
+
.im-face { width: 40px; height: 44px; border: 0; padding: 0; margin: 0 -4px 0 0; background: none; border-radius: 22px; flex: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
|
|
35
|
+
.im-face .ad-svg.hv-ad { width: 36px; height: 36px; }
|
|
36
|
+
@media (hover: hover) { .im-ib:hover, .im-face:hover, .im-wk summary:hover { background: var(--cz-well2); } }
|
|
37
|
+
.im-ib:focus-visible, .im-face:focus-visible, .im-wk summary:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* pm/impact.js — Your impact, the screens (feedback batch 16 item 7, Phases 2 to 4; canvas In development "Your impact": GmA1Home, GmA3Garden,
|
|
2
|
+
* GmA4Moments, GmA2Board, GmP4Chapter; brief next16/briefs/7-your-impact-build.md). The ledger, the weekly check in chat and the Settings switch
|
|
3
|
+
* are the backend's (lib/impact.js, pm/impact-check.js); this file only reads GET /api/impact/week and /weeks (contract 7-impact-api.md) and
|
|
4
|
+
* GET /api/impact-views/chapter (lib/routes-impact-views.js), and marks items read (POST /api/impact/seen).
|
|
5
|
+
*
|
|
6
|
+
* readWeek() → the week's body, kept for the page (cached()); { ok, on, live, grow, celebrate, quiet, items } or { ok: false }
|
|
7
|
+
* shows(W) true when a Phase 2 surface may draw: the switch is on and the 9-of-10 gate passed (live)
|
|
8
|
+
* faceHtml(W, o) Home's greeting face as its own press: Adler with the week's leaves on his sprout (grow), "Your impact this week"
|
|
9
|
+
* openWeek(o) the Viewer "Your impact this week": one row per ✓ item with an open icon to its source
|
|
10
|
+
* openLog(o) the Viewer "Your impact": the weeks in plain words, newest first; a quiet week says so and nothing else; past weeks fold
|
|
11
|
+
* celebrate(W, o) once, on a real event: the newest unread ✓ item; a thanks says itself in the toast (the notification moment)
|
|
12
|
+
* meetingLine() the line under a meeting's decisions · intelItem(W) the ✦ line on Intelligence (a key result moved)
|
|
13
|
+
* madeOf(r, today) the Board's "who made it happen" for a milestone delivered in the last 30 days: Jira assignees, unranked
|
|
14
|
+
* madeHtml(x, W) its section · chapterHtml(c, title, o) the Friday card · firstHtml() the empty log's first-run card
|
|
15
|
+
*
|
|
16
|
+
* The rules (Wawan, binding): only you see it and nothing leaves PMOS (no send press anywhere, and every write is the seen mark, local);
|
|
17
|
+
* no numbers (nothing here prints a count, a score or a streak: an item's own sentence and its source label are the only words that may
|
|
18
|
+
* hold a digit, as a ticket key or a date); the leaf is only on Adler's sprout (everything else is plain PM words); every item has a
|
|
19
|
+
* source you can open, so an item whose source has no safe address is not drawn. Pure string builders above the Viewer part. */
|
|
20
|
+
import { pmGet, pmPost } from './http.js';
|
|
21
|
+
import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
|
|
22
|
+
import { adler, prefs as adPrefs } from './cozy-adler.js';
|
|
23
|
+
|
|
24
|
+
const CSS = new URL('./impact.css', import.meta.url).href;
|
|
25
|
+
function addCss() {
|
|
26
|
+
if (typeof document === 'undefined' || !document.head || document.querySelector(`link[href="${CSS}"]`)) return;
|
|
27
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.append(l);
|
|
28
|
+
}
|
|
29
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
30
|
+
const svg = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
31
|
+
const I = {
|
|
32
|
+
open: 'M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5', lock: 'M7 11V8a5 5 0 0 1 10 0v3M5 11h14v9H5z',
|
|
33
|
+
quote: 'M7 7h4v4c0 3-2 5-4 5M14 7h4v4c0 3-2 5-4 5', unlock: 'M7 11V8a5 5 0 0 1 9.6-2M5 11h14v9H5z', doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
|
|
34
|
+
kr: 'M4 20V10M10 20V4M16 20v-8M22 20H2', ship: 'M12 3l8 9-8 9-8-9z', list: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01',
|
|
35
|
+
person: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8M4 21a8 8 0 0 1 16 0',
|
|
36
|
+
};
|
|
37
|
+
const KIND = { thanks: ['quote', 'b'], unblock: ['unlock', ''], used: ['doc', ''], kr: ['kr', 'g'] };
|
|
38
|
+
const LOCK = `<p class="im-lock">${svg(I.lock, 14)}<span>Only you see this. Nothing leaves PMOS.</span></p>`;
|
|
39
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
40
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
41
|
+
const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
42
|
+
const md = (d) => MON[d.getMonth()] + ' ' + d.getDate();
|
|
43
|
+
const wd = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : WD[d.getDay()]; };
|
|
44
|
+
|
|
45
|
+
/** A source's address PMOS will open: https anywhere, or a page of PMOS itself ("/…", never "//…"). '' otherwise, and the item is not drawn. */
|
|
46
|
+
export const safeUrl = (u) => { const s = String(u || '').trim(); return /^https:\/\/[^\s"'<>]+$/i.test(s) || /^\/(?!\/)[^\s"'<>]*$/.test(s) ? s : ''; };
|
|
47
|
+
const linkAttrs = (u) => (/^https:/i.test(u) ? ' target="_blank" rel="noopener noreferrer"' : '');
|
|
48
|
+
/** The items worth drawing: ✓ (real), with a source that opens. */
|
|
49
|
+
export const itemsOf = (W) => ((W && Array.isArray(W.items)) ? W.items : []).filter((it) => it && it.real !== false && it.text && it.source && safeUrl(it.source.url));
|
|
50
|
+
export const shows = (W) => !!(W && W.ok !== false && W.on && W.live);
|
|
51
|
+
|
|
52
|
+
/* ── reads ── */
|
|
53
|
+
let W0 = null, R0 = null;
|
|
54
|
+
export const cached = () => W0;
|
|
55
|
+
export async function readWeek(get = pmGet) {
|
|
56
|
+
const r = await get('/api/impact/week');
|
|
57
|
+
W0 = r && r.ok ? r : { ok: false, on: false, live: false, error: (r && r.error) || 'not read' };
|
|
58
|
+
return W0;
|
|
59
|
+
}
|
|
60
|
+
/* the Settings switch (7-A fires 'pmos:impact' { on }): off hides every surface at once, then the next read says what is true */
|
|
61
|
+
if (typeof window !== 'undefined') window.addEventListener('pmos:impact', (e) => { if (e && e.detail && e.detail.on === false) W0 = { ok: true, on: false }; readWeek().catch(() => {}); });
|
|
62
|
+
export async function readWeeks(get = pmGet) { const r = await get('/api/impact/weeks'); R0 = r && r.ok ? r : { ok: false, error: (r && r.error) || 'not read' }; return R0; }
|
|
63
|
+
/** Marks items read (the only write here; local, never sent anywhere). */
|
|
64
|
+
export async function seen(ids, post = pmPost) { const L = (ids || []).filter(Boolean); if (!L.length) return { ok: true }; return post('/api/impact/seen', { ids: L }); }
|
|
65
|
+
|
|
66
|
+
/* ── one item, the same row everywhere (GmA1Home, GmA3Garden) ── */
|
|
67
|
+
export function rowHtml(it) {
|
|
68
|
+
const u = safeUrl(it.source.url), [ic, tone] = KIND[it.kind] || KIND.used, when = wd(it.at);
|
|
69
|
+
const sub = [it.source.label, when].filter(Boolean).join(' · ');
|
|
70
|
+
return `<div class="im-row" data-im-id="${esc(it.id)}"><span class="im-tile${tone ? ' ' + tone : ''}" aria-hidden="true">${svg(I[ic])}</span>`
|
|
71
|
+
+ `<span class="im-tx"><span class="im-t">${esc(it.text)}</span>${sub ? `<span class="im-s">${esc(sub)}</span>` : ''}</span>`
|
|
72
|
+
+ `<a class="im-ib" href="${esc(u)}"${linkAttrs(u)} data-im-open aria-label="Open the source: ${esc(it.source.label || it.text)}" title="Open the source">${svg(I.open, 20)}</a></div>`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The first-run card (GmA4Moments, FIRST RUN): the log starts empty and says so once. */
|
|
76
|
+
export const firstHtml = () => `<div class="im-first">${adler('resting', 44, { label: false })}<span class="im-tx"><b class="im-t">Your impact log starts empty.</b><span class="im-s">It fills when your work helps someone. Only you see it.</span></span></div>`;
|
|
77
|
+
|
|
78
|
+
/** "Your impact this week" (GmA1Home's Viewer). No count: the headline says what happened, the rows say who. */
|
|
79
|
+
export function weekHtml(W) {
|
|
80
|
+
const L = itemsOf(W);
|
|
81
|
+
if (!L.length) return (W && W.first ? firstHtml() : `<div class="im-hd"><b>A quiet week.</b><span>Nothing is lost. The sprout rests until your work helps someone.</span></div>`) + LOCK;
|
|
82
|
+
return `<div class="im-hd"><b>People got further because of your work.</b><span>Thank you for that. Each one is a leaf on Adler’s sprout.</span></div>`
|
|
83
|
+
+ `<div class="im-card">${L.map(rowHtml).join('')}</div>` + LOCK;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The log (GmA3Garden): this week open, past weeks folded, a quiet week one plain line. → markup */
|
|
87
|
+
export function logHtml(R) {
|
|
88
|
+
const weeks = ((R && R.weeks) || []).map((w) => ({ ...w, items: itemsOf(w) }));
|
|
89
|
+
if (!weeks.some((w) => w.items.length)) return firstHtml() + LOCK;
|
|
90
|
+
const one = (w, i) => {
|
|
91
|
+
const label = esc(w.label || 'Week of ' + w.week);
|
|
92
|
+
if (!w.items.length) return `<div class="im-wk quiet"><span class="im-wl">${label}</span><span class="im-s">A quiet week</span></div>`;
|
|
93
|
+
const lead = esc(w.items[0].text);
|
|
94
|
+
if (i === 0) return `<section class="im-wk" aria-label="${label}"><span class="im-wl">${label}</span><div class="im-card">${w.items.map(rowHtml).join('')}</div></section>`;
|
|
95
|
+
return `<details class="im-wk"><summary><span class="im-wl">${label}</span><span class="im-s">${lead}</span>${svg('M7 10l5 5 5-5', 16)}</summary><div class="im-card">${w.items.map(rowHtml).join('')}</div></details>`;
|
|
96
|
+
};
|
|
97
|
+
return `<div class="im-log">${adler('handled', 'l', { label: 'Adler, his sprout grows from your work', grow: R.grow || (weeks[0].items.length ? 'leaf' : 'rest') })}</div>` + weeks.map(one).join('') + LOCK;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Home's greeting face (GmA1Home): its own press beside "Good morning". Adler's sprout carries the week's leaves. o: { mood, size, joy } */
|
|
101
|
+
export function faceHtml(W, o = {}) {
|
|
102
|
+
if (!shows(W)) return '';
|
|
103
|
+
addCss();
|
|
104
|
+
const joy = !!o.joy, mood = joy ? 'celebrating' : o.mood || 'handled';
|
|
105
|
+
return `<button type="button" class="im-face" data-hm-impact aria-label="Your impact this week" title="Your impact this week">${adler(mood, o.size || 36, { label: false, cls: 'hv-ad', grow: W.grow || 'rest', growNew: joy })}</button>`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ── the Viewer pages ── */
|
|
109
|
+
const VIEW = { kind: 'Your impact', icon: I.person };
|
|
110
|
+
function markRead(L) { const ids = L.filter((x) => x.read === false).map((x) => x.id); if (ids.length) seen(ids).then(() => { for (const x of L) if (ids.includes(x.id)) x.read = true; }); }
|
|
111
|
+
export function openWeek(o = {}) {
|
|
112
|
+
addCss();
|
|
113
|
+
const body = vwOpen({ ...VIEW, id: 'impact-week', title: 'Your impact this week', back: !!o.back,
|
|
114
|
+
presses: [{ act: 'log', label: 'Your impact log', icon: I.list }], onPress: (act) => { if (act === 'log') openLog({ back: true }); },
|
|
115
|
+
render: (b) => { b.innerHTML = `<div class="im">${W0 && W0.ok ? weekHtml(W0) : '<p class="im-s">Reading your impact.</p>'}</div>`; } });
|
|
116
|
+
readWeek(o.get).then((W) => {
|
|
117
|
+
const c = vwCurrent(); if (!c || c.id !== 'impact-week' || !body || !body.isConnected) return;
|
|
118
|
+
if (!shows(W)) { body.innerHTML = `<div class="im"><p class="im-s">${W.ok === false ? 'Your impact could not be read: ' + esc(W.error) + '.' : 'Your impact is off. Turn it on in Settings › General.'}</p></div>`; return; }
|
|
119
|
+
body.innerHTML = `<div class="im">${weekHtml(W)}</div>`; markRead(itemsOf(W));
|
|
120
|
+
});
|
|
121
|
+
return body;
|
|
122
|
+
}
|
|
123
|
+
export function openLog(o = {}) {
|
|
124
|
+
addCss();
|
|
125
|
+
const body = vwOpen({ ...VIEW, id: 'impact-log', title: 'Your impact', back: !!o.back, render: (b) => { b.innerHTML = '<div class="im"><p class="im-s">Reading your impact.</p></div>'; } });
|
|
126
|
+
readWeeks(o.get).then((R) => {
|
|
127
|
+
const c = vwCurrent(); if (!c || c.id !== 'impact-log' || !body || !body.isConnected) return;
|
|
128
|
+
if (!shows(R)) { body.innerHTML = `<div class="im"><p class="im-s">${R.ok === false ? 'Your impact could not be read: ' + esc(R.error) + '.' : 'Your impact is off. Turn it on in Settings › General.'}</p></div>`; return; }
|
|
129
|
+
body.innerHTML = `<div class="im">${logHtml({ ...R, grow: W0 && W0.grow })}</div>`;
|
|
130
|
+
markRead(((R.weeks || [])[0] || {}).items ? itemsOf(R.weeks[0]) : []);
|
|
131
|
+
});
|
|
132
|
+
return body;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The one celebration (GmA4Moments NOTIFICATION): Adler grows his newest leaf once, and an inbound thanks says itself in the toast. Then the
|
|
136
|
+
* item is marked read, so the next open is still. Never with Settings › Adler › Celebrations: Never. → the item celebrated, or null */
|
|
137
|
+
export function celebrate(W, o = {}) {
|
|
138
|
+
if (!shows(W) || !W.celebrate || adPrefs()['adler.celebrate'] !== 'real') return null;
|
|
139
|
+
const it = itemsOf(W).find((x) => x.id === W.celebrate);
|
|
140
|
+
if (!it) return null;
|
|
141
|
+
if (it.kind === 'thanks' && o.toast) o.toast(it.who ? it.who + ' thanked you · ' + it.text : it.text);
|
|
142
|
+
seen([it.id], o.post);
|
|
143
|
+
W.celebrate = null;
|
|
144
|
+
return it;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The meeting moment (GmA4Moments MEETING NOTES): one quiet line under a meeting's decisions. '' when Your impact is not showing. */
|
|
148
|
+
export const meetingLine = (W = W0) => (shows(W) ? `<p class="im-mt">${svg(I.unlock, 14)}<span>Recorded. If it unblocks someone, it goes in your impact log.</span></p>` : '');
|
|
149
|
+
|
|
150
|
+
/** The Intelligence moment (GmA4Moments INTELLIGENCE): this week's key-result item, as one more ✦ line on the strip. null when none. */
|
|
151
|
+
export function intelItem(W = W0) {
|
|
152
|
+
if (!shows(W)) return null;
|
|
153
|
+
const it = itemsOf(W).find((x) => x.kind === 'kr');
|
|
154
|
+
return it ? { text: it.text, why: 'Your part in it. Only you see this line.', impact: { url: safeUrl(it.source.url), label: it.source.label || 'Open the source' } } : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ── Phase 3: who made it happen (GmA2Board). Read from the Board's own row: no API, no send, no ranking. ── */
|
|
158
|
+
/** The milestone delivered most recently, within 30 days of today, and the people on its tickets. null when there is none or nobody. */
|
|
159
|
+
export function madeOf(r, today) {
|
|
160
|
+
const t = dayOf(today) || new Date(); t.setHours(0, 0, 0, 0);
|
|
161
|
+
const ms = ((r && r.milestones) || []).filter((m) => m && m.done && dayOf(m.date)).map((m) => ({ ...m, d: dayOf(m.date) }))
|
|
162
|
+
.filter((m) => m.d <= t && (t - m.d) / 864e5 <= 30).sort((a, b) => b.d - a.d)[0];
|
|
163
|
+
if (!ms) return null;
|
|
164
|
+
const by = new Map();
|
|
165
|
+
for (const k of (r.track && r.track.tickets) || []) {
|
|
166
|
+
const who = String(k.assignee || '').trim(); if (!who || by.has(who)) continue;
|
|
167
|
+
const url = safeUrl(k.url); if (!url) continue;
|
|
168
|
+
by.set(who, { who, what: k.title || k.key, key: k.key, url });
|
|
169
|
+
}
|
|
170
|
+
const people = [...by.values()].sort((a, b) => a.who.localeCompare(b.who)); // unranked: by name, never by amount of work
|
|
171
|
+
return people.length ? { ms: { name: ms.name, date: md(ms.d) }, people } : null;
|
|
172
|
+
}
|
|
173
|
+
const initial = (s) => esc(String(s || '?').trim().charAt(0).toUpperCase() || '?');
|
|
174
|
+
export function madeHtml(x, W = W0) {
|
|
175
|
+
if (!x || !shows(W)) return '';
|
|
176
|
+
addCss();
|
|
177
|
+
return `<section class="im im-made" aria-label="Who made it happen"><div class="im-mh">${adler('celebrating', 44, { label: false })}<span class="im-tx"><b class="im-t">${esc(x.ms.name)} delivered on ${esc(x.ms.date)}.</b><span class="im-s">Here’s who made it happen.</span></span></div>`
|
|
178
|
+
+ `<div class="im-card">${x.people.map((p) => `<div class="im-row"><span class="im-av" aria-hidden="true">${initial(p.who)}</span><span class="im-tx"><b class="im-t">${esc(p.who)}</b><span class="im-s">${esc(p.what)}</span></span>`
|
|
179
|
+
+ `<a class="im-ib" href="${esc(p.url)}"${linkAttrs(p.url)} aria-label="Open ${esc(p.key || p.what)}" title="Open ${esc(p.key || 'the ticket')}">${svg(I.open, 20)}</a></div>`).join('')}</div>${LOCK}</section>`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* ── Phase 4: the Friday chapter (GmP4Chapter) ── */
|
|
183
|
+
/** The chapter to show today: Fridays only, Your impact showing, and a stage of one of Home's initiatives closed this week. c is one of
|
|
184
|
+
* GET /api/impact-views/chapter's chapters; titleOf(id) → the initiative's title from Home's rows, or ''. → { c, title } | null */
|
|
185
|
+
export function chapterToday(chapters, titleOf, now = Date.now(), W = W0) {
|
|
186
|
+
if (!shows(W) || new Date(now).getDay() !== 5) return null;
|
|
187
|
+
for (const c of chapters || []) { const title = titleOf(c.id); if (title) return { c, title }; }
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
/** o: { href } the initiative's own page in PMOS (its source) */
|
|
191
|
+
export function chapterHtml(x, o = {}) {
|
|
192
|
+
if (!x) return '';
|
|
193
|
+
addCss();
|
|
194
|
+
const { c, title } = x, then = dayOf(c.then && c.then.at), href = safeUrl(o.href);
|
|
195
|
+
const rows = [[then ? md(then).toUpperCase() : 'THEN', c.then && c.then.line ? c.then.line : 'It started on the board'], ['TODAY', c.closed + ' closed. ' + title + ' is in ' + c.now + '.']];
|
|
196
|
+
return `<section class="im im-ch" aria-label="This week’s chapter"><div class="im-hd"><b>Look how far ${esc(title)} came.</b><span>${esc(c.closed)} closed this week. Thank you for the push.</span></div>`
|
|
197
|
+
+ `<div class="im-card">${rows.map(([k, v]) => `<div class="im-row"><span class="im-wl">${esc(k)}</span><span class="im-tx"><span class="im-t">${esc(v)}</span></span></div>`).join('')}`
|
|
198
|
+
+ (href ? `<div class="im-row"><span class="im-tile" aria-hidden="true">${svg(I.ship)}</span><span class="im-tx"><span class="im-t">${esc(title)}</span><span class="im-s">${esc(c.closed)} → ${esc(c.now)}</span></span><a class="im-ib" href="${esc(href)}" aria-label="Open ${esc(title)}" title="Open ${esc(title)}">${svg(I.open, 20)}</a></div>` : '')
|
|
199
|
+
+ `</div></section>`;
|
|
200
|
+
}
|
|
201
|
+
export async function readChapters(get = pmGet) { const r = await get('/api/impact-views/chapter'); return r && r.ok ? r.chapters || [] : []; }
|