create-pmos 0.717.0 → 0.719.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 +51 -33
- 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/changelog.json +50 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +10 -5
- package/workspace/guide/cli.md +14 -0
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/layout.md +8 -2
- package/workspace/lib/item-why.js +235 -0
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/pinned-views.js +26 -0
- package/workspace/lib/pmos-verbs.js +5 -0
- package/workspace/lib/product-health-cli.js +13 -0
- package/workspace/lib/product-health.js +259 -0
- package/workspace/lib/routes-search.js +4 -2
- package/workspace/lib/search-answer.js +164 -0
- package/workspace/lib/why-cli.js +79 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-nav.js +14 -3
- package/workspace/public/pm/cozy-search.js +18 -2
- package/workspace/public/pm/palette-all.js +101 -0
- package/workspace/public/pm/pinned-views.css +17 -0
- package/workspace/public/pm/pinned-views.js +130 -0
- package/workspace/public/pm/premium-board.js +53 -3
- package/workspace/public/premium-board.html +1 -0
- package/workspace/test-lists/item-why.json +9 -0
- package/workspace/test-lists/palette-all.json +9 -0
- package/workspace/test-lists/pinned-filter-views.json +9 -0
- package/workspace/test-lists/product-health.json +9 -0
- package/workspace/test-lists/search-answers-first.json +9 -0
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* a page's own find, the U2 scope, keeps its own hits above it):
|
|
7
7
|
* it puts the words in the one chat, over the page you are on (pm/page-chat.js openCos), or in Home's own box on Home. ↑ ↓ move, ↵ opens,
|
|
8
8
|
* Esc closes. On a phone it is the whole screen.
|
|
9
|
+
* Above everything, when the words clearly point to one thing, one answer: a sentence copied from the user's own files, with its source
|
|
10
|
+
* and the check date when it is an initiative (search-answers-first, lib/search-answer.js). ↵ on it opens the source. No answer: no row.
|
|
9
11
|
* openSearch({ go?, q?, scope? }) go: the page's own opener ({ ini } | { ses } | { doc }), used before a page change
|
|
10
12
|
* scope: the page Search opens from (UI grill U2: one search; the Board's and Intelligence's own find boxes are gone). { name, hits(q) }
|
|
11
13
|
* where hits returns [{ label, rows: [{ id?, title, sub?, tag?, icon?, open() }] }]: the page's own groups, drawn first ("On this Board ·
|
|
@@ -140,12 +142,16 @@ function drawList() {
|
|
|
140
142
|
if (ownIds.size) rows = rows.filter((r) => !(r.kind === 'initiative' && ownIds.has(r.id)));
|
|
141
143
|
const groups = own.concat(searchGroups(rows, { phone: isPhone() }));
|
|
142
144
|
const ask = q.length >= 2 ? { kind: 'ask', title: q } : null;
|
|
145
|
+
// search-answers-first: the answer, with its source, is the first row; only for the words it answered and on All
|
|
146
|
+
const A = S.res && S.res.answer && S.kind === 'all' && q.length >= 2 && String(S.res.q || '').trim() === q ? S.res.answer : null;
|
|
147
|
+
const ansRow = A && A.source ? { kind: 'answer', answer: A } : null;
|
|
143
148
|
// chief-of-staff C5: the one chat is the first row of Search; a page's own find (U2 scope) keeps its own hits first, then the chat
|
|
144
149
|
const ownRows = own.flatMap((g) => g.rows);
|
|
145
|
-
S.rows =
|
|
150
|
+
S.rows = (ansRow ? [ansRow] : []).concat(ownRows, ask ? [ask] : [], groups.slice(own.length).flatMap((g) => g.rows));
|
|
146
151
|
S.at = Math.min(S.at, Math.max(0, S.rows.length - 1));
|
|
147
152
|
let h = '', i = 0;
|
|
148
153
|
const askHtml = () => `<button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(ICON.chat, 18)}<span class="ev-t">Ask PMOS: <b>“${esc(q)}”</b></span><span class="ev-k">${onHome() ? 'In the chat' : 'Opens the chat here'}</span></button>`;
|
|
154
|
+
if (ansRow && !S.err) { h += answerHtml(ansRow.answer, i); i++; }
|
|
149
155
|
// the page's own groups first (UI grill U2): what Search itself could not read is said after them
|
|
150
156
|
own.forEach((g) => { h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join(''); });
|
|
151
157
|
if (ask) { h += askHtml(); i++; }
|
|
@@ -154,7 +160,7 @@ function drawList() {
|
|
|
154
160
|
else if (S.err) h += cantRead({ what: 'Search', why: S.err, sources: false });
|
|
155
161
|
else if (S.busy && !rest.length) h += skelRows(3);
|
|
156
162
|
// nothing found: Adler with his magnifier (canvas AdU4); the words stay the same
|
|
157
|
-
else if (!groups.length) h += `<div class="ev-sp-empty ev-sp-ad" role="status">${adler('needs-you', 'l', { label: false, prop: 'magnifier' })}<p>Nothing matches “${esc(q)}”${S.kind !== 'all' ? ' in this kind' : ''}.</p></div>`;
|
|
163
|
+
else if (!groups.length && !ansRow) h += `<div class="ev-sp-empty ev-sp-ad" role="status">${adler('needs-you', 'l', { label: false, prop: 'magnifier' })}<p>Nothing matches “${esc(q)}”${S.kind !== 'all' ? ' in this kind' : ''}.</p></div>`;
|
|
158
164
|
rest.forEach((g, gi) => {
|
|
159
165
|
h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join('');
|
|
160
166
|
if (gi === 0 && isPhone() && g.key === 'initiative') h += '<div class="ev-sp-chips ev-phchips" aria-hidden="true"></div>';
|
|
@@ -169,6 +175,15 @@ function drawList() {
|
|
|
169
175
|
const r = box.querySelector('[data-ev-retry]'); if (r) r.onclick = () => run();
|
|
170
176
|
const a = box.querySelector('#evo' + S.at); if (a) { S.el.querySelector('#evQ').setAttribute('aria-activedescendant', a.id); a.scrollIntoView({ block: 'nearest' }); }
|
|
171
177
|
}
|
|
178
|
+
/** The answer row: the sentence in full (it wraps), then the check date and where it came from. */
|
|
179
|
+
const dayOf = (iso) => { const d = new Date(String(iso) + 'T00:00:00'); return isNaN(d) ? '' : d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }); };
|
|
180
|
+
function answerHtml(a, i) {
|
|
181
|
+
const src = a.source, kind = { initiative: 'initiative', document: 'document', report: 'report', slides: 'slides' }[src.kind] || 'file';
|
|
182
|
+
const facts = (a.facts || []).filter((f) => f.key === 'check' && dayOf(f.date)).map((f) => 'Check ' + dayOf(f.date));
|
|
183
|
+
const from = 'From ' + (src.title || src.path) + ' (' + kind + (src.main === false ? ', draft in ' + (src.branch || src.wt) : '') + ')';
|
|
184
|
+
// the plain wrapper keeps the row as tall as its lines: the list is a flex column and would squeeze the button to its min-height
|
|
185
|
+
return `<div role="none"><button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}" aria-label="${esc(a.text + ' ' + facts.concat(from).join(' · '))}">${svg(KIND_ICON[src.kind] || ICON.doc, 18)}<span><b>${esc(a.text)}</b><br><span class="ev-small ev-mut">${esc(facts.concat(from).join(' · '))}</span></span></button></div>`;
|
|
186
|
+
}
|
|
172
187
|
function draw() { if (!S.el || S.el.hidden) return; drawChips(); drawList(); }
|
|
173
188
|
addEventListener('resize', () => draw());
|
|
174
189
|
|
|
@@ -178,6 +193,7 @@ function homeUrl(params) { const q = new URLSearchParams(params); if (wsParam())
|
|
|
178
193
|
function go(r) {
|
|
179
194
|
closeSearch();
|
|
180
195
|
if (r.kind === 'ask') { askClaude(r.title); return; }
|
|
196
|
+
if (r.kind === 'answer') { const src = r.answer.source; go({ ...src, kind: src.kind || 'document', title: src.title || src.path }); return; }
|
|
181
197
|
if (r.kind === 'scoped') { if (typeof r.open === 'function') r.open(); return; }
|
|
182
198
|
if (r.kind === 'initiative') { if (S.go) { S.go({ ini: r.id }); return; } location.assign(homeUrl(r.board ? { ini: r.id, board: r.board } : { ini: r.id })); return; }
|
|
183
199
|
if (r.kind === 'session') { if (S.go) { S.go({ ses: r.id }); return; } location.assign(homeUrl({ session: r.id })); return; }
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* pm/palette-all.js — Ctrl K reaches every page, item and action (bet A315, initiative palette-reaches-everything,
|
|
2
|
+
* done test planning/done-tests/palette-reaches-everything.md P1-P9).
|
|
3
|
+
*
|
|
4
|
+
* Search (pm/cozy-search.js) finds work: initiatives, documents, slides, reports, artifacts, meetings and chats. This adds what a person
|
|
5
|
+
* otherwise hunts for in the rail, the menus and the panels, as three groups drawn with a page's own hits (the U2 scope hook, so Search
|
|
6
|
+
* itself is not changed):
|
|
7
|
+
* On this item the item last pointed at or focused: its own buttons for the five action-key actions (pm/action-keys.js targetOf),
|
|
8
|
+
* so a pick presses the button the item already has. No new action and no new route.
|
|
9
|
+
* Go to every place of the rail, plus Intelligence and Workflows; the place you are on is left out
|
|
10
|
+
* Do Ask PMOS, the Guide, the calendar, notes, a new note, each Settings section, and the three themes
|
|
11
|
+
* A query word matches the start of a word in a row's name or its other names ("sett conn" → Settings › Connectors). Under two letters
|
|
12
|
+
* there is nothing, as in Search. Each pick is noted on this computer only (pm/use-log.js noteUse): palette-page, palette-action or
|
|
13
|
+
* palette-item, no text and no value.
|
|
14
|
+
*
|
|
15
|
+
* paletteGroups(q, ctx) PURE (but for the item's buttons, read from the page): [{ label, rows: [{ id, title, sub?, tag?, icon, open() }] }]
|
|
16
|
+
* withEverything(scope, ctx) a Search scope ({ name, hits(q) }): the page's own groups first, then paletteGroups
|
|
17
|
+
* ctx: { places: [{ key, label, href }], here, item?, doc?, wsq?(prefix) → '?ws=…' | '', chat?(), setTheme?(pick), go?(url) } */
|
|
18
|
+
import { KEYS, targetOf, wordsOf } from './action-keys.js';
|
|
19
|
+
import { SECTIONS } from './set-ds.js';
|
|
20
|
+
import { noteUse } from './use-log.js';
|
|
21
|
+
|
|
22
|
+
/* pages that are not in the rail but are a page of their own */
|
|
23
|
+
const MORE_PAGES = [
|
|
24
|
+
{ key: 'intelligence', label: 'Intelligence', href: '/premium-intelligence.html', also: 'charts reports metrics' },
|
|
25
|
+
{ key: 'workflows', label: 'Workflows', href: '/premium-workflows.html', also: 'automations' },
|
|
26
|
+
];
|
|
27
|
+
const PAGE_ALSO = { home: 'home day', board: 'board backlog sprint', insights: 'okrs objectives key results', events: 'calendar meetings', library: 'documents docs files', routine: 'schedule recurring' };
|
|
28
|
+
const SECTION_ALSO = { general: 'theme time role', claude: 'autonomy decides', connectors: 'sources jira slack google', account: 'sign in profile', updates: 'version upgrade' };
|
|
29
|
+
const ITEM_ALSO = { approve: 'yes accept', open: 'view', sprint: 'move next sprint', park: 'hold later', undo: 'revert back' };
|
|
30
|
+
|
|
31
|
+
const words = (s) => String(s || '').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
32
|
+
/** Every query word starts a word of the row's name or its other names. */
|
|
33
|
+
export function matches(q, ...texts) {
|
|
34
|
+
const want = words(q); if (!want.length) return false;
|
|
35
|
+
const have = texts.flatMap(words);
|
|
36
|
+
return want.every((w) => have.some((h) => h.startsWith(w)));
|
|
37
|
+
}
|
|
38
|
+
/** Rows whose own name matches come before rows found only by their other names. */
|
|
39
|
+
const byName = (q) => (a, b) => Number(matches(q, b.title)) - Number(matches(q, a.title));
|
|
40
|
+
const pick = (control, fn) => () => { noteUse(control); return fn(); };
|
|
41
|
+
const go = (ctx, href) => () => { const url = href + (ctx.wsq ? ctx.wsq(href.includes('?') ? '&' : '?') : ''); if (ctx.go) ctx.go(url); else location.assign(url); };
|
|
42
|
+
|
|
43
|
+
function pageRows(q, ctx) {
|
|
44
|
+
const places = (ctx.places || []).filter((p) => p && p.href).map((p) => ({ ...p, also: PAGE_ALSO[p.key] || '' }));
|
|
45
|
+
const known = new Set(places.map((p) => p.href));
|
|
46
|
+
return places.concat(MORE_PAGES.filter((p) => !known.has(p.href)))
|
|
47
|
+
.filter((p) => p.key !== ctx.here && matches(q, p.label, p.also))
|
|
48
|
+
.map((p) => ({ id: 'page:' + p.key, title: p.label, sub: 'Page', icon: 'open', open: pick('palette-page', go(ctx, p.href)) }))
|
|
49
|
+
.sort(byName(q));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const lazy = (path, fn) => () => import(path).then(fn).catch(() => {});
|
|
53
|
+
function actionRows(q, ctx) {
|
|
54
|
+
const A = [
|
|
55
|
+
{ id: 'chat', title: 'Ask PMOS', also: 'chat talk', icon: 'chat', run: () => (ctx.chat ? ctx.chat() : null) },
|
|
56
|
+
{ id: 'guide', title: 'Open the Guide', also: 'help how', icon: 'guide', run: lazy('./premium-vw-open.js', (M) => M.openGuide('index')) },
|
|
57
|
+
{ id: 'calendar', title: 'Open the calendar', also: 'events meetings', icon: 'cal', run: lazy('./premium-vw-open.js', (M) => M.openCalendar({ ws: ctx.ws || '' })) },
|
|
58
|
+
{ id: 'notes', title: 'Open notes', also: 'meeting notes', icon: 'doc', run: lazy('./premium-vw-open.js', (M) => M.openNotes({ ws: ctx.ws || '' })) },
|
|
59
|
+
{ id: 'note', title: 'New note', also: 'write capture', icon: 'doc', run: lazy('./premium-vw-open.js', (M) => M.newNote(ctx.ws || '')) },
|
|
60
|
+
...SECTIONS.map(([k, l]) => ({ id: 'settings:' + k, title: 'Settings › ' + l, also: SECTION_ALSO[k] || '', icon: 'settings', run: lazy('./cozy-settings.js', (M) => M.openSettings(k)) })),
|
|
61
|
+
...[['light', 'Light theme'], ['dark', 'Dark theme'], ['auto', 'Theme follows the computer']].map(([k, l]) => ({ id: 'theme:' + k, title: l, also: 'theme appearance colour color', icon: 'theme', run: () => (ctx.setTheme ? ctx.setTheme(k) : null) })),
|
|
62
|
+
];
|
|
63
|
+
return A.filter((a) => (a.id !== 'chat' || ctx.chat) && (!a.id.startsWith('theme:') || ctx.setTheme) && matches(q, a.title, a.also))
|
|
64
|
+
.map((a) => ({ id: 'act:' + a.id, title: a.title, sub: 'Action', icon: a.icon, open: pick('palette-action', a.run) }))
|
|
65
|
+
.sort(byName(q));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const short = (s, n = 60) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
|
|
69
|
+
function itemRows(q, ctx) {
|
|
70
|
+
if (!ctx.item) return [];
|
|
71
|
+
const out = [];
|
|
72
|
+
for (const k of KEYS) {
|
|
73
|
+
let el = null; try { el = targetOf(k.act, ctx.item, ctx.doc); } catch { el = null; }
|
|
74
|
+
if (!el) continue;
|
|
75
|
+
const said = short(wordsOf(el));
|
|
76
|
+
if (!matches(q, k.say, said, ITEM_ALSO[k.act])) continue;
|
|
77
|
+
out.push({ id: 'item:' + k.act, title: k.say, sub: said, tag: k.key.toUpperCase(), icon: 'check', open: pick('palette-item', () => el.click()) });
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The groups for a query: On this item, Go to, Do; a group with no row is left out. */
|
|
83
|
+
export function paletteGroups(q, ctx = {}) {
|
|
84
|
+
const s = String(q || '').trim();
|
|
85
|
+
if (s.length < 2) return [];
|
|
86
|
+
return [['On this item', itemRows(s, ctx)], ['Go to', pageRows(s, ctx).slice(0, 6)], ['Do', actionRows(s, ctx).slice(0, 6)]]
|
|
87
|
+
.filter(([, rows]) => rows.length).map(([label, rows]) => ({ label, rows }));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A Search scope: the page's own groups first (a page scope that throws gives none), then the palette's. */
|
|
91
|
+
export function withEverything(scope, ctx = {}) {
|
|
92
|
+
const own = scope && typeof scope.hits === 'function' ? scope : null;
|
|
93
|
+
return {
|
|
94
|
+
name: own ? own.name : 'pages and actions',
|
|
95
|
+
hits(q) {
|
|
96
|
+
let mine = [];
|
|
97
|
+
if (own) { try { mine = own.hits(q) || []; } catch { mine = []; } }
|
|
98
|
+
return mine.concat(paletteGroups(q, ctx));
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* pm/pinned-views.css — pinned filter views beside the product switcher (bet A395, initiative pinned-filter-views; pm/pinned-views.js).
|
|
2
|
+
* Design-system parts carry the look (pm-chip, pm-btn, pm-sug); this places them. Tokens only. */
|
|
3
|
+
.pvw-host:empty { display: none; }
|
|
4
|
+
.pvw { display: inline-flex; align-items: center; gap: var(--space-4); overflow-x: auto; scrollbar-width: none; max-width: 48vw; }
|
|
5
|
+
.pvw::-webkit-scrollbar { display: none; }
|
|
6
|
+
.pvw-i { display: inline-flex; align-items: center; flex: none; }
|
|
7
|
+
.pvw-b { border: 0; cursor: pointer; color: var(--cz-ink); white-space: nowrap; }
|
|
8
|
+
.pvw-b:focus-visible { background: var(--cz-bluebg); }
|
|
9
|
+
.pvw-b[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blue); }
|
|
10
|
+
.pvw-x { all: unset; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--radius-pill); color: var(--cz-ink3); cursor: pointer; }
|
|
11
|
+
.pvw-x:focus-visible { background: var(--cz-well); }
|
|
12
|
+
.pvw-pin { margin-left: var(--space-4); }
|
|
13
|
+
.pvw-sug { margin: var(--space-8) 0; }
|
|
14
|
+
@media (hover: hover) {
|
|
15
|
+
.pvw-b:hover { background: var(--cz-bluebg); }
|
|
16
|
+
.pvw-x:hover { background: var(--cz-well); }
|
|
17
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* pm/pinned-views.js — pin a filter as a view beside the product switcher (bet A395, initiative pinned-filter-views; done test
|
|
2
|
+
* planning/done-tests/pinned-filter-views.md). Work's filter (pm/bd-work.js: its facets and Find's words) is kept as a view, pinned as a chip
|
|
3
|
+
* after the product switcher, and opened again with one press. The third time the same filter is settled, PMOS proposes to pin it.
|
|
4
|
+
*
|
|
5
|
+
* sigOf(state) → string PURE. One signature per filter, whatever order its values were turned on in; '' for an empty filter.
|
|
6
|
+
* stateOf(facets, q) → state PURE. { f: { <facet>: [values on] }, q } from bd-work.js facetsOf(...) and query().
|
|
7
|
+
* nameOf(state) → string PURE. What the view shows in the Filter menu's own words, at most 40 characters.
|
|
8
|
+
* readPins(store) / writePins(store, pins) the pins in the page store (premium-shell.js store); junk or a throwing store reads as []
|
|
9
|
+
* pin(pins, state, now) / unpin(pins, id) PURE. A new list: a filter is pinned once, at most MAX, the oldest goes.
|
|
10
|
+
* apply(state, W) clears W's filter, then turns on exactly the view's values and words (W: bd-work.js's own setters)
|
|
11
|
+
* noteUse(store, state, pins) → boolean counts a settled filter; true on its third use when it is not pinned and was not refused
|
|
12
|
+
* dismiss(store, sig) No on the proposal: PMOS never proposes that filter again
|
|
13
|
+
* pinsHtml(pins, curSig) · pinBtnHtml(on) · sugHtml(name) PURE markup, design-system parts only (pm-chip, pm-btn, pm-sug, pm-ic)
|
|
14
|
+
*
|
|
15
|
+
* The pins (KEY, under pmos.board.) are a view choice, so lib/prefs-sync.js lets them follow the person to another browser; the use counter (USE_KEY) stays here.
|
|
16
|
+
* Each open is a press of a button whose first data attribute is data-pvw, so the local use log (pm/use-log.js) counts it: the health
|
|
17
|
+
* number is `node workspace/lib/pinned-views.js count`. Log lines say [pinned-views]. Nothing here names a product. */
|
|
18
|
+
|
|
19
|
+
export const KEY = 'pmos.board.pins';
|
|
20
|
+
export const USE_KEY = 'pmos.pinuse'; // outside pmos.board., so it stays in this browser
|
|
21
|
+
export const MAX = 8;
|
|
22
|
+
const MAX_NAME = 40;
|
|
23
|
+
const PROPOSE_AT = 3;
|
|
24
|
+
const MAX_USES = 50; // the counter keeps the most recent filters only
|
|
25
|
+
|
|
26
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
27
|
+
const NEED = { you: 'Waits on you', late: 'Late', risk: 'At risk', blocked: 'Blocked' };
|
|
28
|
+
// the order a name reads in: what the rows need and where they are, then whose they are, then the words
|
|
29
|
+
const ORDER = ['need', 'stage', 'status', 'sprint', 'product', 'program', 'owner', 'origin'];
|
|
30
|
+
const log = (msg) => { try { console.info('[pinned-views] ' + msg); } catch { /* no console */ } };
|
|
31
|
+
|
|
32
|
+
function clean(state) {
|
|
33
|
+
const f = {}, src = (state && state.f) || {};
|
|
34
|
+
for (const k of Object.keys(src).sort()) {
|
|
35
|
+
const vals = [...new Set((Array.isArray(src[k]) ? src[k] : []).map(String))].sort();
|
|
36
|
+
if (vals.length) f[k] = vals;
|
|
37
|
+
}
|
|
38
|
+
return { f, q: String((state && state.q) || '').trim() };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function sigOf(state) {
|
|
42
|
+
if (!state) return '';
|
|
43
|
+
const c = clean(state);
|
|
44
|
+
return Object.keys(c.f).length || c.q ? JSON.stringify(c) : '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function stateOf(facets, q) {
|
|
48
|
+
const f = {};
|
|
49
|
+
for (const x of facets || []) { const on = (x.vals || []).filter((v) => v.on).map((v) => String(v.v)); if (on.length) f[x.k] = on; }
|
|
50
|
+
return { f, q: String(q || '').trim() };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function nameOf(state) {
|
|
54
|
+
const c = clean(state), keys = [...ORDER.filter((k) => c.f[k]), ...Object.keys(c.f).filter((k) => !ORDER.includes(k))];
|
|
55
|
+
const NK = Object.keys(NEED), needPos = (v) => (NK.includes(v) ? NK.indexOf(v) : NK.length);
|
|
56
|
+
const parts = keys.map((k) => (k === 'need' ? c.f[k].slice().sort((a, b) => needPos(a) - needPos(b)).map((v) => NEED[v] || v) : c.f[k]).join(', '));
|
|
57
|
+
if (c.q) parts.push('“' + c.q + '”');
|
|
58
|
+
const s = parts.join(' · ') || 'View';
|
|
59
|
+
return s.length > MAX_NAME ? s.slice(0, MAX_NAME - 1).trimEnd() + '…' : s;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function readJson(store, key, fallback) {
|
|
63
|
+
try { const v = JSON.parse(store.get(key) || 'null'); return v == null ? fallback : v; } catch { return fallback; }
|
|
64
|
+
}
|
|
65
|
+
function writeJson(store, key, v) { try { store.set(key, JSON.stringify(v)); } catch { /* no storage: the view lives for this page */ } }
|
|
66
|
+
|
|
67
|
+
const isPin = (p) => p && typeof p === 'object' && typeof p.id === 'string' && typeof p.name === 'string' && typeof p.sig === 'string' && p.sig && p.state && typeof p.state === 'object';
|
|
68
|
+
export function readPins(store) { const v = readJson(store, KEY, []); return Array.isArray(v) ? v.filter(isPin).slice(-MAX) : []; }
|
|
69
|
+
export function writePins(store, pins) { writeJson(store, KEY, pins); }
|
|
70
|
+
|
|
71
|
+
export function pin(pins, state, now = Date.now()) {
|
|
72
|
+
const sig = sigOf(state); if (!sig) return pins.slice();
|
|
73
|
+
if (pins.some((p) => p.sig === sig)) return pins.slice();
|
|
74
|
+
const c = clean(state);
|
|
75
|
+
return [...pins, { id: 'v' + Number(now).toString(36) + pins.length, name: nameOf(c), sig, state: c, at: new Date(now).toISOString() }].slice(-MAX);
|
|
76
|
+
}
|
|
77
|
+
export const unpin = (pins, id) => pins.filter((p) => p.id !== id);
|
|
78
|
+
|
|
79
|
+
export function apply(state, W) {
|
|
80
|
+
const c = clean(state);
|
|
81
|
+
W.clearFilter();
|
|
82
|
+
for (const k of Object.keys(c.f)) for (const v of c.f[k]) W.setFilter(k, v);
|
|
83
|
+
W.setQuery(c.q);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function noteUse(store, state, pins) {
|
|
87
|
+
const sig = sigOf(state); if (!sig) return false;
|
|
88
|
+
if ((pins || []).some((p) => p.sig === sig)) return false;
|
|
89
|
+
const U = readJson(store, USE_KEY, {}); if (!U || typeof U !== 'object' || Array.isArray(U)) return false;
|
|
90
|
+
const no = Array.isArray(U.no) ? U.no : [], n = (U.n && typeof U.n === 'object') ? U.n : {};
|
|
91
|
+
if (no.includes(sig)) return false;
|
|
92
|
+
n[sig] = (Number(n[sig]) || 0) + 1;
|
|
93
|
+
const keep = Object.fromEntries(Object.entries(n).slice(-MAX_USES));
|
|
94
|
+
writeJson(store, USE_KEY, { n: keep, no });
|
|
95
|
+
return n[sig] === PROPOSE_AT;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function dismiss(store, sig) {
|
|
99
|
+
const U = readJson(store, USE_KEY, {}), no = Array.isArray(U && U.no) ? U.no : [], n = (U && U.n && typeof U.n === 'object') ? U.n : {};
|
|
100
|
+
if (sig && !no.includes(sig)) no.push(sig);
|
|
101
|
+
writeJson(store, USE_KEY, { n, no: no.slice(-MAX_USES) });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* ── markup: design-system parts only ── */
|
|
105
|
+
const icon = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
106
|
+
const PIN = 'M9 4h6l-1 6 3 3v2H7v-2l3-3zM12 15v5';
|
|
107
|
+
const X = 'M7 7l10 10M17 7L7 17';
|
|
108
|
+
const YES = 'M5 12.5l4.5 4.5L19 7.5';
|
|
109
|
+
const STAR = '<svg class="pm-ic pm-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z"/></svg>';
|
|
110
|
+
|
|
111
|
+
export function pinsHtml(pins, curSig) {
|
|
112
|
+
if (!pins || !pins.length) return '';
|
|
113
|
+
const items = pins.map((p) => `<span class="pvw-i"><button type="button" data-pvw="${esc(p.id)}" class="pm-chip pvw-b" aria-pressed="${p.sig === curSig}" title="${esc('Open the view: ' + p.name)}">${esc(p.name)}</button>`
|
|
114
|
+
+ `<button type="button" data-pvwx="${esc(p.id)}" class="pvw-x" aria-label="${esc('Unpin ' + p.name)}" title="${esc('Unpin ' + p.name)}">${icon(X)}</button></span>`).join('');
|
|
115
|
+
return `<div class="pvw" role="group" aria-label="Pinned views">${items}</div>`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function pinBtnHtml(on) {
|
|
119
|
+
const say = on ? 'This view is pinned' : 'Pin this filter as a view';
|
|
120
|
+
return `<button type="button" data-pvwpin class="pm-btn ghost pvw-pin" aria-pressed="${!!on}" aria-label="${say}" title="${say}"${on ? ' disabled' : ''}>${icon(PIN)}</button>`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function sugHtml(name) {
|
|
124
|
+
return `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span title="You used this filter three times.">${STAR}</span>`
|
|
125
|
+
+ `<span class="say">Pin “${esc(name)}” beside the products, so it is one press away?</span>`
|
|
126
|
+
+ `<button type="button" data-pvwsug="yes" class="pm-btn primary" aria-label="Yes, pin it" title="Yes, pin it">${icon(YES)}</button>`
|
|
127
|
+
+ `<button type="button" data-pvwsug="no" class="pm-btn outline" aria-label="No, do not suggest it again" title="No, do not suggest it again">${icon(X)}</button></div>`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const say = log;
|
|
@@ -23,6 +23,7 @@ import { pmPost } from './http.js';
|
|
|
23
23
|
import { followDoc } from './doc-follow.js';
|
|
24
24
|
import { $, $$, esc, store, chatAbout, setPageGaps } from './premium-shell.js';
|
|
25
25
|
import * as PK from './cozy-pick.js';
|
|
26
|
+
import * as PV from './pinned-views.js'; // pin a filter as a view beside the product switcher (bet A395, initiative pinned-filter-views)
|
|
26
27
|
import * as SW from './product-switcher.js'; // the product switcher row beside the chip, on a desktop (bet A381)
|
|
27
28
|
import { productName, whenNames } from './scope-chip.js'; // the products' display names ("IDPF", not "pmos-idpf") // the one product picker Home, Board and Insights share (batch 12 item 5)
|
|
28
29
|
import { mountNav } from './cozy-nav.js';
|
|
@@ -238,8 +239,9 @@ const dotsPick = (P) => (P ? { ...P, products: P.products.map((p) => ({ ...p, ne
|
|
|
238
239
|
function drawPick() {
|
|
239
240
|
const P = shownPick(), host = $('#crumbHost'); if (!host) return;
|
|
240
241
|
const desk = !matchMedia('(max-width: 760px)').matches;
|
|
241
|
-
host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products', names: desk }) + (desk ? SW.switcherHtml(dotsPick(P)) : '') : `<span class="crpg">${esc(M.board.name || 'Board')}</span
|
|
242
|
-
|
|
242
|
+
host.innerHTML = (P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products', names: desk }) + (desk ? SW.switcherHtml(dotsPick(P)) : '') : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`) + '<span id="pvwHost" class="pvw-host"></span>';
|
|
243
|
+
drawPins();
|
|
244
|
+
host.onclick = (e) => { if (pinPress(e)) return; const b = e.target.closest('[data-psw]'); if (!b) return; e.stopPropagation(); SW.press(dotsPick(shownPick()), b.dataset.psw).then((r) => { if (!r.ok) say(r.error); }); };
|
|
243
245
|
if (P && desk && !DOTS) { DOTS = {}; SW.readDots().then((r) => { if (r) { DOTS = Object.fromEntries(r.products.map((p) => [p.ws, p.needs])); drawPick(); } }).catch(() => null); }
|
|
244
246
|
const chip = $('#bdPick'); if (!chip) return;
|
|
245
247
|
// a product's line: its open initiatives on this page (zero is silence)
|
|
@@ -267,6 +269,53 @@ async function resolvePick() {
|
|
|
267
269
|
return true;
|
|
268
270
|
}
|
|
269
271
|
|
|
272
|
+
/* ── pinned views (bet A395, initiative pinned-filter-views; pm/pinned-views.js): Work's filter kept as a view, a chip after the product
|
|
273
|
+
* switcher, one press to open it. The pin button sits on Work's "Showing …" line; the third time the same filter is settled (the Filter menu
|
|
274
|
+
* closes with it on), PMOS proposes to pin it under that line. Work on a desk only: the phone and classic views keep their own chips. ── */
|
|
275
|
+
let PINS = PV.readPins(store), PV_SUG = null; // PV_SUG: the filter PMOS proposes to pin, until Yes or No
|
|
276
|
+
const pvState = () => PV.stateOf(M ? WV.facetsOf(M.initiatives.list.rows || [], { product: wkProduct, programOf: wkProgOf }) : [], WV.query());
|
|
277
|
+
function drawPins() {
|
|
278
|
+
const h = $('#pvwHost'); if (!h) return;
|
|
279
|
+
const on = !!M && workOn() && !ROC, cur = on ? PV.sigOf(pvState()) : '';
|
|
280
|
+
h.innerHTML = on ? PV.pinsHtml(PINS, cur) : '';
|
|
281
|
+
const sh = on && $('#ibBody .wk-showing');
|
|
282
|
+
if (sh && !sh.querySelector('[data-pvwpin]')) sh.insertAdjacentHTML('beforeend', PV.pinBtnHtml(PINS.some((p) => p.sig === cur)));
|
|
283
|
+
const old = $('#ibBody .pvw-sug'); if (old) old.remove();
|
|
284
|
+
if (on && PV_SUG && PV.sigOf(PV_SUG) === cur) { const at = $('#ibBody .wk-showing'); if (at) at.insertAdjacentHTML('afterend', '<div class="pvw-sug">' + PV.sugHtml(PV.nameOf(PV_SUG)) + '</div>'); }
|
|
285
|
+
}
|
|
286
|
+
function pinNow(state) {
|
|
287
|
+
const was = PINS.length; PINS = PV.pin(PINS, state); PV.writePins(store, PINS); PV_SUG = null;
|
|
288
|
+
if (PINS.length !== was || PINS.some((p) => p.sig === PV.sigOf(state))) { PV.say('pinned ' + PINS.length); say('Pinned beside the products.'); }
|
|
289
|
+
drawPins();
|
|
290
|
+
}
|
|
291
|
+
/** A press on a pin, its Unpin, the pin button or the proposal. → true when it was one. */
|
|
292
|
+
function pinPress(e) {
|
|
293
|
+
const t = e.target;
|
|
294
|
+
let b = t.closest('[data-pvw]');
|
|
295
|
+
if (b) { e.stopPropagation(); const p = PINS.find((x) => x.id === b.dataset.pvw); if (!p) return true; PV.apply(p.state, WV); PV.say('opened'); drawInit(); wkCount(); return true; }
|
|
296
|
+
if ((b = t.closest('[data-pvwx]'))) {
|
|
297
|
+
e.stopPropagation(); const gone = PINS.find((x) => x.id === b.dataset.pvwx); if (!gone) return true;
|
|
298
|
+
const before = PINS; PINS = PV.unpin(PINS, gone.id); PV.writePins(store, PINS); PV.say('unpinned ' + PINS.length); drawPins();
|
|
299
|
+
say('Unpinned “' + gone.name + '”.', () => { PINS = before; PV.writePins(store, PINS); drawPins(); say('Pinned again.'); });
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
if (t.closest('[data-pvwpin]')) { e.stopPropagation(); pinNow(pvState()); return true; }
|
|
303
|
+
if ((b = t.closest('[data-pvwsug]'))) {
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
if (b.dataset.pvwsug === 'yes' && PV_SUG) pinNow(PV_SUG);
|
|
306
|
+
else { if (PV_SUG) PV.dismiss(store, PV.sigOf(PV_SUG)); PV.say('proposal refused'); PV_SUG = null; drawPins(); }
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
/** The Filter menu closed: count the filter that is on; on its third use PMOS proposes to pin it. */
|
|
312
|
+
function pinSettled() {
|
|
313
|
+
if (!M || !workOn() || ROC) return;
|
|
314
|
+
const st = pvState();
|
|
315
|
+
if (PV.noteUse(store, st, PINS)) { PV_SUG = st; PV.say('proposed'); drawPins(); } else drawPins();
|
|
316
|
+
}
|
|
317
|
+
$('#ibBody').addEventListener('click', (e) => { if (e.target.closest('[data-pvwpin],[data-pvwsug]')) pinPress(e); }, true);
|
|
318
|
+
|
|
270
319
|
/* ── the toolbar: picker, chips ───────────────────────────────────────────────────────────────────────────────────── */
|
|
271
320
|
let crumbed = false;
|
|
272
321
|
function drawHead() {
|
|
@@ -812,7 +861,7 @@ const wkSel = (el) => {
|
|
|
812
861
|
};
|
|
813
862
|
/** The button the menu opened from, as drawn now: the Initiatives block's Choose columns is drawn again with the list. */
|
|
814
863
|
const wkBtnOf = () => (WK_MENU && $(WK_MENU.__sel)) || WK_MENU.__btn;
|
|
815
|
-
function closeWorkMenu(back) { if (!WK_MENU) return; const b = wkBtnOf(); WK_MENU.remove(); WK_MENU = null; b.setAttribute('aria-expanded', 'false'); b.classList.remove('on'); if (back) b.focus(); }
|
|
864
|
+
function closeWorkMenu(back) { if (!WK_MENU) return; const b = wkBtnOf(); WK_MENU.remove(); WK_MENU = null; b.setAttribute('aria-expanded', 'false'); b.classList.remove('on'); if (back) b.focus(); pinSettled(); }
|
|
816
865
|
function toggleWorkMenu(btn) {
|
|
817
866
|
if (WK_MENU) { closeWorkMenu(true); return; }
|
|
818
867
|
WK_MENU = document.createElement('div'); WK_MENU.__btn = btn; WK_MENU.__sel = btn.matches('[data-wkmenu]') ? '#ibBody [data-wkmenu]' : '#bdFilter'; document.body.appendChild(WK_MENU);
|
|
@@ -884,6 +933,7 @@ function drawInit() {
|
|
|
884
933
|
if (v === 'work' && WK_MENU) { const b = $(WK_MENU.__sel); if (b) { b.setAttribute('aria-expanded', 'true'); b.classList.add('on'); } }
|
|
885
934
|
$('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
|
|
886
935
|
drawViewMenu();
|
|
936
|
+
drawPins();
|
|
887
937
|
document.body.dataset.bdView = v;
|
|
888
938
|
$('#stage').dataset.bdDesk = view; // what fit() measures: the desktop's view, so the narrow form never flips it back and forth
|
|
889
939
|
markOpen();
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
<link rel="stylesheet" href="/pm/komorebi.css" />
|
|
21
21
|
<link rel="stylesheet" href="/pm/ds-bridge.css" />
|
|
22
22
|
<link rel="stylesheet" href="/pm/cozy-pick.css" />
|
|
23
|
+
<link rel="stylesheet" href="/pm/pinned-views.css" />
|
|
23
24
|
<link rel="stylesheet" href="/pm/cozy-board.css" />
|
|
24
25
|
<link rel="stylesheet" href="/pm/changed-mark.css" />
|
|
25
26
|
<link rel="stylesheet" href="/pm/load-shapes.css" />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Ctrl K reaches every page, item and action (bet A315, initiative palette-reaches-everything, done test planning/done-tests/palette-reaches-everything.md P1-P7): the Go to, Do and On this item groups on a small fake page, word-start matching, the page scope wrap, the local use-log health read, and the menu's hook. No server, network or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"palette-all.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"palette-all.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Pin a filter as a view beside the product switcher (bet A395, initiative pinned-filter-views, done test planning/done-tests/pinned-filter-views.md V1-V8): the signature, name, pin and unpin, opening a view, the third-use proposal, the system parts, the health number over a temporary use log, and the view-preferences allowlist. No browser, server or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"pinned-views.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"pinned-views.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "product-health-score: one health score per product from its state ledgers, the daily history, the drop card on Today and pmos health (lib/product-health.js, lib/product-health-cli.js). Temp product folders only.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"product-health.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"product-health.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative search-answers-first (bet A388): Search shows one answer, with its source, above the matches. The pure answer and the route run in node; the row in pm/cozy-search.js has no browser test (TESTS rule: no new browser tests).",
|
|
3
|
+
"modules": [
|
|
4
|
+
"search-answer.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"search-answer.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|