create-pmos 0.324.0 → 0.325.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.
@@ -0,0 +1,188 @@
1
+ /* pm/premium-vw-notes.js — the Notes list in the premium dialog (initiative premium-viewer, R9; console parity: c3-notes.js, the list).
2
+ *
3
+ * The Briefing's Calendar card has a Notes button. It opens the dialog with every meeting note in the detail pane, with a search
4
+ * field, grouped by what a note is about as the console groups them: Portfolio, each board in the portfolio's order, Initiatives (linked
5
+ * before boards were), then Not linked. The notes of one meeting series (two or more notes with one series key) are one entry: its
6
+ * title, the newest day, "N meetings", "series" and how many next steps are still open; it folds open to its newest three notes.
7
+ * Pressing a note opens its note sheet as a viewer tab (premium-vw-meet.js openNoteTab: Before, During and After, series paging,
8
+ * Since the last one, the notes tables). Pressing a series opens its newest note, which pages through the series.
9
+ *
10
+ * Data: GET /api/notes (rows and series_open), GET /api/boards (the group order), GET /api/notes/search (what was said). Every row
11
+ * field is a field of those answers; a part a note does not hold is left out.
12
+ */
13
+ import { vwStyle } from './premium-viewer.js';
14
+ import { openNoteTab } from './premium-vw-meet.js';
15
+
16
+ const pad = (n) => String(n).padStart(2, '0');
17
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
19
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
20
+ const startOf = (r) => (r.meeting && r.meeting.start) || r.recorded_from || r.created_at || r.updated_at;
21
+ const at = (r) => Date.parse(startOf(r)) || 0;
22
+ const boardKey = (b) => (b.ws || '') + '/' + b.id;
23
+ export const SEARCH_MIN = 2;
24
+
25
+ /** "Mon 19 Oct 10:00", the day and time a note's meeting began (or it was recorded). */
26
+ export function whenOf(iso, withTime = true) {
27
+ const t = new Date(iso);
28
+ if (!Number.isFinite(t.getTime())) return '';
29
+ return WD[t.getDay()] + ' ' + t.getDate() + ' ' + MON[t.getMonth()] + (withTime ? ' ' + pad(t.getHours()) + ':' + pad(t.getMinutes()) : '');
30
+ }
31
+ const lenOf = (ms) => (ms >= 60000 ? Math.round(ms / 60000) + ' min' : '');
32
+ const words = (q) => String(q || '').toLowerCase().split(/\s+/).filter(Boolean);
33
+
34
+ /** One note row as the list draws it. */
35
+ export function rowOf(r) {
36
+ const live = r.state === 'recording' || r.state === 'paused' ? r.state : '';
37
+ const linked = !!(r.meeting && (r.meeting.kind === 'event' || r.meeting.kind === 'adhoc'));
38
+ return {
39
+ id: r.id, title: clip(r.title || 'Untitled note', 120), when: whenOf(startOf(r)), day: whenOf(startOf(r), false), len: lenOf(r.meeting_ms || 0), live,
40
+ initiative: r.initiative && r.initiative.id ? clip(r.initiative.title || r.initiative.id, 60) : '',
41
+ board: !(r.initiative && r.initiative.id) && r.board && r.board.id ? 'board' : '',
42
+ noMeeting: !linked && !live, conflicts: r.conflicts || 0, gist: r.private ? '' : clip((r.summary_lines || [])[0] || '', 140),
43
+ };
44
+ }
45
+
46
+ /** A note matches the search when every word is in its title, meeting, initiative, board or first summary line, or the server found it. */
47
+ export function hits(r, q, found) {
48
+ const ws = words(q);
49
+ if (!ws.length) return true;
50
+ if (found && found.has(r.id)) return true;
51
+ const hay = [r.title, r.meeting && r.meeting.title, r.initiative && (r.initiative.title || r.initiative.id), r.board && (r.board.title || r.board.id),
52
+ r.private ? '' : (r.summary_lines || []).join(' ')].filter(Boolean).join(' ').toLowerCase();
53
+ return ws.every((w) => hay.includes(w));
54
+ }
55
+
56
+ /**
57
+ * The list, from the GET /api/notes answer: { state, count, groups: [{ key, label, entries }] }. An entry is a note
58
+ * { kind: 'note', row } or a series { kind: 'series', key, title, when, size, open, carried, rows } (rows newest first).
59
+ * opts = { boards (GET /api/boards boards), q, found (Set of ids from /api/notes/search) }
60
+ */
61
+ export function notesList(answer, opts = {}) {
62
+ if (!answer || answer.ok !== true) return { state: 'error', error: (answer && answer.error) || 'The notes could not be read.', count: 0, groups: [] };
63
+ const all = (answer.notes || []).filter((r) => r && r.id);
64
+ const shown = all.filter((r) => hits(r, opts.q, opts.found));
65
+ const boards = (opts.boards || []).filter((b) => b && b.id && !b.error);
66
+ const order = new Map(boards.map((b, i) => [boardKey(b), i])), names = new Map(boards.map((b) => [boardKey(b), b.name || b.title || b.id]));
67
+ const size = new Map();
68
+ for (const r of all) { const k = r.series && r.series.key; if (k) size.set(k, (size.get(k) || 0) + 1); }
69
+ const entries = new Map();
70
+ for (const r of shown) {
71
+ const k = r.series && r.series.key, ek = k && size.get(k) >= 2 ? 'S' + k : 'N' + r.id;
72
+ if (!entries.has(ek)) entries.set(ek, { ek, series: ek[0] === 'S' ? k : null, rows: [] });
73
+ entries.get(ek).rows.push(r);
74
+ }
75
+ const g = new Map();
76
+ for (const e of entries.values()) {
77
+ e.rows.sort((a, b) => at(b) - at(a));
78
+ const r = e.rows[0];
79
+ const k = r.portfolio ? '@portfolio' : r.board && r.board.id ? boardKey(r.board) : r.initiative && r.initiative.id ? '@initiative' : '';
80
+ if (!g.has(k)) g.set(k, { key: k, label: k === '@portfolio' ? 'Portfolio' : k === '@initiative' ? 'Initiatives' : !k ? 'Not linked' : names.get(k) || clip(r.board.title || r.board.id, 60), entries: [], t: 0 });
81
+ const o = e.series ? (answer.series_open || {})[e.series] : null;
82
+ g.get(k).entries.push(e.series
83
+ ? { kind: 'series', key: e.series, t: at(r), title: clip((r.meeting && r.meeting.kind === 'event' && r.meeting.title) || r.title || 'Untitled meeting', 120), when: whenOf(startOf(r)), size: size.get(e.series), open: o && o.open ? o.open : 0, carried: !!(o && o.carried), rows: e.rows.map(rowOf) }
84
+ : { kind: 'note', t: at(r), row: rowOf(r) });
85
+ }
86
+ for (const x of g.values()) x.entries.sort((a, b) => b.t - a.t);
87
+ const rank = (x) => (x.key === '@portfolio' ? [0, 0] : x.key === '@initiative' ? [3, 0] : !x.key ? [4, 0] : order.has(x.key) ? [1, order.get(x.key)] : [2, 0]);
88
+ const groups = [...g.values()].sort((a, b) => { const p = rank(a), q = rank(b); return p[0] - q[0] || p[1] - q[1] || a.label.localeCompare(b.label); })
89
+ .map(({ key, label, entries: es }) => ({ key, label, entries: es }));
90
+ return { state: 'ok', count: shown.length, total: all.length, groups };
91
+ }
92
+
93
+ /* ── html, pure ───────────────────────────────────────────────────────────────────────────────────────────────────── */
94
+
95
+ const ICP = { doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>', notes: '<path d="M7 3h7l4 4v14H7zM14 3v4h4M10 12h5M10 16h4"/>', next: '<path d="M9 6l6 6-6 6"/>', fold: '<path d="M6 9l6 6 6-6"/>', search: '<circle cx="11" cy="11" r="6"/><path d="M20 20l-4.5-4.5"/>', alert: '<path d="M12 4l9 16H3zM12 10v4M12 17h.01"/>' };
96
+ const ic = (k) => `<svg class="i" viewBox="0 0 24 24">${ICP[k]}</svg>`;
97
+
98
+ /** A note's row button. `sub` is a note under an open series: it shows its day and the first line of its summary. */
99
+ export function noteRowHtml(r, esc, sub) {
100
+ const meta = [r.live ? 'now' : sub ? r.day : r.when, r.len].filter(Boolean).join(' · ');
101
+ const tags = [r.live ? `<span class="vn-tg vn-live">${r.live === 'paused' ? 'paused' : 'recording'}</span>` : '',
102
+ !sub && r.initiative ? `<span class="vn-tg">${esc(r.initiative)}</span>` : '', !sub && r.board ? '<span class="vn-tg" title="Linked to the board, not to one initiative">board</span>' : '',
103
+ !sub && r.noMeeting ? '<span class="vn-tg" title="Not linked to a meeting">no meeting</span>' : '',
104
+ r.conflicts ? `<span class="vn-tg vn-warn" title="${r.conflicts} ${r.conflicts === 1 ? 'statement differs' : 'statements differ'} from a file">${ic('alert')}${r.conflicts}</span>` : ''].join('');
105
+ return `<li class="vn-r${sub ? ' vn-sub' : ''}"><button type="button" class="vn-o" data-vn-note="${esc(r.id)}"><span class="vn-k${r.live ? ' hot' : ''}">${ic(r.live ? 'mic' : 'doc')}</span><span class="vn-t"><b>${esc(sub && r.gist ? r.gist : r.title)}</b><small>${esc(meta)}</small></span><span class="vn-tgs">${tags}</span></button></li>`;
106
+ }
107
+
108
+ /** A series entry: its row (opens the newest note) and a fold control; open, its newest three notes. */
109
+ export function seriesHtml(e, esc, open) {
110
+ const more = e.rows.length > 3 ? `<li class="vn-r vn-sub vn-more"><span>${e.rows.length - 3} more in the series. Page through them from a note.</span></li>` : '';
111
+ const left = e.open ? `<span class="vn-tg${e.carried ? ' vn-warn' : ''}" title="${e.open} ${e.open === 1 ? 'next step is' : 'next steps are'} still open across the series">${e.open} open</span>` : '';
112
+ return `<li class="vn-r vn-ser"><button type="button" class="vn-o" data-vn-series="${esc(e.key)}" data-vn-note="${esc(e.rows[0].id)}"><span class="vn-k">${ic('notes')}</span><span class="vn-t"><b>${esc(e.title)}</b><small>${esc(e.when)} · ${e.size} meetings</small></span><span class="vn-tgs"><span class="vn-tg" title="A regular meeting: its notes are kept together">series</span>${left}</span></button><button type="button" class="vn-x" data-vn-fold="${esc(e.key)}" aria-expanded="${!!open}" aria-label="${open ? 'Hide its recent meetings' : 'Show its recent meetings'}">${ic(open ? 'fold' : 'next')}</button></li>`
113
+ + (open ? e.rows.slice(0, 3).map((r) => noteRowHtml(r, esc, true)).join('') + more : '');
114
+ }
115
+
116
+ /** The groups, or what is missing. `ui` = { q, expand: Set, searching } */
117
+ export function listBodyHtml(L, esc, ui = {}) {
118
+ if (!L) return '<p class="note vn-none" role="status">Reading the notes.</p>';
119
+ if (L.state === 'error') return `<p class="note vn-none" role="status">The notes could not be read. ${esc(L.error)}</p>`;
120
+ if (!L.total) return '<p class="note vn-none">No notes yet. Notes you record show here, grouped by what they are about.</p>';
121
+ if (!L.count) return `<p class="note vn-none" role="status">${ui.searching ? 'Searching what was said.' : `No note matches “${esc(String(ui.q || '').trim())}”.`}</p>`;
122
+ const q = words(ui.q).length > 0;
123
+ return L.groups.map((g) => `<section class="vn-g" data-vn-group="${esc(g.label)}"><h4>${esc(g.label)}<small>${g.entries.length}</small></h4><ul class="vn-l" role="list">${g.entries.map((e) => (e.kind === 'series' ? seriesHtml(e, esc, q || (ui.expand && ui.expand.has(e.key))) : noteRowHtml(e.row, esc))).join('')}</ul></section>`).join('');
124
+ }
125
+
126
+ export const countLine = (L) => (L && L.state === 'ok' ? (L.count === L.total ? `${L.total} ${L.total === 1 ? 'note' : 'notes'}` : `${L.count} of ${L.total} notes`) : '');
127
+
128
+ /* ── the dialog ──────────────────────────────────────────────────────────────────────────────────────────────────────── */
129
+
130
+ /** Adds the Notes button to the Briefing's Calendar card: in the header on a wide screen, and under the day on a phone, where the
131
+ * header has no room. deps: { $, esc, openDlg, toast, pmGet, pmPost, task } */
132
+ export function mountNotes(d) {
133
+ const card = d.$('#todayCard'), head = card && card.querySelector('.ch');
134
+ if (!head || d.$('#vnOpen')) return null;
135
+ vwStyle('notes');
136
+ const mk = (id, cls) => {
137
+ const b = document.createElement('button');
138
+ b.type = 'button'; b.id = id; b.className = cls; b.setAttribute('aria-haspopup', 'dialog'); b.title = 'Every meeting note, grouped by what it is about';
139
+ b.innerHTML = `${ic('notes')}<span>Notes</span>`;
140
+ b.onclick = () => openNotes(d);
141
+ return b;
142
+ };
143
+ const f = head.querySelector('.fbtn'), b = mk('vnOpen', 'vn-open');
144
+ if (f) f.before(b); else head.append(b);
145
+ card.append(mk('vnOpenFoot', 'vn-open vn-foot'));
146
+ return { open: () => openNotes(d) };
147
+ }
148
+
149
+ /** Opens the dialog with the Notes list in its detail pane. */
150
+ export async function openNotes(d) {
151
+ vwStyle('notes'); vwStyle('meet');
152
+ const ui = { q: '', expand: new Set(), found: null, searching: false, answer: null, boards: [], token: 0 };
153
+ d.openDlg({ eye: 'Calendar', title: 'Notes', label: 'Notes', say: 'Every meeting note you recorded, grouped by what it is about. Press one to open it beside the list.',
154
+ pane: `<div class="vn" id="vnList"><div class="vn-s"><label class="vn-q">${ic('search')}<input type="search" id="vnQ" placeholder="Search notes, decisions, what was said" aria-label="Search the notes" autocomplete="off"></label><span class="vn-c" id="vnCount" aria-live="polite"></span></div><div id="vnBody">${listBodyHtml(null, d.esc)}</div></div>` });
155
+ const box = d.$('#vnList');
156
+ const model = () => (ui.answer ? notesList(ui.answer, { boards: ui.boards, q: ui.q, found: ui.found }) : null);
157
+ const draw = () => {
158
+ if (!box.isConnected) return;
159
+ const L = model();
160
+ d.$('#vnBody').innerHTML = listBodyHtml(L, d.esc, ui);
161
+ d.$('#vnCount').textContent = countLine(L);
162
+ };
163
+ const read = async () => {
164
+ const [l, bs] = await Promise.all([d.pmGet('/api/notes'), d.pmGet('/api/boards')]);
165
+ ui.answer = l || { ok: false, error: 'no answer' };
166
+ ui.boards = bs && bs.ok && Array.isArray(bs.boards) ? bs.boards : [];
167
+ draw();
168
+ };
169
+ let findT = null;
170
+ box.oninput = (e) => {
171
+ if (e.target.id !== 'vnQ') return;
172
+ ui.q = e.target.value; ui.found = null; clearTimeout(findT);
173
+ const q = ui.q.trim(), my = ++ui.token;
174
+ ui.searching = q.length >= SEARCH_MIN; draw();
175
+ if (!ui.searching) return;
176
+ findT = setTimeout(async () => {
177
+ const r = await d.pmGet('/api/notes/search?q=' + encodeURIComponent(q));
178
+ if (my !== ui.token) return;
179
+ ui.searching = false; ui.found = new Set(r && r.ok && Array.isArray(r.ids) ? r.ids : []); draw();
180
+ }, 250);
181
+ };
182
+ box.onclick = (e) => {
183
+ const t = e.target.closest('button'); if (!t) return;
184
+ if (t.dataset.vnFold) { const k = t.dataset.vnFold; if (ui.expand.has(k)) ui.expand.delete(k); else ui.expand.add(k); draw(); const x = box.querySelector(`[data-vn-fold="${CSS.escape(k)}"]`); if (x) x.focus(); return; }
185
+ if (t.dataset.vnNote) openNoteTab({ pmGet: d.pmGet, pmPost: d.pmPost, esc: d.esc, toast: d.toast, task: d.task || (async () => ({ ok: false, text: 'Make task is not available on this page.' })), changed: read }, t.dataset.vnNote);
186
+ };
187
+ await read();
188
+ }
@@ -6,6 +6,7 @@ import { pmPost, pmGet } from './http.js';
6
6
  import { startAgent } from './page-agent.js';
7
7
  import { mountMeeting } from './premium-meeting.js';
8
8
  import { mountCalEntry } from './premium-vw-cal.js';
9
+ import { mountNotes } from './premium-vw-notes.js';
9
10
  import { mountFirst } from './premium-first.js';
10
11
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
11
12
  import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
@@ -25,6 +26,7 @@ const pinned = new Set();
25
26
  wireRail('brief');
26
27
  const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => { if (M) drawTl(); } });
27
28
  mountCalEntry($('#todayCard'), { $, esc, openDlg, turnA, ptx, pmGet, ws: () => new URLSearchParams(location.search).get('ws'), openRow: week.openRow }); // the full calendar: Day, Week and Month in the viewer
29
+ mountNotes({ $, esc, openDlg, toast, pmGet, pmPost, task: week.task });
28
30
 
29
31
  /* ── a day's baseline, kept on this device, so "N of M done" counts rows that cleared since the page first read today ────── */
30
32
  const dayKey = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-viewer S7: an initiative and its tasks as tabs of the premium dialog viewer (PRD R9).",
3
+ "modules": [
4
+ "premium-vw-item.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-vw-item-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-vw-item.test.js": 1,
11
+ "premium-vw-item-test.js": 45
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-viewer, slice S3: the meeting detail laid out as the console's note sheet (Before, During, After) in the premium meeting dialog.",
3
+ "modules": [
4
+ "premium-vw-meet.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-vw-meet-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-vw-meet.test.js": 2,
11
+ "premium-vw-meet-test.js": 60
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-viewer, R9: the Notes list in the premium dialog, a note opened beside it, and the note sheet's Before, During and After stages other views plug into.",
3
+ "modules": [
4
+ "premium-vw-notes.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-vw-notes-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-vw-notes.test.js": 2,
11
+ "premium-vw-notes-test.js": 60
12
+ }
13
+ }