create-pmos 0.837.0 → 0.839.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 +83 -58
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +82 -4
- package/workspace/guide/cli.md +11 -0
- package/workspace/guide/home.md +2 -0
- package/workspace/guide/initiatives-and-next-steps.md +8 -0
- package/workspace/guide/reports.md +9 -1
- package/workspace/lib/features.json +1 -0
- package/workspace/lib/hire-draft.js +4 -3
- package/workspace/lib/initiative-rows.js +3 -0
- package/workspace/lib/meeting-stance.js +199 -0
- package/workspace/lib/people-cli.js +44 -1
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/report-translate.js +26 -1
- package/workspace/lib/report-variants.js +14 -1
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-meeting-stance.js +43 -0
- package/workspace/lib/routes-reports.js +20 -3
- package/workspace/lib/routes-segments.js +47 -0
- package/workspace/lib/routes-surface-moments.js +36 -0
- package/workspace/lib/routes-today.js +15 -1
- package/workspace/lib/segments-cli.js +102 -0
- package/workspace/lib/segments.js +214 -0
- package/workspace/lib/surface-moments.js +185 -0
- package/workspace/lib/tracker-digest.js +12 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-board.css +11 -0
- package/workspace/public/pm/cozy-pop-work.js +5 -2
- package/workspace/public/pm/cozy-today-app.js +61 -2
- package/workspace/public/pm/cozy-today-model.js +70 -3
- package/workspace/public/pm/cozy-today-view.js +6 -0
- package/workspace/public/pm/meeting-stance.js +113 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-report-read.js +61 -3
- package/workspace/public/pm/segments.js +113 -0
- package/workspace/public/pm/standup-line.js +37 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/meeting-stance.json +9 -0
- package/workspace/test-lists/segments.json +9 -0
- package/workspace/test-lists/surface-moments.json +9 -0
- package/workspace/test-lists/surface-reports.json +9 -0
|
@@ -19,6 +19,7 @@ import { productName, whenNames } from './scope-chip.js';
|
|
|
19
19
|
import * as TP from './cozy-today-view.js';
|
|
20
20
|
import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
|
|
21
21
|
import { wireSwipe } from './cozy-phone-swipe.js';
|
|
22
|
+
import * as SU from './standup-line.js'; // surface-reports: before noon, the standup from Jira in the Overview (GET /api/standup)
|
|
22
23
|
let DG = null; // quiet-rows-digest: pm/digest-view.js, loaded on a Monday only (on other days Today loads nothing of the digest)
|
|
23
24
|
import { noteUse } from './use-log.js'; // your-move (A468): each press on a Your move row is one ym-act line in the local use log (its health number)
|
|
24
25
|
import * as QB from './quiet-batch.js'; // quiet-rows: Today's batch, the popup (Approve, Skip, Change it first; nothing sent without a press)
|
|
@@ -48,8 +49,10 @@ export function mountToday(ctx) {
|
|
|
48
49
|
readQuestions();
|
|
49
50
|
readSignoffs();
|
|
50
51
|
readSwitches();
|
|
52
|
+
readMoments();
|
|
51
53
|
readLine();
|
|
52
54
|
readDigest();
|
|
55
|
+
readStandup();
|
|
53
56
|
readSync();
|
|
54
57
|
readPin();
|
|
55
58
|
readCap();
|
|
@@ -206,6 +209,41 @@ export function mountToday(ctx) {
|
|
|
206
209
|
await readSwitches();
|
|
207
210
|
return after(true);
|
|
208
211
|
}
|
|
212
|
+
/* surface-moments (job #1985, LINE.md Rule 12): each product's moments (GET /api/surface-moments), one Your move row each. What Today's own
|
|
213
|
+
* data shows (a free gap, leave, a steering meeting) goes with the ask; the server checks the rest against the files. A product that does not
|
|
214
|
+
* answer is left out; with no moment there is no row (zero is silence). The same AI run kind is one row however many products name it. */
|
|
215
|
+
let momentsAt = 0;
|
|
216
|
+
async function readMoments() {
|
|
217
|
+
const now = ctx.now(), today = day();
|
|
218
|
+
momentsAt = now;
|
|
219
|
+
const P = ((ctx.S.M && ctx.S.M.products) || []).filter((p) => p && p.model);
|
|
220
|
+
const L = [...new Set((P.length ? P.map((p) => p.ws || ctx.boardWs() || '') : [ctx.boardWs() || '']))];
|
|
221
|
+
const free = TM.gapNow(ctx.meetings() || [], now), away = TM.awayOf((X.log && X.log.entries) || [], X.events || [], today), steer = TM.steerOf(X.events || [], today);
|
|
222
|
+
const q = new URLSearchParams();
|
|
223
|
+
if (free) q.set('free', String(free));
|
|
224
|
+
if (away) { q.set('away', away.day); q.set('awayWord', away.word); q.set('awayFrom', away.from); }
|
|
225
|
+
if (steer) { q.set('steer', steer.title); q.set('steerDay', steer.day); q.set('steerWord', steer.word); }
|
|
226
|
+
const got = await Promise.all(L.map((ws) => { const qq = new URLSearchParams(q); if (ws) qq.set('ws', ws); return ctx.pmGet('/api/surface-moments?' + qq.toString()).catch(() => null); }));
|
|
227
|
+
const rows = [], seen = new Set();
|
|
228
|
+
got.forEach((r, i) => { if (!r || !r.ok) return; for (const m of r.rows || []) { const one = m.kind === 'worth' ? 'worth:' + m.act.job : m.kind === 'away' ? 'away' : m.key; if (seen.has(one)) continue; seen.add(one); rows.push({ ...m, ws: L[i] }); } });
|
|
229
|
+
console.info('[moments] products=' + L.length + ' rows=' + rows.length);
|
|
230
|
+
const next = JSON.stringify(rows);
|
|
231
|
+
if (next === (X.moSeen || '[]')) return;
|
|
232
|
+
X.moSeen = next; X.moments = rows;
|
|
233
|
+
draw();
|
|
234
|
+
}
|
|
235
|
+
setInterval(() => { if (ctx.now() - momentsAt > 5 * 60e3) readMoments(); }, 60e3); // a free gap is a matter of minutes
|
|
236
|
+
/** ✓ on a moment: its one step, with Undo in the toast. A free gap's ✓ opens what fits it; nothing is written. */
|
|
237
|
+
async function momentPress(r) {
|
|
238
|
+
const m = r.ref || {}, a = m.act || {};
|
|
239
|
+
if (a.kind === 'minutes') { if (a.ini && ctx.hasIni(a.ini)) ctx.goIni(a.ini); return; }
|
|
240
|
+
const res = await ctx.pmPost('/api/surface-moments', { ws: m.ws || null, ...a }).catch(() => null);
|
|
241
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It did not go through. Nothing changed.');
|
|
242
|
+
const undo = res.undo ? async () => { const u = await ctx.pmPost('/api/surface-moments', { ws: m.ws || null, ...res.undo }).catch(() => null); await readMoments(); return u || { ok: false }; } : null;
|
|
243
|
+
if (undo) ctx.toastUndo(res.said, undo); else ctx.toast(res.said);
|
|
244
|
+
await readMoments();
|
|
245
|
+
return after(true);
|
|
246
|
+
}
|
|
209
247
|
/** ✓ on a sign-off row: recorded with its source; when it was the stage's last missing item the stage moves in the same press. One Undo. */
|
|
210
248
|
async function signoffRecord(r) {
|
|
211
249
|
const s = r.ref || {};
|
|
@@ -277,6 +315,21 @@ export function mountToday(ctx) {
|
|
|
277
315
|
console.info('[quiet-rows-digest] made=' + !!X.digest + (X.digestOff ? ' off' : ''));
|
|
278
316
|
X.html = ''; draw();
|
|
279
317
|
}
|
|
318
|
+
/* surface-reports (Rule 12): before noon, each product's standup from its stored Jira reads (GET /api/standup); none after noon */
|
|
319
|
+
async function readStandup() {
|
|
320
|
+
if (new Date(ctx.now()).getHours() >= SU.MORNING_END) return;
|
|
321
|
+
const P = ((ctx.S.M && ctx.S.M.products) || []).filter((p) => p && p.model);
|
|
322
|
+
const W = [...new Set((P.length ? P.map((p) => p.ws || ctx.boardWs() || '') : [ctx.boardWs() || '']))];
|
|
323
|
+
const got = await Promise.all(W.map((ws) => ctx.pmGet('/api/standup' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
|
|
324
|
+
X.standup = SU.standupParts(got);
|
|
325
|
+
if (X.standup.length) { X.html = ''; draw(); }
|
|
326
|
+
}
|
|
327
|
+
function openStandup() {
|
|
328
|
+
const VW = window.czViewer; if (!VW || !X.standup || !X.standup.length) return;
|
|
329
|
+
noteUse('standupOpen');
|
|
330
|
+
VW.open({ id: 'standup', kind: 'Standup', title: 'What moved in Jira', icon: 'M4 6h16M4 12h10M4 18h7', presses: [],
|
|
331
|
+
render: (body) => { body.innerHTML = SU.standupHtml(X.standup, productOf); } });
|
|
332
|
+
}
|
|
280
333
|
/** The digest in the reading view (the Viewer), read only; its header's switch turns it off (digest.on, POST /api/settings). */
|
|
281
334
|
function openDigest() {
|
|
282
335
|
const VW = window.czViewer; if (!VW || !DG) return;
|
|
@@ -313,7 +366,9 @@ export function mountToday(ctx) {
|
|
|
313
366
|
if (!r || !r.ok) return;
|
|
314
367
|
const today = day();
|
|
315
368
|
X.reports = (r.items || []).filter((x) => x && x.kind === 'report' && x.date === today && x.time).map((x) => ({ key: x.key, title: x.title, time: x.time }));
|
|
369
|
+
X.events = (r.items || []).filter((x) => x && x.kind === 'meeting').map((x) => ({ kind: 'meeting', date: x.date, title: x.title })); // surface-moments: leave and steering
|
|
316
370
|
draw();
|
|
371
|
+
readMoments();
|
|
317
372
|
}
|
|
318
373
|
// the head's clock: the time on it moves each minute, and only its words change
|
|
319
374
|
setInterval(() => { const w = el && el.querySelector('.td-when'); if (w) w.textContent = TM.headModel(ctx.now()).when; }, 30000);
|
|
@@ -339,13 +394,14 @@ export function mountToday(ctx) {
|
|
|
339
394
|
own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now, fixed: X.log.fixed || {},
|
|
340
395
|
signoffs: X.signoffs || [], signoffSuggest: X.signoffSuggest || [],
|
|
341
396
|
switches: X.switches || [],
|
|
397
|
+
moments: X.moments || [],
|
|
342
398
|
// your-move (A468): an initiative's ship date is its board end date; a line with no default on work that ships soon blocks it
|
|
343
399
|
shipOf: (id) => { const r = byId.get('i:' + id); return (r && r.board && r.board.end) || ''; } });
|
|
344
400
|
if (L.move.length !== X.ymN) { X.ymN = L.move.length; console.info('[your-move] rows=' + L.move.length + ' shown=' + L.first.length + (L.move[0] ? ' first-tier=' + L.move[0].tier : '')); }
|
|
345
401
|
const lead = L.rows.find((r) => !r.done && r.src !== 'note' && r.src !== 'own' && r.src !== 'lab');
|
|
346
402
|
const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, reports: X.reports || [], focus: lead ? { key: lead.key, title: lead.title } : null, now,
|
|
347
403
|
iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
|
|
348
|
-
const O = DG && X.digest ? DG.withDigest(TM.overviewModel(L, A), X.digest, now) : TM.overviewModel(L, A);
|
|
404
|
+
const O = SU.withStandup(DG && X.digest ? DG.withDigest(TM.overviewModel(L, A), X.digest, now) : TM.overviewModel(L, A), X.standup || [], now, productOf);
|
|
349
405
|
O.suggest = O.suggest.filter((x) => !X.hide.has(x.key)).concat(TM.syncSuggest(X.sync || [], { nameOf: (ws) => productOf(ws), hidden: syncHidden(), open: X.syncOpen || new Set(), now }));
|
|
350
406
|
return { L, A, O };
|
|
351
407
|
}
|
|
@@ -489,6 +545,7 @@ export function mountToday(ctx) {
|
|
|
489
545
|
if (r.src === 'question') { openQuestion(ref); return; }
|
|
490
546
|
if (r.src === 'signoff') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
|
|
491
547
|
if (r.src === 'switch') { location.href = '/premium-board.html' + (ref.ws ? '?ws=' + encodeURIComponent(ref.ws) : ''); return; } // the Switches block on Work
|
|
548
|
+
if (r.src === 'moment') { momentPress(r); return; }
|
|
492
549
|
if (r.src === 'signoff-by') { if (ref.ini && ctx.hasIni(ref.ini)) ctx.goIni(ref.ini); return; }
|
|
493
550
|
if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
|
|
494
551
|
if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
|
|
@@ -790,8 +847,9 @@ export function mountToday(ctx) {
|
|
|
790
847
|
ctx.VW.popNext({ keep: true, id: x.key, kind: 'meeting', title: x.title }); ctx.openMeeting(x.ref); return;
|
|
791
848
|
}
|
|
792
849
|
if (act === 'open' && key === 'digest') { openDigest(); return; }
|
|
850
|
+
if (act === 'open' && key === 'standup') { openStandup(); return; }
|
|
793
851
|
const r = rowOf(key); if (!r) return;
|
|
794
|
-
if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb|sw)-/.test(act))) noteUse('ym-act'); // your-move's health number
|
|
852
|
+
if (r.tier != null && (act === 'open' || act === 'done' || act === 'tomorrow' || /^(so|sb|sw|mo)-/.test(act))) noteUse('ym-act'); // your-move's health number
|
|
795
853
|
if (act === 'q-remind') { remindQuestion(r.ref); return; }
|
|
796
854
|
if (act === 'open') { open(r); return; }
|
|
797
855
|
if (act === 'so-open') { signoffOpen(r); return; }
|
|
@@ -810,6 +868,7 @@ export function mountToday(ctx) {
|
|
|
810
868
|
else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
|
|
811
869
|
else if (act === 'so-record') await signoffRecord(r);
|
|
812
870
|
else if (act === 'sw-yes' || act === 'sw-no') await switchPress(r, act === 'sw-yes');
|
|
871
|
+
else if (act === 'mo-yes') await momentPress(r);
|
|
813
872
|
else if (act === 'so-ask') await signoffAsk(r);
|
|
814
873
|
else if (act === 'sb-keep' || act === 'sb-change') await signoffSuggest(r, act === 'sb-keep');
|
|
815
874
|
else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
|
|
@@ -143,7 +143,7 @@ function typeOf(r) {
|
|
|
143
143
|
const ref = r.ref || {};
|
|
144
144
|
if (r.bullet === 'note' || r.src === 'note') return 'Note';
|
|
145
145
|
if (r.src === 'draft') return 'Report';
|
|
146
|
-
if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return 'Decision';
|
|
146
|
+
if (r.src === 'lab' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'moment') return 'Decision';
|
|
147
147
|
if (r.src !== 'ask') return 'Task';
|
|
148
148
|
switch (ref.kind) {
|
|
149
149
|
case 'mention': return 'Ask';
|
|
@@ -162,7 +162,8 @@ function typeOf(r) {
|
|
|
162
162
|
* shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now,
|
|
163
163
|
* fixed: GET /api/today-log fixed ({ [ws]: keys }, quiet-rows: the line rows Your move shows today per product),
|
|
164
164
|
* signoffs: GET /api/stage-signoffs rows, each with its ws; signoffSuggest: its suggest list (factory-signoffs-reach-you);
|
|
165
|
-
* switches: GET /api/switches rows with a waiting turn, each with its ws (switch-owners)
|
|
165
|
+
* switches: GET /api/switches rows with a waiting turn, each with its ws (switch-owners),
|
|
166
|
+
* moments: GET /api/surface-moments rows, each with its ws (surface-moments) }
|
|
166
167
|
* quiet-rows: the drafts in the outbox are one row, Today's batch (pm/quiet-rows.js batchRow); Your move keeps at most 3 line rows a day per
|
|
167
168
|
* product (capLine), the rest wait under Later (`held`), and `toFix` is what the page writes once to the day ledger.
|
|
168
169
|
* A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
|
|
@@ -280,6 +281,11 @@ export function logModel(o = {}) {
|
|
|
280
281
|
put({ key: 'switch:' + (w.ws || '') + ':' + w.id, src: 'switch', bullet: 'task', title: 'Turn ' + w.name + ' ' + w.waiting.to + ' for ' + w.customer, ini: null, ws: w.ws || '', work: '', job: 'Decide',
|
|
281
282
|
carried: 0, late: false, when: '', reason: 'Waits for you: PMOS turns nothing', age: at ? Math.max(0, between(at, today) || 0) : 0, ref: w });
|
|
282
283
|
}
|
|
284
|
+
// surface-moments (job #1985, LINE.md Rule 12): a feature that shows by itself when the PM's data says it is time; one ✓ and Put off a day
|
|
285
|
+
for (const m of o.moments || []) {
|
|
286
|
+
if (!m || !m.key || !m.title) continue;
|
|
287
|
+
put({ key: m.key, src: 'moment', bullet: 'task', title: m.title, ini: null, ws: m.ws || '', work: '', job: 'Decide', carried: 0, late: false, when: '', reason: m.why || '', age: 0, ref: m });
|
|
288
|
+
}
|
|
283
289
|
oneLine(out);
|
|
284
290
|
// a row done today whose source has let it go keeps its × from what it said when it was done
|
|
285
291
|
for (const [k, m] of Object.entries(marks)) {
|
|
@@ -456,7 +462,7 @@ export function costOf(r, today, shipOf = () => '') {
|
|
|
456
462
|
if (r.type === 'Ask' && !(r.who && r.who.length)) return null; // nobody waits on the answer
|
|
457
463
|
if (r.src === 'batch') return [2, r.left == null ? QR.LAPSE_DAYS : r.left, r.why]; // quiet-rows: Today's batch, a send today, soonest lapse first
|
|
458
464
|
const ref = r.ref || {}, c = ref.call || null, ld = lateDays(r, today);
|
|
459
|
-
const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
|
|
465
|
+
const waits = r.src === 'ask' || r.src === 'question' || r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch' || r.src === 'moment' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
|
|
460
466
|
if (!waits) return null;
|
|
461
467
|
if (r.src === 'own' && r.first) return [0, 0, 'You marked it first'];
|
|
462
468
|
const age = r.src === 'question' || r.src === 'signoff' || r.src === 'switch' ? r.age || 0 : r.carried || 0;
|
|
@@ -470,6 +476,7 @@ export function costOf(r, today, shipOf = () => '') {
|
|
|
470
476
|
if (c && c.kind === 'session' && (c.state === 'blocked' || c.state === 'needs')) return [3, 0, 'A session waits on you; its work stops until you answer'];
|
|
471
477
|
if (r.src === 'question') return [4, -age, r.reason || 'Waits on you ' + plural(age, 'day', 'days')];
|
|
472
478
|
if (r.src === 'signoff' || r.src === 'signoff-by' || r.src === 'switch') return [4, -age, r.reason || 'Waits on you'];
|
|
479
|
+
if (r.src === 'moment') return [4, 0, '✦ ' + (r.reason || 'PMOS suggests it now')];
|
|
473
480
|
const w = whyOf(r, today);
|
|
474
481
|
return [4, -age, w && !/^Waits on you$/.test(w) ? w : age ? 'Waits on you ' + plural(age, 'day', 'days') : 'Waits on you'];
|
|
475
482
|
}
|
|
@@ -647,3 +654,63 @@ export function syncSuggest(parts, o = {}) {
|
|
|
647
654
|
why: 'Someone set these in PMOS by hand, and Jira says otherwise. PMOS changes nothing in Jira. Undo puts back what PMOS said.' + (p.unread ? ' ' + p.unread + (p.unread === 1 ? ' task' : ' tasks') + ' could not be read and are not counted.' : '') };
|
|
648
655
|
});
|
|
649
656
|
}
|
|
657
|
+
|
|
658
|
+
/* surface-moments (job #1985, LINE.md Rule 12): the moments Today's own data shows. Each is PURE; pm/cozy-today-app.js passes what it finds to
|
|
659
|
+
* GET /api/surface-moments, which checks the rest against the files (lib/surface-moments.js). */
|
|
660
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
661
|
+
const WD_RE = /\b(sun|mon|tues?|wed(?:nes)?|thu(?:rs?)?|fri|sat(?:ur)?)(?:day)?\b/i;
|
|
662
|
+
const LEAVE_RE = /\b(ooo|out of office|on leave|annual leave|leave|holiday|vacation|day off|pto|cuti)\b/i;
|
|
663
|
+
const OFF_RE = /\b(off|away|on leave|out of office|ooo|holiday|vacation|day off)\b/i;
|
|
664
|
+
/** "Fri 28 Nov" for a YYYY-MM-DD. */
|
|
665
|
+
export function weekdayWord(k) { const t = dayMs(k); if (t == null) return ''; const d = new Date(t); return WD[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()]; }
|
|
666
|
+
/** Weekdays after `from`, up to and including `to` (0 for the same day). */
|
|
667
|
+
export function workDays(from, to) {
|
|
668
|
+
const a = dayMs(from), b = dayMs(to); if (a == null || b == null || b < a) return -1;
|
|
669
|
+
let n = 0; for (let t = new Date(a); t.getTime() < b;) { t.setDate(t.getDate() + 1); const w = t.getDay(); if (w !== 0 && w !== 6) n++; }
|
|
670
|
+
return n;
|
|
671
|
+
}
|
|
672
|
+
/** The minutes of a free gap that starts within 10 minutes, 15 to 90, between 09:00 and 18:00; 0 when there is none. meetings: Today's. */
|
|
673
|
+
export function gapNow(meetings, now) {
|
|
674
|
+
const d0 = new Date(now); d0.setHours(9, 0, 0, 0); const d1 = new Date(now); d1.setHours(18, 0, 0, 0);
|
|
675
|
+
if (now < d0.getTime() || now >= d1.getTime()) return 0;
|
|
676
|
+
const S = (meetings || []).filter((m) => m && m.start && Number.isFinite(Date.parse(m.start))).map(span).sort((x, y) => x.a - y.a);
|
|
677
|
+
let start = now;
|
|
678
|
+
const cur = S.find((x) => x.a <= now && x.b > now);
|
|
679
|
+
if (cur) { if (cur.b - now > 10 * 60000) return 0; start = cur.b; }
|
|
680
|
+
const next = S.find((x) => x.a >= start);
|
|
681
|
+
const end = Math.min(next ? next.a : d1.getTime(), d1.getTime());
|
|
682
|
+
const mins = Math.floor((end - start) / 60000 / 5) * 5;
|
|
683
|
+
return mins >= 15 && mins <= 90 ? mins : 0;
|
|
684
|
+
}
|
|
685
|
+
/** The day a Today line names: "tomorrow", a weekday (the next one from today), or "28 Nov". '' when none. */
|
|
686
|
+
function namedDay(text, today) {
|
|
687
|
+
const t = String(text || '');
|
|
688
|
+
if (/\btomorrow\b/i.test(t)) return addDays(today, 1);
|
|
689
|
+
const dm1 = /\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b/i.exec(t);
|
|
690
|
+
if (dm1) { const y = +today.slice(0, 4), m = MON.findIndex((x) => x.toLowerCase() === dm1[2].slice(0, 3).toLowerCase()); const k = y + '-' + String(m + 1).padStart(2, '0') + '-' + String(+dm1[1]).padStart(2, '0'); return k >= today ? k : (y + 1) + k.slice(4); }
|
|
691
|
+
const w = WD_RE.exec(t);
|
|
692
|
+
if (w) { const want = WD.findIndex((x) => x.toLowerCase() === w[1].slice(0, 3).toLowerCase()); for (let i = 1; i <= 7; i++) { const k = addDays(today, i); if (new Date(dayMs(k)).getDay() === want) return k; } }
|
|
693
|
+
return '';
|
|
694
|
+
}
|
|
695
|
+
/** Leave within 7 days: an all-day or leave event on the calendar, else an open Today line ("off Friday"). { day, word, from } | null. */
|
|
696
|
+
export function awayOf(own, events, today) {
|
|
697
|
+
const near = (k) => { const n = between(today, k); return n != null && n >= 0 && n <= 7; };
|
|
698
|
+
for (const e of events || []) {
|
|
699
|
+
if (!e || e.kind !== 'meeting' || !LEAVE_RE.test(e.title || '')) continue;
|
|
700
|
+
const k = String(e.date || '').slice(0, 10); if (near(k)) return { day: k, word: weekdayWord(k), from: 'calendar' };
|
|
701
|
+
}
|
|
702
|
+
for (const e of own || []) {
|
|
703
|
+
if (!e || e.done || !OFF_RE.test(e.text || '')) continue;
|
|
704
|
+
const k = namedDay(e.text, today); if (k && near(k)) return { day: k, word: weekdayWord(k), from: 'line' };
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
/** A steering meeting within 2 working days: { title, day, word } | null. events: GET /api/events-place items. */
|
|
709
|
+
export function steerOf(events, today) {
|
|
710
|
+
for (const e of (events || []).slice().sort((a, b) => String(a.date).localeCompare(String(b.date)))) {
|
|
711
|
+
if (!e || e.kind !== 'meeting' || !/steer/i.test(e.title || '')) continue;
|
|
712
|
+
const k = String(e.date || '').slice(0, 10), n = workDays(today, k);
|
|
713
|
+
if (n >= 0 && n <= 2) return { title: e.title, day: k, word: k === today ? 'today' : weekdayWord(k) };
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
@@ -93,6 +93,9 @@ export function switchActs(r) {
|
|
|
93
93
|
return ib('sw-yes', 'I turned ' + w.name + ' ' + to + ' for ' + w.customer, I.yes, r.key) + ib('sw-no', 'Keep ' + w.name + ' ' + (w.on ? 'on' : 'off') + ' for ' + w.customer, I.no, r.key);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/** surface-moments (job #1985): ✓ does the moment's one step, with Undo in the toast. */
|
|
97
|
+
export function momentAct(r) { const m = r.ref || {}; return ib('mo-yes', m.label || 'Do it: ' + r.title, I.yes, r.key); }
|
|
98
|
+
|
|
96
99
|
/** name-links (A536): the words of a line you typed, with the names that resolve to one record as links (r.ref.links: GET /api/name-links);
|
|
97
100
|
* any other row's words, escaped. The words never change. */
|
|
98
101
|
export function ownWords(r) { return r && r.src === 'own' && r.ref && r.ref.links ? linkedHtml(r.title, r.ref.links, esc) : esc(r && r.title); }
|
|
@@ -106,6 +109,7 @@ export function rowHtml(r, o = {}) {
|
|
|
106
109
|
if (r.src === 'question') acts = ib('open', 'Answer: ' + t, I.decide, r.key); // the register's line: it is answered where it opens, not marked done here
|
|
107
110
|
else if (r.src === 'signoff' || r.src === 'signoff-by') acts = signoffActs(r);
|
|
108
111
|
else if (r.src === 'switch') acts = switchActs(r);
|
|
112
|
+
else if (r.src === 'moment') acts = momentAct(r) + ib('tomorrow', 'Move to tomorrow: ' + t, I.tomorrow, r.key);
|
|
109
113
|
else if (r.src === 'lab') acts = ib('lab-keep', 'Keep it: start an initiative from ' + t, I.yes, r.key) + ib('lab-drop', 'Drop it: ' + t, I.no, r.key);
|
|
110
114
|
else {
|
|
111
115
|
const j = JOB_ACT[r.job];
|
|
@@ -201,6 +205,7 @@ function moveAct(r) {
|
|
|
201
205
|
if (r.src === 'question') return ib('open', 'Answer: ' + t, I.decide, r.key);
|
|
202
206
|
if (r.src === 'signoff' || r.src === 'signoff-by') return signoffActs(r);
|
|
203
207
|
if (r.src === 'switch') return switchActs(r);
|
|
208
|
+
if (r.src === 'moment') return momentAct(r);
|
|
204
209
|
const j = JOB_ACT[r.job];
|
|
205
210
|
if (j) return ib('open', j[1] + ': ' + t, j[2], r.key);
|
|
206
211
|
if (r.members) return ib('open', 'Show them: ' + t, I.more, r.key, ` aria-expanded="false"`);
|
|
@@ -355,6 +360,7 @@ export function swipeActs(r) {
|
|
|
355
360
|
if (r.members && r.drafts) return { right: 'same-yes', left: 'same-no' };
|
|
356
361
|
// a Your move row (your-move): right does its action, so a reply, an answer, a decision or a send opens the item; left puts it off a day
|
|
357
362
|
if (r.src === 'switch') return { right: '', left: 'tomorrow' }; // a turn is recorded by a press, never by a swipe
|
|
363
|
+
if (r.src === 'moment') return { right: '', left: 'tomorrow' }; // a moment acts on a press, never on a swipe
|
|
358
364
|
if (r.src === 'signoff-by') return { right: 'sb-keep', left: 'tomorrow' };
|
|
359
365
|
if (r.src === 'signoff') { const a = (r.ref || {}).action; return { right: a === 'record' ? 'so-record' : a === 'open' ? 'so-open' : 'so-ask', left: 'tomorrow' }; }
|
|
360
366
|
if (r.tier != null && (r.src === 'question' || JOB_ACT[r.job] || r.members)) return { right: 'open', left: 'tomorrow' };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* pm/meeting-stance.js — "Before the meeting: who agrees", under the People block of an initiative on Work: the two questions PMOS drafted
|
|
2
|
+
* for the contested decision, and where each person stands (initiative meeting-stance, job #1897, idea A333; board BatchPeopleDS panel 10,
|
|
3
|
+
* agreed 2026-11-25).
|
|
4
|
+
*
|
|
5
|
+
* blockHtml(stance) → the block's markup ('' when no decision is contested: zero is silence). Pure, so the test reads it.
|
|
6
|
+
* stance: GET /api/meeting-stance → stance
|
|
7
|
+
* blockFor(ini, ws, redraw) → the block for the popup drawn now: reads GET /api/meeting-stance once per initiative, then draws from memory
|
|
8
|
+
* press(e, body, { say }) → the popup's click listener hands each press here first: copy, I sent them, an answer cell
|
|
9
|
+
*
|
|
10
|
+
* Built only from the system parts on the board: pm-block, pm-table, pm-said, pm-btn, pm-meta. The two buttons are icon-only with an
|
|
11
|
+
* aria-label. Before the send the grid's cells are dashes and a ✦ line says PMOS drafted the questions; the PM copies them and sends them.
|
|
12
|
+
* PMOS NEVER SENDS THEM: "I sent them" only records it (POST act sent). Then each cell is a press that goes yes → no → empty, and the ✦
|
|
13
|
+
* line names the point the meeting must settle. Each write offers Undo in the toast. The UI says PMOS, never Claude. */
|
|
14
|
+
import { pmGet, pmPost } from './http.js';
|
|
15
|
+
import { noteUse } from './use-log.js';
|
|
16
|
+
import { undoToast } from './hi-pop.js';
|
|
17
|
+
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
19
|
+
const SV = (d, w = 16) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
20
|
+
const I = { spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', copy: 'M9 9h10v10H9zM5 15V5h10', sent: 'M4 12l16-8-6 16-3-7z' };
|
|
21
|
+
const btn = (attrs, label, icon, kind = '') => `<button type="button" class="pm-btn${kind ? ' ' + kind : ''}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${SV(icon)}</button>`;
|
|
22
|
+
/** The next answer a press on a cell gives: empty → yes → no → empty. */
|
|
23
|
+
export const NEXT_SAYS = Object.freeze({ '': 'yes', yes: 'no', no: '' });
|
|
24
|
+
|
|
25
|
+
export function blockHtml(s) {
|
|
26
|
+
if (!s || !Array.isArray(s.grid) || !s.grid.length || !Array.isArray(s.people) || !s.people.length) return '';
|
|
27
|
+
const asked = !!s.asked;
|
|
28
|
+
const head = `<tr><th scope="col"><span class="ms-sr">Question</span></th>${s.people.map((p) => `<th scope="col">${esc(p.name)}</th>`).join('')}</tr>`;
|
|
29
|
+
const cell = (r, c) => {
|
|
30
|
+
const word = c.says || '—';
|
|
31
|
+
if (!asked) return `<td>${esc(word)}</td>`;
|
|
32
|
+
const label = `${c.name} on "${r.q}": ${c.says || 'no answer yet'}. Press to record ${NEXT_SAYS[c.says || ''] || 'no answer'}`;
|
|
33
|
+
return `<td${c.diff ? ' class="ms-diff"' : ''}><button type="button" class="ms-cell" data-ms-act="answer" data-ms-person="${esc(c.id)}" data-ms-name="${esc(c.name)}" data-ms-q="${r.n}" data-ms-says="${esc(NEXT_SAYS[c.says || ''])}" aria-label="${esc(label)}">${esc(word)}</button></td>`;
|
|
34
|
+
};
|
|
35
|
+
const rows = s.grid.map((r) => `<tr><td>${esc(r.q)}</td>${r.cells.map((c) => cell(r, c)).join('')}</tr>`).join('');
|
|
36
|
+
const said = !asked
|
|
37
|
+
? `<div class="pm-said ms-said" role="group" aria-label="PMOS drafted these questions; you send them">${SV(I.spark, 14)}<p>PMOS drafted these two questions for ${esc(s.people.map((p) => p.name).join(', '))}. You send them.</p>`
|
|
38
|
+
+ `<span class="ms-b">${btn('data-ms-act="copy"', 'Copy the questions', I.copy, 'outline')}${btn('data-ms-act="sent"', 'I sent them', I.sent, 'primary')}</span></div>`
|
|
39
|
+
: s.settle ? `<div class="pm-said ms-said">${SV(I.spark, 14)}<p>${esc(s.settle)}</p></div>` : '';
|
|
40
|
+
const meta = asked ? `<p class="pm-meta ms-meta">${s.answered} of ${s.total} answered · ${esc(s.askedWord)}</p>` : '';
|
|
41
|
+
return `<section class="pm-block ms-block" aria-label="Before the meeting" data-ms-ini="${esc(s.ini)}" data-ms-dec="${esc(s.decision && s.decision.id)}">`
|
|
42
|
+
+ `<table class="pm-table ms-grid"><thead>${head}</thead><tbody>${rows}</tbody></table>${said}${meta}</section>`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* ── the popup ── */
|
|
46
|
+
const ST = new Map(); // ws|ini → stance | null while reading | false when there is none
|
|
47
|
+
const kOf = (ini, ws) => (ws || '') + '|' + ini;
|
|
48
|
+
let CSS_DONE = false;
|
|
49
|
+
function css() {
|
|
50
|
+
if (CSS_DONE || typeof document === 'undefined' || !document.head) return;
|
|
51
|
+
CSS_DONE = true;
|
|
52
|
+
const s = document.createElement('style');
|
|
53
|
+
s.textContent = '.ms-block .ms-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.ms-block .ms-grid td:first-child{width:50%}'
|
|
54
|
+
+ '.ms-block .ms-cell{all:unset;cursor:pointer;min-width:44px;min-height:32px;display:inline-flex;align-items:center}.ms-block .ms-cell:focus-visible{outline:2px solid var(--blue);outline-offset:2px}'
|
|
55
|
+
+ '.ms-block .ms-diff{color:var(--state-late)}.ms-block .ms-said{max-width:none;margin:8px 0 0;align-items:flex-start}.ms-block .ms-said p{flex:1;margin:0}'
|
|
56
|
+
+ '.ms-block .ms-said>svg{color:var(--blue);flex:none;margin-top:3px}.ms-block .ms-b{display:flex;gap:4px}.ms-block .ms-meta{margin:4px 0 0}';
|
|
57
|
+
document.head.appendChild(s);
|
|
58
|
+
}
|
|
59
|
+
let lastRedraw = null, lastWs = '';
|
|
60
|
+
function load(ini, ws, again = false) {
|
|
61
|
+
const k = kOf(ini, ws);
|
|
62
|
+
if (!again) ST.set(k, null);
|
|
63
|
+
pmGet('/api/meeting-stance?ini=' + encodeURIComponent(ini) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
|
|
64
|
+
.then((x) => { ST.set(k, x && x.ok && x.stance ? x.stance : false); if (x && x.ok && (x.stance || again) && lastRedraw) lastRedraw(); })
|
|
65
|
+
.catch(() => ST.set(k, false));
|
|
66
|
+
}
|
|
67
|
+
export function blockFor(ini, ws, redraw) {
|
|
68
|
+
if (!ini) return '';
|
|
69
|
+
lastRedraw = redraw; lastWs = ws || '';
|
|
70
|
+
const k = kOf(ini, ws);
|
|
71
|
+
if (!ST.has(k)) load(ini, ws);
|
|
72
|
+
const s = ST.get(k);
|
|
73
|
+
if (!s) return '';
|
|
74
|
+
css();
|
|
75
|
+
return blockHtml(s);
|
|
76
|
+
}
|
|
77
|
+
if (typeof document !== 'undefined' && document.addEventListener) document.addEventListener('cz:chat-turn', () => { ST.clear(); if (lastRedraw) lastRedraw(); });
|
|
78
|
+
|
|
79
|
+
async function write(ini, body) {
|
|
80
|
+
const r = await pmPost('/api/meeting-stance', { ws: lastWs || null, ini, ...body }).catch(() => null);
|
|
81
|
+
load(ini, lastWs, true);
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
/** One press inside the popup body: the popup's own click listener (pm/cozy-pop-work.js) hands every press here first; true when it was
|
|
85
|
+
* this block's, so the popup leaves it alone. */
|
|
86
|
+
export function press(e, body, { say } = {}) {
|
|
87
|
+
const b = e.target.closest && e.target.closest('[data-ms-act]');
|
|
88
|
+
if (!b || !body || !body.contains(b)) return false;
|
|
89
|
+
const sec = b.closest('[data-ms-ini]');
|
|
90
|
+
if (!sec) return false;
|
|
91
|
+
e.stopImmediatePropagation();
|
|
92
|
+
act(b, sec, say);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
async function act(b, sec, say) {
|
|
96
|
+
const ini = sec.dataset.msIni, decision = sec.dataset.msDec, what = b.dataset.msAct;
|
|
97
|
+
const s = ST.get(kOf(ini, lastWs));
|
|
98
|
+
if (!s) return;
|
|
99
|
+
const tell = (text, undoIt) => { if (undoIt) undoToast(text, undoIt); else if (say) say(text); };
|
|
100
|
+
if (what === 'copy') {
|
|
101
|
+
noteUse('meetingStanceCopy');
|
|
102
|
+
try { await navigator.clipboard.writeText(s.draft || ''); tell('Copied. Send them from your mail or chat.'); } catch { tell('Select the questions and copy them.'); }
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
noteUse(what === 'sent' ? 'meetingStanceSent' : 'meetingStanceAnswer');
|
|
106
|
+
b.disabled = true;
|
|
107
|
+
const body = what === 'sent' ? { decision, act: 'sent', people: s.people }
|
|
108
|
+
: { decision, act: 'answer', person: b.dataset.msPerson, name: b.dataset.msName, q: Number(b.dataset.msQ), says: b.dataset.msSays || '' };
|
|
109
|
+
const r = await write(ini, body);
|
|
110
|
+
if (!r || !r.ok) { b.disabled = false; tell((r && r.error) || 'Not saved.'); return; }
|
|
111
|
+
const word = what === 'sent' ? 'Marked: you sent the questions' : `${b.dataset.msName}: ${b.dataset.msSays || 'answer cleared'}`;
|
|
112
|
+
tell(word, () => { write(ini, { decision, act: 'undo' }); });
|
|
113
|
+
}
|
|
@@ -74,6 +74,7 @@ import * as ST from './bd-stands.js'; // Where it stands, its Suggestion and t
|
|
|
74
74
|
import * as LS from './load-shapes.js'; // the skeleton and the slow-case line while the board is read (page-open-speed, SpD) // the Board as the first panel: fit(), the rows that open beside, the open row's mark
|
|
75
75
|
import * as STRAT from './bd-strategy.js'; // the product's strategy in five lines above the initiatives (bet A458)
|
|
76
76
|
import * as PRIN from './bd-principles.js'; // the product's principles drafted from its decisions, below the strategy (bet A352)
|
|
77
|
+
import * as SEG from './segments.js'; // the product's user groups and the roadmap items that serve each, below the principles (idea A327)
|
|
77
78
|
import * as SWO from './switch-owners.js'; // who has which switch, per customer, below the principles (idea A263)
|
|
78
79
|
import * as SKM from './skill-map.js'; // the team skill map below the principles (bet A208)
|
|
79
80
|
import * as FHR from './first-hour.js'; // the first hour for a new engineer, below Team skills (bet A55)
|
|
@@ -1532,6 +1533,7 @@ async function load() {
|
|
|
1532
1533
|
LE.loaded({ since, stale: !!r.stale }); // a change still saving stays on the new read; open views (the big Work breakdown) follow it
|
|
1533
1534
|
STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
|
|
1534
1535
|
PRIN.refresh($('#cPrin'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1536
|
+
SEG.refresh($('#cSeg'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1535
1537
|
SWO.refresh($('#cSw'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1536
1538
|
SKM.refresh($('#cSkills'), { ws: M.board.ws || null, single: !ALL, say });
|
|
1537
1539
|
FHR.refresh($('#cWelcome'), { ws: M.board.ws || null, single: !ALL, say });
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
* thumbnails; Undo and Redo dim when there is nothing to take back or do again. premium-vw-slides.js draws it in the card.
|
|
35
35
|
*
|
|
36
36
|
* openReport(row, hand) row = a Reports card document { cadence, slot, date, path, state, archived }; hand = { ws, name, cycles, onIssue, onChange }
|
|
37
|
+
* versionsHtml(V) the Draft | For executives | For engineers | For customers | In <language> tabs, '' with none (pure)
|
|
38
|
+
* langHtml(H) the ✦ when the readers name a language with no copy: ✓ adds it, then Undo; '' with no hint (pure)
|
|
37
39
|
* openReportView(ref, o) ref = a report path reports/<cadence>/<date>.md or a row; the window.czViews entry (premium-vw-open.js).
|
|
38
40
|
* o.cuts: a ready-made report (batch 17 item 1, PbG5): Sponsors · 1 minute | Team · full over the same numbers
|
|
39
41
|
* wordsOf(md, fallback) the document as { title, sections: [{ h, lines }] } (pure)
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
* (Read again: a redraft that keeps the notes; Start the next cycle without a template), /api/report-setups/draft (Start the next cycle),
|
|
52
54
|
* /api/report-design/revert (Go back to it). */
|
|
53
55
|
import { pmGet, pmPost } from './http.js';
|
|
56
|
+
import { noteUse } from './use-log.js'; // surface-reports: reportVersionTab, reportLanguageAdd
|
|
54
57
|
import * as PR from './print-pdf.js'; // Print or PDF and Send a copy: the one print layout (job #1911, A379)
|
|
55
58
|
import { open as vOpen, current as vCur, czSections } from './cozy-viewer.js';
|
|
56
59
|
import * as MP from './premium-mtg-present.js'; // the one presenter window for every kind (canvas note xvPresent)
|
|
@@ -413,9 +416,57 @@ async function cutTo(k) {
|
|
|
413
416
|
R.text = C.sponsors; R.W = wordsOf(R.text, R.name); R.i = 0;
|
|
414
417
|
draw();
|
|
415
418
|
}
|
|
419
|
+
/* ── the versions beside a draft (initiative report-three-audiences, Wawan's try feedback 2026-11-25): Draft | For executives | For engineers |
|
|
420
|
+
* For customers, only the versions on disk (GET /api/report/draft `versions`, lib/report-variants.js versionsOf). A press shows that version's
|
|
421
|
+
* words in this same view; the designed render and the Pyramid deck belong to the draft, so a version shows its own words. Only the draft is
|
|
422
|
+
* edited. No versions: nothing is drawn. */
|
|
423
|
+
export function versionsHtml(V) {
|
|
424
|
+
if (!V || !Array.isArray(V.list) || !V.list.length) return '';
|
|
425
|
+
const b = (k, l) => `<button type="button" data-r="ver|${esc(k)}" aria-pressed="${(V.on || '') === k}"><span>${esc(l)}</span></button>`;
|
|
426
|
+
return `<div class="vz-cut"><div class="rp-seg vz-cuts" role="group" aria-label="Which version">${b('', 'Draft')}${V.list.map((x) => b(x.audience, x.label)).join('')}</div>${V.err ? `<p class="vz-msg" role="status">${esc(V.err)}</p>` : ''}</div>`;
|
|
427
|
+
}
|
|
428
|
+
/** The ✦ on the draft when the report's readers name a language that has no copy yet (surface-reports; GET /api/report/draft langHint):
|
|
429
|
+
* one sentence and an icon-only ✓ that adds it to the definition (POST /api/report/language). After the ✓: what changed, and Undo. '' with
|
|
430
|
+
* no hint. H: { list: [{ language, code }], done: language | null }. */
|
|
431
|
+
export function langHtml(H) {
|
|
432
|
+
if (!H || !Array.isArray(H.list) || !H.list.length) return '';
|
|
433
|
+
const star = '<span class="pm-star" aria-hidden="true">✦</span>';
|
|
434
|
+
if (H.done) {
|
|
435
|
+
const u = `Stop the ${H.done} copy`;
|
|
436
|
+
return `<p class="pm-said vz-lh" role="status">${star}<span>Each new draft now gets a copy in ${esc(H.done)}.</span><button type="button" class="vz-ib vz-hv" data-r="langundo|${esc(H.done)}" aria-label="${esc(u)}" title="Undo">${ic('undo', 15)}</button></p>`;
|
|
437
|
+
}
|
|
438
|
+
const L = H.list[0].language, a = `Add a copy in ${L} to each draft`;
|
|
439
|
+
return `<p class="pm-said vz-lh">${star}<span>Your readers include ${esc(L)}. Add a copy in ${esc(L)} to each draft?</span><button type="button" class="vz-ib vz-hv" data-r="lang|${esc(L)}" aria-label="${esc(a)}" title="${esc(a)}">${ic('check', 15)}</button></p>`;
|
|
440
|
+
}
|
|
441
|
+
async function langSet(language, off) {
|
|
442
|
+
const me = R, c = cycleOf(R.row); if (!R.lh || !c.cadence) return;
|
|
443
|
+
R.busy = true; draw();
|
|
444
|
+
const r = await pmPost('/api/report/language', { ws: R.ws, cadence: c.cadence, language, ...(off ? { off: true } : {}) }).catch(() => null);
|
|
445
|
+
if (R !== me) return;
|
|
446
|
+
R.busy = false;
|
|
447
|
+
if (!r || !r.ok) return say((r && r.error) || 'The language was not saved. Nothing changed.', 'bad');
|
|
448
|
+
if (!off) noteUse('reportLanguageAdd');
|
|
449
|
+
R.lh.done = off ? null : language;
|
|
450
|
+
draw();
|
|
451
|
+
}
|
|
452
|
+
async function verTo(k) {
|
|
453
|
+
const V = R.vers, me = R; if (!V || (V.on || '') === k) return;
|
|
454
|
+
if (!k) { V.on = ''; V.err = ''; R.text = V.draft.text; R.cyc = V.draft.cyc; R.pyr = V.draft.pyr; R.W = wordsOf(R.text, R.name); R.i = 0; return draw(); }
|
|
455
|
+
const x = V.list.find((y) => y.audience === k); if (!x) return;
|
|
456
|
+
if (V.texts[k] == null) {
|
|
457
|
+
let t = null; try { t = await textOf('/api/doc?' + q({ ws: R.ws, path: x.path })); } catch { t = null; }
|
|
458
|
+
if (R !== me) return;
|
|
459
|
+
if (t == null) { V.err = x.label + ' could not be read. The draft is shown.'; return draw(); }
|
|
460
|
+
V.texts[k] = t;
|
|
461
|
+
}
|
|
462
|
+
if (!V.on) V.draft = { text: R.text, cyc: R.cyc, pyr: R.pyr };
|
|
463
|
+
noteUse('reportVersionTab');
|
|
464
|
+
V.err = ''; V.on = k; R.text = V.texts[k]; R.cyc = null; R.pyr = null; R.W = wordsOf(R.text, R.name); R.i = 0;
|
|
465
|
+
draw();
|
|
466
|
+
}
|
|
416
467
|
function barHtml() {
|
|
417
468
|
return rpBarHtml({ view: R.view, views: [['deck', 'Slides'], ['doc', 'Document'], ['live', 'Live page']], tools: [
|
|
418
|
-
R.issued || (R.cuts && R.cuts.on === 'sponsors') ? null : { act: 'edit', label: 'Edit', icon: 'pen' }, { act: 'present', label: 'Present', icon: 'present' },
|
|
469
|
+
R.issued || (R.cuts && R.cuts.on === 'sponsors') || (R.vers && R.vers.on) ? null : { act: 'edit', label: 'Edit', icon: 'pen' }, { act: 'present', label: 'Present', icon: 'present' },
|
|
419
470
|
R.issued && !R.archived ? null : { act: 'share', label: 'Share', icon: 'share', exp: R.pop === 'share', pop: 'dialog' },
|
|
420
471
|
{ act: 'dlm', label: 'Download', icon: 'dl', exp: R.pop === 'dl' }] });
|
|
421
472
|
}
|
|
@@ -493,7 +544,7 @@ function bodyHtml() {
|
|
|
493
544
|
}
|
|
494
545
|
const view = R.err ? SB.error('The document could not be read: ' + R.err) : !R.W ? SB.loading('Reading the report.')
|
|
495
546
|
: R.gal ? galView() : (R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml()) + ordAssHtml();
|
|
496
|
-
return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() + ordRowHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
|
|
547
|
+
return `<div class="vz-rpb">${R.conf ? confHtml() : R.W ? sumHtml() + ordRowHtml() : ''}${R.W && !R.err ? cutsHtml() : ''}${R.W && !R.err && !R.edit ? versionsHtml(R.vers) : ''}${R.W && !R.err && !R.edit && !R.issued ? langHtml(R.lh) : ''}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${R.edit ? '' : waitHtml()}${R.W && !R.err ? barHtml() : ''}${view}${R.W && !R.err && !R.issued ? rvHtml() : ''}${R.W && !R.err ? foldsHtml() : ''}${askHtml()}</div>`;
|
|
497
548
|
}
|
|
498
549
|
/* ── the orders of a draft (batch 27 item 16; canvas TpA, TpD, TpE; report-orders-ui.js, GET /api/report-orders) ── */
|
|
499
550
|
const ORD_HIDE = 'pmos-report-orders-hidden';
|
|
@@ -720,6 +771,9 @@ async function act([k, v], t) {
|
|
|
720
771
|
if (k === 'ord') return ordAct(v, t.dataset.r.split('|').slice(2).join('|'));
|
|
721
772
|
if (k === 'pop') { R.pop = v || null; return draw(); }
|
|
722
773
|
if (k === 'cut') return cutTo(v);
|
|
774
|
+
if (k === 'ver') return verTo(v || '');
|
|
775
|
+
if (k === 'lang') return langSet(v, false);
|
|
776
|
+
if (k === 'langundo') return langSet(v, true);
|
|
723
777
|
if (k === 'bf') return briefAct(v, t.dataset.r.split('|').slice(2).join('|'));
|
|
724
778
|
if (k === 'lv') return liveAct(v, t.dataset.r.split('|').slice(2).join('|'));
|
|
725
779
|
if (k === 'dlm') { R.pop = R.pop === 'dl' ? null : 'dl'; return draw(); }
|
|
@@ -1135,6 +1189,10 @@ export async function openReport(row, hand = {}) {
|
|
|
1135
1189
|
if (R !== me) return me;
|
|
1136
1190
|
if (!R.ws && d && d.ws) R.ws = d.ws;
|
|
1137
1191
|
R.also = d && Array.isArray(d.also) ? d.also : [];
|
|
1192
|
+
// Draft | For … | In …: the versions for an audience and the translated copies beside the draft (surface-reports: shown, never asked for)
|
|
1193
|
+
const vl = [...(d && Array.isArray(d.versions) ? d.versions : []), ...R.also.filter((a) => a && a.path && a.language).map((a) => ({ audience: 'lang-' + a.code, label: 'In ' + a.language, path: a.path }))];
|
|
1194
|
+
R.vers = vl.length ? { on: '', list: vl, texts: {}, draft: null, err: '' } : null;
|
|
1195
|
+
R.lh = d && Array.isArray(d.langHint) && d.langHint.length ? { list: d.langHint, done: null } : null; // the ✦ when a reader's language has no copy
|
|
1138
1196
|
}
|
|
1139
1197
|
await Promise.all([readCycle(), readSetup(), readShares()]);
|
|
1140
1198
|
if (R !== me) return me;
|
|
@@ -1155,7 +1213,7 @@ async function watchFile(me) {
|
|
|
1155
1213
|
while (R === me) {
|
|
1156
1214
|
await new Promise((ok) => setTimeout(ok, CHECK_MS));
|
|
1157
1215
|
if (R !== me) return;
|
|
1158
|
-
if (document.hidden || me.edit || me.busy || me.pop || (me.cuts && me.cuts.on === 'sponsors')) continue; // the sponsors cut is read from the file, not the file
|
|
1216
|
+
if (document.hidden || me.edit || me.busy || me.pop || (me.cuts && me.cuts.on === 'sponsors') || (me.vers && me.vers.on)) continue; // the sponsors cut is read from the file, not the file
|
|
1159
1217
|
const h = await stamp();
|
|
1160
1218
|
if (R !== me || !h) continue;
|
|
1161
1219
|
// a session writes the draft in many steps: read it when the file has been still for one more check, so a burst of writes is one redraw
|