create-pmos 0.611.0 → 0.613.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 +105 -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/briefing-premium-board-test.js +1 -1
- 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-insights-test.js +1 -1
- package/workspace/briefing-premium-test.js +1 -1
- package/workspace/changelog.json +104 -0
- package/workspace/guide/layout.md +52 -18
- package/workspace/guide/programs.md +3 -3
- package/workspace/guide/routine.md +28 -13
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/board-premium.js +12 -4
- 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 +190 -38
- 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 +196 -24
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/plan-items.js +17 -3
- 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 +47 -10
- package/workspace/lib/routes-library.js +74 -8
- package/workspace/lib/routes-report-setups.js +13 -2
- package/workspace/lib/routine-reports.js +36 -4
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +6 -6
- package/workspace/public/pm/bd-span.js +7 -1
- package/workspace/public/pm/bd-work.css +62 -0
- package/workspace/public/pm/bd-work.js +195 -68
- 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 +0 -4
- package/workspace/public/pm/cozy-events-view.js +165 -33
- package/workspace/public/pm/cozy-events.css +75 -3
- package/workspace/public/pm/cozy-events.js +86 -18
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +106 -17
- package/workspace/public/pm/cozy-nav.js +2 -3
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +83 -24
- package/workspace/public/pm/cozy-pop-work.js +313 -72
- 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 +139 -31
- package/workspace/public/pm/cozy-routine-pop.js +164 -42
- package/workspace/public/pm/cozy-routine.css +61 -8
- package/workspace/public/pm/cozy-routine.js +207 -28
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -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-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +8 -6
- 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 +170 -42
- package/workspace/public/pm/library-open.js +8 -5
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +199 -41
- package/workspace/public/pm/premium-board.js +108 -43
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +376 -62
- 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 +207 -0
- package/workspace/public/premium-events.html +3 -1
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +15 -7
- package/workspace/public/premium-routine.html +2 -0
- package/workspace/server.js +2 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
|
@@ -1,108 +1,423 @@
|
|
|
1
|
-
/* pm/premium-library.js — Library, the place (initiative library-place
|
|
2
|
-
* StLibMeetings, StLibDocs, StLibMeetingOpen on Exploring 2, page "Navigation: Today, Work, Goals, Events, Library, Routine").
|
|
1
|
+
/* pm/premium-library.js — Library, the place (initiative library-place; slice 7 of the six-place navigation, Library round 2).
|
|
3
2
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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. */
|
|
10
15
|
import './fetch-share.js';
|
|
11
|
-
import { pmGet } from './http.js';
|
|
16
|
+
import { pmGet, pmPost } from './http.js';
|
|
12
17
|
import { mountNav } from './cozy-nav.js';
|
|
13
18
|
import { mountLivePill } from './cozy-live-pill.js';
|
|
14
19
|
import './cozy-viewer.js';
|
|
15
20
|
import './cozy-popup.js'; // the one popup: window.czOpenChat for the rail's chat icon, and the popup a row opens in
|
|
16
|
-
import {
|
|
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';
|
|
17
24
|
import { openItem } from './library-open.js';
|
|
18
25
|
|
|
19
26
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
20
|
-
const svg = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
27
|
+
const svg = (d, cls = '') => `<svg viewBox="0 0 24 24" aria-hidden="true"${cls ? ` class="${cls}"` : ''}><path d="${d}"/></svg>`;
|
|
21
28
|
const ICON = {
|
|
22
29
|
doc: 'M7 4h7l4 4v12H7zM14 4v4h4',
|
|
23
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',
|
|
24
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',
|
|
25
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',
|
|
26
34
|
};
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
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;
|
|
30
49
|
|
|
31
50
|
mountNav('library', document, { scope: () => ({ name: 'Library', hits: (q) => libHits(q) }) });
|
|
32
51
|
mountLivePill();
|
|
33
52
|
|
|
34
53
|
const $ = (id) => document.getElementById(id);
|
|
35
|
-
const
|
|
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
|
+
}
|
|
36
231
|
|
|
37
|
-
|
|
38
|
-
|
|
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>');
|
|
39
240
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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>';
|
|
46
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 ── */
|
|
47
304
|
function draw() {
|
|
48
305
|
if (S.items == null) return;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
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 });
|
|
52
309
|
S.shown = [];
|
|
53
|
-
|
|
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) {
|
|
54
317
|
// zero is silence: one quiet line, no empty table
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
for (const g of groups) {
|
|
63
|
-
h += `<div class="lb-r lb-g" role="row"><div role="rowheader">${esc(g.group)}</div></div>`;
|
|
64
|
-
// a long Older group shows its newest rows; one quiet press shows the rest
|
|
65
|
-
const cut = g.group === 'Older' && !S.all && !S.q ? g.items.slice(0, OLDER) : g.items;
|
|
66
|
-
left += g.items.length - cut.length;
|
|
67
|
-
for (const x of cut) { h += rowHtml(x, S.shown.length); S.shown.push(x); }
|
|
68
|
-
}
|
|
69
|
-
if (left) h += `<button type="button" class="lb-r lb-more" data-lb-more><span></span><span class="c q">Show ${left} older</span></button>`;
|
|
70
|
-
body.innerHTML = h + '</div>';
|
|
71
|
-
note.textContent = S.filter === 'All' && !S.q ? 'Press a row to open it with the chat beside it. Reports are in Routine.' : '';
|
|
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();
|
|
72
325
|
}
|
|
73
326
|
/* Search (⌘K) lists the Library's own rows first */
|
|
74
327
|
function libHits(q) {
|
|
75
328
|
if (!S.items) return [];
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
return list.length ? [{ label: 'In the Library', rows: list.map((x) => ({ id: x.id, title: x.name, sub: x.kindText + (x.about && x.about.title ? ' · ' + x.about.title : ''), open: () => openItem(x) })) }] : [];
|
|
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' }) })) }] : [];
|
|
79
331
|
}
|
|
80
332
|
|
|
81
333
|
async function load() {
|
|
82
|
-
const r = await pmGet('/api/library-items').catch((e) => ({ ok: false, error: (e && e.message) || 'the server did not answer' }));
|
|
83
|
-
S.at = Date.now();
|
|
84
|
-
if (r && r.ok) { S.items = r.items || []; S.error = ''; } else { S.items = S.items || []; S.error = (r && r.error) || 'the server did not answer'; }
|
|
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'; }
|
|
85
337
|
draw();
|
|
338
|
+
whenNames().then(() => { drawFilters(); draw(); }).catch(() => {});
|
|
86
339
|
}
|
|
87
340
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
}
|
|
91
403
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (e.target.closest('[data-lb-
|
|
96
|
-
|
|
97
|
-
const
|
|
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' }); }
|
|
98
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(); } });
|
|
99
413
|
addEventListener('keydown', (e) => {
|
|
100
414
|
if (e.key !== '/' || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
101
415
|
const t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
|
|
102
416
|
if (document.body.classList.contains('cz-pop-on')) return;
|
|
103
417
|
e.preventDefault(); qBox.focus();
|
|
104
418
|
});
|
|
105
|
-
|
|
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
|
|
106
421
|
$('lbAdd').onclick = async () => {
|
|
107
422
|
const M = await import('./page-chat.js');
|
|
108
423
|
await M.openCos({ here: 'Library' });
|
|
@@ -111,12 +426,11 @@ $('lbAdd').onclick = async () => {
|
|
|
111
426
|
const box = document.querySelector('.pc-chat textarea');
|
|
112
427
|
if (box || ++n > 20) {
|
|
113
428
|
clearInterval(t);
|
|
114
|
-
if (box && !box.value) { box.value = 'Add to Library: '; box.dispatchEvent(new Event('input', { bubbles: true })); }
|
|
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 })); }
|
|
115
430
|
if (box) box.focus();
|
|
116
431
|
}
|
|
117
432
|
}, 50);
|
|
118
433
|
};
|
|
119
434
|
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible' && Date.now() - S.at > 60000) load(); });
|
|
120
435
|
|
|
121
|
-
drawKinds();
|
|
122
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 }; } }
|