create-pmos 0.655.0 → 0.657.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.
@@ -1,4 +1,19 @@
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,
1
+ /* pm/premium-goals.js — Goals, the place. REBUILT FROM DESIGN SYSTEM BLOCKS (initiative goals-ds-page; board GoalsDS on Exploring 3, page "pages";
2
+ * brief design-system/pages-rebuild/brief.md). One column of blocks (pm/goals-ds.js writes them):
3
+ * · the top line: the path Goals › the product chip, the period chip, then Search, New key result (+: the words go in the Conversation box) and More
4
+ * (Set up, Charts and dashboards, Export CSV). The old Filter button is the Key results tabs now.
5
+ * · Where it stands (a Summary block): behind key results with the work that moves them and its date, a key result with no reading and since when,
6
+ * the next check. One Suggestion in the expanded form follows: the North Star draft (Yes keeps it, No drops it, both with Undo), else a source to
7
+ * connect, else drafting a North Star. Yes on an ask sends its words to PMOS in the Conversation; No hides it on this device ('pmos.goals.no');
8
+ * the pencil puts the words in the box to change first.
9
+ * · North Star, input and guardrail as Number blocks; a North Star not set keeps its draft (✓ ✕) or the ask (✦) in its block.
10
+ * · Key results: one Table grouped by objective, then health budgets, then the work no key result names (PMOS's guess of the key result, Link).
11
+ * Tabs All, Behind, No reading, On pace ('pmos.goals.filt'); Choose columns adds Left and Levers ('pmos.goals.cols').
12
+ * · the Conversation block: the one chat (pm/page-chat.js) about Goals of the product. The popup borrows the same element (cozy-popup.js
13
+ * useChat) and gives it back, so the page never holds two chats.
14
+ * Everything below this line is as goals-place built it, unless it says otherwise.
15
+ *
16
+ * First built as Goals (initiative goals-place, slice 9 of the six-place navigation; boards 8, 13, 31, 32, 33 on Exploring 2,
2
17
  * page "Navigation: Today, Work, Goals, Events, Library, Routine"; handover /mnt/project-files/goals-handover/).
3
18
  *
4
19
  * "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
@@ -24,16 +39,20 @@ import * as POP from './cozy-popup.js'; // the one popup: window.czOpenChat fo
24
39
  import * as GM from './goals-model.js';
25
40
  import * as GO from './goals-open.js';
26
41
  import { undoToast } from './hi-pop.js';
27
- import { productName, whenNames } from './scope-chip.js'; // names, not ids: the product's display name (IDPF), not its folder name
42
+ import { productName, whenNames } from './scope-chip.js';
43
+ import * as DS from './goals-ds.js'; // names, not ids: the product's display name (IDPF), not its folder name
28
44
 
29
45
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
30
46
  const SVG = (d, w = 16) => `<svg class="pm-ic" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
31
- 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' };
47
+ const I = { check: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z' };
32
48
  const STAR = (w = 16) => `<svg class="pm-ic pm-star" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${I.spark}"/></svg>`;
33
49
  const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
34
50
  const todayIso = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
35
- const FILT = GM.FILTERS.map((f) => f[0]);
36
- const S = { P: null, list: [], at: 0, filter: FILT.includes(store.get('pmos.goals.filt')) ? store.get('pmos.goals.filt') : 'all', error: '' };
51
+ const FILT = GM.FILTERS.map((f) => f[0]).concat('read'); // 'read' was the old fourth choice: a device that stored it keeps its view
52
+ const COLS0 = (() => { try { const v = JSON.parse(store.get('pmos.goals.cols') || 'null'); return Array.isArray(v) ? v : null; } catch { return null; } })();
53
+ const NO0 = (() => { try { const v = JSON.parse(store.get('pmos.goals.no') || '[]'); return Array.isArray(v) ? v : []; } catch { return []; } })();
54
+ const S = { P: null, list: [], at: 0, filter: FILT.includes(store.get('pmos.goals.filt')) ? store.get('pmos.goals.filt') : 'all', error: '',
55
+ cols: new Set(COLS0 || DS.COLS.filter((c) => c[2]).map((c) => c[0])), no: new Set(NO0), sug: null };
37
56
  const DEEP = new URLSearchParams(location.search).get('ws');
38
57
 
39
58
  mountNav('insights', document, { scope: () => ({ name: 'Goals', hits: (q) => hits(q) }) });
@@ -62,69 +81,92 @@ function drawPer() {
62
81
  const x = S.list.find((p) => p.model && p.model.okrFile && p.model.okrFile.period);
63
82
  const per = x ? GM.periodOf(x.model.okrFile) : null, el = $('glPer');
64
83
  el.hidden = !per;
65
- if (per) el.innerHTML = `${SVG(I.cal, 16)}<b>${esc(per.label)}</b>${per.sub ? `<span class="gl-pers">${esc(per.sub)}</span>` : ''}`;
84
+ if (per) { el.innerHTML = `<b>${esc(per.label)}</b>`; el.title = per.sub || ''; }
66
85
  }
67
86
 
68
- /* ── the North Star: a Number block once it is set, else PMOS's Suggestion (its draft with ✓ ✕, or ✦ to draft one) ── */
69
- function nsHtml(p) {
87
+ /* ── the blocks (pm/goals-ds.js writes the words; here they are laid out) ── */
88
+ /** A North Star not set: its block holds PMOS's draft (✓ ✕) or the ask to draft one (✦). */
89
+ function nsAsk(p) {
70
90
  const ns = p.ns;
71
- if (ns.state === 'set') return `<section class="pm-block gl-ns" aria-label="North Star"><div class="head"><h3 class="pm-h-sm">North Star</h3></div><div class="heading">${esc(ns.title)}</div><p class="pm-meta gl-m0">${esc(ns.sub)}</p></section>`;
72
- const head = `<div class="head"><h3 class="pm-h-sm pm-row">${STAR()}North Star</h3><span class="sp"></span><span class="pm-meta">not set in your OKR file</span></div>`;
73
- if (ns.state === 'draft') return `<section class="pm-block gl-ns" aria-label="North Star">${head}<div class="pm-sug" role="group" aria-label="PMOS suggests"><span class="say"><b>${esc(ns.title)}</b><br>${esc(ns.sub)}</span>`
74
- + `<button type="button" class="pm-btn primary" data-gl-nskeep="${esc(p.ws)}" aria-label="Approve this North Star" title="Approve this North Star">${SVG(I.check)}</button><button type="button" class="pm-btn outline" data-gl-nsdrop="${esc(p.ws)}" aria-label="No, drop this North Star" title="No">${SVG(I.x)}</button></div></section>`;
75
- return `<section class="pm-block gl-ns" aria-label="North Star">${head}<div class="pm-sug" role="group" aria-label="PMOS suggests"><span class="say"><b>${esc(ns.title)}</b><br>${esc(ns.sub)}</span>`
76
- + `<button type="button" class="pm-btn primary" 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)}</button></div></section>`;
91
+ if (S.sug && S.sug.ws === p.ws && (S.sug.kind === 'ns' || S.sug.kind === 'draft')) return `<p class="pm-meta gl-m0">${ns.state === 'draft' ? 'PMOS drafted one: it waits for your answer in Where it stands.' : 'PMOS can draft one: see Where it stands.'}</p>`; // say it once
92
+ if (ns.state === 'draft') return `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span class="say"><b>${esc(ns.title)}</b><br>${esc(ns.sub)}</span>`
93
+ + `<button type="button" class="pm-btn primary" data-gl-nskeep="${esc(p.ws)}" aria-label="Approve this North Star" title="Approve this North Star">${SVG(I.check)}</button><button type="button" class="pm-btn outline" data-gl-nsdrop="${esc(p.ws)}" aria-label="No, drop this North Star" title="No">${SVG(I.x)}</button></div>`;
94
+ return `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span class="say">${esc(ns.sub)}</span>`
95
+ + `<button type="button" class="pm-btn primary" 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)}</button></div>`;
77
96
  }
78
-
79
- /* ── the hierarchy: one Table (rowspans hold an objective's name, its levers and its initiatives beside its key results) ── */
80
- const dm = (k) => (k ? `<i class="gl-dm${k === 'rd' ? ' rd' : ''}" aria-hidden="true"></i>` : '');
81
- const iniHtml = (p, i) => `<button type="button" class="gl-hit" 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="pm-meta${i.tone ? ' gl-al' : ''}">${dm(i.dm)}${esc(i.line)}</span>` : ''}</button>`;
82
- const inis = (p, items) => `<div class="gl-inis">${items.map((i) => iniHtml(p, i)).join('')}</div>`;
83
- const rs = (n) => (n > 1 ? ` rowspan="${n}"` : '');
84
- function krCells(p, k) {
85
- const act = k.act ? `<b class="${k.tone ? 'gl-al' : ''}">${esc(k.act)}</b>` : '<span class="pm-meta">—</span>';
86
- return `<td class="gl-kr"><button type="button" class="gl-hit" 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)}">`
87
- + `<span><span class="pm-meta gl-tok">${esc(k.token)}</span>${esc(k.title)}</span><span class="pm-meta gl-sub">${esc(k.sub)}</span></button></td>`
88
- + `<td class="gl-act">${act}${k.target ? `<span class="pm-meta"> / ${esc(k.target)}</span>` : ''}</td><td class="gl-left pm-meta">${esc(k.left)}</td>`;
89
- }
90
- function objRows(p, o) {
91
- const n = o.krs.length;
92
- return o.krs.map((k, i) => {
93
- let h = '';
94
- if (i === 0) h += `<th scope="rowgroup" class="gl-obj"${rs(n)}><b>${esc(o.label)}</b>${o.title ? `<span class="pm-meta">${esc(o.title)}</span>` : ''}${o.slip ? `<span class="pm-badge alert">${esc(o.slip)}</span>` : ''}</th>`;
95
- h += krCells(p, k);
96
- if (i === 0) h += `<td class="gl-lv"${rs(n)}>${o.levers.map((l) => `<div><b>${esc(l.title)}</b><span class="pm-meta${l.tone ? ' gl-al' : ''}">${esc(l.txt)}</span></div>`).join('')}</td>`;
97
- const c = o.inis.find((x) => x.from === i + 1);
98
- if (c) h += `<td class="gl-in"${rs(c.span)}>${inis(p, c.items)}</td>`;
99
- else if (!o.inis.some((x) => i + 1 > x.from && i + 1 < x.from + x.span)) h += '<td class="gl-in"></td>';
100
- return `<tr${i === 0 ? ' class="gl-first"' : ''}>${h}</tr>`;
101
- }).join('');
102
- }
103
- const wideRow = (head, tone, line, say, items, p) => `<tbody><tr class="gl-first"><th scope="row" class="gl-obj"><b>${esc(head)}</b>${line ? `<span class="pm-meta${tone ? ' gl-al' : ''}">${esc(line)}</span>` : ''}</th>`
104
- + `<td class="gl-wide" colspan="4">${say}</td><td class="gl-in">${inis(p, items)}</td></tr></tbody>`;
105
- function tableHtml(p) {
106
- const T = p.T;
107
- if (!p.model.okrFile) return `<p class="pm-meta gl-none">No OKR file was found for ${esc(nm(p))}, so there is no key result to show. Goals reads the OKR file in planning/okrs/.</p>`;
108
- if (!T.objectives.length && S.filter !== 'all') return `<p class="pm-meta gl-none">No key result is ${esc((GM.FILTERS.find((f) => f[0] === S.filter) || [])[1] || '').toLowerCase()} in ${esc(nm(p))}.</p>`;
109
- const hd = '<thead><tr><th scope="col">Objective</th><th scope="col">Key result</th><th scope="col" class="gl-act">Actual / target</th><th scope="col" class="gl-left">Left</th><th scope="col" class="gl-lv">Levers</th><th scope="col">Initiative</th></tr></thead>';
110
- const bud = T.budgets.map((b) => wideRow('Budget', b.over, b.label + (b.share ? ' · ' + b.share : ''), `<b>No key result: a budget that is always on</b>${b.covers ? `<span class="pm-meta">${esc(b.covers)}</span>` : ''}`, b.items, p)).join('');
111
- const un = T.unlinked.length ? wideRow('Unlinked', false, '', `<span class="pm-meta">${T.unlinked.length === 1 ? 'An initiative with no key result named' : T.unlinked.length + ' initiatives with no key result named'}</span>`, T.unlinked, p) : '';
112
- return `<div class="pm-block list gl-tb"><table class="pm-table" aria-label="Goals of ${esc(nm(p))}">${hd}${T.objectives.map((o) => `<tbody>${objRows(p, o)}</tbody>`).join('')}${bud}${un}</table></div>`;
97
+ function numbersHtml(p) {
98
+ const N = DS.numbersOf(p.model, p.ns);
99
+ if (!N.length) return '';
100
+ return `<div class="gl-nums">${N.map((n) => `<section class="pm-block" aria-label="${esc(n.name)}"><div class="head"><h3 class="pm-h-sm">${esc(n.name)}</h3><span class="sp"></span>`
101
+ + (n.ns ? `<span class="pm-meta">not set</span></div>${nsAsk(p)}` : `${n.at ? `<span class="pm-meta">read ${esc(GM.mdy(n.at))}</span>` : ''}</div>`
102
+ + `<div class="pm-row gl-numr"><span class="pm-num">${esc(n.value)}</span>${n.spark ? `<svg aria-hidden="true" width="120" height="32" viewBox="0 0 120 32"><polyline points="${n.spark}" fill="none" stroke="var(--blue)" stroke-width="2"/></svg>` : ''}</div>`
103
+ + `<p class="pm-meta gl-m0">${esc(n.line)}</p>`) + '</section>').join('')}</div>`;
104
+ }
105
+ /** Where it stands and its one Suggestion, for the first product that has something to say. */
106
+ function standsHtml(p, sug) {
107
+ const say = DS.standsOf(p.model, todayIso());
108
+ if (!say.length && !sug) return '';
109
+ return `<section class="pm-block gl-stands" aria-label="Where it stands"><h2 class="pm-h-sm pm-row">${STAR()}Where it stands</h2>`
110
+ + (say.length ? `<p class="gl-m0">${say.join(' ')}</p>` : '') + (sug ? DS.sugHtml(sug, `data-gl-sk="${esc(sug.key)}" data-gl-sws="${esc(p.ws)}"`, 'data-gl-sug') : '') + '</section>';
113
111
  }
114
112
  function draw() {
115
- if (!S.list.length) { body.innerHTML = `<p class="pm-meta 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; }
113
+ if (!S.list.length) { body.innerHTML = `<p class="pm-meta 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; $('glTalk').hidden = true; return; }
116
114
  const today = todayIso(), many = S.list.length > 1;
117
115
  let h = '';
116
+ S.sug = null;
118
117
  for (const p of S.list) {
119
118
  if (!p.model) { h += `<section class="gl-p">${many ? `<h2 class="pm-h">${esc(nm(p))}</h2>` : ''}<p class="pm-meta gl-none">${esc(nm(p))} could not be read: ${esc(p.error || 'the server did not answer')}.</p></section>`; continue; }
120
119
  p.T = GM.tableOf(p.model, today, S.filter);
121
120
  p.ns = GM.northStarOf(p.model, p.drafts);
122
- h += `<section class="gl-p" aria-label="${esc(nm(p))}">${many ? `<h2 class="pm-h">${esc(nm(p))}</h2>` : ''}${p.model.okrFile ? nsHtml(p) : ''}${tableHtml(p)}</section>`;
121
+ p.counts = Object.fromEntries(GM.FILTERS.map(([k]) => [k, GM.tableOf(p.model, today, k).shown]));
122
+ const sug = S.sug ? null : DS.sugOf(p.model, p.ns, S.no); // one Suggestion on the page
123
+ if (sug) S.sug = { ...sug, ws: p.ws };
124
+ if (!p.model.okrFile) { h += `<section class="gl-p" aria-label="${esc(nm(p))}">${many ? `<h2 class="pm-h">${esc(nm(p))}</h2>` : ''}<p class="pm-meta gl-none">No OKR file was found for ${esc(nm(p))}, so there is no key result to show. Goals reads the OKR file in planning/okrs/.</p></section>`; continue; }
125
+ h += `<section class="gl-p" aria-label="${esc(nm(p))}">${many ? `<h2 class="pm-h">${esc(nm(p))}</h2>` : ''}${standsHtml(p, sug)}${numbersHtml(p)}`
126
+ + `${DS.tableHtml({ ...p, name: nm(p) }, { today, filter: S.filter === 'read' ? 'pace' : S.filter, cols: S.cols, many })}</section>`;
123
127
  }
124
128
  body.innerHTML = h;
125
129
  $('glNote').hidden = false;
126
- $('glFdot').hidden = S.filter === 'all';
127
130
  drawPer();
131
+ talk();
132
+ }
133
+
134
+ /* ── the Conversation block: the one chat, about Goals of the product ── */
135
+ const T = { box: null, target: null, phone: matchMedia('(max-width: 760px)') };
136
+ function goalsTarget(PC) {
137
+ const p = S.list.find((x) => x.model) || null, ws = p ? p.ws : '', name = p && S.list.length === 1 ? nm(p) : '';
138
+ const base = PC.popTarget({ kind: 'goal', id: 'goals-' + (ws || 'all'), title: name ? 'Goals of ' + name : 'Goals' }, ws || undefined);
139
+ return { ...base, placeholder: 'Ask about a key result, or say a new one', empty: 'Ask why a key result is behind, or say a new one. PMOS reads your goals and says where each answer came from.' };
140
+ }
141
+ async function talk() {
142
+ const host = $('glChat'), sec = $('glTalk');
143
+ if (!S.list.some((x) => x.model) || (window.PMOS_READONLY)) { sec.hidden = true; return; } // a read-only copy has no chat
144
+ sec.hidden = false;
145
+ const PC = await import('./page-chat.js');
146
+ if (!T.box) {
147
+ T.box = await PC.box();
148
+ host.appendChild(T.box.el);
149
+ // the popup borrows this chat and gives it back (cozy-popup.js useChat): never a second chat on the page
150
+ POP.useChat({ el: T.box.el, open: (t) => T.box.chat.open(t), current: () => (T.box.chat.current ? T.box.chat.current() : null), focus: () => T.box.chat.focus(), stop: () => T.box.chat.stop && T.box.chat.stop() });
151
+ new MutationObserver(() => {
152
+ const home = T.box.el.parentNode === host;
153
+ host.classList.toggle('away', !home);
154
+ if (home && T.target) T.box.chat.open(T.target); // back from the popup: the chat about Goals again
155
+ }).observe(host, { childList: true });
156
+ }
157
+ const t = goalsTarget(PC);
158
+ if (!T.target || T.target.key !== t.key) { T.target = t; if (T.box.el.parentNode === host) T.box.chat.open(t); }
159
+ }
160
+ /** Words for PMOS: sent at once (Yes), or put in the box to change first (the pencil, Link, +). */
161
+ async function say(text, send) {
162
+ await talk();
163
+ if (!T.box) return;
164
+ const host = $('glChat');
165
+ if (T.box.el.parentNode !== host) { POP.close(); }
166
+ $('glTalk').scrollIntoView({ block: 'nearest', behavior: 'smooth' });
167
+ if (send) { await T.box.chat.send(text); return; }
168
+ const ta = T.box.el.querySelector('textarea');
169
+ if (ta) { ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); ta.setSelectionRange(text.length, text.length); }
128
170
  }
129
171
 
130
172
  /* ── load ── */
@@ -164,21 +206,64 @@ async function dropNs(p, row) {
164
206
  undoToast('Dropped.', async () => { await pmPost('/api/metric-drafts/undo', base).catch(() => null); await load(); });
165
207
  await load();
166
208
  }
209
+ const saveNo = () => store.set('pmos.goals.no', JSON.stringify([...S.no].slice(-40)));
210
+ async function onSug(t) {
211
+ const sg = S.sug; if (!sg || t.dataset.glSk !== sg.key) return;
212
+ const p = S.list.find((x) => x.ws === sg.ws) || S.list[0], act = t.dataset.glSug;
213
+ if (sg.kind === 'ns') { // the North Star draft: the metric-drafts keep and drop, with Undo, as before
214
+ if (act === 'yes') { t.disabled = true; keepNs(p, p.ns.row); } else if (act === 'no') { t.disabled = true; dropNs(p, p.ns.row); }
215
+ else say('Change the North Star draft "' + p.ns.title + '": ', false);
216
+ return;
217
+ }
218
+ if (act === 'yes') { say(sg.say, true); return; }
219
+ if (act === 'edit') { say(sg.say, false); return; }
220
+ // No: this Suggestion stays away on this device, with Undo
221
+ S.no.add(sg.key); saveNo(); draw();
222
+ undoToast('PMOS will not suggest this again here.', () => { S.no.delete(sg.key); saveNo(); draw(); });
223
+ }
167
224
  body.onclick = (e) => {
168
- const t = e.target.closest('button'); if (!t) return;
225
+ const t = e.target.closest('button,a'); if (!t || !body.contains(t)) return;
169
226
  const d = t.dataset;
227
+ if (t.tagName === 'A' && (d.glKr || d.glIni)) e.preventDefault();
170
228
  if (d.glKr) { GO.openKr(ctxOf(d.glWs), d.glKr); return; }
171
229
  if (d.glIni) { const c = ctxOf(d.glWs); if ('glVerdict' in d) GO.openVerdict(c, d.glIni); else GO.openIni(c, d.glIni); return; }
230
+ if (d.glSug) { onSug(t); return; }
231
+ if (d.glF) { S.filter = d.glF; store.set('pmos.goals.filt', S.filter); draw(); const b = body.querySelector(`[data-gl-f="${S.filter}"]`); if (b) b.focus(); return; }
232
+ if (d.glCols !== undefined) { openCols(t); return; }
233
+ if (d.glLink) { say(d.glSay, false); return; }
172
234
  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; }
173
235
  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; }
174
236
  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); }
175
237
  };
238
+ /* the tabs move with the arrow keys (the system's Tabs part) */
239
+ body.addEventListener('keydown', (e) => {
240
+ const t = e.target.closest && e.target.closest('[data-gl-f]'); if (!t || (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft')) return;
241
+ const all = [...t.parentNode.querySelectorAll('[data-gl-f]')], i = all.indexOf(t), n = all[(i + (e.key === 'ArrowRight' ? 1 : all.length - 1)) % all.length];
242
+ e.preventDefault(); n.click();
243
+ });
244
+ $('glNew').onclick = () => say('New key result: ', false);
176
245
 
177
- /* ── the menus: Filter and ⋯ ── */
178
- const MENUS = [['glFilt', 'glFiltMenu'], ['glMore', 'glMoreMenu']];
246
+ /* ── Choose columns: a Menu of the columns, each a tick; remembered on this device ── */
247
+ function openCols(btn) {
248
+ closeMenus();
249
+ const old = document.getElementById('glColsMenu'); if (old) { old.remove(); btn.setAttribute('aria-expanded', 'false'); return; }
250
+ const m = document.createElement('div');
251
+ m.className = 'pm-menu gl-menu'; m.id = 'glColsMenu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'Choose columns');
252
+ m.innerHTML = DS.COLS.map(([k, label]) => `<button type="button" role="menuitemcheckbox" aria-checked="${S.cols.has(k)}" data-gl-c="${k}">${esc(label)}</button>`).join('');
253
+ btn.parentNode.appendChild(m); btn.setAttribute('aria-expanded', 'true');
254
+ m.onclick = (e) => {
255
+ const b = e.target.closest('[data-gl-c]'); if (!b) return;
256
+ const k = b.dataset.glC; if (S.cols.has(k)) S.cols.delete(k); else S.cols.add(k);
257
+ store.set('pmos.goals.cols', JSON.stringify([...S.cols])); draw();
258
+ };
259
+ m.querySelector('button').focus();
260
+ }
261
+ document.addEventListener('click', (e) => { const m = document.getElementById('glColsMenu'); if (m && !e.target.closest('#glColsMenu') && !e.target.closest('[data-gl-cols]')) m.remove(); });
262
+
263
+ /* ── the ⋯ menu ── */
264
+ const MENUS = [['glMore', 'glMoreMenu']];
179
265
  function closeMenus(except) { for (const [b, m] of MENUS) if (m !== except && !$(m).hidden) { $(m).hidden = true; $(b).setAttribute('aria-expanded', 'false'); } }
180
266
  function drawMenus() {
181
- $('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('');
182
267
  $('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>';
183
268
  }
184
269
  for (const [b, m] of MENUS) {
@@ -189,11 +274,11 @@ for (const [b, m] of MENUS) {
189
274
  };
190
275
  }
191
276
  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'); } });
192
- 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(); } });
193
- $('glFiltMenu').onclick = (e) => {
194
- const t = e.target.closest('[data-gl-f]'); if (!t) return;
195
- S.filter = t.dataset.glF; store.set('pmos.goals.filt', S.filter); closeMenus(); draw();
196
- };
277
+ document.addEventListener('keydown', (e) => {
278
+ if (e.key !== 'Escape') return;
279
+ const c = document.getElementById('glColsMenu'); if (c) { c.remove(); const b = body.querySelector('[data-gl-cols]'); if (b) b.focus(); }
280
+ for (const [b, m] of MENUS) if (!$(m).hidden) { $(m).hidden = true; $(b).setAttribute('aria-expanded', 'false'); $(b).focus(); }
281
+ });
197
282
  $('glMoreMenu').onclick = (e) => {
198
283
  const t = e.target.closest('[data-gl-m]'); if (!t) return;
199
284
  closeMenus();
@@ -5,7 +5,10 @@
5
5
  <meta name="pmos-nonce" content="" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
7
7
  <title>PMOS · Goals</title>
8
- <!-- Goals (initiative goals-place, slice 9 of the six-place navigation; boards 8, 13, 31, 32, 33 on Exploring 2, handover
8
+ <!-- Goals, rebuilt from design system blocks (initiative goals-ds-page; board GoalsDS on Exploring 3, page "pages"): the path with the product
9
+ chip, the period chip, Search, New key result and More; then one column of blocks: Where it stands with one Suggestion, North Star, input and
10
+ guardrail as Number blocks, the Key results Table, and the Conversation block (the one chat, pm/page-chat.js) at the end.
11
+ First built as Goals (initiative goals-place, slice 9 of the six-place navigation; boards 8, 13, 31, 32, 33 on Exploring 2, handover
9
12
  /mnt/project-files/goals-handover/). "Am I on track? What do I do?" as one hierarchy: the North Star, then one table Objective › Key result
10
13
  (Actual / target, Left) › Levers › Initiative, a Budget row per health budget with work in it, and the work no key result names (Unlinked).
11
14
  A press on a key result, an initiative or ⋯ › Set up opens it in the one popup (pm/cozy-popup.js) with the chat about it. It reads
@@ -25,16 +28,18 @@
25
28
  <main class="stage cz-panel gl" id="stage">
26
29
  <h1 class="vh">Goals</h1>
27
30
  <div class="pm-row gl-bar">
28
- <span class="title gl-ttl" aria-hidden="true">Goals</span>
29
- <span id="glPick"></span>
31
+ <nav class="pm-path" aria-label="Path"><b>Goals</b><svg class="pm-ic" width="14" height="14" viewBox="0 0 24 24" aria-hidden="true"><path d="M10 8l4 4-4 4"/></svg><span id="glPick"></span></nav>
30
32
  <span class="pm-chip gl-per" id="glPer" hidden></span>
31
33
  <span class="gl-sp"></span>
32
34
  <button type="button" class="pm-btn" id="glFind" aria-label="Find a goal" title="Find a goal"><svg class="pm-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M11 4.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 1 0 0-13M16 16l4 4"/></svg></button>
33
- <span class="gl-mw"><button type="button" class="pm-btn" id="glFilt" aria-haspopup="menu" aria-expanded="false" aria-controls="glFiltMenu" aria-label="Filter: all, slipping, not read or read" title="Filter"><svg class="pm-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M7 12h10M10 18h4"/></svg><i class="gl-fdot" id="glFdot" hidden></i></button><div class="pm-menu gl-menu" id="glFiltMenu" role="menu" aria-label="Filter" hidden></div></span>
35
+ <button type="button" class="pm-btn" id="glNew" aria-label="New key result" title="New key result"><svg class="pm-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
34
36
  <span class="gl-mw"><button type="button" class="pm-btn" id="glMore" aria-haspopup="menu" aria-expanded="false" aria-controls="glMoreMenu" aria-label="More: set up, charts and dashboards, export" title="More"><svg class="pm-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h.01M12 12h.01M19 12h.01"/></svg></button><div class="pm-menu gl-menu" id="glMoreMenu" role="menu" aria-label="More" hidden></div></span>
35
37
  </div>
36
- <div id="glBody" aria-live="polite"><div class="gl-sk" aria-hidden="true"><i class="pm-block flat"></i><i class="pm-block flat"></i><i class="pm-block flat"></i></div></div>
37
- <p class="pm-meta gl-n" id="glNote" hidden>Reports are routine jobs, so they live in <a href="/premium-routine.html">Routine</a>: who each one tells, when it runs, what PMOS did.</p>
38
+ <div class="gl-col">
39
+ <div id="glBody" aria-live="polite"><div class="gl-sk" aria-hidden="true"><i class="pm-block flat"></i><i class="pm-block flat"></i><i class="pm-block flat"></i></div></div>
40
+ <section class="pm-block gl-talk" id="glTalk" aria-label="Ask about your goals" hidden><div class="head"><svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg><h2 class="pm-h-sm">Ask about your goals</h2></div><div class="gl-chat" id="glChat"></div></section>
41
+ <p class="pm-meta gl-n" id="glNote" hidden>Reports are routine jobs, so they live in <a href="/premium-routine.html">Routine</a>: who each one tells, when it runs, what PMOS did.</p>
42
+ </div>
38
43
  </main>
39
44
  <noscript>This page needs JavaScript.</noscript>
40
45
  <script type="module" src="/pm/premium-goals.js"></script>
@@ -0,0 +1,11 @@
1
+ {
2
+ "_comment": "Act alone only with a source (initiative act-alone-only-with-a-source, done test C1-C11): PMOS holds a plan change with no source, and a close, rename or big date move on one kind of source; the held changes fold into one question list a day. Pure checks plus a scratch server each. No connector, model or network.",
3
+ "modules": [
4
+ "source-guard.test.js",
5
+ "question-batch.test.js"
6
+ ],
7
+ "seconds": {
8
+ "source-guard.test.js": 10,
9
+ "question-batch.test.js": 10
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Goals rebuilt from design system blocks (initiative goals-ds-page, done test C2-C7): pm/goals-ds.js, pm/goals-model.js pace, the page's top line, Conversation and sheet. Pure, node.",
3
+ "modules": [
4
+ "goals-ds.test.js"
5
+ ],
6
+ "seconds": {
7
+ "goals-ds.test.js": 2
8
+ }
9
+ }