create-pmos 0.812.0 → 0.814.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.
@@ -18,6 +18,12 @@
18
18
 
19
19
  import { dashModel as lineDash, dashHtml as lineDashHtml } from './line-view.js'; // quiet-rows-line: Your move ends with the line's dashed line
20
20
  import { groupsHtml as questionGroups, phoneGroupsHtml as phoneQuestionGroups } from './open-questions-view.js'; // open-questions-today (A420)
21
+
22
+ /** What a right-click on a Today row names (initiative ask-anywhere): its initiative when it has one, else the row itself. */
23
+ function askOf(r) {
24
+ if (r.ini) return ` data-ask="initiative:${esc(r.ini)}" data-ask-title="${esc(r.work || r.ini)}"${r.ws ? ` data-ask-ws="${esc(r.ws)}"` : ''}`;
25
+ return ` data-ask="today item:${esc(r.key)}" data-ask-title="${esc(r.title || r.text || '')}"`;
26
+ }
21
27
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
22
28
  const svg = (d, w = 15, sw = 1.9) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
23
29
  /** The system's icon (pm-ic: stroke, size and caps come from the part). */
@@ -87,7 +93,7 @@ export function rowHtml(r, o = {}) {
87
93
  const why = r.member ? '' : whyLine(r);
88
94
  const w = why || did ? `<span class="w td-rs">${did}${esc(why)}</span>` : '';
89
95
  const late = lateOf(r);
90
- const row = `<div class="${cls}" data-key="${esc(r.key)}"><span class="td-kind" role="img" aria-label="${esc(kl)}">${ic(kd)}</span><span class="txt">${title}${w}</span>`
96
+ const row = `<div class="${cls}" data-key="${esc(r.key)}"${askOf(r)}><span class="td-kind" role="img" aria-label="${esc(kl)}">${ic(kd)}</span><span class="txt">${title}${w}</span>`
91
97
  + `${first}${chips}${late ? `<span class="pm-badge alert">${esc(late)}</span>` : ''}${acts ? `<span class="acts td-a">${acts}</span>` : ''}</div>`;
92
98
  const sug = r.drop ? sugHtml('PMOS suggests: drop it from your log.', ['drop', 'Drop it'], ['keep', 'Keep it'], r.key) : '';
93
99
  const lk = r.looks && !r.done ? sugHtml('Looks answered: ' + (r.looks.who ? r.looks.who + ' replied' : 'someone replied') + ' “' + r.looks.text + '”. Close it?', ['lk-yes', 'Yes, close it: it is answered'], ['lk-no', 'No, it still waits on me'], r.key) : '';
@@ -132,7 +138,7 @@ export function overviewHtml(O) {
132
138
  let said = esc(O.said || '');
133
139
  for (const x of O.refs || []) {
134
140
  const t = esc(x.text), at = said.indexOf(t);
135
- if (at >= 0) said = said.slice(0, at) + `<button type="button" class="td-ln" data-td="open" data-key="${esc(x.key)}">${t}</button>` + said.slice(at + t.length);
141
+ if (at >= 0) said = said.slice(0, at) + `<button type="button" class="td-ln" data-td="open" data-key="${esc(x.key)}"${askOf(x)}>${t}</button>` + said.slice(at + t.length);
136
142
  }
137
143
  const sug = (O.suggest || []).map((x) => (x.act === 'sync' ? syncHtml(x) : sugHtml(x.text, ['ov-yes', x.text], ['ov-no', 'Keep them: ' + x.text], x.key, 'td-ovs'))).join('');
138
144
  return `<section class="td-ov pm-block" aria-label="Overview"><h2 class="pm-h-sm pm-row">${ic(I.spark, 16, 'pm-star')}Overview</h2>${said ? `<p>${said}</p>` : ''}${sug}</section>`;
@@ -161,7 +167,7 @@ export function moveRowHtml(r, n, o = {}) {
161
167
  // what the PM typed opens nothing: its words are the whole of it
162
168
  const title = r.src === 'own' ? `<span class="t td-t">${esc(r.title)}</span>`
163
169
  : `<button type="button" class="t td-t" data-td="open" data-key="${esc(r.key)}"${r.members ? ` aria-expanded="${!!o.sopen}"` : ''}>${esc(r.title)}${r.members ? ic(I.more, 14) : ''}</button>`;
164
- return `<div class="td-li pm-li ym-r${n === 1 ? ' now' : ''}" data-key="${esc(r.key)}"><span class="ym-n pm-meta" aria-hidden="true">${n}</span>`
170
+ return `<div class="td-li pm-li ym-r${n === 1 ? ' now' : ''}" data-key="${esc(r.key)}"${askOf(r)}><span class="ym-n pm-meta" aria-hidden="true">${n}</span>`
165
171
  + `<span class="td-kind" role="img" aria-label="${esc(kl)}">${ic(kd)}</span><span class="txt">${title}${meta ? `<span class="w td-rs">${esc(meta)}</span>` : ''}`
166
172
  + `<span class="w td-rs ym-why">${ic(I.spark, 13, 'pm-star')}${esc(r.why || '')}</span></span>${late ? `<span class="pm-badge alert">${esc(late)}</span>` : ''}`
167
173
  + `<span class="acts td-a">${moveAct(r)}${ib('tomorrow', 'Put off a day: ' + r.title, I.tomorrow, r.key)}</span></div>`
@@ -335,7 +341,7 @@ export function phoneRowHtml(r, o = {}) {
335
341
  : fx ? `<span class="tdp-pro">${svg(PI.spark, 13, 1.9)}<span>${esc(fx)}</span></span>` : '';
336
342
  const dot = rowDot(r, o), dl = r.done ? 'Done' : dot === 'alert' ? 'Late' : dot === 'blue' ? 'For today' : 'Can wait';
337
343
  const say = sw.right ? ` aria-describedby="tdpHint"` : '';
338
- return `<li class="tdp-r${r.done ? ' done' : ''}${r.first && !r.done ? ' first' : ''}" data-key="${esc(r.key)}"${sw.right ? ` data-sw-right="${sw.right}"` : ''}${sw.left ? ` data-sw-left="${sw.left}"` : ''}${say}>`
344
+ return `<li class="tdp-r${r.done ? ' done' : ''}${r.first && !r.done ? ' first' : ''}" data-key="${esc(r.key)}"${askOf(r)}${sw.right ? ` data-sw-right="${sw.right}"` : ''}${sw.left ? ` data-sw-left="${sw.left}"` : ''}${say}>`
339
345
  + (r.done ? `<span class="tdp-b" role="img" aria-label="Done">${svg(I.done, 13, 2)}</span>` : `<i class="tdp-dot ${dot}" role="img" aria-label="${dl}"></i>`)
340
346
  + `<div class="tdp-x">${title}${meta ? `<small class="tdp-m">${meta}</small>` : ''}${fix}</div></li>`;
341
347
  }
@@ -350,13 +350,19 @@ function tileHtml(r) {
350
350
  if (r.kind === 'update') return `<span class="hm-tile">${SVG(I.doc, 14)}</span>`;
351
351
  return `<span class="hm-tile">${SVG(ROW_ICON[r.icon] || I.chat, 14)}</span>`;
352
352
  }
353
+ // what a right-click on a Today row names (initiative ask-anywhere): its initiative when it has one, else the row itself
354
+ function askOf(r) {
355
+ const ir = r.ini && r.ini !== 'product' ? iniRowOf(r.ini) : null;
356
+ if (ir) return ` data-ask="initiative:${esc(r.ini)}" data-ask-title="${esc(ir.title || r.ini)}"${r.ws ? ` data-ask-ws="${esc(r.ws)}"` : ''}`;
357
+ return ` data-ask="today item:${esc(r.id)}" data-ask-title="${esc(r.name || '')}"`;
358
+ }
353
359
  function rowHtml(r, o = {}) {
354
360
  const sel = S.sel === r.id;
355
361
  const end = r.kind === 'session' && r.sid ? `<button type="button" class="hm-x" data-hm-end="${esc(r.id)}" aria-label="End ${esc(r.name)}" title="End this session">${SVG(I.x, 14, 2)}</button>`
356
362
  : r.kind === 'need' && r.row ? `<button type="button" class="hm-x" data-hm-end="${esc(r.id)}" aria-label="Put off ${esc(r.name)} until tomorrow" title="Put off until tomorrow">${SVG(I.x, 14, 2)}</button>` : '';
357
363
  const chip = r.chip ? `<button type="button" class="hm-kc${r.chip.loud ? ' loud' : ''}" data-hm-kids="${esc(r.id)}" aria-expanded="${S.kids.has(r.id)}" aria-label="${esc(r.chip.text)} in ${esc(r.name)}. Show">${esc(r.chip.text)}${SVG(S.kids.has(r.id) ? I.down : I.chev, 12, 2.2)}</button>` : '';
358
364
  const kids = r.kids && S.kids.has(r.id) ? `<div class="hm-kids" role="group" aria-label="In ${esc(r.name)}">${r.kids.map((k) => rowHtml(k, { kid: true })).join('') || '<p class="hm-none">Nothing here now.</p>'}</div>` : '';
359
- return `<div class="hm-r${sel ? ' sel' : ''}${o.kid ? ' kid' : ''} st-${esc(r.state)}" data-id="${esc(r.id)}">`
365
+ return `<div class="hm-r${sel ? ' sel' : ''}${o.kid ? ' kid' : ''} st-${esc(r.state)}" data-id="${esc(r.id)}"${askOf(r)}>`
360
366
  + `<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}><i class="hm-dot ${dotCls(r.state)}" aria-hidden="true"></i>${tileHtml(r)}`
361
367
  + `<span class="hm-rt"><b>${r.kind === 'ini' ? SM.nameHtml(r.board, r.name) : esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
362
368
  }
@@ -450,6 +456,8 @@ function rankIn() {
450
456
  if (S.movesRow) extra.push(S.movesRow);
451
457
  // quiet-work-sweep (A503): the initiatives quiet 30 days or more on every product, one row a week until the PM opens the list (pm/quiet-view.js)
452
458
  if (S.quietRow) extra.push(S.quietRow);
459
+ // week-went-summary (A342): where the PM's week went, every product in one row from Friday to Sunday until opened (pm/week-went-view.js)
460
+ if (S.weekRow) extra.push(S.weekRow);
453
461
  // try-what-shipped: one row while the updates brought changes to try (beta only; GET /api/try says the row, pm/try-view.js opens the list)
454
462
  if (S.tryRow) extra.push(S.tryRow);
455
463
  return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], gaps: (S.wait && S.wait.gaps) || [], extra };
@@ -483,12 +491,19 @@ async function readMove() {
483
491
  S.quiet = qs.filter((r) => r && r.ok);
484
492
  const prevQuiet = JSON.stringify(S.quietRow || null);
485
493
  try { const QV = await import('./quiet-view.js'); S.quietRow = QV.rowOf(S.quiet, { looked: QV.lookedWeek() }); } catch { S.quietRow = null; }
494
+ // week-went-summary (A342): each product's week (GET /api/week-went), read only from Friday to Sunday, folded into one Your move row
495
+ const prevWeek = JSON.stringify(S.weekRow || null);
496
+ if ([5, 6, 0].includes(new Date().getDay())) {
497
+ const wk = await Promise.all(L.map((ws) => pmGet('/api/week-went' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
498
+ S.week = wk.filter((r) => r && r.ok);
499
+ try { const WV = await import('./week-went-view.js'); S.weekRow = WV.rowOf(S.week, { looked: WV.lookedWeek() }); } catch { S.weekRow = null; }
500
+ } else S.weekRow = null;
486
501
  const prevTry = JSON.stringify(S.tryRow || null);
487
502
  try { const TV = await import('./try-view.js'); S.tryRow = TV.rowOf(await pmGet('/api/try').catch(() => null)); } catch { S.tryRow = null; }
488
503
  const ob = await pmGet('/api/outbox').catch(() => null);
489
504
  const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
490
505
  const lab = labs.filter(Boolean);
491
- const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevQuiet === JSON.stringify(S.quietRow || null) && prevTry === JSON.stringify(S.tryRow || null);
506
+ const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevQuiet === JSON.stringify(S.quietRow || null) && prevWeek === JSON.stringify(S.weekRow || null) && prevTry === JSON.stringify(S.tryRow || null);
492
507
  S.move = next; S.outbox = outbox; S.lab = lab;
493
508
  if (!same) { redrawLater(); drawList(); }
494
509
  // a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
@@ -526,6 +541,7 @@ async function movePress(b) {
526
541
  if (r.go === 'impact') { S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; }
527
542
  if (r.go === 'loose') { VW.drill(); LPV.open(lpHost); return; }
528
543
  if (r.go === 'moves') { VW.drill(); import('./moves-view.js').then((MV) => { MV.openMoves(S.moves || [], { toast }); S.movesRow = null; drawList(); }); return; }
544
+ if (r.go === 'week') { VW.drill(); import('./week-went-view.js').then((WV) => { WV.openWeek(S.week || [], { toast }); S.weekRow = null; drawList(); }); return; }
529
545
  if (r.go === 'quiet') { VW.drill(); import('./quiet-view.js').then((QV) => { QV.openQuiet(S.quiet || [], { pmPost, toast, toastUndo }); S.quietRow = null; drawList(); }); return; }
530
546
  if (r.go === 'try') { VW.drill(); import('./try-view.js').then((TV) => TV.openTry({ toast, toastUndo, onChange: (l) => { S.tryRow = TV.rowOf({ ...l, ok: true, row: l.total ? { ...S.tryRow, title: l.total + (l.total === 1 ? ' new thing to try' : ' new things to try') } : null }); drawList(); } })); return; }
531
547
  if (r.go === 'lab') { VW.drill(); import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: r.ws, board: r.board }), iniHref: (id) => '/premium-initiative.html?' + (r.ws ? 'ws=' + encodeURIComponent(r.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })); return; }
@@ -39,6 +39,8 @@ const ICON = {
39
39
  proto: 'M4 5h16v12H4zM9 20h6',
40
40
  checks: 'M4 6.5l2 2 3.5-3.5M4 13.5l2 2 3.5-3.5M13 7h7M13 14h7M13 19h7',
41
41
  };
42
+ // what a right-click on a row names (initiative ask-anywhere): the item, in plain words
43
+ const ASK_KIND = { meeting: 'meeting note', link: 'link', proto: 'prototype', checks: 'checklist' };
42
44
  const PEN = 'M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17zM13.5 6.5l3 3', CLEAR = 'M4 6h16M7 12h10M10 18h4', RELOAD = 'M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5';
43
45
  const CHEV_D = 'M6 9l6 6 6-6', CHEV_R = 'M9 6l6 6-6 6', TICK = 'M5 12.5l4.5 4.5L19 7.5', X = 'M6 6l12 12M18 6L6 18', PART = 'M7 12h10';
44
46
  const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', OPEN = 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5';
@@ -219,7 +221,7 @@ function rowHtml(r, i, sub = false, shelf = '') {
219
221
  if (!aboutText(x) && x.kind === 'meeting' && x.suggest) {
220
222
  why += ` · <button type="button" class="lb-sg" data-lb-link="${esc(x.id)}" title="PMOS suggests: this note is about ${esc(x.suggest.title)}. Press to link it">${svg(SPARK, 'pm-star')}<span>${esc(x.suggest.title)}?</span></button>`;
221
223
  }
222
- return `<div class="pm-li lb-i${sub ? ' nest' : ''}${S.pick === x.id ? ' now' : ''}" role="listitem" data-lb-i="${i}" aria-label="${esc(label)}">`
224
+ return `<div class="pm-li lb-i${sub ? ' nest' : ''}${S.pick === x.id ? ' now' : ''}" role="listitem" data-lb-i="${i}" data-ask="${ASK_KIND[x.kind] || 'document'}:${esc(x.path || x.id)}" data-ask-title="${esc(x.name)}" aria-label="${esc(label)}">`
223
225
  + `<span class="pm-meta lb-mi">${svg(ICON[x.kind] || ICON.doc)}</span>`
224
226
  + `<span class="txt">${nameHtml(shown, older)}<span class="w">${why}</span></span>${badge(r)}${actsHtml(x)}</div>`;
225
227
  }
@@ -327,7 +327,7 @@ function makePage(d, ctx) {
327
327
  if (!el || !el.isConnected) return;
328
328
  const keepScroll = el.scrollTop;
329
329
  const reading = P.mode === 'read' && !ctx.host && P.text != null && !P.err && !openProp();
330
- el.innerHTML = `<div class="vwdoc${reading ? ' rdw pm-reads' : ''}">${pageHtml()}</div>`;
330
+ el.innerHTML = `<div class="vwdoc${reading ? ' rdw pm-reads' : ''}" data-ask="document:${esc(d.path)}" data-ask-title="${esc(d.title || String(d.path).split('/').pop())}"${baseWs() ? ` data-ask-ws="${esc(baseWs())}"` : ''}>${pageHtml()}</div>`;
331
331
  el.scrollTop = keepScroll;
332
332
  if (reading) wireReading(el, el, d.path); else if (P.mode === 'read') tocOf();
333
333
  if (P.mode === 'edit') startEdit();
@@ -41,10 +41,12 @@ function chartSvg(e) {
41
41
  if (e.kind === 'line') {
42
42
  const P = d.map((x, i) => [bw * i + bw / 2, Y(+x[1] || 0)]);
43
43
  g += `<polyline class="sl-line" points="${P.map((p) => p.join(',')).join(' ')}"/>` + P.map((p, i) => `<circle class="sl-pt" cx="${p[0]}" cy="${p[1]}" r="8"/>${lab(p[0], p[1] - 16, d[i][1])}`).join('');
44
- } else g += d.map((x, i) => { const y = Y(+x[1] || 0); return `<rect class="sl-bar${i === d.length - 1 ? ' last' : ''}" x="${bw * i + bw * 0.17}" y="${y}" width="${bw * 0.66}" height="${Math.max(0, h - B - y)}" rx="6"/>${lab(bw * i + bw / 2, y - 10, x[1])}`; }).join('');
44
+ } else g += d.map((x, i) => { const y = Y(+x[1] || 0); return `<rect class="sl-bar${i === d.length - 1 ? ' last' : ''}" data-ask-field="Chart bar" aria-label="${esc(x[0] + ' · ' + x[1])}" x="${bw * i + bw * 0.17}" y="${y}" width="${bw * 0.66}" height="${Math.max(0, h - B - y)}" rx="6"/>${lab(bw * i + bw / 2, y - 10, x[1])}`; }).join('');
45
45
  g += d.map((x, i) => `<text class="sl-axl" x="${bw * i + bw / 2}" y="${h - 8}" text-anchor="middle">${esc(x[0])}</text>`).join('');
46
46
  return `<svg viewBox="0 0 ${w} ${h}" role="img" aria-label="${esc((e.kind === 'line' ? 'Line' : 'Bar') + ' chart: ' + d.map((x) => x[0] + ' ' + x[1]).join(', '))}">${g}</svg>`;
47
47
  }
48
+ // what a right-click on a part of a slide names (initiative ask-anywhere)
49
+ const PART = { title: 'Title', text: 'Text', chart: 'Chart', table: 'Table', img: 'Image' };
48
50
  function elHtml(e, ws, edit) {
49
51
  const inner = e.t === 'text' ? `<div class="sl-tx">${e.html}</div>`
50
52
  : e.t === 'chart' ? chartSvg(e)
@@ -52,7 +54,7 @@ function elHtml(e, ws, edit) {
52
54
  : e.t === 'img' ? (e.src ? `<img src="${esc(asset(ws, e.src))}" alt="${esc(e.alt || '')}" data-src="${esc(e.src)}">` : `<div class="sl-ph">${I('img')}<span>${edit ? 'Double-click to choose an image' : 'No image'}</span></div>`)
53
55
  : `<div class="sl-sh f-${e.fill || 'acc'}${e.round ? ' dot' : ''}"></div>`;
54
56
  const cls = `sl-it t-${e.t}${e.role ? ' r-' + e.role : ''}${e.align && e.align !== 'left' ? ' a-' + e.align : ''}${e.color ? ' c-' + e.color : ''}`;
55
- return `<div class="${cls}" data-id="${e.id || ''}" data-g="${e.x},${e.y},${e.w},${e.h}">${inner}${edit ? ['nw', 'ne', 'sw', 'se'].map((h) => `<i class="sl-hdot h-${h}" data-h="${h}"></i>`).join('') : ''}</div>`;
57
+ return `<div class="${cls}" data-id="${e.id || ''}" data-ask-field="${PART[e.t === 'text' && e.k === 'title' ? 'title' : e.t] || 'Shape'}" data-g="${e.x},${e.y},${e.w},${e.h}">${inner}${edit ? ['nw', 'ne', 'sw', 'se'].map((h) => `<i class="sl-hdot h-${h}" data-h="${h}"></i>`).join('') : ''}</div>`;
56
58
  }
57
59
  export function slideHtml(s, theme, ws, edit) {
58
60
  return `<div class="sl-cv${edit ? ' ed' : ''}" data-th="${esc(theme)}">${s.els.map((e) => elHtml(e, ws, edit)).join('')}${edit ? '<i class="sl-guide gv"></i><i class="sl-guide gh"></i>' : ''}</div>`;
@@ -273,6 +275,9 @@ const railName = (s, k) => { const t = s.els.find((e) => e.t === 'text' && e.k =
273
275
  function drawStage(S) {
274
276
  const st = S.$('.sl-stage');
275
277
  st.innerHTML = slideHtml(cur(S), S.deck.theme, S.ws, !S.ro);
278
+ // the slide is the record a right-click names (initiative ask-anywhere): the deck's path and the slide's number
279
+ st.dataset.ask = 'slide:' + S.path + '#' + (S.i + 1); st.dataset.askTitle = String(S.path).split('/').pop() + ' · slide ' + (S.i + 1);
280
+ if (S.ws) st.dataset.askWs = S.ws;
276
281
  fit(st); place(st);
277
282
  if (S.sel) { const n = node(S, S.sel); if (n) n.classList.add('sel'); else S.sel = null; }
278
283
  }
@@ -0,0 +1,99 @@
1
+ /* pm/week-went-view.js — where the PM's week went (initiative week-went-summary, idea A342; lib/week-went.js, GET /api/week-went).
2
+ * Pure apart from openWeek: Node imports it (week-went.test.js W4, N1).
3
+ *
4
+ * foldOf(lists) → { week, meetings, minutes, decisions, reviews, writing, done, moves, top, line, total } | null
5
+ * every product's GET /api/week-went answer as one week: the calendar meetings and the notes are the
6
+ * runtime's, so they count once (from the first answer); decisions, reviews, tasks done and moves sum
7
+ * rowOf(lists, { looked, day }) → Today's Your move row ({ key, go: 'week', week, title, sub }) or null: only on Friday, Saturday or
8
+ * Sunday (day: 0-6, Sunday 0, the browser's day by default), null for an empty week (zero is silence) and
9
+ * once the PM opened this week's card
10
+ * cardHtml(fold, { esc }) → the card: one row per kind, most first, then the line on what moved
11
+ * openWeek(lists, H) the card in the Viewer. H: { toast }. Opening it marks the week as looked and logs the use-log control
12
+ * weekWentOpen (the health number). It reads nothing more, writes nothing to a product and sends nothing.
13
+ * lookedWeek() · markLooked(week) which week the PM opened (this browser only; a missing store reads as not looked) */
14
+
15
+ const KEY = 'pmos.weekwent.looked';
16
+ const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+ const ICON = 'M3 3v18h18M7 15l4-4 3 3 5-6';
18
+ const ok = (l) => l && l.ok && l.week;
19
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
20
+ const WEEKEND = new Set([5, 6, 0]); // Friday, Saturday, Sunday
21
+
22
+ /** Hours and minutes, short: 45 min, 2 h, 9 h 30 min. */
23
+ export function hoursOf(min) {
24
+ const m = Math.max(0, Math.round(Number(min) || 0));
25
+ if (m < 60) return m + ' min';
26
+ const h = Math.floor(m / 60), r = m % 60;
27
+ return h + ' h' + (r ? ' ' + r + ' min' : '');
28
+ }
29
+
30
+ export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
31
+ export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
32
+
33
+ /** Every product's answer as one week. */
34
+ export function foldOf(lists) {
35
+ const L = (lists || []).filter(ok);
36
+ if (!L.length) return null;
37
+ const week = L[0].week, rt = L[0].runtime || {};
38
+ const f = { week, meetings: rt.meetings || 0, minutes: rt.minutes || 0, writing: rt.writing || 0, decisions: 0, reviews: 0, done: 0, moves: 0, top: null };
39
+ for (const l of L.filter((x) => x.week === week)) {
40
+ const p = l.product || {};
41
+ f.decisions += p.decisions || 0; f.reviews += p.reviews || 0; f.done += p.done || 0; f.moves += p.moves || 0;
42
+ if (p.top && (!f.top || p.top.n > f.top.n)) f.top = { ...p.top, product: L.length > 1 ? l.name || l.ws : '' };
43
+ }
44
+ f.total = f.meetings + f.decisions + f.reviews + f.writing + f.done;
45
+ f.line = lineOf(f);
46
+ return f;
47
+ }
48
+
49
+ /** The one sentence on what moved, over every product (lib/week-went.js lineOf, said the same way). */
50
+ function lineOf({ done = 0, top = null, moves = 0 }) {
51
+ const bits = [];
52
+ if (done) bits.push(plural(done, 'task', 'tasks') + ' done' + (top && done > 1 && top.n > 1 ? ', most on ' + top.title + ' (' + top.n + ')' : top ? ' on ' + top.title : ''));
53
+ if (moves) bits.push(plural(moves, 'date or scope change', 'dates or scope changes'));
54
+ return bits.length ? 'What moved: ' + bits.join('; ') + '.' : 'Nothing moved on the plan this week.';
55
+ }
56
+
57
+ /** Today's Your move row for this week, or null. */
58
+ export function rowOf(lists, { looked = '', day = new Date().getDay() } = {}) {
59
+ if (!WEEKEND.has(day)) return null;
60
+ const f = foldOf(lists);
61
+ if (!f || !f.total) return null;
62
+ if (looked === f.week) return null;
63
+ const head = [];
64
+ if (f.meetings) head.push(hoursOf(f.minutes) + ' in ' + plural(f.meetings, 'meeting', 'meetings'));
65
+ if (f.decisions) head.push(plural(f.decisions, 'decision', 'decisions'));
66
+ if (!head.length && f.done) head.push(plural(f.done, 'task', 'tasks') + ' done');
67
+ if (!head.length && f.reviews) head.push(plural(f.reviews, 'review', 'reviews'));
68
+ if (!head.length && f.writing) head.push(plural(f.writing, 'note', 'notes') + ' written');
69
+ return { key: 'week:' + f.week, go: 'week', week: f.week, title: 'Where your week went: ' + head.join(', '), sub: 'Your week by kind, and what moved.' };
70
+ }
71
+
72
+ /** The card: one row per kind with its count, most first, then what moved. A kind with nothing is left out (zero is silence). */
73
+ export function cardHtml(f, { esc = escDefault } = {}) {
74
+ if (!f || !f.total) return '<p class="yd-exp">Nothing to show for this week yet.</p>';
75
+ const kinds = [
76
+ { k: 'meetings', n: f.meetings, say: plural(f.meetings, 'meeting', 'meetings') + (f.meetings ? ', ' + hoursOf(f.minutes) : '') },
77
+ { k: 'decisions', n: f.decisions, say: plural(f.decisions, 'decision', 'decisions') },
78
+ { k: 'reviews', n: f.reviews, say: plural(f.reviews, 'review of what PMOS proposed', 'reviews of what PMOS proposed') },
79
+ { k: 'writing', n: f.writing, say: plural(f.writing, 'note written', 'notes written') },
80
+ { k: 'done', n: f.done, say: plural(f.done, 'task done', 'tasks done') },
81
+ ].filter((x) => x.n > 0);
82
+ // most first: where the week went is the order
83
+ kinds.sort((a, b) => b.n - a.n);
84
+ const bars = kinds.map((x) => `<li class="mv-row" data-ww="${esc(x.k)}"><span class="mv-say">${esc(x.say)}</span></li>`).join('');
85
+ return `<p class="yd-exp">The week of ${esc(f.week)}, from what PMOS already reads. Nothing was sent.</p><ul class="mv-list">${bars}</ul>`
86
+ + `<p class="yd-exp">${esc(f.line)}</p>`;
87
+ }
88
+
89
+ /** The card in the Viewer; opening it marks the week as looked. */
90
+ export function openWeek(lists, H = {}) {
91
+ const VW = window.czViewer;
92
+ const toast = H.toast || (() => {});
93
+ const f = foldOf(lists);
94
+ if (f) markLooked(f.week);
95
+ import('./use-log.js').then((U) => { if (U.startUseLog) U.startUseLog(); if (U.noteUse) U.noteUse('weekWentOpen'); }).catch(() => {}); // the health number, local only
96
+ if (!VW) { toast('The card could not open here.'); return; }
97
+ VW.open({ id: 'week:' + ((f && f.week) || ''), kind: 'Your week', title: 'Where your week went', icon: ICON, presses: [],
98
+ render: (b) => { b.innerHTML = cardHtml(f); } });
99
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Ask PMOS about anything you click (initiative ask-anywhere, A528, done test planning/done-tests/ask-anywhere.md R1-R3): pm/ask-here-ctx.js names the pressed record, field and value on a fake tree, steps out with ↑, and hands page-chat.js itemTarget the facts. No server, network or browser.",
3
+ "modules": [
4
+ "ask-here.test.js"
5
+ ],
6
+ "seconds": {
7
+ "ask-here.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Where the week went (initiative week-went-summary, done test W1-W5, N1, N2): the pure split, the read-only route in process on a scratch repository and runtime folder, the Today row and the card. No server, browser, model or network.",
3
+ "modules": [
4
+ "week-went.test.js"
5
+ ],
6
+ "seconds": {
7
+ "week-went.test.js": 5
8
+ }
9
+ }