create-pmos 0.610.0 → 0.612.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 +135 -27
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/board-columns-test.js +2 -1
- package/workspace/board-deliveries-test.js +2 -1
- package/workspace/board-programs-test.js +7 -3
- package/workspace/board-publish-ui-test.js +2 -1
- package/workspace/board-shared-ui-test.js +2 -1
- package/workspace/board-workflows-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +3 -2
- package/workspace/briefing-premium-calendar-2-test.js +3 -2
- package/workspace/briefing-premium-calendar-3-test.js +1 -1
- package/workspace/briefing-premium-calendar-test.js +1 -1
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-insights-test.js +4 -3
- package/workspace/briefing-premium-test.js +3 -2
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +134 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +3 -2
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +97 -3
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +65 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +2 -2
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/board-premium.js +12 -4
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/doc-library.js +43 -12
- package/workspace/lib/doc-path.js +30 -0
- package/workspace/lib/engine/boards.js +4 -2
- package/workspace/lib/events-place.js +368 -0
- package/workspace/lib/events-stated.js +129 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/insights-premium.js +13 -1
- package/workspace/lib/library-find.js +162 -0
- package/workspace/lib/library-items.js +250 -0
- package/workspace/lib/notes.js +9 -1
- package/workspace/lib/plan-items.js +17 -3
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-artefacts.js +5 -2
- package/workspace/lib/routes-boards.js +6 -2
- package/workspace/lib/routes-doc-sheet.js +1 -0
- package/workspace/lib/routes-events-place.js +203 -0
- package/workspace/lib/routes-library.js +155 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +32 -1
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +84 -0
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +10 -7
- package/workspace/metric-drafts-ui-test.js +3 -1
- package/workspace/milestone-pins-test.js +2 -1
- package/workspace/milestone-suggest-test.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +2 -1
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +2 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +3 -1
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +77 -12
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-span.js +5 -0
- package/workspace/public/pm/bd-work.css +192 -0
- package/workspace/public/pm/bd-work.js +483 -0
- package/workspace/public/pm/cozy-bar.css +11 -0
- package/workspace/public/pm/cozy-bar.js +99 -0
- package/workspace/public/pm/cozy-day-pick.css +27 -0
- package/workspace/public/pm/cozy-day-pick.js +97 -0
- package/workspace/public/pm/cozy-ev.css +2 -5
- package/workspace/public/pm/cozy-events-view.js +274 -0
- package/workspace/public/pm/cozy-events.css +179 -0
- package/workspace/public/pm/cozy-events.js +278 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +125 -0
- package/workspace/public/pm/cozy-live-pill.js +1 -0
- package/workspace/public/pm/cozy-nav.js +6 -7
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +224 -0
- package/workspace/public/pm/cozy-pop-work.js +668 -0
- package/workspace/public/pm/cozy-popup.css +11 -2
- package/workspace/public/pm/cozy-popup.js +67 -9
- package/workspace/public/pm/cozy-routine-job.js +203 -0
- package/workspace/public/pm/cozy-routine-model.js +219 -0
- package/workspace/public/pm/cozy-routine-pop.js +318 -0
- package/workspace/public/pm/cozy-routine.css +155 -0
- package/workspace/public/pm/cozy-routine.js +335 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -0
- package/workspace/public/pm/cozy-today-app.js +236 -0
- package/workspace/public/pm/cozy-today-model.js +176 -0
- package/workspace/public/pm/cozy-today-page.css +100 -0
- package/workspace/public/pm/cozy-today-view.js +76 -0
- package/workspace/public/pm/cozy-viewer.js +19 -8
- package/workspace/public/pm/cozy-vw-mtg.css +39 -0
- package/workspace/public/pm/goals-model.js +205 -0
- package/workspace/public/pm/goals-open.js +124 -0
- package/workspace/public/pm/home-app.js +18 -3
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +43 -10
- package/workspace/public/pm/ini-edit.js +3 -1
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/library-model.js +197 -0
- package/workspace/public/pm/library-open.js +37 -0
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +493 -0
- package/workspace/public/pm/premium-board.js +204 -17
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +436 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +79 -1
- package/workspace/public/pm/scope-chip.js +204 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +44 -0
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +39 -0
- package/workspace/public/premium-routine.html +33 -0
- package/workspace/public/today.html +50 -0
- package/workspace/ready-dash-ui-test.js +3 -1
- package/workspace/rename-test.js +2 -1
- package/workspace/run-tests.js +4 -1
- package/workspace/server.js +4 -2
- package/workspace/sort-order-test.js +2 -1
- package/workspace/split-merge-ui-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +3 -1
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-delete-test.js +2 -1
- package/workspace/task-links-test.js +2 -1
- package/workspace/task-milestones-test.js +4 -2
- package/workspace/task-plans-test.js +3 -1
- package/workspace/task-press-test.js +3 -1
- package/workspace/task-views-test.js +3 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/library-place.json +9 -0
- package/workspace/test-lists/pop-work.json +9 -0
- package/workspace/test-lists/routine-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
- package/workspace/test-lists/today-log.json +9 -0
- package/workspace/test-lists/work-view.json +9 -0
- package/workspace/timeline-holds-test.js +3 -1
- package/workspace/tk-tasks-test.js +2 -1
|
@@ -28,7 +28,7 @@ import { quietPlace } from './quiet-place.js'; // onboarding B3: before three
|
|
|
28
28
|
import { mountLivePill } from './cozy-live-pill.js';
|
|
29
29
|
import { stepsHelpHtml } from './bd-stages.js';
|
|
30
30
|
import { msMode } from './bd-pins.js';
|
|
31
|
-
import { timelineHtml, legendHtml, hasHold, planKeys, gapKeys, plainGaps, skipsOf, skipWords, gapWords, SPANS, md, fcRange } from './bd-span.js';
|
|
31
|
+
import { timelineHtml, legendHtml, hasHold, planKeys, gapKeys, plainGaps, skipsOf, skipWords, gapWords, SPANS, md, fcRange, rowBar } from './bd-span.js';
|
|
32
32
|
import * as FCC from './bd-fc-card.js'; // the forecast card under a hatched range (FcBoard)
|
|
33
33
|
import * as TL from './bd-scroll.js';
|
|
34
34
|
import './readonly.js'; // the read-only mode of a published board: nothing happens unless the page was opened with ?pack= (board-publish)
|
|
@@ -60,7 +60,9 @@ import { initiativeRename, taskRename } from './rename-press.js';
|
|
|
60
60
|
import { setSay } from './cozy-xv.js';
|
|
61
61
|
import { narrowForm } from './pn-narrow.js';
|
|
62
62
|
import * as BP2 from './bd-pane.js';
|
|
63
|
+
import * as WV from './bd-work.js'; // Work, one view on a desk (slice 4 of the six-place navigation, initiative work-one-view)
|
|
63
64
|
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
|
|
65
|
+
import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
|
|
64
66
|
|
|
65
67
|
const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUPING_KEY = 'pmos.board.grouping';
|
|
66
68
|
let M = null; // the model
|
|
@@ -135,6 +137,10 @@ let nview = 'list';
|
|
|
135
137
|
const NF = narrowForm({ page: $('#stage'), sheets: /\/pm\/(cozy-board|bd-[\w-]+)\.css(\?|$)/, onChange: () => { if (M) { drawChips(); drawInit(); } } });
|
|
136
138
|
const narrow = () => !PHONE.matches && NF.narrow();
|
|
137
139
|
const small = () => PHONE.matches || narrow();
|
|
140
|
+
/** Work, one view (initiative work-one-view, boards 4, 5 and 24): on a desk the list of initiatives with its timeline replaces the four views.
|
|
141
|
+
* A phone, the narrow form and a published read-only copy keep their views. */
|
|
142
|
+
const CLASSIC = (() => { try { return localStorage.getItem('pmos.work.classic') === '1'; } catch { return false; } })(); // a test seam (lib/classic-board.js): suites of the four views
|
|
143
|
+
const workOn = () => !CLASSIC && !small() && !window.PMOS_READONLY;
|
|
138
144
|
const goneRows = () => { const G = (M && M.initiatives && M.initiatives.gone) || {}; return [...(G.cancelled || []), ...(G.archived || [])]; };
|
|
139
145
|
const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || goneRows().find((r) => r.key === key) || null;
|
|
140
146
|
/** The rows on screen grouped (pm/bd-prog.js groupsOf): programs first, then the product; or By product. null when no program holds a row here. */
|
|
@@ -269,7 +275,7 @@ let jiraReading = false; // a press is reading Jira again: the chip's Adler we
|
|
|
269
275
|
const CHIP_F = [['late', 'late', 'm-warn', 'Late'], ['risk', 'risk', 'm-warn', 'At risk'], ['blocked', 'red', 'm-crit', 'Blocked'], ['idle', 'q', '', 'Idle 30+ days']];
|
|
270
276
|
/** The sprint filter (the "Sprint N only" chip and Filter's Sprint group) shows on the Sprint span only among the timeline's spans (TsSprintFilter);
|
|
271
277
|
* the stage track keeps its chip. */
|
|
272
|
-
const curView = () => (PHONE.matches ? pview : narrow() ? nview : view);
|
|
278
|
+
const curView = () => (PHONE.matches ? pview : narrow() ? nview : workOn() ? 'work' : view);
|
|
273
279
|
const sprintFilterOn = () => curView() !== 'time' || span === 'sprint';
|
|
274
280
|
/** What needs a look (batch 24 item 7, canvas BbB): new asks, late, at risk, blocked and idle are ONE pill of dots and numbers. A press opens the
|
|
275
281
|
* rows; a row opens what its chip opened (the asks, a metric's trend, whose "Show only" filters); a filter that is on turns off at once.
|
|
@@ -311,6 +317,8 @@ function drawChips() {
|
|
|
311
317
|
if (pip) pip.hidden = !(phone && (jMood === 'honest' || filtered())); fb.setAttribute('aria-label', say); fb.title = say; }
|
|
312
318
|
TUNE = { jira, jMood };
|
|
313
319
|
if (phone) { $('#bdChipset').innerHTML = need; return; }
|
|
320
|
+
// Work on a desk: no count pill and no (i); the rows say late and at risk, the key is under the list, the rest is in the view menu
|
|
321
|
+
if (workOn()) { $('#bdChipset').innerHTML = ''; drawWorkMore(); wkCount(); if (WK_MENU) drawWorkMenu(); return; }
|
|
314
322
|
// the pill's (i) (UI grill U2): the timeline's legend (PgTimeline; a program milestone only where a program is drawn and "On hold" only where a
|
|
315
323
|
// hold is drawn, feedback batch 9 item 8), the sprints and releases the calendar icon opened (BdSprint), and the Jira read with its ↻
|
|
316
324
|
const lo = menuOpen('bdLgdMenu');
|
|
@@ -422,7 +430,7 @@ function visible() {
|
|
|
422
430
|
if (F.chips.has('blocked') && !t.blocked) return false;
|
|
423
431
|
if (F.chips.has('idle') && t.idle == null) return false;
|
|
424
432
|
if (F.chips.has('you') && !t.you) return false;
|
|
425
|
-
if (F.chips.has('sprint') && sp && (view === 'track' || view === 'time' || small()) && sprintFilterOn() && !inSprint(r, sp)) return false;
|
|
433
|
+
if (F.chips.has('sprint') && sp && !workOn() && (view === 'track' || view === 'time' || small()) && sprintFilterOn() && !inSprint(r, sp)) return false;
|
|
426
434
|
if (F.q && !String(r.title || '').toLowerCase().includes(F.q.toLowerCase())) return false;
|
|
427
435
|
if (F.owners.size && !F.owners.has(r.owner || 'No owner')) return false;
|
|
428
436
|
if (F.cats.size && !F.cats.has(WF.catOfRow(r))) return false;
|
|
@@ -525,7 +533,7 @@ function readGoals() {
|
|
|
525
533
|
const rows = M.initiatives.list.rows, sig = ((M.board && M.board.ws) || '') + '|' + rows.map((r) => r.anchor || '').join(',');
|
|
526
534
|
if (sig === goalsFor) return;
|
|
527
535
|
goalsFor = sig;
|
|
528
|
-
GL.readGoals((M.board && M.board.ws) || '', rows).then((R) => { if (sig !== goalsFor) return; const was = goalOn(); GOALS = R; if (goalOn() !== was || goalOn()) { drawChips(); drawInit(); } });
|
|
536
|
+
GL.readGoals((M.board && M.board.ws) || '', rows).then((R) => { if (sig !== goalsFor) return; const was = goalOn(); GOALS = R; if (goalOn() !== was || goalOn() || workOn()) { drawChips(); drawInit(); } });
|
|
529
537
|
}
|
|
530
538
|
function drawTrack(L) {
|
|
531
539
|
TK = trackMode(L);
|
|
@@ -595,6 +603,161 @@ function drawTime(L) {
|
|
|
595
603
|
lane: (c) => DL.laneHtml(c, { span, progState }) });
|
|
596
604
|
return T.html;
|
|
597
605
|
}
|
|
606
|
+
/* ── Work, one view on a desk (initiative work-one-view; pm/bd-work.js draws, this wires): the list, its view menu, the Stage cell ── */
|
|
607
|
+
let WK_MENU = null, WK_STM = null;
|
|
608
|
+
const wkMany = () => !!(M && M.board.all && (M.board.products || []).length > 1);
|
|
609
|
+
const wkProduct = (r) => r.product || (M && M.board && (M.board.product || M.board.name)) || '';
|
|
610
|
+
const wkGoalOf = (r) => { if (!GOALS) return ''; const k = (GOALS.of || {})[String(r.anchor || '')], g = k && (GOALS.goals || []).find((x) => x.key === k); return g ? g.title : ''; };
|
|
611
|
+
const wkProgOf = (r) => { const p = programOf(PGS, r.ws || (M && M.board.ws) || '', r.id); return p ? p.title || p.id : ''; };
|
|
612
|
+
function drawWork(L) {
|
|
613
|
+
const pk = prodKey((M.board && (M.board.product || M.board.name)) || ''), lay = SO.layout();
|
|
614
|
+
return WV.listHtml(L, { many: wkMany(), sel: peek && peek.kind === 'ini' ? peek.key : null, rowOf, bar: wkBar,
|
|
615
|
+
product: wkProduct, goalOf: wkGoalOf, programOf: wkProgOf, order: (rows) => sortInis(pk, rows, lay, INI_ACC),
|
|
616
|
+
goalGroups: (rows) => (GOALS ? GL.asGroups(rows, GOALS, (rs) => sortInis(pk, rs, lay, INI_ACC)) : null),
|
|
617
|
+
canMove: (r) => !!(r.track && r.acts && (r.acts.stages || []).length > 1) });
|
|
618
|
+
}
|
|
619
|
+
/** One row's bar on Work: the Board's own (pm/bd-span.js rowBar, Wawan's round 2): done, now, planned, every milestone ◇ with its popup, the
|
|
620
|
+
* gap line, the late line. W: Work's window { from, to }. The track's width is measured once drawn, so close ◇s merge at about 40 px. */
|
|
621
|
+
let WK_TPX = 0;
|
|
622
|
+
function wkBar(r, W) {
|
|
623
|
+
const span = +W.to - +W.from || 1, X = (d) => ((+d - +W.from) / span) * 100;
|
|
624
|
+
const px = WK_TPX || Math.max(320, Math.round(innerWidth * 0.4)), pxDay = px / (span / 864e5);
|
|
625
|
+
return rowBar(r, X, new Date(), { pxPct: px / 100, reach: Math.max(1, Math.round(40 / pxDay)), mode: 'all', label: false });
|
|
626
|
+
}
|
|
627
|
+
const wkMeasure = () => { const x = $('#ibBody .wk-i .wk-bw'); const w = x ? Math.round(x.getBoundingClientRect().width) : 0; if (w && Math.abs(w - WK_TPX) > 40) { WK_TPX = w; return true; } return false; };
|
|
628
|
+
/** A press in the list that is Work's own (a column title, the span, the timeline's hide, a Stage cell, a bar, the closed line). → true when handled. */
|
|
629
|
+
function workPress(e) {
|
|
630
|
+
const p = WV.pressOf(e.target); if (!p) return false;
|
|
631
|
+
if (p.kind === 'inside') return true; // a press in the open stage card stays there
|
|
632
|
+
if (p.kind === 'spanmenu') { spanMenu(); return true; }
|
|
633
|
+
if (p.kind === 'stage') { stageMenu(rowOf(p.key), p.el); return true; }
|
|
634
|
+
if (!WV.apply(p)) return false;
|
|
635
|
+
drawInit(); wkCount(); if (WK_MENU) drawWorkMenu();
|
|
636
|
+
const f = p.kind === 'sort' ? `[data-wksort="${p.k}"]` : p.kind === 'span' ? '[data-wkspan]' : p.kind === 'timeline' ? (p.on ? '[data-wktl="off"]' : '[data-wktl="on"]') : p.kind === 'closed' ? '[data-wkclosed]' : null;
|
|
637
|
+
const n = f && $('#ibBody ' + f); if (n) n.focus();
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
function spanMenu(open) {
|
|
641
|
+
const m = $('#ibBody .wk-spm'), b = $('#ibBody [data-wkspan]'); if (!m || !b) return;
|
|
642
|
+
const o = open == null ? m.hidden : open; m.hidden = !o; b.setAttribute('aria-expanded', String(o));
|
|
643
|
+
if (o) (m.querySelector('.on') || m.querySelector('button')).focus();
|
|
644
|
+
}
|
|
645
|
+
document.addEventListener('click', (e) => {
|
|
646
|
+
if (!e.target.closest('.wk-spw')) { const m = $('#ibBody .wk-spm'); if (m && !m.hidden) spanMenu(false); }
|
|
647
|
+
if (WK_STM && !e.target.closest('.wk-stm, [data-wkstage]')) closeStageMenu();
|
|
648
|
+
// the stage card closes on a press outside it and outside a bar (a bar's own press toggles it in workPress)
|
|
649
|
+
if (WV.cardOf() && !e.target.closest('.wk-card') && !(e.target.closest('[data-wkbar]') && e.target.closest('.tg-bar, .wk-bar')) && WV.closeCard()) drawInit();
|
|
650
|
+
});
|
|
651
|
+
$('#ibBody').addEventListener('keydown', (e) => {
|
|
652
|
+
if (curView() !== 'work') return;
|
|
653
|
+
if (e.key === 'Escape') {
|
|
654
|
+
const m = $('#ibBody .wk-spm'); if (m && !m.hidden) { e.stopPropagation(); spanMenu(false); $('#ibBody [data-wkspan]').focus(); return; }
|
|
655
|
+
const k = WV.cardOf(); if (k && WV.closeCard()) { e.stopPropagation(); drawInit(); const r = $(`#ibBody .wk-i[data-key="${CSS.escape(k)}"]`); if (r) r.focus(); }
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
// a row is a button: Enter or Space opens it in the popup
|
|
659
|
+
if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('.wk-i[data-key]')) { e.preventDefault(); openIni(rowOf(e.target.dataset.key), e.target); }
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
/** The Stage cell: the stages of the row's own workflow in a short list; a pick moves it (POST /api/boards/move, the By stage drag's write), with Undo. */
|
|
663
|
+
function closeStageMenu() { if (WK_STM) { WK_STM.remove(); WK_STM = null; } }
|
|
664
|
+
function stageMenu(r, el) {
|
|
665
|
+
closeStageMenu(); if (!r || !r.acts) return;
|
|
666
|
+
const names = r.acts.stages || [], cur = r.acts.stage;
|
|
667
|
+
const m = document.createElement('div'); m.className = 'wk-stm'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'Stage of ' + r.title);
|
|
668
|
+
m.innerHTML = '<span class="h">Stage</span>' + names.map((n) => `<button type="button" role="menuitemradio" aria-checked="${n === cur}" class="${n === cur ? 'on' : ''}" data-to="${esc(n)}">${esc(n)}</button>`).join('');
|
|
669
|
+
document.body.appendChild(m); WK_STM = m;
|
|
670
|
+
const b = el.getBoundingClientRect();
|
|
671
|
+
m.style.left = Math.max(8, Math.min(b.left, innerWidth - m.offsetWidth - 8)) + 'px'; m.style.top = Math.max(8, Math.min(b.bottom + 4, innerHeight - m.offsetHeight - 8)) + 'px';
|
|
672
|
+
(m.querySelector('.on') || m.querySelector('[data-to]')).focus();
|
|
673
|
+
m.addEventListener('click', (e) => { const x = e.target.closest('[data-to]'); if (!x) return; closeStageMenu(); el.focus(); if (x.dataset.to !== cur) moveStage(r, cur, x.dataset.to); });
|
|
674
|
+
m.addEventListener('keydown', (e) => {
|
|
675
|
+
if (e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); e.stopPropagation(); closeStageMenu(); el.focus(); return; }
|
|
676
|
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
|
|
677
|
+
e.preventDefault(); const B = [...m.querySelectorAll('[data-to]')], i = B.indexOf(document.activeElement);
|
|
678
|
+
B[(i + (e.key === 'ArrowDown' ? 1 : -1) + B.length) % B.length].focus();
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/** What left the toolbar goes under ⋯ on a desk (board 5: the view menu ends at "PMOS remembers this · Reset"), so no feature is dropped:
|
|
683
|
+
* Sort and filter, New asks, Only what waits on you, Sprints and releases, Shared with me, Read Jira again. Rows of the shell's ⋯ menu. */
|
|
684
|
+
function workMore() {
|
|
685
|
+
const C = (M && M.chips) || {}, J = (M && M.jira) || {}, sp = J.sprint, rel = J.release, you = youRows().length;
|
|
686
|
+
const it = (k, label, note) => `<button type="button" role="menuitem" class="wk-xo" data-wkx="${k}">${esc(label)}${note ? `<span class="k">${esc(String(note))}</span>` : ''}</button>`;
|
|
687
|
+
const sprint = [sp ? sp.name : null, rel ? rel.name : null].filter(Boolean).join(' · ');
|
|
688
|
+
// Sort and filter, and what waits on you, are in the view menu itself (round 3); ⋯ keeps the asks, the sprint, the shared and the Jira read
|
|
689
|
+
void you;
|
|
690
|
+
return (C.asks ? it('asks', C.asks === 1 ? 'New ask' : 'New asks', C.asks) : '')
|
|
691
|
+
+ (!ALL && sprint ? it('sprint', 'Sprints and releases', sprint) : '')
|
|
692
|
+
+ it('shared', tab === 'shared' ? 'Back to the initiatives' : 'Shared with me', tab === 'shared' ? '' : SH_N || '')
|
|
693
|
+
+ it('jira', jiraReading ? 'Reading Jira' : 'Read Jira again', TUNE.jira.replace(/^Jira · /, ''));
|
|
694
|
+
}
|
|
695
|
+
/** The tune button's small count: how many filter values are on (round 3); none, no count (zero is silence). */
|
|
696
|
+
function wkCount() {
|
|
697
|
+
const b = $('#bdFilter'); if (!b) return;
|
|
698
|
+
let c = b.querySelector('.wk-fc'); const n = workOn() ? WV.filterCount() : 0;
|
|
699
|
+
if (!n) { if (c) c.remove(); b.setAttribute('aria-label', 'Filter, sort and view'); return; }
|
|
700
|
+
if (!c) { c = document.createElement('i'); c.className = 'wk-fc'; c.setAttribute('aria-hidden', 'true'); b.appendChild(c); }
|
|
701
|
+
c.textContent = String(n); b.setAttribute('aria-label', 'Filter, sort and view. ' + n + (n === 1 ? ' filter is on' : ' filters are on'));
|
|
702
|
+
}
|
|
703
|
+
/** Puts Work's rows at the top of ⋯, or takes them out when the page is not Work. */
|
|
704
|
+
function drawWorkMore() {
|
|
705
|
+
const menu = $('#moreMenu'); if (!menu) return;
|
|
706
|
+
for (const x of $$('#moreMenu > .wk-xo')) x.remove();
|
|
707
|
+
if (!workOn() || !M) return;
|
|
708
|
+
const at = $('#bdPublish') || menu.firstElementChild;
|
|
709
|
+
at.insertAdjacentHTML('beforebegin', workMore());
|
|
710
|
+
}
|
|
711
|
+
{ const mm = $('#moreMenu'); if (mm) mm.addEventListener('click', (e) => { const x = e.target.closest('.wk-xo'); if (x) workExtra(x.dataset.wkx, $('#moreBtn')); }); }
|
|
712
|
+
function drawWorkMenu(focus) {
|
|
713
|
+
if (!WK_MENU) return;
|
|
714
|
+
const was = focus || (WK_MENU.contains(document.activeElement) ? wkSel(document.activeElement) : null);
|
|
715
|
+
const sc = WK_MENU.firstElementChild ? WK_MENU.firstElementChild.scrollTop : 0;
|
|
716
|
+
WK_MENU.innerHTML = WV.menuHtml({ many: wkMany(), sprint: (M && M.jira && M.jira.sprint) || null });
|
|
717
|
+
const m = WK_MENU.firstElementChild, b = WK_MENU.__btn.getBoundingClientRect();
|
|
718
|
+
const top = Math.round(b.bottom + 8);
|
|
719
|
+
m.style.top = top + 'px'; m.style.left = Math.max(8, Math.round(b.right - m.offsetWidth)) + 'px';
|
|
720
|
+
m.style.maxHeight = Math.max(240, innerHeight - top - 12) + 'px'; // it scrolls inside the window; Filter's title and Clear stay on top
|
|
721
|
+
m.scrollTop = sc;
|
|
722
|
+
const n = was && m.querySelector(was); if (n) n.focus({ preventScroll: true });
|
|
723
|
+
}
|
|
724
|
+
/** Where the focus goes back after the menu is drawn again: the same control, or the nearest one that is still there. */
|
|
725
|
+
const wkSel = (el) => {
|
|
726
|
+
const x = el.closest('[data-wkgroup],[data-wkcolsw],[data-wktlsw],[data-wkreset],[data-wkx],[data-wkf],[data-wksortp],[data-wksortx],[data-wkcols],[data-wkmore],[data-wkclear]'); if (!x) return null;
|
|
727
|
+
const d = x.dataset;
|
|
728
|
+
if (d.wkf) return `[data-wkf="${d.wkf}"][data-wkv="${CSS.escape(d.wkv)}"]`;
|
|
729
|
+
if (d.wksortx) return '[data-wksortp=""]';
|
|
730
|
+
if ('wksortp' in d) return `[data-wksortp="${d.wksortp}"]`;
|
|
731
|
+
if (d.wkmore) return `[data-wkf="${d.wkmore}"]`;
|
|
732
|
+
for (const a of ['wkgroup', 'wkcolsw', 'wkx']) if (d[a]) return `[data-${a}="${d[a]}"]`;
|
|
733
|
+
return x.hasAttribute('data-wktlsw') ? '[data-wktlsw]' : x.hasAttribute('data-wkcols') ? '[data-wkcols]' : x.hasAttribute('data-wkclear') ? '[data-wkcols]' : '[data-wkcols]';
|
|
734
|
+
};
|
|
735
|
+
function closeWorkMenu(back) { if (!WK_MENU) return; const b = WK_MENU.__btn; WK_MENU.remove(); WK_MENU = null; b.setAttribute('aria-expanded', 'false'); b.classList.remove('on'); if (back) b.focus(); }
|
|
736
|
+
function toggleWorkMenu(btn) {
|
|
737
|
+
if (WK_MENU) { closeWorkMenu(true); return; }
|
|
738
|
+
WK_MENU = document.createElement('div'); WK_MENU.__btn = btn; document.body.appendChild(WK_MENU);
|
|
739
|
+
btn.setAttribute('aria-expanded', 'true'); btn.classList.add('on');
|
|
740
|
+
drawWorkMenu();
|
|
741
|
+
const f = WK_MENU.querySelector('[data-wkgroup].on') || WK_MENU.querySelector('button'); if (f) f.focus();
|
|
742
|
+
WK_MENU.addEventListener('click', (e) => {
|
|
743
|
+
const x = e.target.closest('[data-wkx]'); if (x) { workExtra(x.dataset.wkx, btn); return; }
|
|
744
|
+
const p = WV.pressOf(e.target); if (!p || !WV.apply(p)) return;
|
|
745
|
+
const sel = wkSel(e.target); drawInit(); wkCount(); drawWorkMenu(sel);
|
|
746
|
+
});
|
|
747
|
+
WK_MENU.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); closeWorkMenu(true); } });
|
|
748
|
+
WV.wireDrag(WK_MENU, (k) => { drawInit(); drawWorkMenu(k ? `[data-wkcolsw="${k}"]` : null); });
|
|
749
|
+
}
|
|
750
|
+
// a press inside the menu draws it again, so its target may have left the page by now: that is not a press outside
|
|
751
|
+
document.addEventListener('click', (e) => { if (WK_MENU && e.target.isConnected && !WK_MENU.contains(e.target) && !e.target.closest('#bdFilter')) closeWorkMenu(); });
|
|
752
|
+
function workExtra(k, btn) {
|
|
753
|
+
if (k === 'jira') { refreshJira(null).then(() => { drawWorkMore(); drawWorkMenu(); }); drawWorkMore(); return; }
|
|
754
|
+
if (k === 'you') { if (F.chips.has('you')) F.chips.delete('you'); else F.chips.add('you'); drawInit(); drawWorkMore(); return; }
|
|
755
|
+
if (k === 'shared') { setTab(tab === 'shared' ? 'ini' : 'shared'); drawWorkMore(); return; }
|
|
756
|
+
closeWorkMenu();
|
|
757
|
+
if (k === 'filter') Acts.open.filter(btn);
|
|
758
|
+
else if (k === 'asks') Acts.open.asks(btn);
|
|
759
|
+
else if (k === 'sprint') Acts.open.sprint(btn);
|
|
760
|
+
}
|
|
598
761
|
/** The View chip (batch 28 item 3, canvas BhA; on a desktop too since UI grill U2): the four views, the span and (a desktop) the Columns where they
|
|
599
762
|
* apply (the timeline), then Shared with me. */
|
|
600
763
|
const VIEW_ITEMS = [['list', 'List'], ['stages', 'By stage'], ['track', 'Track'], ['time', 'Timeline']];
|
|
@@ -627,7 +790,8 @@ function drawInit() {
|
|
|
627
790
|
const phone = small(), L = visible(), v = curView();
|
|
628
791
|
const body = $('#ibBody');
|
|
629
792
|
body.dataset.view = v; body.dataset.span = v === 'time' ? span : '';
|
|
630
|
-
|
|
793
|
+
document.body.classList.toggle('wk-on', v === 'work');
|
|
794
|
+
const html = v === 'work' ? drawWork(L) : v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
|
|
631
795
|
// a phone has no ⋯ menu: Metrics and Cancelled and archived stay one press away in every view, not only the track
|
|
632
796
|
const phx = phone && v !== 'track' ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : '';
|
|
633
797
|
if (v === 'time') TL.hold(); else TL.forget();
|
|
@@ -636,6 +800,7 @@ function drawInit() {
|
|
|
636
800
|
body.innerHTML = html + phx;
|
|
637
801
|
if (fk) { const n = $$('#ibBody [data-key]').find((x) => x.dataset.key === fk); if (n) n.focus({ preventScroll: true }); }
|
|
638
802
|
if (v === 'time') TL.mount(body);
|
|
803
|
+
if (v === 'work' && wkMeasure()) { drawInit(); return; } // the bars' ◇s merge by the track's real width: once measured, draw again
|
|
639
804
|
$('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
|
|
640
805
|
drawViewMenu();
|
|
641
806
|
document.body.dataset.bdView = v;
|
|
@@ -661,6 +826,7 @@ $('#bdShowing').addEventListener('click', (e) => {
|
|
|
661
826
|
});
|
|
662
827
|
function setSpan(s) { span = s; store.set(SPAN_KEY, span); drawChips(); drawInit(); }
|
|
663
828
|
$('#ibBody').addEventListener('click', (e) => {
|
|
829
|
+
if (curView() === 'work' && workPress(e)) return;
|
|
664
830
|
if (e.target.closest('#fold, [data-mefold]')) { foldOpen = !foldOpen; drawInit(); const f = $('#fold') || $('#ibBody [data-mefold]'); if (f) f.focus(); return; }
|
|
665
831
|
const gf = e.target.closest('[data-fold]'); if (gf) { const k = gf.dataset.fold; PG.fold(k); drawInit(); const b = $$('#ibBody [data-fold]').find((x) => x.dataset.fold === k); if (b) b.focus(); return; }
|
|
666
832
|
const pc = e.target.closest('[data-pcat]'); if (pc) { const k = pc.dataset.pcat; V.togglePcat(k); drawInit(); const b = $$('#ibBody [data-pcat]').find((x) => x.dataset.pcat === k); if (b) b.focus(); return; }
|
|
@@ -717,12 +883,16 @@ $('#ibBody').addEventListener('drop', async (e) => {
|
|
|
717
883
|
const step = M.steps[j]; to = (r.acts.stages || []).find((n) => stepOfName(n) === step.key) || (WF.isPF(WF.wfOf(r)) ? step.label : null); // batch 7 item 4
|
|
718
884
|
if (!to) { say(step.label + ' is not one of this board\'s stages, so it did not move.'); return; }
|
|
719
885
|
}
|
|
886
|
+
moveStage(r, from, to);
|
|
887
|
+
});
|
|
888
|
+
/** Move an initiative to another of its stages (POST /api/boards/move), with Undo in the toast: the By stage drag and Work's Stage cell. */
|
|
889
|
+
async function moveStage(r, from, to) {
|
|
720
890
|
const body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, id: r.id };
|
|
721
891
|
const res = await pmPost('/api/boards/move', { ...body, to }).catch(() => null);
|
|
722
892
|
if (!res || !res.ok) { say((res && res.error) || 'It did not move. The server did not say why.'); return; }
|
|
723
893
|
say('Moved to ' + to + ' · ' + r.title + '.', async () => { const u = await pmPost('/api/boards/move', { ...body, to: from, why: 'Undo' }).catch(() => null); say(u && u.ok ? 'Back in ' + from + '.' : (u && u.error) || 'The undo did not land.'); load(); });
|
|
724
894
|
load();
|
|
725
|
-
}
|
|
895
|
+
}
|
|
726
896
|
/** The step key of one of the board's own stage names, by the same old-name map as the model (lib/board-premium.js OLD_STEP). */
|
|
727
897
|
const OLD_STEP = { ideate: 'discover', ideation: 'discover', strategize: 'prioritize', intake: 'triage', ship: 'deliver', release: 'deliver', learn: 'monitor' };
|
|
728
898
|
function stepOfName(n) { const k = String(n || '').trim().toLowerCase(); const s = (M.steps || []).find((x) => x.key === k || x.label.toLowerCase() === k); return s ? s.key : OLD_STEP[k] || null; }
|
|
@@ -910,23 +1080,39 @@ function markOpen() {
|
|
|
910
1080
|
const keys = new Set(BP2.openKeys(VW.panels.list(), M ? [...(M.rows || []), ...goneRows()] : [], BI.vidOf));
|
|
911
1081
|
if (peek && peek.kind === 'ini') keys.add(peek.key);
|
|
912
1082
|
$$('#ibBody [data-row]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.row)));
|
|
913
|
-
$$('#ibBody .tgp-r, #ibBody .bd-lrow[data-key], #ibBody .bd-bc[data-key]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.key)));
|
|
1083
|
+
$$('#ibBody .tgp-r, #ibBody .bd-lrow[data-key], #ibBody .bd-bc[data-key], #ibBody .wk-i[data-key]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.key)));
|
|
914
1084
|
}
|
|
915
1085
|
VW.onChange(() => markOpen());
|
|
916
1086
|
BP2.wire();
|
|
917
1087
|
/** A linked document opens in the Viewer: GET /api/doc, shown as its text, and drawn again when the file changes (pm/doc-follow.js). */
|
|
918
1088
|
document.addEventListener('click', (e) => {
|
|
919
1089
|
const d = e.target.closest('[data-doc]'); if (!d || !M) return;
|
|
920
|
-
|
|
1090
|
+
// the document's own workspace: an initiative of another product on a program board reads from its repository, not the board's (round 3
|
|
1091
|
+
// point 17: "pmos/planning/prd/smrt-news-feed-prd.md could not be read" was read from the board's workspace)
|
|
1092
|
+
const path = d.dataset.doc, ws = d.dataset.docWs || M.board.ws || '', inVw = !!d.closest('.cz-vw');
|
|
1093
|
+
// in the popup a markdown document opens as the document page (pm/library-open.js), with its name as the title; the Viewer beside the
|
|
1094
|
+
// Board keeps its plain text view
|
|
1095
|
+
if (/\.md$/i.test(path) && (d.closest('.cz-pop') || d.dataset.docPage)) {
|
|
1096
|
+
const name = (d.getAttribute('aria-label') || '').replace(/^Open /, '') || d.textContent.trim().split('\n')[0] || path.split('/').pop();
|
|
1097
|
+
import('./library-open.js').then((L) => { if (inVw && VW.drill) VW.drill(); L.openItem({ id: 'doc:' + path, kind: 'doc', name, open: { doc: { path, ws } }, about: { ws } }); });
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
921
1100
|
viewerOpen({ kind: 'Document', title: path.split('/').pop(), icon: 'doc', id: 'doc:' + path, back: inVw, render: async (body) => {
|
|
922
1101
|
body.innerHTML = '<p class="bd-amut">Reading the document…</p>';
|
|
923
|
-
|
|
924
|
-
onText: (text) => {
|
|
1102
|
+
const draw = () => followDoc({ ws, path, alive: () => body.isConnected && !!viewerCur() && viewerCur().id === 'doc:' + path,
|
|
1103
|
+
onText: async (text) => {
|
|
1104
|
+
if (text != null) { body.innerHTML = `<p class="bd-amut">${esc(path)}</p><pre class="bd-doc">${esc(text)}</pre>`; return; }
|
|
1105
|
+
// plain words with the server's reason, and Retry; never a bare path as the whole page
|
|
1106
|
+
const why = await fetch('/api/doc?ws=' + encodeURIComponent(ws) + '&path=' + encodeURIComponent(path), { credentials: 'same-origin' }).then((r) => (r.ok ? '' : r.text())).catch(() => 'the server did not answer');
|
|
1107
|
+
body.innerHTML = `<p class="bd-amut">This document could not be opened${why ? ': ' + esc(why) : ''}.</p><button type="button" class="hi-btn ghost" data-doc-retry>Retry</button>`;
|
|
1108
|
+
const b = body.querySelector('[data-doc-retry]'); if (b) b.onclick = () => { body.innerHTML = '<p class="bd-amut">Reading the document…</p>'; draw(); };
|
|
1109
|
+
} });
|
|
1110
|
+
await draw();
|
|
925
1111
|
} });
|
|
926
1112
|
});
|
|
927
1113
|
/* ── the tools the Agreed design draws but has no frame for: plain versions with a "Waiting for design" tag (pm/bd-acts.js) ─────────── */
|
|
928
1114
|
$('#bdFind').addEventListener('click', (e) => Acts.open.find(e.currentTarget));
|
|
929
|
-
$('#bdFilter').addEventListener('click', (e) => Acts.open.filter(e.currentTarget));
|
|
1115
|
+
$('#bdFilter').addEventListener('click', (e) => { if (workOn()) toggleWorkMenu(e.currentTarget); else Acts.open.filter(e.currentTarget); });
|
|
930
1116
|
// New (PgBoard: "New program or initiative"): a menu of the two. The program panel's own "New initiative" presses this button from code,
|
|
931
1117
|
// and that press opens New initiative at once.
|
|
932
1118
|
$('#newIni').addEventListener('click', (e) => { if (e.isTrusted) Asks.openNewMenu(e.currentTarget); else Acts.open.new(e.currentTarget); });
|
|
@@ -1126,13 +1312,14 @@ async function loadWorkflows() {
|
|
|
1126
1312
|
if (r && r.ok && Array.isArray(r.workflows)) { WF.setDefs(r.workflows); drawInit(); }
|
|
1127
1313
|
}
|
|
1128
1314
|
/** A task's state from the initiative panel (✓ on its Tasks or its stage card); Undo puts the old state back. */
|
|
1129
|
-
async function setTask(r, uid, state) {
|
|
1130
|
-
const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
|
|
1131
|
-
const res = await pmPost('/api/boards/tasks/state', { ...body, state }).catch(() => null);
|
|
1315
|
+
async function setTask(r, uid, state, w) {
|
|
1316
|
+
const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid }, happened = (w && w.happened) || null;
|
|
1317
|
+
const res = await pmPost('/api/boards/tasks/state', { ...body, state, ...(happened ? { happened } : {}) }).catch(() => null);
|
|
1132
1318
|
if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
|
|
1133
1319
|
// a breakdown item closed as Won't do is withdrawn, which the ledger cannot undo; every other change can go back (batch 9 item 5b)
|
|
1134
1320
|
const undo = k && k.status !== state && !(k.item && state === "Won't do");
|
|
1135
|
-
|
|
1321
|
+
// the day it really happened is said too (round 3 point 18): "Done on 14 Nov, noted today: <title>."
|
|
1322
|
+
say((happened ? SWN.whenWords(state, happened).replace(/\.$/, '') : state) + ': ' + (k ? k.title : uid) + '.', undo ? async () => { const u = await pmPost('/api/boards/tasks/state', { ...body, state: k.status }).catch(() => null); say(u && u.ok ? 'Back to ' + k.status + '.' : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
|
|
1136
1323
|
load();
|
|
1137
1324
|
}
|
|
1138
1325
|
/** A task's start and due from the panel's Tasks (the date press, a Timeline drag), or its ◇ milestone flag (batch 11 item 3): POST
|
|
@@ -1195,7 +1382,7 @@ function nextAct(b) {
|
|
|
1195
1382
|
else if (k === 'epic') import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say }));
|
|
1196
1383
|
else if (k === 'jira') refreshJira(b);
|
|
1197
1384
|
}
|
|
1198
|
-
const viewDoc = (path) => { const a = document.createElement('button'); a.dataset.doc = path; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); };
|
|
1385
|
+
const viewDoc = (path, ws) => { const a = document.createElement('button'); a.dataset.doc = path; if (ws) a.dataset.docWs = ws; if (document.body.classList.contains('cz-pop-on')) a.dataset.docPage = '1'; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); };
|
|
1199
1386
|
const anchors = async (ws, board) => { try { const r = await (await fetch('/api/boards/anchors?ws=' + encodeURIComponent(ws || M.board.ws || '') + '&board=' + encodeURIComponent(board || M.board.id || ''), { credentials: 'same-origin' })).json(); return r && r.ok ? r.anchors || [] : []; } catch { return []; } };
|
|
1200
1387
|
// Find and the other jumps: on the timeline the row's bar scrolls into view and the row tints for a moment (TsCEdges 4)
|
|
1201
1388
|
/** The ✦ on the forecast card (FcBoard): the initiative opens and its "Claude proposes" drill-in with it (pm/ini-props.js, the Grill's findings). */
|
|
@@ -1213,7 +1400,7 @@ V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, sel: () =
|
|
|
1213
1400
|
Asks.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, rowOf, openIni: openIniAny, openDoc: viewDoc, anchors, programs: () => PGS, reloadPrograms: loadPrograms });
|
|
1214
1401
|
Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); }, F, rowOf, statusOf, openIni: openIniAny,
|
|
1215
1402
|
openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, viewDoc,
|
|
1216
|
-
grouping: () => ({ on: groupingOn(), byProduct, by: grouping === 'goal' && !goalsHere() ? (groupingOn() ? 'program' : 'product') : grouping, goal: goalsHere() }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
|
|
1403
|
+
grouping: () => (workOn() ? null : { on: groupingOn(), byProduct, by: grouping === 'goal' && !goalsHere() ? (groupingOn() ? 'program' : 'product') : grouping, goal: goalsHere() }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
|
|
1217
1404
|
tune: tuneParts, sprintOnly, toggleSprintOnly: () => { if (F.chips.has('sprint')) F.chips.delete('sprint'); else F.chips.add('sprint'); }, sortPick, refreshJira: () => refreshJira() });
|
|
1218
1405
|
BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
|
|
1219
1406
|
send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/* pm/premium-goals.js — Goals, the place (initiative goals-place, slice 9 of the six-place navigation; boards 8, 13, 31, 32, 33 on Exploring 2,
|
|
2
|
+
* page "Navigation: Today, Work, Goals, Events, Library, Routine"; handover /mnt/project-files/goals-handover/).
|
|
3
|
+
*
|
|
4
|
+
* "Am I on track? What do I do?" as one hierarchy. Top: the product choice Work and Goals share (cozy-pick.js, full names) and the OKR period. Then
|
|
5
|
+
* the North Star card (a kept record; else PMOS's open draft with ✓ ✕; else "not set"), then one table: Objective › Key result (Actual / target,
|
|
6
|
+
* Left) › Levers › Initiative, a Budget row per health budget with work in it, and Unlinked, the open work no key result names. The words and
|
|
7
|
+
* numbers are pm/goals-model.js, which makes none up. With more than one product ticked, each product is its own block under its name.
|
|
8
|
+
* A press on a key result opens it in the popup (board 31); on an initiative, the initiative (slice 3's popup), or the verdict page when its
|
|
9
|
+
* outcome check is overdue (board 33); ⋯ › Set up opens the setup page (board 32) (pm/goals-open.js).
|
|
10
|
+
* Search opens Search with Goals' own rows first; Filter shows All, Slipping, Not read or Read (remembered on this device, 'pmos.goals.filt').
|
|
11
|
+
* ⋯ › Charts and dashboards opens the Intelligence page, where the readings, charts and dashboards stay; ⋯ › Export CSV saves the table.
|
|
12
|
+
* Reads GET /api/insights-premium?ws= and GET /api/metric-drafts?ws=&scope=product&id= for each ticked product, again when the tab comes back after a
|
|
13
|
+
* minute. Writes only the North Star draft's ✓ (POST /api/metric-drafts/keep, Undo /undo) and ✕ (/drop). */
|
|
14
|
+
import './fetch-share.js';
|
|
15
|
+
import { pmGet, pmPost } from './http.js';
|
|
16
|
+
import { mountNav } from './cozy-nav.js';
|
|
17
|
+
import { mountLivePill } from './cozy-live-pill.js';
|
|
18
|
+
import * as PK from './cozy-pick.js';
|
|
19
|
+
import './cozy-viewer.js';
|
|
20
|
+
import * as POP from './cozy-popup.js'; // the one popup: window.czOpenChat for the rail's chat icon, and the popup a row opens in
|
|
21
|
+
import * as GM from './goals-model.js';
|
|
22
|
+
import * as GO from './goals-open.js';
|
|
23
|
+
import { undoToast } from './hi-pop.js';
|
|
24
|
+
|
|
25
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
26
|
+
const SVG = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
27
|
+
const I = { check: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', cal: 'M4 5.5h16v14H4zM4 10h16M9 3.5v4M15 3.5v4', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z' };
|
|
28
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
|
|
29
|
+
const todayIso = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
30
|
+
const FILT = GM.FILTERS.map((f) => f[0]);
|
|
31
|
+
const S = { P: null, list: [], at: 0, filter: FILT.includes(store.get('pmos.goals.filt')) ? store.get('pmos.goals.filt') : 'all', error: '' };
|
|
32
|
+
const DEEP = new URLSearchParams(location.search).get('ws');
|
|
33
|
+
|
|
34
|
+
mountNav('insights', document, { scope: () => ({ name: 'Goals', hits: (q) => hits(q) }) });
|
|
35
|
+
mountLivePill();
|
|
36
|
+
|
|
37
|
+
const $ = (id) => document.getElementById(id);
|
|
38
|
+
const body = $('glBody');
|
|
39
|
+
|
|
40
|
+
/* ── the product choice and the period ── */
|
|
41
|
+
function shownPick() {
|
|
42
|
+
if (!S.P) return null;
|
|
43
|
+
if (!DEEP) return S.P;
|
|
44
|
+
return { ...S.P, products: S.P.products.map((p) => ({ ...p, on: p.ws === DEEP })) };
|
|
45
|
+
}
|
|
46
|
+
function drawPick() {
|
|
47
|
+
const P = shownPick(), host = $('glPick');
|
|
48
|
+
host.innerHTML = P ? PK.chipHtml(P, { id: 'glPickB', label: 'Products', names: !matchMedia('(max-width: 760px)').matches }) : '';
|
|
49
|
+
const chip = $('glPickB'); if (!chip) return;
|
|
50
|
+
const lines = (ws) => { const x = S.list.find((p) => p.ws === ws); const n = x && x.model && x.model.okrFile ? x.model.okrFile.total : 0; return n ? n + (n === 1 ? ' key result' : ' key results') : ''; };
|
|
51
|
+
chip.onclick = (e) => { e.stopPropagation(); closeMenus(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for Today, Work and Goals: unticking a product here also takes it off Today.', onApply: async (on) => { const r = await PK.savePick(on); if (!r.ok) undoToast(r.error, () => {}, 4000); } }); };
|
|
52
|
+
}
|
|
53
|
+
addEventListener('pp:changed', () => { if (DEEP) { location.assign(location.pathname); return; } S.P = null; load(); });
|
|
54
|
+
function drawPer() {
|
|
55
|
+
const x = S.list.find((p) => p.model && p.model.okrFile && p.model.okrFile.period);
|
|
56
|
+
const per = x ? GM.periodOf(x.model.okrFile) : null, el = $('glPer');
|
|
57
|
+
el.hidden = !per;
|
|
58
|
+
if (per) el.innerHTML = `${SVG(I.cal, 16)}<b>${esc(per.label)}</b>${per.sub ? `<span>${esc(per.sub)}</span>` : ''}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ── the North Star card ── */
|
|
62
|
+
function nsHtml(p) {
|
|
63
|
+
const ns = p.ns;
|
|
64
|
+
if (ns.state === 'set') return `<div class="gl-ns set"><i class="gl-mark" aria-hidden="true">${SVG(I.spark, 14)}</i><div class="t"><div class="k">North Star</div><b>${esc(ns.title)}</b><p>${esc(ns.sub)}</p></div></div>`;
|
|
65
|
+
if (ns.state === 'draft') return `<div class="gl-ns"><i class="gl-mark" aria-hidden="true">${SVG(I.spark, 14)}</i><div class="t"><div class="k">North Star · not set in your OKR file</div><b>${esc(ns.title)}</b><p>${esc(ns.sub)}</p></div>`
|
|
66
|
+
+ `<button type="button" class="gl-go" data-gl-nsdrop="${esc(p.ws)}" aria-label="No, drop this North Star" title="No">${SVG(I.x, 16)}</button><button type="button" class="gl-go" data-gl-nskeep="${esc(p.ws)}" aria-label="Approve this North Star" title="Approve this North Star">${SVG(I.check, 18)}</button></div>`;
|
|
67
|
+
return `<div class="gl-ns"><i class="gl-mark" aria-hidden="true">${SVG(I.spark, 14)}</i><div class="t"><div class="k">North Star · not set in your OKR file</div><b>${esc(ns.title)}</b><p>${esc(ns.sub)}</p></div>`
|
|
68
|
+
+ `<button type="button" class="gl-go" data-gl-setup="${esc(p.ws)}" aria-label="Ask PMOS to draft the North Star" title="Ask PMOS to draft the North Star">${SVG(I.spark, 16)}</button></div>`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ── the table ── */
|
|
72
|
+
const dm = (k) => (k ? `<i class="gl-dm ${k === 'rd' ? 'rd' : ''}" aria-hidden="true"></i>` : '');
|
|
73
|
+
const iniHtml = (p, i) => `<button type="button" class="gl-ini" data-gl-ws="${esc(p.ws)}" data-gl-ini="${esc(i.id)}"${i.verdict ? ' data-gl-verdict' : ''}><b>${esc(i.title)}</b>${i.line ? `<span class="${i.tone}">${dm(i.dm)}${esc(i.line)}</span>` : ''}</button>`;
|
|
74
|
+
function krHtml(p, k, first) {
|
|
75
|
+
const act = k.act ? `<b>${esc(k.act)}</b>${k.target ? ' / ' + esc(k.target) : ''}` : `<span class="gl-ph">—</span>${k.target ? ' / ' + esc(k.target) : ''}`;
|
|
76
|
+
return `<button type="button" class="gl-kr${first ? ' f' : ''}" data-gl-ws="${esc(p.ws)}" data-gl-kr="${esc(k.key)}" aria-label="${esc(k.token + ' ' + k.title + '. ' + (k.act ? 'Now ' + k.act : 'No reading') + '. ' + k.sub)}">`
|
|
77
|
+
+ `<span class="n"><i class="gl-d ${k.dot}"></i><span><i>${esc(k.token)}</i>${esc(k.title)}<small>${esc(k.sub)}</small></span></span>`
|
|
78
|
+
+ `<span class="a ${k.tone}">${act}</span><span class="l">${esc(k.left)}</span></button>`;
|
|
79
|
+
}
|
|
80
|
+
function objHtml(p, o) {
|
|
81
|
+
const n = o.krs.length;
|
|
82
|
+
let h = `<div class="gl-o gl-r1 gl-s${n}"><b>${esc(o.label)}</b>${o.title ? `<span>${esc(o.title)}</span>` : ''}${o.slip ? `<span class="rk">${esc(o.slip)}</span>` : ''}</div>`;
|
|
83
|
+
o.krs.forEach((k, i) => { h += `<div class="gl-kc gl-r${i + 1}">${krHtml(p, k, i === 0)}</div>`; });
|
|
84
|
+
h += `<div class="gl-lv gl-r1 gl-s${n}">${o.levers.map((l) => `<div><b>${esc(l.title)}</b><span class="${l.tone}">${esc(l.txt)}</span></div>`).join('')}</div>`;
|
|
85
|
+
for (const c of o.inis) h += `<div class="gl-in gl-r${c.from} gl-s${c.span}">${c.items.map((i) => iniHtml(p, i)).join('')}</div>`;
|
|
86
|
+
return `<div class="gl-ob" role="rowgroup">${h}</div>`;
|
|
87
|
+
}
|
|
88
|
+
function tableHtml(p) {
|
|
89
|
+
const T = p.T;
|
|
90
|
+
if (!p.model.okrFile) return `<p class="gl-none">No OKR file was found for ${esc(p.name)}, so there is no key result to show. Goals reads the OKR file in planning/okrs/.</p>`;
|
|
91
|
+
if (!T.objectives.length && S.filter !== 'all') return `<p class="gl-none">No key result is ${esc((GM.FILTERS.find((f) => f[0] === S.filter) || [])[1] || '').toLowerCase()} in ${esc(p.name)}.</p>`;
|
|
92
|
+
const hd = '<div class="gl-hd" role="row"><span>Objective</span><span class="gl-kh"><span>Key result</span><span>Actual / target</span><span>Left</span></span><span>Levers</span><span>Initiative</span></div>';
|
|
93
|
+
const bud = T.budgets.map((b) => `<div class="gl-ob gl-row1"><div class="gl-o"><b>Budget</b><span class="${b.over ? 'late' : ''}">${esc(b.label)}${b.share ? ' · ' + esc(b.share) : ''}</span></div><div class="gl-wide"><b>No key result: a budget that is always on</b>${b.covers ? `<span>${esc(b.covers)}</span>` : ''}</div><div class="gl-in">${b.items.map((i) => iniHtml(p, i)).join('')}</div></div>`).join('');
|
|
94
|
+
const un = T.unlinked.length ? `<div class="gl-ob gl-row1"><div class="gl-o"><b>Unlinked</b></div><div class="gl-wide"><span>${T.unlinked.length === 1 ? 'An initiative with no key result named' : T.unlinked.length + ' initiatives with no key result named'}</span></div><div class="gl-in">${T.unlinked.map((i) => iniHtml(p, i)).join('')}</div></div>` : '';
|
|
95
|
+
return `<div class="gl-card" role="table" aria-label="Goals of ${esc(p.name)}">${hd}${T.objectives.map((o) => objHtml(p, o)).join('')}${bud}${un}</div>`;
|
|
96
|
+
}
|
|
97
|
+
function draw() {
|
|
98
|
+
if (!S.list.length) { body.innerHTML = `<p class="gl-none">${esc(S.error ? 'Goals could not be read: ' + S.error + '.' : 'No product is ticked. Tick one in the product choice.')}</p>`; $('glNote').hidden = true; return; }
|
|
99
|
+
const today = todayIso(), many = S.list.length > 1;
|
|
100
|
+
let h = '';
|
|
101
|
+
for (const p of S.list) {
|
|
102
|
+
if (!p.model) { h += `<section class="gl-p">${many ? `<h2 class="gl-ph2">${esc(p.name)}</h2>` : ''}<p class="gl-none">${esc(p.name)} could not be read: ${esc(p.error || 'the server did not answer')}.</p></section>`; continue; }
|
|
103
|
+
p.T = GM.tableOf(p.model, today, S.filter);
|
|
104
|
+
p.ns = GM.northStarOf(p.model, p.drafts);
|
|
105
|
+
h += `<section class="gl-p" aria-label="${esc(p.name)}">${many ? `<h2 class="gl-ph2">${esc(p.name)}</h2>` : ''}${p.model.okrFile ? nsHtml(p) : ''}${tableHtml(p)}</section>`;
|
|
106
|
+
}
|
|
107
|
+
body.innerHTML = h;
|
|
108
|
+
$('glNote').hidden = false;
|
|
109
|
+
$('glFdot').hidden = S.filter === 'all';
|
|
110
|
+
drawPer();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── load ── */
|
|
114
|
+
async function loadOne(ws, name) {
|
|
115
|
+
const q = ws ? '?ws=' + encodeURIComponent(ws) : '';
|
|
116
|
+
const r = await pmGet('/api/insights-premium' + q).catch((e) => ({ ok: false, error: (e && e.message) || '' }));
|
|
117
|
+
if (!r || !r.ok || !r.model) return { ws, name, model: null, error: (r && r.error) || 'the server did not answer' };
|
|
118
|
+
const w = ws || r.model.board.ws || '';
|
|
119
|
+
const d = w ? await pmGet('/api/metric-drafts?ws=' + encodeURIComponent(w) + '&scope=product&id=' + encodeURIComponent(w)).catch(() => null) : null;
|
|
120
|
+
return { ws: w, name: name || r.model.board.name || w, model: r.model, drafts: d && d.ok !== false ? d : null };
|
|
121
|
+
}
|
|
122
|
+
async function load() {
|
|
123
|
+
if (!S.P) { S.P = await PK.readPick().catch(() => null); drawPick(); }
|
|
124
|
+
const P = shownPick();
|
|
125
|
+
const on = P ? P.products.filter((p) => p.on).sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0)) : [];
|
|
126
|
+
const want = on.length ? on.map((p) => [p.ws, p.name]) : [[DEEP || '', '']];
|
|
127
|
+
S.list = await Promise.all(want.map(([ws, name]) => loadOne(ws, name)));
|
|
128
|
+
S.error = S.list.every((p) => !p.model) ? (S.list[0] && S.list[0].error) || '' : '';
|
|
129
|
+
S.at = Date.now();
|
|
130
|
+
draw();
|
|
131
|
+
drawPick();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* ── presses ── */
|
|
135
|
+
const ctxOf = (ws) => { const p = S.list.find((x) => x.ws === ws) || S.list[0]; return { model: p.model, ws: p.ws, today: todayIso(), ns: p.ns, keepNs: (row) => keepNs(p, row), dropNs: (row) => dropNs(p, row) }; };
|
|
136
|
+
async function keepNs(p, row) {
|
|
137
|
+
const base = { ws: p.ws, scope: 'product', id: p.ws, row };
|
|
138
|
+
const r = await pmPost('/api/metric-drafts/keep', base).catch(() => null);
|
|
139
|
+
if (!r || r.ok === false) { undoToast((r && r.error) || 'The North Star was not kept.', () => {}, 4000); return; }
|
|
140
|
+
undoToast('North Star set.', async () => { await pmPost('/api/metric-drafts/undo', base).catch(() => null); await load(); });
|
|
141
|
+
await load();
|
|
142
|
+
}
|
|
143
|
+
async function dropNs(p, row) {
|
|
144
|
+
const base = { ws: p.ws, scope: 'product', id: p.ws, row };
|
|
145
|
+
const r = await pmPost('/api/metric-drafts/drop', base).catch(() => null);
|
|
146
|
+
if (!r || r.ok === false) { undoToast((r && r.error) || 'Nothing was changed.', () => {}, 4000); return; }
|
|
147
|
+
undoToast('Dropped.', async () => { await pmPost('/api/metric-drafts/undo', base).catch(() => null); await load(); });
|
|
148
|
+
await load();
|
|
149
|
+
}
|
|
150
|
+
body.onclick = (e) => {
|
|
151
|
+
const t = e.target.closest('button'); if (!t) return;
|
|
152
|
+
const d = t.dataset;
|
|
153
|
+
if (d.glKr) { GO.openKr(ctxOf(d.glWs), d.glKr); return; }
|
|
154
|
+
if (d.glIni) { const c = ctxOf(d.glWs); if ('glVerdict' in d) GO.openVerdict(c, d.glIni); else GO.openIni(c, d.glIni); return; }
|
|
155
|
+
if (d.glNskeep) { const p = S.list.find((x) => x.ws === d.glNskeep); if (p && p.ns.row) { t.disabled = true; keepNs(p, p.ns.row); } return; }
|
|
156
|
+
if (d.glNsdrop) { const p = S.list.find((x) => x.ws === d.glNsdrop); if (p && p.ns.row) { t.disabled = true; dropNs(p, p.ns.row); } return; }
|
|
157
|
+
if (d.glSetup) { GO.openSetup(ctxOf(d.glSetup)); setTimeout(() => GO.toChat('Draft a North Star for this product from its key results. I approve it with a tick.'), 150); }
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/* ── the menus: Filter and ⋯ ── */
|
|
161
|
+
const MENUS = [['glFilt', 'glFiltMenu'], ['glMore', 'glMoreMenu']];
|
|
162
|
+
function closeMenus(except) { for (const [b, m] of MENUS) if (m !== except && !$(m).hidden) { $(m).hidden = true; $(b).setAttribute('aria-expanded', 'false'); } }
|
|
163
|
+
function drawMenus() {
|
|
164
|
+
$('glFiltMenu').innerHTML = GM.FILTERS.map(([k, label]) => `<button type="button" role="menuitemradio" aria-checked="${S.filter === k}" data-gl-f="${k}">${esc(label)}</button>`).join('');
|
|
165
|
+
$('glMoreMenu').innerHTML = '<button type="button" role="menuitem" data-gl-m="setup">Set up</button><button type="button" role="menuitem" data-gl-m="charts">Charts and dashboards</button><button type="button" role="menuitem" data-gl-m="csv">Export CSV</button>';
|
|
166
|
+
}
|
|
167
|
+
for (const [b, m] of MENUS) {
|
|
168
|
+
$(b).onclick = (e) => {
|
|
169
|
+
e.stopPropagation(); const open = $(m).hidden; closeMenus(m); drawMenus();
|
|
170
|
+
$(m).hidden = !open; $(b).setAttribute('aria-expanded', String(open));
|
|
171
|
+
if (open) { const f = $(m).querySelector('button'); if (f) f.focus(); }
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
document.addEventListener('click', (e) => { for (const [b, m] of MENUS) if (!$(m).hidden && !e.target.closest('#' + m) && !e.target.closest('#' + b)) { $(m).hidden = true; $(b).setAttribute('aria-expanded', 'false'); } });
|
|
175
|
+
document.addEventListener('keydown', (e) => { if (e.key !== 'Escape') return; for (const [b, m] of MENUS) if (!$(m).hidden) { $(m).hidden = true; $(b).setAttribute('aria-expanded', 'false'); $(b).focus(); } });
|
|
176
|
+
$('glFiltMenu').onclick = (e) => {
|
|
177
|
+
const t = e.target.closest('[data-gl-f]'); if (!t) return;
|
|
178
|
+
S.filter = t.dataset.glF; store.set('pmos.goals.filt', S.filter); closeMenus(); draw();
|
|
179
|
+
};
|
|
180
|
+
$('glMoreMenu').onclick = (e) => {
|
|
181
|
+
const t = e.target.closest('[data-gl-m]'); if (!t) return;
|
|
182
|
+
closeMenus();
|
|
183
|
+
const k = t.dataset.glM, p = S.list.find((x) => x.model) || null;
|
|
184
|
+
if (k === 'setup' && p) GO.openSetup(ctxOf(p.ws));
|
|
185
|
+
else if (k === 'charts') location.assign('/premium-intelligence.html' + (DEEP ? '?ws=' + encodeURIComponent(DEEP) : ''));
|
|
186
|
+
else if (k === 'csv') exportCsv();
|
|
187
|
+
};
|
|
188
|
+
function exportCsv() {
|
|
189
|
+
const q = (v) => '"' + String(v == null ? '' : v).replace(/"/g, '""') + '"';
|
|
190
|
+
const lines = [['Product', 'Objective', 'Key result', 'Name', 'Actual', 'Target', 'Left', 'Waits on', 'Initiatives'].map(q).join(',')];
|
|
191
|
+
for (const p of S.list) if (p.T) for (const o of p.T.objectives) for (const k of o.krs) {
|
|
192
|
+
const ini = o.inis.flatMap((c) => c.items).filter((i) => k.moves.includes(i.id)).map((i) => i.title).join('; ');
|
|
193
|
+
lines.push([p.name, o.label + (o.title ? ': ' + o.title : ''), k.token, k.title, k.act, k.target, k.left, k.need, ini].map(q).join(','));
|
|
194
|
+
}
|
|
195
|
+
const a = document.createElement('a');
|
|
196
|
+
a.href = URL.createObjectURL(new Blob([lines.join('\n') + '\n'], { type: 'text/csv' }));
|
|
197
|
+
a.download = 'goals-' + todayIso() + '.csv'; document.body.appendChild(a); a.click(); a.remove();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* ── Search: Goals' own rows first ── */
|
|
201
|
+
function hits(q) {
|
|
202
|
+
const s = String(q || '').toLowerCase().trim(); if (!s) return [];
|
|
203
|
+
const rows = [];
|
|
204
|
+
for (const p of S.list) if (p.model && p.model.okrFile) {
|
|
205
|
+
for (const o of p.model.okrFile.objectives) for (const k of o.krs) if ((k.token + ' ' + k.title).toLowerCase().includes(s)) rows.push({ id: 'kr:' + k.key, title: k.token + ' ' + k.title, sub: GM.objLabel(o.token) + (S.list.length > 1 ? ' · ' + p.name : ''), open: () => GO.openKr(ctxOf(p.ws), k.key) });
|
|
206
|
+
}
|
|
207
|
+
return rows.length ? [{ label: 'In Goals', rows: rows.slice(0, 8) }] : [];
|
|
208
|
+
}
|
|
209
|
+
$('glFind').onclick = () => import('./cozy-search.js').then((M) => M.openSearch({ scope: { name: 'Goals', hits } }));
|
|
210
|
+
|
|
211
|
+
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible' && Date.now() - S.at > 60000) load(); });
|
|
212
|
+
void POP;
|
|
213
|
+
load();
|