create-pmos 0.408.0 → 0.410.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/board-programs-test.js +1 -1
- package/workspace/board-wf-shot.js +45 -0
- package/workspace/board-workflows-test.js +186 -0
- package/workspace/briefing-premium-board-test.js +2 -2
- package/workspace/briefing-premium-initiative-test.js +1 -1
- package/workspace/changelog.json +24 -0
- package/workspace/fixtures/board-workflows-facts.js +49 -0
- package/workspace/fixtures/workflows-facts.js +53 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/programs.md +2 -1
- package/workspace/guide/workflows.md +58 -0
- package/workspace/ini-workflow-test.js +177 -0
- package/workspace/lib/board-premium.js +30 -5
- package/workspace/lib/board-trail.js +24 -7
- package/workspace/lib/briefing-premium-agent.js +3 -0
- package/workspace/lib/engine/boards.js +30 -2
- package/workspace/lib/engine/workflows.js +204 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/programs.js +22 -7
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +157 -7
- package/workspace/lib/routes-programs.js +5 -0
- package/workspace/lib/routes-workflows.js +105 -0
- package/workspace/lib/workflow-chat.js +26 -0
- package/workspace/lib/workflow-cli.js +141 -0
- package/workspace/lib/workflows-store.js +108 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/program-charter-test.js +243 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +10 -5
- package/workspace/public/pm/bd-asks.js +2 -2
- package/workspace/public/pm/bd-prog-panel.js +36 -15
- package/workspace/public/pm/bd-prog.js +14 -4
- package/workspace/public/pm/bd-views.js +128 -45
- package/workspace/public/pm/bd-wf.js +99 -0
- package/workspace/public/pm/cozy-board.css +67 -6
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-panel.css +12 -6
- package/workspace/public/pm/cozy-settings.js +4 -2
- package/workspace/public/pm/cozy-viewer.js +36 -9
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-app.js +17 -9
- package/workspace/public/pm/home-ini-model.js +2 -2
- package/workspace/public/pm/home-ini.css +30 -0
- package/workspace/public/pm/home-ini.js +52 -9
- package/workspace/public/pm/home-list.js +10 -5
- package/workspace/public/pm/home-today.js +5 -5
- package/workspace/public/pm/ini-wf-model.js +91 -0
- package/workspace/public/pm/ini-wf.js +160 -0
- package/workspace/public/pm/premium-board.js +98 -30
- package/workspace/public/pm/premium-initiative-head.js +18 -8
- package/workspace/public/pm/program-charter.css +135 -0
- package/workspace/public/pm/program-charter.js +333 -0
- package/workspace/public/pm/program-model.js +48 -5
- package/workspace/public/pm/wf-edit.js +119 -0
- package/workspace/public/pm/wf-model.js +48 -0
- package/workspace/public/pm/wf-page.css +162 -0
- package/workspace/public/pm/wf-page.js +398 -0
- package/workspace/public/pm/wf-stage.js +187 -0
- package/workspace/public/premium-workflows.html +31 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +1 -1
- package/workspace/skills/workflow-setup.skill +57 -0
- package/workspace/test-lists/ini-workflow.json +6 -0
- package/workspace/test-lists/program-charter.json +9 -0
- package/workspace/test-lists/workflows-board.json +13 -0
- package/workspace/test-lists/workflows-setup.json +13 -0
- package/workspace/test-lists/workflows.json +5 -0
- package/workspace/workflows-setup-test.js +346 -0
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
* back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
|
|
30
30
|
* keep true: this item takes the place of the one shown now, and what was behind that one stays behind this one (a view switch)
|
|
31
31
|
* add { label, on(button) }: a quiet + before ⋯ (Home's "New session" on an initiative, canvas HbC). Not drawn on a phone.
|
|
32
|
+
* sub one quiet line under the title: what the item is when the title is its parent's name (a program's "Charter", canvas MsBCharter)
|
|
33
|
+
* presses [{ act, label, icon, text?, solid? }]: the item's own presses before ⋯ (a program's charter icon, canvas MsB0Entry; the
|
|
34
|
+
* charter's Save, MsBCharter). text draws the word beside the icon (not on a phone); solid is the one dark primary.
|
|
35
|
+
* onPress(act, button) runs them. setPresses(id, list) changes them while the item is shown (Save shows only after a change).
|
|
36
|
+
* guard (go, anchor) → true when the item holds unsaved changes and asks first: Close, ←, Escape and another open() call it, and
|
|
37
|
+
* nothing leaves until the caller runs go() (canvas MsB5Leave: Save or Discard). false or none: it leaves at once.
|
|
32
38
|
* render called with the body element to draw into; html is the same as a string. Neither: the body is left empty for the caller.
|
|
33
39
|
* id optional; current() returns it, so a caller can tell whether its item is the one shown
|
|
34
40
|
* onClose called once when this item leaves the card (Close, Escape, close(), or another open())
|
|
@@ -43,7 +49,7 @@
|
|
|
43
49
|
* line and ONE primary press ({ label, act } → data-czs-act="<act>", or { label, href }). tone 'you' (blue dot), 'warn' (amber), 'live' (red).
|
|
44
50
|
* also: [{ act, label, icon }] quiet icon-only presses after the primary (the Done check of a task). second: { label, act } one quiet
|
|
45
51
|
* word press, only where a decision has two answers (Return it | Keep it as is).
|
|
46
|
-
* czSections([{ id, title, count, open, render | html }], { key }) → the folding rows. A row folds and unfolds in place, and the fold
|
|
52
|
+
* czSections([{ id, title, count, open, render | html, tail? }], { key }) → the folding rows. A row folds and unfolds in place, and the fold
|
|
47
53
|
* is remembered per key and id (localStorage, a private window forgets it). render(): a string of markup, called once when drawn.
|
|
48
54
|
* widthOf(kind) · setWidth(px) · wide(on?) · railOn() for the page and the tests.
|
|
49
55
|
* The look is in cozy-vw-shell.css (loaded here once) over cozy.css (.cz-vw…). The old #dlg path (premium-viewer.js) is separate. */
|
|
@@ -111,10 +117,14 @@ export function headHtml(it) {
|
|
|
111
117
|
const disc = o.discuss && !o.home ? ib('discuss', 'Discuss in chat', P.chat) : '';
|
|
112
118
|
const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
|
|
113
119
|
const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
|
|
120
|
+
const own = (o.presses || []).filter((x) => x && x.act && x.label).map((x) => x.solid
|
|
121
|
+
? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
|
|
122
|
+
: `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 18)}</button>`).join('');
|
|
123
|
+
const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
|
|
114
124
|
return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
|
|
115
125
|
+ `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`
|
|
116
|
-
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3
|
|
117
|
-
+ disc + add + more
|
|
126
|
+
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3>${sub}</div>`)
|
|
127
|
+
+ disc + own + add + more
|
|
118
128
|
+ (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
|
|
119
129
|
+ (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
|
|
120
130
|
}
|
|
@@ -150,9 +160,10 @@ export function czSections(list, opt = {}) {
|
|
|
150
160
|
const body = typeof s.render === 'function' ? s.render() : s.html || '';
|
|
151
161
|
const n = s.count === 0 || s.count == null || s.count === '' ? '' : `<span class="czs-n">${esc(s.count)}</span>`;
|
|
152
162
|
const can = !!body || typeof s.on === 'string';
|
|
153
|
-
return `<div class="czs-sec${open && body ? ' on' : ''}" data-czs-id="${esc(id)}">`
|
|
163
|
+
return `<div class="czs-sec${open && body ? ' on' : ''}${s.tail ? ' t' : ''}" data-czs-id="${esc(id)}">`
|
|
154
164
|
+ `<button type="button" class="czs-row" ${body ? `data-czs-fold="${esc(id)}" aria-expanded="${open ? 'true' : 'false'}"` : can ? `data-czs-act="${esc(s.on)}"` : 'disabled'}>`
|
|
155
165
|
+ `<b>${esc(s.title)}</b>${n}${can ? `<span class="czs-cv">${svg(open && body ? P.down : P.chev, 15, 2)}</span>` : ''}</button>`
|
|
166
|
+
+ (s.tail ? `<span class="czs-tail">${s.tail}</span>` : '')
|
|
156
167
|
+ (body ? `<div class="czs-body"${open ? '' : ' hidden'}>${body}</div>` : '')
|
|
157
168
|
+ '</div>';
|
|
158
169
|
}).join('') + '</div>';
|
|
@@ -337,8 +348,9 @@ function mount() {
|
|
|
337
348
|
if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
|
|
338
349
|
const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
|
|
339
350
|
const a = b.dataset.czVw;
|
|
340
|
-
if (a === 'close') close
|
|
341
|
-
else if (a === 'back') { if (V.stack.length) back(); else close(); }
|
|
351
|
+
if (a === 'close') guarded(close, b);
|
|
352
|
+
else if (a === 'back') guarded(() => { if (V.stack.length) back(); else close(); }, b);
|
|
353
|
+
else if (a === 'press') { if (V.cur && typeof V.cur.onPress === 'function') V.cur.onPress(b.dataset.czVwP, b); }
|
|
342
354
|
else if (a === 'more') moreMenu(b);
|
|
343
355
|
else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
|
|
344
356
|
else if (a === 'wide') wide();
|
|
@@ -368,6 +380,12 @@ function emit() {
|
|
|
368
380
|
V.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
|
|
369
381
|
document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
|
|
370
382
|
}
|
|
383
|
+
/** Runs go now, or after the item's guard says so (it holds unsaved changes and asks Save or Discard first). */
|
|
384
|
+
function guarded(go, anchor) {
|
|
385
|
+
const g = V.cur && V.cur.guard;
|
|
386
|
+
if (typeof g === 'function') { let held = false; try { held = g(go, anchor || (V.el && V.el.querySelector('[data-cz-vw="back"],[data-cz-vw="close"]'))) === true; } catch { held = false; } if (held) return; }
|
|
387
|
+
go();
|
|
388
|
+
}
|
|
371
389
|
function leave() {
|
|
372
390
|
const was = V.cur; V.cur = null;
|
|
373
391
|
if (was && typeof was.onClose === 'function') { try { was.onClose(); } catch { /* the caller's own fault */ } }
|
|
@@ -406,19 +424,28 @@ async function saveRename() {
|
|
|
406
424
|
cur.title = r.title || v; if (cur.rename.value != null && r.title == null) cur.rename.value = v; if (cur.args) cur.args = { ...cur.args, title: cur.title };
|
|
407
425
|
endRename(); emit();
|
|
408
426
|
}
|
|
427
|
+
/** The item's own presses change while it is shown (the charter's Save shows only after a change). */
|
|
428
|
+
export function setPresses(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
|
|
409
429
|
/** The caller's own rename landed elsewhere (Undo, or a reload): the header shows the name. */
|
|
410
430
|
export function retitle(id, title) { if (V.cur && V.cur.id === String(id) && title) { V.cur.title = title; if (V.cur.args) V.cur.args = { ...V.cur.args, title }; if (!V.cur.renaming) redraw(); emit(); } }
|
|
411
431
|
|
|
412
432
|
/** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
|
|
413
433
|
export function open(it) {
|
|
414
434
|
const o = it || {};
|
|
435
|
+
// an item with unsaved changes asks first; the open goes on when it says so (and keeps a drill-in asked for before it)
|
|
436
|
+
if (!o._asked && V.cur && typeof V.cur.guard === 'function') {
|
|
437
|
+
const dr = V.drill; let now = true, ran = false;
|
|
438
|
+
guarded(() => { ran = true; if (!now) { V.drill = dr; open({ ...o, _asked: true }); } });
|
|
439
|
+
now = false;
|
|
440
|
+
if (!ran) return null;
|
|
441
|
+
}
|
|
415
442
|
const el = mount(); place(el);
|
|
416
443
|
if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
|
|
417
444
|
if ((o.back || V.drill) && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back && !o.keep) V.stack = [];
|
|
418
445
|
V.drill = false;
|
|
419
446
|
const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
|
|
420
447
|
leave();
|
|
421
|
-
V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, add: o.add || null, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
|
|
448
|
+
V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, add: o.add || null, sub: o.sub || '', presses: o.presses || null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
|
|
422
449
|
el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
|
|
423
450
|
redraw();
|
|
424
451
|
const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
|
|
@@ -470,7 +497,7 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
|
|
|
470
497
|
window.addEventListener('keydown', (e) => {
|
|
471
498
|
if (e.key !== 'Escape' || !isOpen() || e.defaultPrevented) return;
|
|
472
499
|
if (document.querySelector('[data-esc-layer]')) return;
|
|
473
|
-
e.preventDefault(); e.stopImmediatePropagation(); close
|
|
500
|
+
e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
|
|
474
501
|
}, true);
|
|
475
502
|
}
|
|
476
|
-
if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|
|
503
|
+
if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
.cz-vw-t { display: block; }
|
|
13
13
|
.cz-vw-kind { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* say it once: the kind is for a screen reader */
|
|
14
14
|
.cz-vw-title { font-size: 16px; font-weight: 800; }
|
|
15
|
+
.cz-vw-sub { margin: 1px 0 0; font-size: 12.5px; color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* what the item is under its parent's name (MsBCharter "Charter") */
|
|
16
|
+
/* the item's one dark primary in the header (the charter's Save, canvas MsBCharter): a word on a desk, a round check on a phone (MsBPhone) */
|
|
17
|
+
.cz-vw-pri { height: 36px; padding: 0 14px; margin: 0 4px; border-radius: 999px; border: 0; background: var(--cz-ink); color: var(--cz-card); font: inherit; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; flex: none; cursor: pointer; }
|
|
18
|
+
.cz-vw-pri.i { width: 40px; height: 40px; padding: 0; justify-content: center; }
|
|
19
|
+
.cz-vw-pri:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
15
20
|
.cz-vw-ib { border-radius: 999px; }
|
|
16
21
|
|
|
17
22
|
/* rename (canvas RnATask, RnAIni, RnAProg, RnAPhone): the title is the press; a tap makes it one field with a blue check */
|
|
@@ -80,6 +85,9 @@ body.cz-vw-drag, body.cz-vw-drag * { cursor: col-resize !important; user-select:
|
|
|
80
85
|
.czs-sec + .czs-sec::before { content: ""; position: absolute; left: 14px; right: 12px; top: 0; height: 1px; background: var(--cz-hair); }
|
|
81
86
|
.czs-row { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 12px 0 14px; background: none; border: 0; font: inherit; color: var(--cz-ink); text-align: left; cursor: pointer; }
|
|
82
87
|
.czs-row:disabled { cursor: default; }
|
|
88
|
+
/* a row's own quiet press at its right end, after the chevron (the pencil on a program's Milestones row, canvas MsB0Entry) */
|
|
89
|
+
.czs-sec.t > .czs-row { padding-right: 52px; }
|
|
90
|
+
.czs-tail { position: absolute; right: 6px; top: 6px; display: inline-flex; }
|
|
83
91
|
.czs-row:hover:not(:disabled) { background: color-mix(in srgb, var(--cz-well) 40%, var(--cz-card)); }
|
|
84
92
|
.czs-row:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: -2px; border-radius: 12px; }
|
|
85
93
|
.czs-row b { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -39,7 +39,7 @@ export function shownUser(text) {
|
|
|
39
39
|
const g = t.indexOf(MARK.grill + ' The PM set a goal: ');
|
|
40
40
|
if (g >= 0) return '/goal ' + t.slice(g + (MARK.grill + ' The PM set a goal: ').length).split('\n')[0];
|
|
41
41
|
if (t.startsWith(OPENING)) { const i = t.lastIndexOf('\nThe PM says: '); if (i >= 0) return t.slice(i + '\nThe PM says: '.length); }
|
|
42
|
-
if (t.startsWith('[PMOS report]') || t.startsWith('[PMOS program]')) { const i = t.lastIndexOf('\nThe PM says: '); if (i >= 0) return t.slice(i + '\nThe PM says: '.length); } // premium-reports-from-chat: lib/report-chat.js wrap; lib/program-chat.js wrap
|
|
42
|
+
if (t.startsWith('[PMOS report]') || t.startsWith('[PMOS program]') || t.startsWith('[PMOS workflow]')) { const i = t.lastIndexOf('\nThe PM says: '); if (i >= 0) return t.slice(i + '\nThe PM says: '.length); } // premium-reports-from-chat: lib/report-chat.js wrap; lib/program-chat.js wrap; lib/workflow-chat.js wrap
|
|
43
43
|
return t;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -21,6 +21,8 @@ import * as H from './home-data.js';
|
|
|
21
21
|
import { mountChat, avHtml } from './home-chat.js';
|
|
22
22
|
import * as MORE from './home-more.js';
|
|
23
23
|
import { headModel, STEPS } from './premium-initiative-head.js';
|
|
24
|
+
import * as WFM from './ini-wf-model.js'; // D99: the workflow an initiative runs (kind line, usual days)
|
|
25
|
+
import { wfIcon, wfOf } from './wf-model.js';
|
|
24
26
|
import { startAgent } from './page-agent.js';
|
|
25
27
|
import { mdHtml } from './chat-md.js';
|
|
26
28
|
import { mountPhoneCard } from './home-phone-card.js';
|
|
@@ -200,6 +202,9 @@ function poll() {
|
|
|
200
202
|
}, 8000);
|
|
201
203
|
}
|
|
202
204
|
setInterval(() => { if (!document.hidden) load(); }, 300000);
|
|
205
|
+
// back on this tab (a program or an initiative made on the Board in another tab): read again at once, at most every 15 seconds
|
|
206
|
+
let shownAt = Date.now();
|
|
207
|
+
document.addEventListener('visibilitychange', () => { if (document.hidden || Date.now() - shownAt < 15000) return; shownAt = Date.now(); load(); });
|
|
203
208
|
window.addEventListener('hm:reload', () => load());
|
|
204
209
|
|
|
205
210
|
/* ── the list ── */
|
|
@@ -292,12 +297,13 @@ function otherIni(id) {
|
|
|
292
297
|
return null;
|
|
293
298
|
}
|
|
294
299
|
function headOf(id) {
|
|
295
|
-
const
|
|
300
|
+
const row = iniRowOf(id) || {};
|
|
301
|
+
const M = S.IM && S.IMid === id ? { ...S.IM } : { head: { stage: row.stage }, acts: row.acts || {} };
|
|
302
|
+
Object.assign(M, { wf: row.wf || null, wfStage: row.wfStage || null, wfStages: row.wfStages || null }); // D99: the initiative's own workflow
|
|
296
303
|
const t = S.D.trail && S.D.trail.items && S.D.trail.items[id];
|
|
297
|
-
const
|
|
298
|
-
const u = S.D.trail && S.D.trail.usual && S.D.trail.usual[k];
|
|
304
|
+
const u = WFM.usualOf(S.D.trail, { ...row, stage: (M.head && M.head.stage) || row.stage }); // "usually N days" within its own workflow
|
|
299
305
|
if (t && t.since) M.stageSince = t.since;
|
|
300
|
-
if (u
|
|
306
|
+
if (u) M.usualDays = u.days;
|
|
301
307
|
const h = headModel(M, S.D.now);
|
|
302
308
|
// the Needs-you rows of this initiative make it the PM's turn too
|
|
303
309
|
const need = H.needsOf(S.D).find((r) => r.ini === id);
|
|
@@ -320,8 +326,10 @@ const MS = '<i class="cz-ms" aria-hidden="true"></i>'; // the milestone mark (
|
|
|
320
326
|
const msStep = (label) => !!(STEPS.find((s) => s.label === label) || {}).ms;
|
|
321
327
|
/** "To reach ◆ Deliver": the milestone mark before a milestone's name in the checklist's title. */
|
|
322
328
|
const ckTitle = (t, ms) => { const m = ms && /^(To reach |To finish )(.+)$/.exec(String(t || '')); return m ? esc(m[1]) + MS + esc(m[2]) : esc(t); };
|
|
323
|
-
/**
|
|
324
|
-
|
|
329
|
+
/** The workflow's icon on the stage card (WfTriage): a press opens the Change picker (ini-wf.js). */
|
|
330
|
+
const wfPill = (id) => { const w = wfOf(iniRowOf(id) || {}); return `<button type="button" class="hm-wf" data-hm-wf aria-haspopup="listbox" aria-expanded="false" aria-label="Workflow: ${esc(w.name)}. Change" title="${esc(w.name)} · Change">${wfIcon(w, 18)}</button>`; };
|
|
331
|
+
/** "Tender · KR 2.1": the workflow an initiative runs and its anchor, the kind line over its name (D99: Kind becomes Workflow). */
|
|
332
|
+
function kindOf(id) { return WFM.kindLine(iniRowOf(id) || {}); }
|
|
325
333
|
function cardHtml(id) {
|
|
326
334
|
const prod = id === 'product';
|
|
327
335
|
let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
|
|
@@ -351,7 +359,7 @@ function cardHtml(id) {
|
|
|
351
359
|
}
|
|
352
360
|
// on the initiative's page the Viewer's header names it (kind, title, New session): the card is its stage box alone (HbCDesk)
|
|
353
361
|
return `<section class="hm-card hm-pcard" aria-label="${esc(title)}">`
|
|
354
|
-
+ `<div class="hm-box ${esc(turn)}"><div class="hm-br"><span class="hm-turn ${esc(turn)}"><i aria-hidden="true"></i>${esc(turnLabel)}</span
|
|
362
|
+
+ `<div class="hm-box ${esc(turn)}"><div class="hm-br"><span class="hm-turn ${esc(turn)}"><i aria-hidden="true"></i>${esc(turnLabel)}</span>${prod ? '' : wfPill(id)}<span class="st">${esc(stage)}</span></div>`
|
|
355
363
|
+ lad + bars
|
|
356
364
|
// the checklist folds to one line (AgInitSpec): its title, the summary and a chevron; Then and the time line show only unfolded
|
|
357
365
|
+ (S.cardFold
|
|
@@ -448,7 +456,7 @@ function chatHead(t) {
|
|
|
448
456
|
const ini = t.ini || (r && r.ini) || null;
|
|
449
457
|
const ir = ini ? rowById('i:' + ini) : null, b = ini ? iniRowOf(ini) : null;
|
|
450
458
|
const stage = (ir && ir.stage) || (b && b.stage) || '';
|
|
451
|
-
return { row: r || ir, title, scope: ini ? iniTitle(ini) : '', at: L.stageAt(stage), stage };
|
|
459
|
+
return { row: r || ir, title, scope: ini ? iniTitle(ini) : '', at: b ? L.rowAt({ ...b, stage }) : L.stageAt(stage), steps: L.ownSteps(b), stage };
|
|
452
460
|
}
|
|
453
461
|
function scopeItems() {
|
|
454
462
|
return [{ label: 'All work', sub: 'Home', go: () => select(null) }, { label: H.productName(S.D) + ' · product', go: () => goIni('product') }]
|
|
@@ -1371,7 +1379,7 @@ function cta() {
|
|
|
1371
1379
|
}
|
|
1372
1380
|
|
|
1373
1381
|
/* ── start ── */
|
|
1374
|
-
mountIni({ S, VW, pmGet, pmPost, toast, renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
|
|
1382
|
+
mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
|
|
1375
1383
|
// the initiative's page (HbCDesk): its card, its header and its ⋯
|
|
1376
1384
|
cardHtml: (id) => cardHtml(id), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), talk: () => talk(),
|
|
1377
1385
|
foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
|
|
@@ -36,7 +36,7 @@ export function moveModel(h, M, L, now = Date.now()) {
|
|
|
36
36
|
const open = items.filter((x) => !x.done);
|
|
37
37
|
const self = !!acts.self, life = acts.life || null;
|
|
38
38
|
const lay = L || { auto: true, held: [] };
|
|
39
|
-
const ms = !!next && isMilestone(next);
|
|
39
|
+
const ms = !!next && (Array.isArray(acts.msNames) ? acts.msNames.includes(next) : isMilestone(next)); // D99: the workflow's own ◆ stages
|
|
40
40
|
const finished = String((m.head && m.head.statusLabel) || '') === 'Done';
|
|
41
41
|
const canMove = !self && !life && !!next, canBack = !self && !life && !!prev;
|
|
42
42
|
const allDone = items.length > 0 && open.length === 0;
|
|
@@ -44,7 +44,7 @@ export function moveModel(h, M, L, now = Date.now()) {
|
|
|
44
44
|
const auto = lay.auto !== false;
|
|
45
45
|
const n = items.length;
|
|
46
46
|
const swText = !n ? 'Moves on by itself when its exit items are done' : n === 1 ? 'Moves on by itself when it is done' : n === 2 ? 'Moves on by itself when both are done' : 'Moves on by itself when all ' + n + ' are done';
|
|
47
|
-
const why = self ? 'The stage of this board comes from the workflow engine.' : life === 'hold' ? 'On hold: resume it to move the stage.' : life === 'cancelled' ? 'Cancelled: resume it to move the stage.' : !next && cur ? cur + ' is the last stage.' : !cur ? 'No stage on record.' : '';
|
|
47
|
+
const why = self ? 'The stage of this board comes from the workflow engine.' : life === 'hold' ? 'On hold: resume it to move the stage.' : life === 'cancelled' ? 'Cancelled: resume it to move the stage.' : life === 'ended' ? 'Won’t do: bring it back to Triage to move it.' : !next && cur ? cur + ' is the last stage.' : !cur ? 'No stage on record.' : '';
|
|
48
48
|
return {
|
|
49
49
|
cur, next, prev, items, open, allDone, ms, self, life, canMove, canBack, auto, held, swText, why,
|
|
50
50
|
title: next ? 'To finish ' + cur : cur ? 'To finish ' + cur : 'What is next',
|
|
@@ -183,3 +183,33 @@ button.hi-pill { cursor: pointer; }
|
|
|
183
183
|
.hi-pge p { margin: 0; font-size: 13px; color: var(--cz-ink3); }
|
|
184
184
|
.hi-talk { min-height: 44px; border: 0; border-radius: 22px; background: var(--cz-well); color: var(--cz-ink3); font: inherit; font-size: 14px; text-align: left; padding: 0 16px; cursor: pointer; }
|
|
185
185
|
@media (hover: hover) { .hi-pgm:hover { background: var(--cz-well2); } }
|
|
186
|
+
|
|
187
|
+
/* ── D99: the initiative's own workflow (WfTriage, WfAChange, WfAWontDo) ── */
|
|
188
|
+
.cz .wfi { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 6px; background: var(--cz-well); color: var(--cz-ink2); }
|
|
189
|
+
.cz .wfi svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
190
|
+
.hm-br .hm-wf { margin-left: auto; display: inline-flex; align-items: center; padding: 3px; border: 0; border-radius: 9px; background: none; cursor: pointer; color: inherit; }
|
|
191
|
+
.hm-br .hm-wf:hover, .hm-br .hm-wf[aria-expanded="true"] { background: var(--cz-well); }
|
|
192
|
+
.hm-br .hm-wf + .st { margin-left: 0; }
|
|
193
|
+
.hi-pop.wide:not(.sheet) { width: 560px; }
|
|
194
|
+
.hi-pop.menu .hi-mi .wfi { margin-left: -2px; }
|
|
195
|
+
.hi-wfpad { padding: 4px 12px 6px; }
|
|
196
|
+
.hi-wfchain { line-height: 1.5; }
|
|
197
|
+
.hi-mut { color: var(--cz-ink3); }
|
|
198
|
+
.hi-wfh { display: flex; align-items: center; gap: 8px; }
|
|
199
|
+
.hi-wfh .hi-h3 { flex: 1; min-width: 0; }
|
|
200
|
+
.hi-wfrows { display: flex; flex-direction: column; }
|
|
201
|
+
.hi-wfrow { display: grid; grid-template-columns: minmax(0, 130px) 14px minmax(0, 130px) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: 13.5px; }
|
|
202
|
+
.hi-wfrow:first-child { border-top: 0; }
|
|
203
|
+
.hi-wfrow span { min-width: 0; }
|
|
204
|
+
.hi-wfrow em { display: block; font-style: normal; font-size: 12px; color: var(--cz-ink3); }
|
|
205
|
+
.hi-wfland { display: flex; align-items: center; gap: 8px; }
|
|
206
|
+
.hi-wfland span { flex: 1; }
|
|
207
|
+
.hi-wfland select { font: inherit; font-size: 13px; font-weight: 700; color: var(--cz-ink); background: var(--cz-well); border: 0; border-radius: 10px; padding: 6px 10px; max-width: 60%; }
|
|
208
|
+
.hi-end { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--cz-well); font-size: 13px; }
|
|
209
|
+
.hi-end p { margin: 0; flex: 1; min-width: 0; color: var(--cz-ink2); }
|
|
210
|
+
.hi-endi { display: inline-flex; color: var(--cz-ink3); }
|
|
211
|
+
@media (max-width: 760px) {
|
|
212
|
+
.hi-wfrow { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); }
|
|
213
|
+
.hi-wfrow > .hi-small { grid-column: 1 / -1; }
|
|
214
|
+
.hi-end { flex-wrap: wrap; }
|
|
215
|
+
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* under ⋯; the phone keeps the Tasks | Documents | Stage switch. The pure half of the tickets is tk-model.js. */
|
|
24
24
|
import * as MD from './home-ini-model.js';
|
|
25
25
|
import * as TKM from './tk-model.js';
|
|
26
|
+
import * as WF from './ini-wf.js'; // D99: the initiative's own workflow (Change picker, switch, Won't do, Archive)
|
|
26
27
|
|
|
27
28
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
28
29
|
const SVG = (d, w = 16, sw = 1.8) => `<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>`;
|
|
@@ -76,10 +77,37 @@ function moveHtml(id, M, mv) {
|
|
|
76
77
|
+ `<div class="hi-mvb"><button type="button" class="hi-btn sm dark" data-hi-move aria-haspopup="dialog" aria-expanded="${!!(X.pop && X.pop.kind === 'move')}">Move to ${mv.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(mv.next)}${SVG(I.next, 14)}</button>`
|
|
77
78
|
+ (mv.canBack ? `<button type="button" class="hi-ib" data-hi-back aria-haspopup="dialog" aria-label="Move back a stage, to ${esc(mv.prev)}" title="Move back to ${esc(mv.prev)}">${SVG(I.back, 16)}</button>` : '') + '</div></div>';
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
+
/** D99: an initiative on a workflow of the library moves between ITS stages (the row's wfStages; a skipped stage is left out), and that
|
|
81
|
+
* stage's Moves on by itself is the default (the PM's own choice for this one initiative wins, POST /api/boards/ini-auto). */
|
|
82
|
+
const rowOf = (id) => (X.ctx.rowOf ? X.ctx.rowOf(id) : null) || {};
|
|
83
|
+
const ownWf = (row) => !!(row.wf && row.wf.id && row.wf.id !== 'product-feature' && Array.isArray(row.wfStages) && row.wfStage);
|
|
84
|
+
function wfM(id, M) {
|
|
85
|
+
const row = rowOf(id);
|
|
86
|
+
if (!ownWf(row) && !row.ended) return M;
|
|
87
|
+
const acts = { ...M.acts };
|
|
88
|
+
if (ownWf(row)) {
|
|
89
|
+
const st = row.wfStages.filter((s) => s.status !== 'skipped' || s.key === row.wfStage.key);
|
|
90
|
+
Object.assign(acts, { stages: st.map((s) => s.name), stage: row.wfStage.name, msNames: st.filter((s) => s.milestone).map((s) => s.name), self: false });
|
|
91
|
+
}
|
|
92
|
+
if (row.ended) acts.life = 'ended';
|
|
93
|
+
return { ...M, acts };
|
|
94
|
+
}
|
|
95
|
+
function wfL(id, L) {
|
|
96
|
+
const row = rowOf(id);
|
|
97
|
+
if (!ownWf(row)) return L;
|
|
98
|
+
const cur = row.wfStages.find((s) => s.key === row.wfStage.key) || {};
|
|
99
|
+
return { ...L, auto: !!cur.auto, held: L.held || [] };
|
|
100
|
+
}
|
|
101
|
+
function mvOf(id, M) { return MD.moveModel(X.ctx.S.H || null, wfM(id, M), wfL(id, Lof(id)), Date.now()); }
|
|
102
|
+
/** What ini-wf.js needs from the page. */
|
|
103
|
+
function wfUi() {
|
|
104
|
+
const C = X.ctx;
|
|
105
|
+
return { openPop, closePop, undoToast, toast: C.toast, pmGet: C.pmGet, pmPost: C.pmPost, load: async () => { await C.load(); redrawView(); }, row: rowOf, title: C.iniTitle,
|
|
106
|
+
bw: (id) => { const M = curM(); const r = rowOf(id); return M ? bw(M) : { ws: r.ws, board: r.board }; } };
|
|
107
|
+
}
|
|
80
108
|
|
|
81
109
|
async function doMove(id, M, to, why, o = {}) {
|
|
82
|
-
const from = M.acts.stage;
|
|
110
|
+
const from = wfM(id, M).acts.stage;
|
|
83
111
|
const r = await X.ctx.pmPost('/api/boards/move', { ...bw(M), id, to, why });
|
|
84
112
|
if (!r || r.ok === false) { X.ctx.toast((r && r.error) || 'The stage did not move.'); return false; }
|
|
85
113
|
const title = X.ctx.iniTitle(id);
|
|
@@ -119,8 +147,8 @@ function openPop(anchor, kind, html, onClick, o = {}) {
|
|
|
119
147
|
closePop();
|
|
120
148
|
const el = document.createElement('div');
|
|
121
149
|
const sheet = isPhone() && !o.menu;
|
|
122
|
-
el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '');
|
|
123
|
-
el.setAttribute('role', o.menu ? 'menu' : 'dialog'); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
|
|
150
|
+
el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
|
|
151
|
+
el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
|
|
124
152
|
el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
|
|
125
153
|
let scrim = null;
|
|
126
154
|
if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
|
|
@@ -214,22 +242,34 @@ function pageHtml(id, M) {
|
|
|
214
242
|
+ look.map(drow).join('') + `<button type="button" class="hi-pgm" data-hi-open="docs">Show all ${docs.length}${SVG(I.right, 14, 2)}</button></section>` : '';
|
|
215
243
|
// a phone: the page is a sheet over the list, and the chat is one press away (HbCPhone)
|
|
216
244
|
const talk = isPhone() ? `<button type="button" class="hi-talk" data-hi-talk>Message Claude about ${esc(X.ctx.iniTitle(id))}</button>` : '';
|
|
217
|
-
return `<div class="hi-v hi-page" data-hi-v="page">${card}${tasks}${dsec}${talk}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
|
|
245
|
+
return `<div class="hi-v hi-page" data-hi-v="page">${WF.endedHtml(rowOf(id))}${card}${tasks}${dsec}${talk}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
|
|
218
246
|
}
|
|
219
247
|
/** ⋯ of the page (HbCMore): change it, look at it elsewhere, then stop it, red and last. */
|
|
220
248
|
function pageMore(id) {
|
|
221
249
|
const M = curM(); if (!M) return [];
|
|
222
|
-
const mv = mvOf(id, M), out = [];
|
|
223
|
-
|
|
250
|
+
const mv = mvOf(id, M), out = [], row = rowOf(id), self = !!(M.acts && M.acts.self);
|
|
251
|
+
// D99 (WfAWontDo): Change workflow and Rename first; the PMOS-self board keeps its derived ladder, so it has no workflow to change
|
|
252
|
+
if (!self && !row.ended) out.push({ label: 'Change workflow', note: (row.wf || {}).name || 'Product feature', on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) });
|
|
253
|
+
if (X.ctx.renameIni) out.push({ label: 'Rename', on: () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } });
|
|
254
|
+
if (!mv.why) out.push({ label: 'Moves on by itself', note: mv.auto ? 'On' : 'Off', on: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) });
|
|
224
255
|
if (mv.canBack) out.push({ label: 'Move back a stage', note: mv.prev, on: (b) => popBack(b || document.querySelector('#czViewer [data-cz-vw="more"]'), id, M, mv) });
|
|
225
256
|
if ((M.acts.stages || []).length && !M.acts.self) out.push({ label: 'Move to a stage', on: () => iniOverview('stage', { back: true }) });
|
|
226
257
|
out.push({ label: 'Add a stakeholder', on: () => X.ctx.addPerson() });
|
|
227
258
|
if (X.ctx.turnProgram) out.push({ label: 'Turn into a program', on: () => X.ctx.turnProgram(id) });
|
|
228
259
|
out.push({ sep: true }, { label: 'Open on the Board', on: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); } },
|
|
229
260
|
{ label: 'The record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) });
|
|
230
|
-
|
|
261
|
+
// Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage. Cancel stays red and last (HbCMore)
|
|
262
|
+
if (!self) out.push({ sep: true }, row.ended ? { label: 'Back to Triage', on: () => WF.backToTriage(wfUi(), id) } : { label: 'Won’t do', on: (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) }, { label: 'Archive', on: () => WF.archive(wfUi(), id) });
|
|
263
|
+
if (!M.acts.life && !row.ended) out.push({ sep: true }, { label: 'Put on hold', on: () => { iniOverview('stage', { back: true, ask: 'on-hold' }); } }, { label: 'Cancel the initiative', danger: true, on: () => { iniOverview('stage', { back: true, ask: 'cancelled' }); } });
|
|
231
264
|
return out;
|
|
232
265
|
}
|
|
266
|
+
const moreBtn = () => document.querySelector('#czViewer [data-cz-vw="more"]') || document.body;
|
|
267
|
+
/** Moves on by itself for this one initiative, on a workflow of the library (POST /api/boards/ini-auto): the stage sets the default. */
|
|
268
|
+
async function autoPress(id, M, on) {
|
|
269
|
+
const r = await X.ctx.pmPost('/api/boards/ini-auto', { ...bw(M), id, stage: rowOf(id).wfStage.key, auto: on });
|
|
270
|
+
if (!r || r.ok === false) { X.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
|
|
271
|
+
await X.ctx.load(); redrawView();
|
|
272
|
+
}
|
|
233
273
|
export function iniPage() {
|
|
234
274
|
if (!X.ctx) return false;
|
|
235
275
|
const S = X.ctx.S, id = S.ini;
|
|
@@ -241,6 +281,7 @@ export function iniPage() {
|
|
|
241
281
|
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', more: () => pageMore(id), rename,
|
|
242
282
|
add: { label: 'New session', on: () => X.ctx.newIn(id) },
|
|
243
283
|
render: (b) => { X.view = 'page'; BODY = b; draw(b); wire(b, id); } });
|
|
284
|
+
WF.pmosNotice(wfUi(), id); // WfTriage: "Set to Tender from the BRD · Undo", once
|
|
244
285
|
if (!curM()) { X.failed = null; X.ctx.loadIni().then(() => { if (S.ini !== id) return; if (!curM()) X.failed = id; redrawView(); }); }
|
|
245
286
|
return true;
|
|
246
287
|
}
|
|
@@ -491,7 +532,7 @@ function wire(body, id) {
|
|
|
491
532
|
const d = t.dataset;
|
|
492
533
|
if (X.view === 'page' && pagePress(t, id, M)) return;
|
|
493
534
|
if (d.hiView) { iniOverview(d.hiView); return; }
|
|
494
|
-
if ('hiAuto' in d) { press(id, M, { kind: 'auto', on
|
|
535
|
+
if ('hiAuto' in d) { const on = t.getAttribute('aria-checked') !== 'true'; if (ownWf(rowOf(id))) autoPress(id, M, on); else press(id, M, { kind: 'auto', on }); return; }
|
|
495
536
|
if ('hiBy' in d) { groupMenu(t, id, M); return; }
|
|
496
537
|
// PRD to Jira (T1 to T3)
|
|
497
538
|
if (d.czsAct === 'tk-sendall') { sendSheet(id, M); return; }
|
|
@@ -598,6 +639,8 @@ function pagePress(t, id, M) {
|
|
|
598
639
|
if ('hmCta' in d) { C.cta(); return true; }
|
|
599
640
|
if ('hmOv' in d) { C.overviewAsk(id); return true; }
|
|
600
641
|
if ('hmCfold' in d) { C.foldCard(); redrawView(); return true; }
|
|
642
|
+
if ('hmWf' in d) { if (!(M.acts && M.acts.self)) WF.openPicker(t, wfUi(), id); else C.toast('This board takes its stages from the workflow engine.'); return true; }
|
|
643
|
+
if ('wfBack' in d) { WF.backToTriage(wfUi(), id); return true; }
|
|
601
644
|
if ('hmDone' in d) { C.S.doneOpen = !C.S.doneOpen; redrawView(); return true; }
|
|
602
645
|
if ('hiTalk' in d) { C.talk(id); return true; }
|
|
603
646
|
if ('hiMove' in d) { const mv = mvOf(id, M); if (!mv.canMove) return true; if (mv.open.length) popMove(t, id, M, mv); else doMove(id, M, mv.next, mv.allDone ? 'Moved by hand: every exit item is done.' : 'Moved by hand'); return true; }
|
|
@@ -23,7 +23,6 @@ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct
|
|
|
23
23
|
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
24
24
|
const RANK = { needs: 4, blocked: 3, working: 2, quiet: 1 };
|
|
25
25
|
const pad = (n) => String(n).padStart(2, '0');
|
|
26
|
-
const cap1 = (s) => (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : '');
|
|
27
26
|
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
28
27
|
const isoDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()); };
|
|
29
28
|
const dayDiff = (iso, now) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return null; const a = new Date(+m[1], +m[2] - 1, +m[3]); const t = new Date(now); t.setHours(0, 0, 0, 0); return Math.round((a - t) / 86400000); };
|
|
@@ -102,6 +101,9 @@ const meetIni = (m) => (m && (m.initiative || (m.level && m.level.kind === 'init
|
|
|
102
101
|
const bareHint = (x) => { const h = String(x.hint || ''), p = prodOf(x); return p && h.startsWith(p + ' · ') ? h.slice(p.length + 3) : p && h === p ? '' : h; }; // the group names the product; "Across products" stays
|
|
103
102
|
/** Where an initiative is on the eight stages (the row's stage track, HvAC .mt): 0 Triage … 7 Evaluate, or -1 when its stage is not one of them. */
|
|
104
103
|
export const stageAt = (stage) => { const k = stageKey(stage); return k ? STEPS.findIndex((s) => s.key === k) : -1; };
|
|
104
|
+
/** D99: an initiative on another workflow draws ITS stages ({ ms } each) and its place among them; Product feature draws the eight. */
|
|
105
|
+
export const ownSteps = (r) => (r && r.wf && r.wf.id && r.wf.id !== 'product-feature' && Array.isArray(r.wfStages) && r.wfStage ? r.wfStages.map((s) => ({ ms: !!s.milestone })) : null);
|
|
106
|
+
export const rowAt = (r) => (ownSteps(r) ? r.wfStage.n - 1 : stageAt(r && r.stage));
|
|
105
107
|
/** A row under an initiative that is the PM's move now (Your move, and the initiative's count badge): a next step, a session
|
|
106
108
|
* that waits on the PM, or a task of the PM's own that is late. */
|
|
107
109
|
const isMove = (k) => k.step || (k.kind === 'session' && (k.state === 'needs' || k.state === 'blocked')) || (k.kind === 'task' && k.mine && k.late);
|
|
@@ -117,15 +119,15 @@ function iniRowOf(D, r, needs, now) {
|
|
|
117
119
|
const right = turn ? 'your turn' + (mine ? ' · ' + plural(mine, 'task', 'tasks') : '') : mine ? plural(mine, 'task', 'tasks') : run ? run + ' running' : 'Nothing today';
|
|
118
120
|
// next steps, sessions and today's meetings always show; tasks show the TASKS_SHOWN most urgent, the rest behind "Show N more tasks"
|
|
119
121
|
const kids = [...steps, ...ses.sort((a, b) => (RANK[b.state] || 0) - (RANK[a.state] || 0)), ...tasks.map((t, i) => (i < TASKS_SHOWN ? t : { ...t, extra: true })), ...meet];
|
|
120
|
-
const hint =
|
|
122
|
+
const hint = [(r.wf && r.wf.name) || 'Product feature', r.stage].filter(Boolean).join(' · '); // D99: Kind becomes Workflow
|
|
121
123
|
return { id: 'i:' + r.id, kind: 'ini', ini: r.id, name: r.title, hint, right, turn, busy: kids.length > 0, state: turn ? 'needs' : run ? 'working' : 'quiet', kids, board: r, updated: r.updated || '',
|
|
122
|
-
stage: r.stage || '', at:
|
|
124
|
+
stage: r.stage || '', at: rowAt(r), steps: ownSteps(r), yours: kids.filter(isMove).length, late: kids.some((k) => k.kind === 'task' && k.mine && k.late) };
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
/* ── programs (initiative program-hierarchy, H4; canvas PgHomePhone, PgHomeDesk) ── */
|
|
126
128
|
const closedOf = (n, turnN) => [n ? plural(n, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open';
|
|
127
129
|
const isMe = (D, who) => { const me = String((D.today && D.today.me) || '').toLowerCase(), w = String(who || '').toLowerCase(); return !w || /^(pm|you)(:|$)/.test(w) || (!!me && (w === me || w.startsWith(me + ' '))); };
|
|
128
|
-
/** One group per program that has an initiative or an open task in
|
|
130
|
+
/** One group per program, placed above the products: with one product picked, only a program that has an initiative or an open task in it, or whose home it is. The grouping is
|
|
129
131
|
* groupRows (program-model.js), the one Board and Kanban use: a program's initiatives leave their product's group, so each initiative shows
|
|
130
132
|
* once, and sit under one sub-heading per product, in the order the products first appear. The program's own open tasks come first.
|
|
131
133
|
* With one product picked, only that product's initiatives and tasks show. D.programs is GET /api/programs' programs. */
|
|
@@ -153,7 +155,10 @@ export function programGroups(D, groups, products, o, now) {
|
|
|
153
155
|
});
|
|
154
156
|
const subs = ((G && G.products) || []).map((sp) => { const at = products.findIndex((p) => p.name === sp.name); return { name: sp.name, initials: at >= 0 ? products[at].initials : initialsOf(sp.name), tone: Math.max(0, at) % TONES, inis: sp.rows.map((x) => x.r) }; });
|
|
155
157
|
const inis = subs.flatMap((x) => x.inis);
|
|
156
|
-
|
|
158
|
+
// a program with no open initiative here (just made, or its initiatives all cancelled or archived) still shows, under all products or its
|
|
159
|
+
// home product, so the PM finds it and can move initiatives in
|
|
160
|
+
const fresh = !o.product || products.some((p) => p.key === o.product && (!pr.home || p.ws === pr.home));
|
|
161
|
+
if (!inis.length && !tasks.length && !fresh) continue;
|
|
157
162
|
const st = programState(pr, rowsOf, now);
|
|
158
163
|
const turnN = inis.filter((x) => x.turn).length;
|
|
159
164
|
out.push({ key: 'g:' + pr.id, kind: 'program', program: pr, st, name: pr.title, subs, inis, rest: [], tasks, count: inis.length, turnN,
|
|
@@ -45,7 +45,7 @@ function checkHtml(r) {
|
|
|
45
45
|
return `<button type="button" class="hv-mk hm-ck" data-hm-check="${esc(r.id)}" aria-label="${esc(what)}. Mark ${esc(r.name)} done" title="Mark done"><span class="hv-ck${r.late ? ' late' : ''}"></span></button>`;
|
|
46
46
|
}
|
|
47
47
|
const isCheck = (r) => r.check || r.kind === 'task' || r.done;
|
|
48
|
-
const track = (at, label) => (at < 0 ? '' : `<span class="hv-mt" role="img" aria-label="${esc(label)}">${STEPS.map((x, i) => `<i class="${[i < at ? 'on' : i === at ? 'now' : '', x.ms ? 'ms' : ''].filter(Boolean).join(' ')}"></i>`).join('')}</span>`);
|
|
48
|
+
const track = (at, label, steps) => (at < 0 ? '' : `<span class="hv-mt" role="img" aria-label="${esc(label)}">${(steps || STEPS).map((x, i) => `<i class="${[i < at ? 'on' : i === at ? 'now' : '', x.ms ? 'ms' : ''].filter(Boolean).join(' ')}"></i>`).join('')}</span>`);
|
|
49
49
|
const clock = (when) => (when ? `<span class="hv-st">${svg(P.clock, 13)}${esc(String(when).split(' ')[0])}</span>` : '');
|
|
50
50
|
/** A row of the list: a next step, a task, a note, a mention, a session or a meeting. o: { sel, kid } */
|
|
51
51
|
export function rowHtml(r, o) {
|
|
@@ -68,8 +68,8 @@ export function chatHeadHtml(h) {
|
|
|
68
68
|
const mk = !r ? '' : isCheck(r) ? `<span class="hv-mk"><span class="hv-ck${r.late ? ' late' : ''}" role="img" aria-label="${r.late ? 'Task, late' : 'Task'}"></span></span>` : markHtml(r.kind === 'ini' && r.yours && r.state !== 'blocked' ? { state: 'needs' } : r);
|
|
69
69
|
const lead = h.prog ? `<span class="hv-tl tp sm" aria-hidden="true">${svg(P.layers, 13)}</span>` : '';
|
|
70
70
|
const same = !h.scope || h.scope === h.title;
|
|
71
|
-
const chip = same ? '' : `<span class="hm-chs" title="In ${esc(h.scope)}">${h.prog ? svg(P.layers, 13) : track(h.at == null ? -1 : h.at, h.stage || '')}<span>${esc(h.scope)}</span></span>`;
|
|
72
|
-
return `${mk}${same ? lead : ''}<b class="hm-chb">${esc(h.title)}</b>${same && !h.prog ? track(h.at == null ? -1 : h.at, h.stage || '') : ''}${chip}`;
|
|
71
|
+
const chip = same ? '' : `<span class="hm-chs" title="In ${esc(h.scope)}">${h.prog ? svg(P.layers, 13) : track(h.at == null ? -1 : h.at, h.stage || '', h.steps)}<span>${esc(h.scope)}</span></span>`;
|
|
72
|
+
return `${mk}${same ? lead : ''}<b class="hm-chb">${esc(h.title)}</b>${same && !h.prog ? track(h.at == null ? -1 : h.at, h.stage || '', h.steps) : ''}${chip}`;
|
|
73
73
|
}
|
|
74
74
|
/** An initiative row: its mark, its title, the count of what is yours while it is folded, the stage track, and a chevron when something
|
|
75
75
|
* sits under it. The title opens the initiative; the chevron shows or hides its sessions, next steps, tasks and meetings. */
|
|
@@ -82,7 +82,7 @@ function iniHtml(r, o) {
|
|
|
82
82
|
const badge = !open && r.yours ? `<span class="hv-c" role="img" aria-label="${r.yours === 1 ? '1 is yours' : r.yours + ' are yours'}">${r.yours}</span>` : '';
|
|
83
83
|
const chev = r.kids.length ? `<button type="button" class="hv-xc" data-hm-kids="${esc(r.id)}" aria-expanded="${open}" aria-label="${open ? 'Hide' : 'Show'} what is in ${esc(r.name)}">${svg(open ? P.chevD : P.chevR, 15)}</button>` : '<span class="hv-xc" aria-hidden="true"></span>';
|
|
84
84
|
return `<div class="hm-r hv-r ini st-${esc(r.state)}${o.sel === r.id ? ' sel' : ''}" data-id="${esc(r.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${o.sel === r.id ? ' aria-current="true"' : ''} title="${esc(r.hint)}">${markHtml(r.yours && r.state !== 'blocked' ? { state: 'needs' } : r)}`
|
|
85
|
-
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span>${badge}${track(r.at, r.stage)}</button>${chev}</div>${nest}`;
|
|
85
|
+
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span>${badge}${track(r.at, r.stage, r.steps)}</button>${chev}</div>${nest}`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/* ── a group (HvAC .pg, .card; PgHomePhone .psub) ── */
|
|
@@ -124,7 +124,7 @@ function programHtml(g, o) {
|
|
|
124
124
|
if (!open) return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}</section>`;
|
|
125
125
|
const body = g.tasks.map((t) => rowHtml(t, o)).join('')
|
|
126
126
|
+ g.subs.map((x) => `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>${x.inis.map((r) => iniHtml(r, o)).join('')}`).join('');
|
|
127
|
-
return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body}</div></section>`;
|
|
127
|
+
return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
|
|
128
128
|
}
|
|
129
129
|
/** "Not in an initiative" (HvAC .lh): a line under the groups. Folded it shows a blue dot when a row waits on you, an amber square when one
|
|
130
130
|
* of your own is late, and the count; open, the rows in a card. */
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* pm/ini-wf-model.js — the pure half of an initiative's own workflow screens (D99, initiative workflows-per-initiative; canvas WfTriage,
|
|
2
|
+
* WfAChange, WfAWontDo). ini-wf.js draws what these return; a node test imports them.
|
|
3
|
+
*
|
|
4
|
+
* kindLine(row) "Tender · KR 2.1": the workflow and the anchor over the initiative's name (HbC*; was the lane)
|
|
5
|
+
* chainText(wf) "Triage → Requirements → ◆ RFP out → …": a workflow's stages in order
|
|
6
|
+
* pickerItems(lib, row) the Change picker's rows: every workflow not archived, with its stage count, the current one picked
|
|
7
|
+
* switchTarget(from, to, key) the stage an initiative lands on (scripts/workflows.js switchTarget, the same rule)
|
|
8
|
+
* switchPlan(row, to, landing?) the switch dialog: each done or current stage → where it lands, the landing stage, the stages to pick from
|
|
9
|
+
* wontdoReady(reason, note) Won't do can go: a reason, and words when the reason is Other
|
|
10
|
+
* endedLine(row) "Won't do · No budget: Moved to next year's budget." or ''
|
|
11
|
+
* usualOf(trail, row) the usual days in the row's stage, compared within its own workflow only
|
|
12
|
+
* setByPmos(row) { name, why } when PMOS set the workflow from the BRD, else null
|
|
13
|
+
* Every figure comes from a row field or the workflow library (GET /api/workflows). */
|
|
14
|
+
import { PRODUCT_FEATURE_ID, WONTDO_REASONS, catLabel, wfOf } from './wf-model.js';
|
|
15
|
+
|
|
16
|
+
/** The workflow and the anchor: the kind line over an initiative's name. */
|
|
17
|
+
export function kindLine(row) {
|
|
18
|
+
const r = row || {};
|
|
19
|
+
return [wfOf(r).name, r.kr || r.anchor || ''].filter(Boolean).join(' · ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A workflow's stages in order, a milestone marked ◆. */
|
|
23
|
+
export const chainText = (wf) => ((wf && wf.stages) || []).map((s) => (s.milestone ? '◆\u00a0' : '') + s.name).join(' → ');
|
|
24
|
+
|
|
25
|
+
/** The Change picker: every workflow that is not archived (Product feature first, as GET /api/workflows answers), with its stage count. */
|
|
26
|
+
export function pickerItems(lib, row) {
|
|
27
|
+
const cur = wfOf(row).id;
|
|
28
|
+
return (lib || []).filter((w) => !w.archived || w.id === cur).map((w) => ({ id: w.id, name: w.name, icon: w.icon, n: (w.stages || []).length, on: w.id === cur, archived: !!w.archived }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const same = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
|
|
32
|
+
/** Switching workflow (WfAChange): a stage of the same name carries over, else the first stage of the same category, else the first stage. */
|
|
33
|
+
export function switchTarget(fromStage, to) {
|
|
34
|
+
const st = (to && to.stages) || [];
|
|
35
|
+
if (!st.length) return null;
|
|
36
|
+
if (!fromStage) return st[0].key;
|
|
37
|
+
const s = st.find((x) => same(x.name, fromStage.name));
|
|
38
|
+
if (s) return s.key;
|
|
39
|
+
return (st.find((x) => x.cat === fromStage.cat) || st[0]).key;
|
|
40
|
+
}
|
|
41
|
+
/** Why a stage lands where it does, in a few words. */
|
|
42
|
+
function landNote(fromStage, toStage) {
|
|
43
|
+
if (!toStage) return '';
|
|
44
|
+
if (same(fromStage.name, toStage.name)) return 'same stage, carries over';
|
|
45
|
+
if (fromStage.cat === toStage.cat) return 'first ' + catLabel(toStage.cat) + ' stage';
|
|
46
|
+
return 'first stage';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The switch dialog. row: a board row (wfStages with status); to: the workflow picked (with stages); landing: the PM's own pick, a key.
|
|
50
|
+
* Answers { rows: [{ from, state, to, note }], land, lands: [{ key, name, milestone }], name } — nothing is deleted, so a done stage of the
|
|
51
|
+
* old workflow shows where its work sits now. */
|
|
52
|
+
export function switchPlan(row, to, landing) {
|
|
53
|
+
const mine = ((row && row.wfStages) || []).filter((s) => s.status === 'done' || s.status === 'current');
|
|
54
|
+
const tst = (to && to.stages) || [];
|
|
55
|
+
const byKey = (k) => tst.find((s) => s.key === k) || null;
|
|
56
|
+
const rows = mine.map((s) => {
|
|
57
|
+
const t = byKey(switchTarget(s, to));
|
|
58
|
+
return { from: s.name, state: s.status === 'current' ? 'now' : 'done', to: t ? t.name : '', note: t ? landNote(s, t) : '' };
|
|
59
|
+
});
|
|
60
|
+
const cur = mine.find((s) => s.status === 'current') || (row && row.wfStage) || null;
|
|
61
|
+
const auto = switchTarget(cur, to);
|
|
62
|
+
const land = landing && byKey(landing) ? landing : auto;
|
|
63
|
+
return { rows, land, auto, lands: tst.map((s) => ({ key: s.key, name: s.name, milestone: !!s.milestone })), name: (to && to.name) || '' };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Won't do can go: a reason; Other needs at least a few words. */
|
|
67
|
+
export const wontdoReady = (reason, note) => WONTDO_REASONS.some(([k]) => k === reason) && (reason !== 'other' || String(note || '').trim().length >= 3);
|
|
68
|
+
const REASON = Object.fromEntries(WONTDO_REASONS);
|
|
69
|
+
/** "Won't do · No budget: Moved to next year's budget." */
|
|
70
|
+
export function endedLine(row) {
|
|
71
|
+
const e = row && row.ended;
|
|
72
|
+
if (!e) return '';
|
|
73
|
+
const r = REASON[e.reason] || REASON.other;
|
|
74
|
+
return "Won't do · " + r + (e.note ? ': ' + e.note : '');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The usual days in the row's stage, from GET /api/board-trail: Product feature reads `usual`, another workflow its own `usualBy[id]`
|
|
78
|
+
* (D99: "usually N days" compares only within one workflow). { days, n } or null. */
|
|
79
|
+
export function usualOf(trail, row) {
|
|
80
|
+
if (!trail || !row) return null;
|
|
81
|
+
const w = wfOf(row);
|
|
82
|
+
const key = String((row.wfStage && row.wfStage.key) || row.stage || '').toLowerCase();
|
|
83
|
+
const u = w.id === PRODUCT_FEATURE_ID ? (trail.usual || {})[key] : ((trail.usualBy || {})[w.id] || {})[key];
|
|
84
|
+
return u && u.n >= 3 && u.days != null ? u : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** PMOS set the workflow from the BRD (WfTriage: "Set to Tender from the BRD · Undo"). */
|
|
88
|
+
export function setByPmos(row) {
|
|
89
|
+
const w = row && row.wf;
|
|
90
|
+
return w && w.setBy === 'pmos' ? { id: w.id, name: w.name, why: w.why || '', from: w.from || PRODUCT_FEATURE_ID } : null;
|
|
91
|
+
}
|