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
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/* pm/premium-library.js — Library, the place (initiative library-place; slice 7 of the six-place navigation, Library round 2).
|
|
2
|
+
*
|
|
3
|
+
* A catalogue of everything that was made, from every product: one record per item with the columns Name, Kind, Product, About, By, State,
|
|
4
|
+
* Updated (pm/library-model.js). One filter row: the Kind chip (families, each opens to its kinds), the product, program and project chip
|
|
5
|
+
* (pm/scope-chip.js, the same control as on Events and Work) and the State chip, each with its counts; when a filter hides rows one grey
|
|
6
|
+
* line says how many, with Show all. The tune button groups the rows by New (default), Work (program and initiative shelves, the work in its
|
|
7
|
+
* order), Kind or Product. Editions fold under the newest; grouped by New, an initiative's gate records fold into one "Checks · N" row.
|
|
8
|
+
* A note with no title shows the name PMOS gave it with ✦ until the PM accepts or renames it; a note with no work offers ✦ the work it
|
|
9
|
+
* talks about. Finding is the main job: the search field always shows (/ puts the cursor in it); a title match is instant, and the items
|
|
10
|
+
* about the question by meaning arrive under it ("Also about this · 6", lib/library-find.js), each with its passage and the idea in bold.
|
|
11
|
+
* On a screen 1600 px or wider a press shows the record at the right (all fields, the first lines, where it is linked from, its editions);
|
|
12
|
+
* a second press or Enter opens it in the one popup with the chat about it (pm/library-open.js). A link opens a new tab.
|
|
13
|
+
* Writes only what the PM accepts: a note's name (POST /api/notes/save) and a note's work (POST /api/notes/link). The group and the Kind
|
|
14
|
+
* and State filters are remembered on this device (localStorage 'pmos.lib.view'). The + asks PMOS to add a file, a link or a document. */
|
|
15
|
+
import './fetch-share.js';
|
|
16
|
+
import { pmGet, pmPost } from './http.js';
|
|
17
|
+
import { mountNav } from './cozy-nav.js';
|
|
18
|
+
import { mountLivePill } from './cozy-live-pill.js';
|
|
19
|
+
import './cozy-viewer.js';
|
|
20
|
+
import './cozy-popup.js'; // the one popup: window.czOpenChat for the rail's chat icon, and the popup a row opens in
|
|
21
|
+
import { readPick } from './cozy-pick.js';
|
|
22
|
+
import { scopeChipHtml, openScope, matches as scopeMatches, narrowed, scopeWords, whenNames } from './scope-chip.js';
|
|
23
|
+
import { COLUMNS, FAMILIES, GROUPS, STATES, view, counts, passes, matches, aboutText, stateText, dayText, when, noteOf, hiddenText } from './library-model.js';
|
|
24
|
+
import { openItem } from './library-open.js';
|
|
25
|
+
|
|
26
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
27
|
+
const svg = (d, cls = '') => `<svg viewBox="0 0 24 24" aria-hidden="true"${cls ? ` class="${cls}"` : ''}><path d="${d}"/></svg>`;
|
|
28
|
+
const ICON = {
|
|
29
|
+
doc: 'M7 4h7l4 4v12H7zM14 4v4h4',
|
|
30
|
+
link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
|
|
31
|
+
meeting: 'M9 6a3 3 0 1 0 0 6a3 3 0 1 0 0-6M3.5 19c.6-3 2.8-4.5 5.5-4.5s4.9 1.5 5.5 4.5M16 6.5a3 3 0 0 1 0 5.5M17.5 14.8c1.7.6 2.7 2 3 4.2',
|
|
32
|
+
proto: 'M4 5h16v12H4zM9 20h6',
|
|
33
|
+
checks: 'M4 6.5l2 2 3.5-3.5M4 13.5l2 2 3.5-3.5M13 7h7M13 14h7M13 19h7',
|
|
34
|
+
};
|
|
35
|
+
const CHEV_D = 'M6 9l6 6 6-6', CHEV_R = 'M9 6l6 6-6 6', TICK = 'M5 12.5l4.5 4.5L19 7.5', X = 'M6 6l12 12M18 6L6 18', PART = 'M7 12h10';
|
|
36
|
+
const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', OPEN = 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5';
|
|
37
|
+
const store = { get(k) { try { return JSON.parse(localStorage.getItem(k) || 'null'); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* a private window */ } } };
|
|
38
|
+
const saved = store.get('pmos.lib.view') || {};
|
|
39
|
+
const S = {
|
|
40
|
+
items: null, programs: [], error: '', at: 0, q: '', P: null, sel: { programs: [], projects: [] },
|
|
41
|
+
kinds: Array.isArray(saved.kinds) ? saved.kinds : [], states: Array.isArray(saved.states) ? saved.states : [],
|
|
42
|
+
group: GROUPS.some(([k]) => k === saved.group) ? saved.group : 'new',
|
|
43
|
+
open: new Set(), shut: new Set(), ed: new Set(), ck: new Set(), naming: null, pick: null, peek: new Map(),
|
|
44
|
+
meaning: null, // { q, results, ranked, why, busy }
|
|
45
|
+
shown: [],
|
|
46
|
+
};
|
|
47
|
+
const remember = () => store.set('pmos.lib.view', { kinds: S.kinds, states: S.states, group: S.group });
|
|
48
|
+
const wide = () => typeof matchMedia === 'function' && matchMedia('(min-width: 1600px)').matches;
|
|
49
|
+
|
|
50
|
+
mountNav('library', document, { scope: () => ({ name: 'Library', hits: (q) => libHits(q) }) });
|
|
51
|
+
mountLivePill();
|
|
52
|
+
|
|
53
|
+
const $ = (id) => document.getElementById(id);
|
|
54
|
+
const filters = $('lbFilters'), body = $('lbBody'), note = $('lbNote'), qBox = $('lbQ'), hid = $('lbHid'), pv = $('lbPv');
|
|
55
|
+
|
|
56
|
+
/* ── the filters ── */
|
|
57
|
+
const F = () => ({ kinds: S.kinds, states: S.states, scope: (tokens) => scopeMatches(tokens, S.P, S.sel) });
|
|
58
|
+
function scopeGroups() {
|
|
59
|
+
const byProg = new Map(), byIni = new Map();
|
|
60
|
+
for (const x of S.items || []) {
|
|
61
|
+
const a = x.about || {};
|
|
62
|
+
if (a.program) byProg.set(a.program, (byProg.get(a.program) || 0) + 1);
|
|
63
|
+
if (a.ws && a.ini) { const k = 'j:' + a.ws + '|' + a.ini; const r = byIni.get(k) || { id: k, name: a.title || a.ini, product: a.product, n: 0 }; r.n++; byIni.set(k, r); }
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
programs: S.programs.filter((g) => byProg.has(g.id)).map((g) => ({ id: 'g:' + g.id, name: g.title, n: byProg.get(g.id) })),
|
|
67
|
+
projects: [...byIni.values()].sort((a, b) => a.name.localeCompare(b.name)),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const chip = (id, label, on, n) => `<span class="lb-cw"><button type="button" class="ppk-chip lb-chip${on ? ' on' : ''}" id="${id}" aria-haspopup="menu" aria-expanded="false"><span class="ppk-all ppk-nmc">${esc(label)}${n ? ` <em>${n}</em>` : ''}</span>${svg(CHEV_D)}</button></span>`;
|
|
71
|
+
function kindLabel() {
|
|
72
|
+
if (!S.kinds.length) return 'Every kind';
|
|
73
|
+
const names = S.kinds.map((k) => (k.startsWith('f:') ? (FAMILIES.find(([f]) => 'f:' + f === k) || [, k.slice(2)])[1] : k.slice(2)));
|
|
74
|
+
return names[0] + (names.length > 1 ? ` +${names.length - 1}` : '');
|
|
75
|
+
}
|
|
76
|
+
const stateLabel = () => (!S.states.length ? 'Any state' : S.states[0] + (S.states.length > 1 ? ` +${S.states.length - 1}` : ''));
|
|
77
|
+
function drawFilters() {
|
|
78
|
+
filters.innerHTML = chip('lbKind', kindLabel(), S.kinds.length > 0)
|
|
79
|
+
+ scopeChipHtml(S.P, S.sel, { id: 'lbScope', groups: scopeGroups() })
|
|
80
|
+
+ chip('lbState', stateLabel(), S.states.length > 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ── a menu under a chip: one at a time (the Kind, State and Group by menus; the scope chip has its own) ── */
|
|
84
|
+
let menu = null; // { id, el, draw, press }
|
|
85
|
+
function closeMenu() {
|
|
86
|
+
if (!menu) return;
|
|
87
|
+
const m = menu; menu = null;
|
|
88
|
+
m.el.remove(); document.removeEventListener('click', outMenu, true); removeEventListener('keydown', keyMenu, true);
|
|
89
|
+
const c = $(m.id); if (c) { c.setAttribute('aria-expanded', 'false'); c.classList.remove('open'); c.focus(); }
|
|
90
|
+
}
|
|
91
|
+
function outMenu(e) { if (menu && !menu.el.contains(e.target) && !($(menu.id) || document.body).contains(e.target)) closeMenu(); }
|
|
92
|
+
function keyMenu(e) {
|
|
93
|
+
if (!menu) return;
|
|
94
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopImmediatePropagation(); closeMenu(); return; }
|
|
95
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
const L = [...menu.el.querySelectorAll('button')], i = L.indexOf(document.activeElement);
|
|
98
|
+
if (L.length) L[(i + (e.key === 'ArrowDown' ? 1 : L.length - 1)) % L.length].focus();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function openMenu(id, draw, press, cls = '') {
|
|
102
|
+
if (menu && menu.id === id) { closeMenu(); return; }
|
|
103
|
+
closeMenu();
|
|
104
|
+
const c = $(id); if (!c) return;
|
|
105
|
+
const el = document.createElement('div');
|
|
106
|
+
el.className = 'ppk-menu lb-menu ' + cls; el.setAttribute('role', 'menu'); el.setAttribute('data-esc-layer', '');
|
|
107
|
+
// the menu stands under its chip inside the chip's own wrapper (CSS places it; nothing is written into a style)
|
|
108
|
+
(c.closest('.lb-cw') || document.body).append(el);
|
|
109
|
+
menu = { id, el, draw, press };
|
|
110
|
+
const paint = (focus) => { el.innerHTML = draw(); const f = (focus && el.querySelector(focus)) || el.querySelector('button'); if (f) f.focus(); };
|
|
111
|
+
paint();
|
|
112
|
+
c.setAttribute('aria-expanded', 'true'); c.classList.add('open');
|
|
113
|
+
el.onclick = (e) => { e.stopPropagation(); const b = e.target.closest('button'); if (!b) return; const f = press(b); if (f !== false) paint(f); };
|
|
114
|
+
addEventListener('keydown', keyMenu, true);
|
|
115
|
+
setTimeout(() => document.addEventListener('click', outMenu, true), 0);
|
|
116
|
+
}
|
|
117
|
+
const box = (st) => `<i class="ppk-tk${st === 'true' ? ' on' : st === 'mixed' ? ' part' : ''}" aria-hidden="true">${st === 'true' ? svg(TICK) : st === 'mixed' ? svg(PART) : ''}</i>`;
|
|
118
|
+
const famOpen = new Set();
|
|
119
|
+
function kindMenu() {
|
|
120
|
+
const C = counts(S.items, F());
|
|
121
|
+
const kindsOf = (fam) => Object.keys(C.kinds).filter((k) => (S.items || []).some((x) => x.family === fam && x.kindText === k)).sort();
|
|
122
|
+
let h = '<p class="scp-h" role="presentation">Kind</p>';
|
|
123
|
+
for (const [f, name] of FAMILIES) {
|
|
124
|
+
const n = C.families[f] || 0; if (!n) continue;
|
|
125
|
+
const K = kindsOf(f), on = S.kinds.includes('f:' + f), some = !on && K.some((k) => S.kinds.includes('k:' + k));
|
|
126
|
+
const st = on ? 'true' : some ? 'mixed' : 'false';
|
|
127
|
+
h += `<div class="lb-fam"><button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${st}" data-lk-f="${f}"><span class="ppk-nm"><b>${esc(name)}</b><em>${n}</em></span>${box(st)}</button>`
|
|
128
|
+
+ (K.length > 1 ? `<button type="button" class="lb-fx" data-lk-x="${f}" aria-expanded="${famOpen.has(f)}" aria-label="${esc(name)}: each kind">${svg(famOpen.has(f) ? CHEV_D : CHEV_R)}</button>` : '<span class="lb-fx" aria-hidden="true"></span>') + '</div>';
|
|
129
|
+
if (famOpen.has(f) && K.length > 1) for (const k of K) {
|
|
130
|
+
const kon = on || S.kinds.includes('k:' + k);
|
|
131
|
+
h += `<button type="button" class="ppk-mi lb-kmi" role="menuitemcheckbox" aria-checked="${kon}" data-lk-k="${esc(k)}" data-lk-of="${f}"><span class="ppk-nm"><b>${esc(k)}</b><em>${C.kinds[k] || 0}</em></span>${box(String(kon))}</button>`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (S.kinds.length) h += '<div class="ppk-sep" role="separator"></div><button type="button" class="ppk-mi" role="menuitem" data-lk-clear><span class="ppk-nm"><b>Every kind</b></span></button>';
|
|
135
|
+
return h;
|
|
136
|
+
}
|
|
137
|
+
function kindPress(b) {
|
|
138
|
+
if (b.dataset.lkX) { const f = b.dataset.lkX; if (famOpen.has(f)) famOpen.delete(f); else famOpen.add(f); return `[data-lk-x="${f}"]`; }
|
|
139
|
+
if (b.matches('[data-lk-clear]')) S.kinds = [];
|
|
140
|
+
else if (b.dataset.lkF) {
|
|
141
|
+
const f = b.dataset.lkF, K = new Set((S.items || []).filter((x) => x.family === f).map((x) => 'k:' + x.kindText));
|
|
142
|
+
const on = S.kinds.includes('f:' + f);
|
|
143
|
+
S.kinds = S.kinds.filter((k) => k !== 'f:' + f && !K.has(k));
|
|
144
|
+
if (!on) S.kinds.push('f:' + f);
|
|
145
|
+
} else if (b.dataset.lkK) {
|
|
146
|
+
const k = 'k:' + b.dataset.lkK, f = b.dataset.lkOf;
|
|
147
|
+
if (S.kinds.includes('f:' + f)) {
|
|
148
|
+
// the family was on: every kind of it but this one
|
|
149
|
+
const K = [...new Set((S.items || []).filter((x) => x.family === f).map((x) => 'k:' + x.kindText))];
|
|
150
|
+
S.kinds = S.kinds.filter((x) => x !== 'f:' + f).concat(K.filter((x) => x !== k));
|
|
151
|
+
} else if (S.kinds.includes(k)) S.kinds = S.kinds.filter((x) => x !== k);
|
|
152
|
+
else S.kinds.push(k);
|
|
153
|
+
} else return false;
|
|
154
|
+
remember(); drawFilters(); draw();
|
|
155
|
+
return b.dataset.lkF ? `[data-lk-f="${b.dataset.lkF}"]` : b.dataset.lkK ? `[data-lk-k="${CSS.escape(b.dataset.lkK)}"]` : null;
|
|
156
|
+
}
|
|
157
|
+
function stateMenu() {
|
|
158
|
+
const C = counts(S.items, F());
|
|
159
|
+
let h = '<p class="scp-h" role="presentation">State</p>';
|
|
160
|
+
for (const s of STATES) { const on = S.states.includes(s); h += `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-ls="${s}"><span class="ppk-nm"><b>${s}</b><em>${C.states[s] || 0}</em></span>${box(String(on))}</button>`; }
|
|
161
|
+
if (S.states.length) h += '<div class="ppk-sep" role="separator"></div><button type="button" class="ppk-mi" role="menuitem" data-ls-clear><span class="ppk-nm"><b>Any state</b></span></button>';
|
|
162
|
+
return h;
|
|
163
|
+
}
|
|
164
|
+
function statePress(b) {
|
|
165
|
+
if (b.matches('[data-ls-clear]')) S.states = [];
|
|
166
|
+
else if (b.dataset.ls) { const s = b.dataset.ls; S.states = S.states.includes(s) ? S.states.filter((x) => x !== s) : S.states.concat(s); }
|
|
167
|
+
else return false;
|
|
168
|
+
remember(); drawFilters(); draw();
|
|
169
|
+
return b.dataset.ls ? `[data-ls="${b.dataset.ls}"]` : null;
|
|
170
|
+
}
|
|
171
|
+
const groupMenu = () => `<p class="scp-h" role="presentation">Group by</p><div class="lb-pl" role="radiogroup" aria-label="Group by">${GROUPS.map(([k, n]) => `<button type="button" role="radio" aria-checked="${k === S.group}" class="${k === S.group ? 'on' : ''}" data-lg="${k}">${esc(n)}</button>`).join('')}</div>`;
|
|
172
|
+
function groupPress(b) { if (!b.dataset.lg) return false; S.group = b.dataset.lg; remember(); draw(); return `[data-lg="${S.group}"]`; }
|
|
173
|
+
|
|
174
|
+
/* ── the table ── */
|
|
175
|
+
const head = () => `<div class="lb-r lb-h" role="row"><span role="columnheader"><span class="vh">Kind of item</span></span>${COLUMNS.map((c) => `<span role="columnheader">${c}</span>`).join('')}</div>`;
|
|
176
|
+
function nameCell(x, extra = '') {
|
|
177
|
+
if (S.naming === x.id) {
|
|
178
|
+
return `<span class="n lb-nm" role="cell"><input id="lbNameIn" value="${esc(x.name)}" aria-label="The note's name" maxlength="120" />`
|
|
179
|
+
+ `<button type="button" class="lb-ib" data-lb-name-ok aria-label="Keep this name" title="Keep this name">${svg(TICK)}</button>`
|
|
180
|
+
+ `<button type="button" class="lb-ib" data-lb-name-no aria-label="Cancel" title="Cancel">${svg(X)}</button></span>`;
|
|
181
|
+
}
|
|
182
|
+
const spark = x.named ? `<button type="button" class="lb-ib lb-sp" data-lb-name="${esc(x.id)}" aria-label="PMOS named this note. Keep the name or rename it" title="PMOS named this note: keep or rename">${svg(SPARK)}</button>` : '';
|
|
183
|
+
return `<span class="n" role="cell"><button type="button" class="lb-nb" data-lb-open>${esc(x.name)}</button>${spark}${extra}</span>`;
|
|
184
|
+
}
|
|
185
|
+
function aboutCell(x) {
|
|
186
|
+
const a = aboutText(x);
|
|
187
|
+
if (!a && x.kind === 'meeting' && x.suggest) {
|
|
188
|
+
return `<span class="c" role="cell"><button type="button" class="lb-sg" data-lb-link="${esc(x.id)}" title="PMOS suggests: this note is about ${esc(x.suggest.title)}. Press to link it">${svg(SPARK)}<span>${esc(x.suggest.title)}</span></button></span>`;
|
|
189
|
+
}
|
|
190
|
+
return `<span class="c" role="cell" title="${esc(a)}">${esc(a)}</span>`;
|
|
191
|
+
}
|
|
192
|
+
function rowHtml(r, i, sub = false, shelf = '') {
|
|
193
|
+
const x = r.x;
|
|
194
|
+
// on a Work shelf, a name that only repeats the shelf's says its Kind instead, and About (which the shelf already says) is quiet
|
|
195
|
+
const same = !!shelf && (bare(x.name) === bare(shelf) || (bare(shelf).length >= 4 && bare(x.name).startsWith(bare(shelf))));
|
|
196
|
+
const older = r.older && r.older.length ? `<button type="button" class="lb-old" data-lb-ed="${esc(x.id)}" aria-expanded="${S.ed.has(x.id)}">${r.older.length} earlier</button>` : '';
|
|
197
|
+
const label = `${x.name}${x.state ? ', ' + x.state : ''}. ${x.kindText}${aboutText(x) ? '. About ' + aboutText(x) : ''}${x.open && x.open.url ? '. Opens in a new tab' : ''}`;
|
|
198
|
+
return `<div class="lb-r lb-i${sub ? ' sub' : ''}${S.pick === x.id ? ' on' : ''}" role="row" data-lb-i="${i}" aria-label="${esc(label)}">`
|
|
199
|
+
+ `<span class="ic" role="cell">${svg(ICON[x.kind] || ICON.doc)}</span>${nameCell(same ? { ...x, name: x.kindText } : x, older)}`
|
|
200
|
+
+ `<span class="c" role="cell">${same ? '' : esc(x.kindText)}</span><span class="c" role="cell">${esc(x.product || '')}</span>${shelf ? '<span class="c" role="cell"></span>' : aboutCell(x)}`
|
|
201
|
+
+ `<span class="c" role="cell">${esc(x.by || '')}</span><span class="c q" role="cell">${esc(stateText(r))}</span>`
|
|
202
|
+
+ `<span class="c" role="cell">${esc(dayText(when(x)))}</span></div>`;
|
|
203
|
+
}
|
|
204
|
+
function checksHtml(r) {
|
|
205
|
+
const open = S.ck.has(r.key), a = r.about || {};
|
|
206
|
+
const newest = r.checks.reduce((m, x) => (String(when(x)) > String(when(m)) ? x : m), r.checks[0]);
|
|
207
|
+
let h = `<div class="lb-r lb-i lb-ck" role="row"><span class="ic" role="cell">${svg(ICON.checks)}</span>`
|
|
208
|
+
+ `<span class="n" role="cell"><button type="button" class="lb-nb" data-lb-ck="${esc(r.key)}" aria-expanded="${open}">Checks · ${r.checks.length}</button></span>`
|
|
209
|
+
+ `<span class="c" role="cell">${esc([...new Set(r.checks.map((x) => x.kindText))].join(', '))}</span><span class="c" role="cell">${esc(a.product || '')}</span>`
|
|
210
|
+
+ `<span class="c" role="cell">${esc([a.programTitle, a.title].filter(Boolean).join(' › '))}</span><span class="c" role="cell">PMOS</span><span class="c" role="cell"></span>`
|
|
211
|
+
+ `<span class="c" role="cell">${esc(dayText(when(newest)))}</span></div>`;
|
|
212
|
+
if (open) for (const x of r.checks) { h += rowHtml({ x, older: [] }, S.shown.length, true); S.shown.push(x); }
|
|
213
|
+
return h;
|
|
214
|
+
}
|
|
215
|
+
function tableHtml(groups) {
|
|
216
|
+
let h = `<div class="lb-t" role="table" aria-label="Library">${head()}`;
|
|
217
|
+
for (const g of groups) {
|
|
218
|
+
if (g.level === 2) {
|
|
219
|
+
h += `<div class="lb-r lb-g lb-s" role="row"><button type="button" role="rowheader" data-lb-fold="${esc(g.key)}" aria-expanded="${!g.folded}">${svg(g.folded ? CHEV_R : CHEV_D)}<b>${esc(g.label)}</b><em>${g.n}</em></button></div>`;
|
|
220
|
+
if (g.folded) continue;
|
|
221
|
+
} else h += `<div class="lb-r lb-g" role="row"><div role="rowheader">${esc(g.label)}${S.group === 'work' ? ` <em>${g.n}</em>` : ''}</div></div>`;
|
|
222
|
+
const shelf = g.level === 2 && g.key !== 'w:none' ? g.label : '';
|
|
223
|
+
for (const r of g.rows) {
|
|
224
|
+
if (r.checks) { h += checksHtml(r); continue; }
|
|
225
|
+
h += rowHtml(r, S.shown.length, false, shelf); S.shown.push(r.x);
|
|
226
|
+
if (r.older.length && S.ed.has(r.x.id)) for (const o of r.older) { h += rowHtml({ x: o, older: [] }, S.shown.length, true, shelf); S.shown.push(o); }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return h + '</div>';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* ── search by meaning ── */
|
|
233
|
+
const bare = (s) => String(s || '').toLowerCase().replace(/…$/, '').replace(/[^a-z0-9]+/g, ' ').trim();
|
|
234
|
+
const reEsc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
235
|
+
function bolded(passage, idea, words) {
|
|
236
|
+
const t = esc(passage);
|
|
237
|
+
if (idea) { const i = passage.toLowerCase().indexOf(idea.toLowerCase()); if (i >= 0) return esc(passage.slice(0, i)) + '<b>' + esc(passage.slice(i, i + idea.length)) + '</b>' + esc(passage.slice(i + idea.length)); }
|
|
238
|
+
if (!words || !words.length) return t;
|
|
239
|
+
return t.replace(new RegExp('\\b(' + words.map(reEsc).join('|') + ')[a-z]*', 'gi'), '<b>$&</b>');
|
|
240
|
+
}
|
|
241
|
+
function meaningHtml(titled) {
|
|
242
|
+
const M = S.meaning;
|
|
243
|
+
if (!M || M.q !== S.q) return '';
|
|
244
|
+
const byId = new Map((S.items || []).map((x) => [x.id, x]));
|
|
245
|
+
const seen = new Set(titled);
|
|
246
|
+
const list = (M.results || []).map((r) => ({ ...r, x: byId.get(r.id) })).filter((r) => r.x && !seen.has(r.id) && passes(r.x, F()));
|
|
247
|
+
const line = M.busy ? 'PMOS is reading them for meaning…' : !M.ranked && M.why ? 'Ranked by shared words: ' + M.why + '.' : '';
|
|
248
|
+
if (!list.length) return M.busy && !M.results ? `<p class="lb-mq">${esc(line || 'PMOS is reading for meaning…')}</p>` : '';
|
|
249
|
+
let h = `<h2 class="lb-mh">${titled.length ? 'Also about this' : 'About this'} <em>${list.length}</em></h2>${line ? `<p class="lb-mq">${esc(line)}</p>` : ''}<div class="lb-t lb-m" role="list">`;
|
|
250
|
+
for (const r of list) {
|
|
251
|
+
const x = r.x, i = S.shown.length; S.shown.push(x);
|
|
252
|
+
h += `<div class="lb-mr" role="listitem" data-lb-i="${i}"><span class="ic">${svg(ICON[x.kind] || ICON.doc)}</span><div><button type="button" class="lb-nb" data-lb-open>${esc(x.name)}</button>`
|
|
253
|
+
+ `<small>${esc([x.kindText, x.product, aboutText(x)].filter(Boolean).join(' · '))}</small><p>${bolded(r.passage || '', r.idea, r.words)}</p></div></div>`;
|
|
254
|
+
}
|
|
255
|
+
return h + '</div>';
|
|
256
|
+
}
|
|
257
|
+
let findT = null, findN = 0;
|
|
258
|
+
function findByMeaning() {
|
|
259
|
+
clearTimeout(findT);
|
|
260
|
+
const q = S.q;
|
|
261
|
+
if (q.replace(/\s+/g, '').length < 3) { S.meaning = null; return; }
|
|
262
|
+
findT = setTimeout(async () => {
|
|
263
|
+
const n = ++findN;
|
|
264
|
+
S.meaning = { q, results: null, ranked: false, busy: true }; draw();
|
|
265
|
+
const on = S.P && S.P.products ? S.P.products.filter((p) => p.on).map((p) => p.ws) : [];
|
|
266
|
+
const ws = on.length && S.P.products.some((p) => !p.on) ? '&ws=' + encodeURIComponent(on.join(',')) : '';
|
|
267
|
+
const w = await pmGet('/api/library-items/find?q=' + encodeURIComponent(q) + ws).catch(() => null);
|
|
268
|
+
if (n !== findN) return;
|
|
269
|
+
S.meaning = { q, results: (w && w.ok && w.results) || [], ranked: false, busy: !!(w && w.ok && w.results && w.results.length) }; draw();
|
|
270
|
+
if (!S.meaning.busy) return;
|
|
271
|
+
const r = await pmGet('/api/library-items/find?rank=1&q=' + encodeURIComponent(q) + ws).catch(() => null);
|
|
272
|
+
if (n !== findN) return;
|
|
273
|
+
S.meaning = r && r.ok ? { q, results: r.results || [], ranked: !!r.ranked, why: r.why || '', busy: false }
|
|
274
|
+
: { ...S.meaning, busy: false, why: 'PMOS could not read for meaning' };
|
|
275
|
+
draw();
|
|
276
|
+
}, 450);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* ── the record preview (≥ 1600 px) ── */
|
|
280
|
+
function field(k, v) { return v ? `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>` : ''; }
|
|
281
|
+
async function drawPreview() {
|
|
282
|
+
const x = S.pick && (S.items || []).find((i) => i.id === S.pick);
|
|
283
|
+
if (!x || !wide()) { pv.hidden = true; pv.innerHTML = ''; document.body.classList.remove('lb-pv-on'); return; }
|
|
284
|
+
pv.hidden = false; document.body.classList.add('lb-pv-on');
|
|
285
|
+
const older = (S.items || []).filter((o) => o.ed && o.ed === x.ed && o.id !== x.id).sort((a, b) => (b.v || 0) - (a.v || 0) || String(when(b)).localeCompare(String(when(a))));
|
|
286
|
+
const p = x.open && x.open.doc ? S.peek.get(x.id) : null;
|
|
287
|
+
const lines = x.kind === 'meeting' ? x.gist || [] : p && p.head ? p.head : [];
|
|
288
|
+
pv.innerHTML = `<div class="lb-pvh"><span class="ic">${svg(ICON[x.kind] || ICON.doc)}</span><h2>${esc(x.name)}</h2>`
|
|
289
|
+
+ `<button type="button" class="lb-ib" data-lb-pv-open aria-label="Open ${esc(x.name)}" title="Open">${svg(OPEN)}</button>`
|
|
290
|
+
+ `<button type="button" class="lb-ib" data-lb-pv-close aria-label="Close the preview" title="Close">${svg(X)}</button></div>`
|
|
291
|
+
+ `<dl>${field('Kind', x.kindText)}${field('Product', x.product)}${field('About', aboutText(x) || (x.about && x.about.title))}${field('By', x.by)}${field('State', stateText({ x, older }))}`
|
|
292
|
+
+ `${field(x.kind === 'meeting' ? 'Held' : 'Updated', dayText(when(x)))}${field('Came out of it', x.came)}${field('Title', x.sub)}${field('File', x.path)}</dl>`
|
|
293
|
+
+ (lines.length ? `<h3>First lines</h3><div class="lb-pvl">${lines.map((l) => `<p>${esc(l)}</p>`).join('')}</div>` : x.open && x.open.doc && !p ? '<p class="lb-mq">Reading the first lines…</p>' : '')
|
|
294
|
+
+ (p && p.from && p.from.length ? `<h3>Linked from</h3><ul>${p.from.map((f) => `<li>${esc(f.title)}</li>`).join('')}</ul>` : '')
|
|
295
|
+
+ (older.length ? `<h3>Editions</h3><ul>${older.map((o) => `<li><button type="button" class="lb-nb" data-lb-pv-ed="${esc(o.id)}">${esc(o.name)}${o.v ? ' · v' + o.v : ''}</button> <small>${esc(dayText(when(o)))}</small></li>`).join('')}</ul>` : '');
|
|
296
|
+
if (x.open && x.open.doc && !p) {
|
|
297
|
+
const r = await pmGet('/api/library-items/peek?ws=' + encodeURIComponent(x.open.doc.ws) + '&path=' + encodeURIComponent(x.open.doc.path)).catch(() => null);
|
|
298
|
+
S.peek.set(x.id, r && r.ok ? r : { head: [], from: [] });
|
|
299
|
+
if (S.pick === x.id) drawPreview();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* ── draw ── */
|
|
304
|
+
function draw() {
|
|
305
|
+
if (S.items == null) return;
|
|
306
|
+
drawFilters();
|
|
307
|
+
if (!S.items.length && S.error) { body.innerHTML = `<p class="lb-none">The Library could not be read: ${esc(S.error)}.</p>`; note.textContent = ''; hid.innerHTML = ''; return; }
|
|
308
|
+
const V = view(S.items, { q: S.q, f: F(), group: S.group, open: S.open, shut: S.shut });
|
|
309
|
+
S.shown = [];
|
|
310
|
+
const filtered = S.kinds.length || S.states.length || narrowed(S.P, S.sel);
|
|
311
|
+
if (filtered && V.hidden) {
|
|
312
|
+
const words = [kindLabel(), S.states.join(', '), narrowed(S.P, S.sel) ? scopeWords(S.P, S.sel, scopeGroups()) : ''].filter((w) => w && w !== 'Every kind');
|
|
313
|
+
hid.innerHTML = `${esc(words.length ? 'Showing ' + words.join(' · ') + ' only. ' : '')}${esc(hiddenText(V.hidden))} <button type="button" data-lb-all>Show all</button>`;
|
|
314
|
+
} else hid.innerHTML = '';
|
|
315
|
+
let h = '';
|
|
316
|
+
if (!V.groups.length) {
|
|
317
|
+
// zero is silence: one quiet line, no empty table
|
|
318
|
+
h = S.q && S.meaning && S.meaning.q === S.q && (S.meaning.busy || (S.meaning.results || []).length) ? '' : `<p class="lb-none">${esc(S.q ? 'No title in the Library matches "' + S.q + '".' : filtered ? 'Nothing here fits the filters.' : 'Nothing was made yet. Documents, meeting notes and prototypes show here as they are made.')}</p>`;
|
|
319
|
+
} else h = tableHtml(V.groups);
|
|
320
|
+
const titled = S.shown.map((x) => x.id);
|
|
321
|
+
body.innerHTML = h + meaningHtml(titled);
|
|
322
|
+
note.textContent = noteOf(S.q, S.group);
|
|
323
|
+
if (S.naming) { const i = $('lbNameIn'); if (i) { i.focus(); i.select(); } }
|
|
324
|
+
if (S.pick) drawPreview();
|
|
325
|
+
}
|
|
326
|
+
/* Search (⌘K) lists the Library's own rows first */
|
|
327
|
+
function libHits(q) {
|
|
328
|
+
if (!S.items) return [];
|
|
329
|
+
const list = S.items.filter((x) => matches(x, q)).slice(0, 8);
|
|
330
|
+
return list.length ? [{ label: 'In the Library', rows: list.map((x) => ({ id: x.id, title: x.name, sub: x.kindText + (aboutText(x) ? ' · ' + aboutText(x) : ''), open: () => openItem(x, { from: 'Library' }) })) }] : [];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async function load() {
|
|
334
|
+
const [r, P] = await Promise.all([pmGet('/api/library-items').catch((e) => ({ ok: false, error: (e && e.message) || 'the server did not answer' })), readPick().catch(() => null)]);
|
|
335
|
+
S.at = Date.now(); S.P = P || S.P;
|
|
336
|
+
if (r && r.ok) { S.items = r.items || []; S.programs = r.programs || []; S.error = ''; } else { S.items = S.items || []; S.error = (r && r.error) || 'the server did not answer'; }
|
|
337
|
+
draw();
|
|
338
|
+
whenNames().then(() => { drawFilters(); draw(); }).catch(() => {});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* ── presses ── */
|
|
342
|
+
filters.onclick = (e) => {
|
|
343
|
+
const b = e.target.closest('button'); if (!b) return;
|
|
344
|
+
if (b.id === 'lbKind') openMenu('lbKind', kindMenu, kindPress);
|
|
345
|
+
else if (b.id === 'lbState') openMenu('lbState', stateMenu, statePress);
|
|
346
|
+
else if (b.id === 'lbScope') { closeMenu(); openScope(b, { P: S.P, groups: scopeGroups(), sel: S.sel, unit: 'items', onApply: async (next) => { S.sel = { programs: next.programs, projects: next.projects }; S.P = (await readPick().catch(() => null)) || S.P; draw(); } }); }
|
|
347
|
+
};
|
|
348
|
+
$('lbTune').onclick = () => openMenu('lbTune', groupMenu, groupPress, 'lb-gm');
|
|
349
|
+
hid.onclick = async (e) => {
|
|
350
|
+
if (!e.target.closest('[data-lb-all]')) return;
|
|
351
|
+
S.kinds = []; S.states = []; S.sel = { programs: [], projects: [] }; remember();
|
|
352
|
+
if (S.P && S.P.products && S.P.products.some((p) => !p.on)) { const { savePick } = await import('./cozy-pick.js'); await savePick(S.P.products.map((p) => p.ws)); }
|
|
353
|
+
draw();
|
|
354
|
+
};
|
|
355
|
+
addEventListener('pp:changed', (e) => { if (e.detail && e.detail.products) { S.P = e.detail; draw(); } });
|
|
356
|
+
function press(x) {
|
|
357
|
+
if (!x) return;
|
|
358
|
+
if (wide() && S.pick !== x.id && !(x.open && x.open.url)) { S.pick = x.id; draw(); return; }
|
|
359
|
+
openItem(x, { from: 'Library' });
|
|
360
|
+
}
|
|
361
|
+
async function saveName(id, name) {
|
|
362
|
+
const x = (S.items || []).find((i) => i.id === id); if (!x) return;
|
|
363
|
+
const title = String(name || '').trim() || x.name;
|
|
364
|
+
const r = await pmPost('/api/notes/save', { id: x.note, title }).catch(() => null);
|
|
365
|
+
if (r && r.ok) { x.name = title; x.named = false; }
|
|
366
|
+
S.naming = null; draw();
|
|
367
|
+
}
|
|
368
|
+
body.onclick = async (e) => {
|
|
369
|
+
const t = e.target;
|
|
370
|
+
let b;
|
|
371
|
+
if ((b = t.closest('[data-lb-fold]'))) {
|
|
372
|
+
const k = b.dataset.lbFold, folded = b.getAttribute('aria-expanded') !== 'true';
|
|
373
|
+
if (folded) { S.open.add(k); S.shut.delete(k); } else { S.shut.add(k); S.open.delete(k); }
|
|
374
|
+
draw(); return;
|
|
375
|
+
}
|
|
376
|
+
if ((b = t.closest('[data-lb-ed]'))) { const k = b.dataset.lbEd; if (S.ed.has(k)) S.ed.delete(k); else S.ed.add(k); draw(); return; }
|
|
377
|
+
if ((b = t.closest('[data-lb-ck]'))) { const k = b.dataset.lbCk; if (S.ck.has(k)) S.ck.delete(k); else S.ck.add(k); draw(); return; }
|
|
378
|
+
if ((b = t.closest('[data-lb-name]'))) { S.naming = b.dataset.lbName; draw(); return; }
|
|
379
|
+
if (t.closest('[data-lb-name-ok]')) { const i = $('lbNameIn'); saveName(S.naming, i ? i.value : ''); return; }
|
|
380
|
+
if (t.closest('[data-lb-name-no]')) { S.naming = null; draw(); return; }
|
|
381
|
+
if (t.closest('#lbNameIn')) return;
|
|
382
|
+
if ((b = t.closest('[data-lb-link]'))) {
|
|
383
|
+
const x = (S.items || []).find((i) => i.id === b.dataset.lbLink); if (!x || !x.suggest) return;
|
|
384
|
+
const s = x.suggest;
|
|
385
|
+
const r = await pmPost('/api/notes/link', { id: x.note, initiative: { id: s.ini, ws: s.ws, title: s.title } }).catch(() => null);
|
|
386
|
+
if (r && r.ok) { x.about = { ...x.about, ws: s.ws, ini: s.ini, title: s.title }; x.suggest = null; draw(); }
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const row = t.closest('[data-lb-i]'); if (!row) return;
|
|
390
|
+
press(S.shown[Number(row.dataset.lbI)]);
|
|
391
|
+
};
|
|
392
|
+
body.onkeydown = (e) => {
|
|
393
|
+
if (e.target.id === 'lbNameIn') {
|
|
394
|
+
if (e.key === 'Enter') { e.preventDefault(); saveName(S.naming, e.target.value); }
|
|
395
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); S.naming = null; draw(); }
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
// Enter on a name opens the item, on any screen
|
|
399
|
+
if (e.key === 'Enter' && e.target.matches('[data-lb-open]')) {
|
|
400
|
+
e.preventDefault();
|
|
401
|
+
const row = e.target.closest('[data-lb-i]'); const x = row && S.shown[Number(row.dataset.lbI)]; if (x) openItem(x, { from: 'Library' });
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
pv.onclick = (e) => {
|
|
405
|
+
const x = S.pick && (S.items || []).find((i) => i.id === S.pick);
|
|
406
|
+
let b;
|
|
407
|
+
if (e.target.closest('[data-lb-pv-close]')) { S.pick = null; draw(); drawPreview(); return; }
|
|
408
|
+
if (e.target.closest('[data-lb-pv-open]') && x) { openItem(x, { from: 'Library' }); return; }
|
|
409
|
+
if ((b = e.target.closest('[data-lb-pv-ed]'))) { const o = (S.items || []).find((i) => i.id === b.dataset.lbPvEd); if (o) openItem(o, { from: 'Library' }); }
|
|
410
|
+
};
|
|
411
|
+
qBox.addEventListener('input', () => { S.q = qBox.value.trim(); draw(); findByMeaning(); });
|
|
412
|
+
qBox.addEventListener('keydown', (e) => { if (e.key === 'Escape' && qBox.value) { e.stopPropagation(); qBox.value = ''; S.q = ''; S.meaning = null; draw(); } });
|
|
413
|
+
addEventListener('keydown', (e) => {
|
|
414
|
+
if (e.key !== '/' || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
415
|
+
const t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
|
|
416
|
+
if (document.body.classList.contains('cz-pop-on')) return;
|
|
417
|
+
e.preventDefault(); qBox.focus();
|
|
418
|
+
});
|
|
419
|
+
addEventListener('resize', () => { if (S.pick) drawPreview(); });
|
|
420
|
+
// the +: Ask PMOS, with the words ready to finish; PMOS adds the file, the link or the new document, fills its record and shows it to confirm
|
|
421
|
+
$('lbAdd').onclick = async () => {
|
|
422
|
+
const M = await import('./page-chat.js');
|
|
423
|
+
await M.openCos({ here: 'Library' });
|
|
424
|
+
let n = 0;
|
|
425
|
+
const t = setInterval(() => {
|
|
426
|
+
const box = document.querySelector('.pc-chat textarea');
|
|
427
|
+
if (box || ++n > 20) {
|
|
428
|
+
clearInterval(t);
|
|
429
|
+
if (box && !box.value) { box.value = 'Add to Library (fill its kind, product and work, and show me the record to confirm): '; box.dispatchEvent(new Event('input', { bubbles: true })); }
|
|
430
|
+
if (box) box.focus();
|
|
431
|
+
}
|
|
432
|
+
}, 50);
|
|
433
|
+
};
|
|
434
|
+
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible' && Date.now() - S.at > 60000) load(); });
|
|
435
|
+
|
|
436
|
+
load();
|
|
@@ -937,7 +937,7 @@ export function wireCrumb(o) {
|
|
|
937
937
|
const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
|
|
938
938
|
const IC = (d) => `<svg class="i" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
939
939
|
const GL = { place: IC('M4 5h16v14H4zM4 10h16'), ini: IC('M12 3l9 9-9 9-9-9z'), doc: IC('M6 3h9l4 4v14H6zM14 3v5h5'), ses: IC('M5 4l14 8-14 8z'), need: IC('M12 4v10M12 18v2') };
|
|
940
|
-
const PLACES = [['Today', '/premium.html'], ['Work', '/premium-board.html'], ['Goals', '/premium-
|
|
940
|
+
const PLACES = [['Today', '/premium.html'], ['Work', '/premium-board.html'], ['Goals', '/premium-goals.html']]; // the places' names since slice 1 of the six places
|
|
941
941
|
const PV_WS = new URLSearchParams(location.search).get('ws');
|
|
942
942
|
const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
|
|
943
943
|
async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
|
|
@@ -497,6 +497,54 @@ export function meetHtml(m, ui = {}) {
|
|
|
497
497
|
return summaryHtml(m, ui) + `<div class="vz vz-mtg" data-mk="${m.mk}">${h.join('')}</div>`;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
+
/** A held meeting's notes, as one view from every place (board 34, StLibMeetingOpen; Library audit item 6): the short lead, Decisions,
|
|
501
|
+
* Tasks that came out of it (a press opens the initiative), the ✦ ask to add the tasks that are not in the Work breakdown, Notes, and the
|
|
502
|
+
* grey box "The meeting" at the right. The full card (the replay, the transcript, material, names) is one press away: Recording, or
|
|
503
|
+
* "Transcript and more". ctx = { ini: { id, ws, name } | null }. Only a coming or live meeting keeps the card of meetHtml. */
|
|
504
|
+
const DMON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
505
|
+
const dm = (iso) => (ok(iso) ? new Date(iso).getDate() + ' ' + DMON[new Date(iso).getMonth()] : '');
|
|
506
|
+
/* an initiative's short name, as the Board says it ("Tender new CIAM"): the part before the first dash, colon or comma */
|
|
507
|
+
const shortName = (t) => { const x = String(t || '').split(/\s[—–]\s|:\s|,\s/)[0].trim(); return clip(x || t, 44); };
|
|
508
|
+
const dueText = (d) => (/^\d{4}-\d{2}-\d{2}$/.test(d || '') ? dm(d + 'T12:00:00') : d || '');
|
|
509
|
+
export function heldOf(m, ctx = {}) {
|
|
510
|
+
const N = m.notes;
|
|
511
|
+
const held = [dm(m.at), hasTime(m.at) ? hm(m.at) + (hasTime(m.end) ? ' to ' + hm(m.end) : '') : ''].filter(Boolean).join(', ');
|
|
512
|
+
const tasks = N.steps.map((a) => ({ i: a.i, text: a.text, meta: [a.owner || '', dueText(a.due)].filter(Boolean).join(' · '), made: !!(a.task || a.ticket) }));
|
|
513
|
+
const missing = tasks.filter((x) => !x.made);
|
|
514
|
+
const recMin = N.track && N.track.len ? Math.max(1, Math.round(N.track.len / 60000)) : 0;
|
|
515
|
+
const from = m.private ? 'Your notes' : recMin || N.lines.length ? 'The recording' : 'Your notes';
|
|
516
|
+
const notes = N.facts.map((f) => f.text).concat(N.questions.map((x) => 'Open: ' + x.text)).filter(Boolean);
|
|
517
|
+
return { lead: N.summary || (m.private ? 'This note is private: only what you typed is kept.' : ''), decisions: N.decisions.map((d) => d.text), tasks, missing, notes, held,
|
|
518
|
+
about: shortName(m.about), ini: ctx.ini ? { ...ctx.ini, name: shortName(ctx.ini.name || m.about) } : null, who: ['You'].concat(m.people.filter((p) => !/^you$/i.test(p))).join(', '), from, recMin,
|
|
519
|
+
foot: (from === 'The recording' ? 'PMOS wrote these notes from the recording.' : 'PMOS wrote these notes from what you typed.') + (tasks.length && ctx.ini ? ' Press a task to open it in its initiative.' : '') };
|
|
520
|
+
}
|
|
521
|
+
export function heldHtml(m, ui = {}, ctx = {}) {
|
|
522
|
+
const H = heldOf(m, ctx), h = [];
|
|
523
|
+
if (ui.msg) h.push(`<p class="vz-msg" role="status" data-tone="${ui.msg.tone || ''}"><span>${esc(ui.msg.text)}</span>${ui.msg.undo ? '<button type="button" class="vz-link vz-hv" data-a="msgundo">Undo</button>' : ''}</p>`);
|
|
524
|
+
if (H.lead) h.push(`<p>${esc(H.lead)}</p>`);
|
|
525
|
+
if (H.decisions.length) h.push('<h6>Decisions</h6><ul>' + H.decisions.map((d) => `<li>${esc(d)}</li>`).join('') + '</ul>');
|
|
526
|
+
if (H.tasks.length) {
|
|
527
|
+
h.push('<h6>Tasks that came out of it</h6><div class="vzh-t">' + H.tasks.map((x) => `<button type="button" class="vzh-r" data-a="h-task" data-i="${x.i}"${H.ini ? '' : ' disabled'}><i aria-hidden="true"></i><span>${esc(x.text)}</span>${x.meta ? `<em>${esc(x.meta)}</em>` : ''}</button>`).join('') + '</div>');
|
|
528
|
+
}
|
|
529
|
+
if (H.ini && H.missing.length && !ui.sgNo) {
|
|
530
|
+
const n = H.missing.length;
|
|
531
|
+
h.push(`<div class="vzh-sg" role="group" aria-label="PMOS suggests"><p class="vzh-sgh">PMOS suggests</p><div><span>${n === 1 ? 'One task is' : esc(String(n)) + ' tasks are'} not in the Work breakdown of ${esc(H.ini.name || H.about)}. Add ${n === 1 ? 'it' : 'them'}?</span>`
|
|
532
|
+
+ `<button type="button" class="y" data-a="h-add" aria-label="Yes, add ${n === 1 ? 'it' : 'them'}" title="Yes, add ${n === 1 ? 'it' : 'them'}">${svg('check', 14)}</button><button type="button" data-a="h-no" aria-label="No" title="No">${svg('x', 14)}</button></div></div>`);
|
|
533
|
+
}
|
|
534
|
+
if (H.notes.length) h.push('<h6>Notes</h6><ul>' + H.notes.map((t) => `<li>${esc(t)}</li>`).join('') + '</ul>');
|
|
535
|
+
if (!H.lead && !H.decisions.length && !H.tasks.length && !H.notes.length) h.push(`<p class="vz-empty">${esc(NO_NOTES)}</p>`);
|
|
536
|
+
const about = H.about ? `<button type="button" class="vzh-sel" data-a="${H.ini ? 'h-ini' : 'm-about'}" title="${esc(m.about)}"><span>${esc(H.about)}</span>${svg('next', 14)}</button>` : `<button type="button" class="vzh-sel" data-a="m-about">Link it</button>`;
|
|
537
|
+
const side = ['<h6>The meeting</h6>',
|
|
538
|
+
H.held ? `<div class="r"><span>Held</span><em>${esc(H.held)}</em></div>` : '',
|
|
539
|
+
`<div class="r"><span>About</span>${about}</div>`,
|
|
540
|
+
`<div class="r"><span>Who</span><em>${esc(H.who)}</em></div>`,
|
|
541
|
+
`<div class="r"><span>Written from</span><em>${esc(H.from)}</em></div>`,
|
|
542
|
+
H.recMin ? `<div class="r"><span>Recording</span><button type="button" class="vzh-sel" data-a="h-full" aria-label="Play the recording, ${H.recMin} min">${svg('play', 12)} ${H.recMin} min</button></div>` : '',
|
|
543
|
+
`<p>${esc(H.foot)}</p>`,
|
|
544
|
+
`<button type="button" class="vz-link vz-hv vzh-more" data-a="h-full">Transcript and more</button>`].join('');
|
|
545
|
+
return `<div class="vz vz-mtg vzh" data-mk="held"><div class="vzm-anc" data-pop="head"></div><div class="vzh-w"><div class="vzh-o">${h.join('')}</div><aside class="vzh-s" aria-label="The meeting">${side}</aside></div></div>`;
|
|
546
|
+
}
|
|
547
|
+
|
|
500
548
|
/** Add material's popover (XvAMaterial): Upload a file, Paste a link, Find in PMOS, then the suggestions. P = { row, sug, found, q, topics, err, busy } */
|
|
501
549
|
export function matPopHtml(P) {
|
|
502
550
|
if (!P.row) return `<div class="vzm-pop" role="dialog" aria-label="Add material"><p class="vzm-sm vzm-mut">Material is kept per calendar meeting. This note has no calendar event.</p></div>`;
|
|
@@ -733,9 +781,38 @@ async function serMember(me, out) {
|
|
|
733
781
|
me.ui.pop = ''; const r = await pmPost('/api/notes/series-member', { id: me.n.id, key: out ? 'off' : null });
|
|
734
782
|
say(me, r && r.ok ? (out ? 'Taken out of the series. It stays a note on its own.' : 'Back in its series.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad'); return load(me);
|
|
735
783
|
}
|
|
784
|
+
/* a held meeting opens in board 34's view (heldHtml); Recording or "Transcript and more" shows the full card, ← in the card comes back */
|
|
785
|
+
const held = (me) => !!(me.model && me.model.mk === 'notes' && !me.ui.full);
|
|
786
|
+
function iniOf(me) {
|
|
787
|
+
const S = me.D && me.D.S, L = me.D && me.D.level;
|
|
788
|
+
if (S && S.initiative && S.initiative.id) return { id: S.initiative.id, ws: S.initiative.ws || me.ws || '', name: S.initiative.name || me.model.about };
|
|
789
|
+
if (L && L.kind === 'initiative' && L.id) return { id: L.id, ws: L.ws || me.ws || '', name: L.name || L.id };
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
const SGNO = 'pmos.mtg.sgno.';
|
|
793
|
+
const sgNo = (id) => { try { return !!id && localStorage.getItem(SGNO + id) === '1'; } catch { return false; } };
|
|
794
|
+
async function heldPress(me, a, t) {
|
|
795
|
+
const ui = me.ui, ini = iniOf(me);
|
|
796
|
+
if (a === 'h-full') { ui.full = true; return draw(me); }
|
|
797
|
+
if (a === 'h-held') { ui.full = false; return draw(me); }
|
|
798
|
+
if (a === 'h-no') { ui.sgNo = true; try { localStorage.setItem(SGNO + me.n.id, '1'); } catch { /* a private window: only this open */ } return repaint(me); }
|
|
799
|
+
if ((a === 'h-ini' || a === 'h-task') && ini) {
|
|
800
|
+
const M = await import('./premium-vw-item.js');
|
|
801
|
+
return M.openWorkItem({ kind: 'initiative', id: ini.id, ws: ini.ws, title: ini.name });
|
|
802
|
+
}
|
|
803
|
+
if (a === 'h-add') {
|
|
804
|
+
const H = heldOf(me.model, { ini }); let n = 0, err = '';
|
|
805
|
+
t.disabled = true;
|
|
806
|
+
for (const x of H.missing) { const r = await makeTask(me, x.i, true); if (r && r.ok) n++; else if (!err) err = (r && r.error) || 'no answer'; }
|
|
807
|
+
ui.sgNo = true;
|
|
808
|
+
return say(me, n ? (n === 1 ? 'One task is' : n + ' tasks are') + ' added to ' + (ini ? ini.name : 'the initiative') + (err ? '. The rest were not: ' + err : '.') : 'Not added: ' + err, n ? '' : 'bad');
|
|
809
|
+
}
|
|
810
|
+
}
|
|
736
811
|
function paint(me, body) {
|
|
737
812
|
const top = body.scrollTop;
|
|
738
|
-
|
|
813
|
+
if (me.n && sgNo(me.n.id)) me.ui.sgNo = true;
|
|
814
|
+
body.innerHTML = held(me) ? heldHtml(me.model, me.ui, { ini: iniOf(me) })
|
|
815
|
+
: (me.model && me.model.mk === 'notes' ? '<button type="button" class="vz-link vz-hv vzh-back" data-a="h-held">Back to the notes</button>' : '') + meetHtml(me.model, me.ui);
|
|
739
816
|
body.scrollTop = top;
|
|
740
817
|
const line = body.querySelector('.czs-sum .czs-line > span:not(.czs-dot):not(.czs-r)'); if (line) line.dataset.clk = 'state';
|
|
741
818
|
if (me.ui.edit) { const ta = body.querySelector('.vzp-ed [data-a="etext"]'); if (ta && me.ui.focusEdit) { me.ui.focusEdit = false; ta.focus(); ta.setSelectionRange(ta.value.length, ta.value.length); } }
|
|
@@ -800,6 +877,7 @@ async function press(me, e) {
|
|
|
800
877
|
if (t.disabled) return;
|
|
801
878
|
const a = pa ? pa.dataset.czsAct : t.dataset.a, ui = me.ui, m = me.model, C = rec();
|
|
802
879
|
if (ui.pop && !t.closest('.vzm-pop') && !['addmat', 'm-about'].includes(a)) ui.pop = '';
|
|
880
|
+
if (/^h-/.test(a)) return heldPress(me, a, t);
|
|
803
881
|
switch (a) {
|
|
804
882
|
case 'popx': ui.pop = ''; return repaint(me);
|
|
805
883
|
case 'askno': ui.ask = null; return repaint(me);
|