create-pmos 0.323.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.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- 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/workspace/briefing-premium-calendar-2-test.js +8 -6
- package/workspace/briefing-premium-calendar-3-test.js +7 -4
- package/workspace/briefing-premium-calendar-test.js +4 -2
- package/workspace/guide/briefing-premium.md +15 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-item-test.js +128 -0
- package/workspace/premium-vw-meet-test.js +210 -0
- package/workspace/premium-vw-notes-test.js +161 -0
- package/workspace/premium-vw-slides-test.js +269 -0
- package/workspace/public/pm/premium-board.js +3 -1
- package/workspace/public/pm/premium-deck.js +218 -0
- package/workspace/public/pm/premium-initiative.js +7 -2
- package/workspace/public/pm/premium-meeting.js +84 -31
- package/workspace/public/pm/premium-report-read.js +11 -3
- package/workspace/public/pm/premium-shell.js +1 -0
- package/workspace/public/pm/premium-vw-item-model.js +58 -0
- package/workspace/public/pm/premium-vw-item.css +25 -0
- package/workspace/public/pm/premium-vw-item.js +66 -0
- package/workspace/public/pm/premium-vw-meet.css +87 -0
- package/workspace/public/pm/premium-vw-meet.js +322 -0
- package/workspace/public/pm/premium-vw-notes.css +43 -0
- package/workspace/public/pm/premium-vw-notes.js +188 -0
- package/workspace/public/pm/premium-vw-slides.css +163 -0
- package/workspace/public/pm/premium-vw-slides.js +472 -0
- package/workspace/public/pm/premium.js +2 -0
- package/workspace/test-lists/premium-viewer.json +9 -3
- package/workspace/test-lists/premium-vw-item.json +13 -0
- package/workspace/test-lists/premium-vw-meet.json +13 -0
- package/workspace/test-lists/premium-vw-notes.json +13 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* pm/premium-deck.js — a deck as a markdown file (initiative premium-viewer, R-SL1). Pure: no DOM, so Node tests import it as it is.
|
|
2
|
+
* The file stays plain markdown. `# Title` is the title slide and each `## Heading` is one slide. Under a heading, a
|
|
3
|
+
* `<!-- pmos:slide {json} -->` comment holds what markdown cannot: the layout, the speaker notes, and the items (text, image, chart,
|
|
4
|
+
* table, shape) with their place on a 960 x 540 canvas. Below the comment the slide's text is written again as markdown, so the file
|
|
5
|
+
* reads on GitHub and an agent can propose a change to it. The block keeps a hash of that text: when the text no longer matches
|
|
6
|
+
* (someone edited the file by hand), the file's text wins and the slide is marked `changed`.
|
|
7
|
+
* parseDeck(md, fallbackTitle) -> { front, title, theme, slides: [{ l, notes, els, keep?, h1?, changed? }], blocks } blocks = slides that had a block;
|
|
8
|
+
* keep = the parts of the section the editor does not change (see KEEP)
|
|
9
|
+
* writeDeck(deck) -> md (the first slide is always the `# ` title slide of the file)
|
|
10
|
+
* mkLayout(l, c) the items of a layout, filled from c ({ title, body, body2, kicker, big, chart, img })
|
|
11
|
+
* cleanHtml(html, inline) the text html an item may hold: b, i, u, br, p, div, ul, ol, li, h3 (inline: b, i, u, br); no attributes
|
|
12
|
+
* htmlToMd(html) · mdToHtml(md) · cleanEl(e) · hash(s)
|
|
13
|
+
* Nothing here reads or writes a file: the editor (premium-vw-slides.js) reads through /api/doc and saves through /api/doc-sheet/edit. */
|
|
14
|
+
|
|
15
|
+
export const W = 960, H = 540;
|
|
16
|
+
export const LAYOUTS = [['title', 'Title'], ['content', 'Title and text'], ['two', 'Two columns'], ['chart', 'Chart and text'], ['big', 'Big number'], ['image', 'Image and text'], ['quote', 'Quote'], ['section', 'Section break']];
|
|
17
|
+
export const ROLES = [['title', 'Title'], ['heading', 'Heading'], ['body', 'Body'], ['small', 'Small'], ['kicker', 'Kicker'], ['big', 'Big number'], ['quote', 'Quote']];
|
|
18
|
+
export const THEMES = [['ember', 'Ember'], ['paper', 'Paper'], ['sky', 'Sky']];
|
|
19
|
+
export const COLORS = [['', 'Theme text'], ['acc', 'Accent'], ['mut', 'Muted']];
|
|
20
|
+
export const FILLS = [['acc', 'Accent'], ['fg', 'Text colour'], ['soft', 'Soft']];
|
|
21
|
+
const has = (list, k) => list.some((x) => x[0] === k);
|
|
22
|
+
/* Parts of a section the editor keeps as they are and never shows as slide text: a report's note (`<!-- pmos:note id -->` … `<!-- /pmos:note -->`),
|
|
23
|
+
* the drafter's `<!-- pmos:slides v1 … -->` block, and any other comment. They are written back after the slide's text. */
|
|
24
|
+
const KEEP = /<!-- pmos:note [^>]*-->[\s\S]*?<!-- \/pmos:note -->|<!--(?!\s*pmos:slide\s)[\s\S]*?-->/g;
|
|
25
|
+
const BLOCK = /^<!--\s*pmos:slide\s+(\{[\s\S]*?\})\s*-->\s*$/;
|
|
26
|
+
|
|
27
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
28
|
+
const unesc = (s) => String(s).replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, ' ').replace(/&/g, '&');
|
|
29
|
+
export function hash(s) { let h = 5381; const t = String(s); for (let i = 0; i < t.length; i++) h = ((h << 5) + h + t.charCodeAt(i)) >>> 0; return h.toString(36); }
|
|
30
|
+
|
|
31
|
+
/* ── text html: a small allow-list, no attributes ── */
|
|
32
|
+
const BLOCK_TAGS = ['b', 'i', 'u', 'br', 'p', 'div', 'ul', 'ol', 'li', 'h3'], INLINE_TAGS = ['b', 'i', 'u', 'br'];
|
|
33
|
+
const SYN = { strong: 'b', em: 'i' };
|
|
34
|
+
export function cleanHtml(html, inline) {
|
|
35
|
+
const ok = inline ? INLINE_TAGS : BLOCK_TAGS, keep = [];
|
|
36
|
+
let s = String(html == null ? '' : html).replace(/<!--[\s\S]*?-->/g, '').replace(/<(script|style|template|iframe|object|svg|math|textarea|title)\b[\s\S]*?<\/\1\s*>/gi, '');
|
|
37
|
+
s = s.replace(/<(\/?)([a-zA-Z][\w-]*)\b[^<>]*>/g, (m, close, tag) => {
|
|
38
|
+
let t = tag.toLowerCase(); t = SYN[t] || t;
|
|
39
|
+
if (!ok.includes(t) || (close && t === 'br')) return inline && !close && /^(p|div|li|h3)$/.test(t) && keep.length ? '\u0001' + (keep.push('<br>') - 1) + '\u0002' : '';
|
|
40
|
+
return '\u0001' + (keep.push(close ? `</${t}>` : `<${t}>`) - 1) + '\u0002';
|
|
41
|
+
});
|
|
42
|
+
s = s.replace(/[<>\u0001\u0002]/g, (c) => (c === '<' ? '<' : c === '>' ? '>' : c)).replace(/\u0001(\d+)\u0002/g, (m, n) => keep[+n]).replace(/[\u0001\u0002]/g, '');
|
|
43
|
+
return s.slice(0, 20000);
|
|
44
|
+
}
|
|
45
|
+
const inlineMd = (h) => unesc(String(h).replace(/<br>/g, ' ').replace(/<b>([\s\S]*?)<\/b>/g, '**$1**').replace(/<i>([\s\S]*?)<\/i>/g, '_$1_').replace(/<u>([\s\S]*?)<\/u>/g, '$1').replace(/<[^>]+>/g, '')).replace(/\s+/g, ' ').trim();
|
|
46
|
+
/** Text html as markdown: paragraphs, bullets, numbered lists, ### subheads, bold and italic. */
|
|
47
|
+
export function htmlToMd(html) {
|
|
48
|
+
const s = cleanHtml(html), out = [];
|
|
49
|
+
const re = /<(ul|ol)>([\s\S]*?)<\/\1>|<h3>([\s\S]*?)<\/h3>|<(?:p|div)>([\s\S]*?)<\/(?:p|div)>|([^<]+|<(?:b|i|u|br)>|<\/(?:b|i|u)>)/g;
|
|
50
|
+
let run = '';
|
|
51
|
+
const flush = () => { const t = inlineMd(run); if (t) out.push(t); run = ''; };
|
|
52
|
+
for (const m of s.matchAll(re)) {
|
|
53
|
+
if (m[1]) { flush(); const items = [...m[2].matchAll(/<li>([\s\S]*?)<\/li>/g)].map((x) => inlineMd(x[1])).filter(Boolean); out.push(items.map((t, k) => (m[1] === 'ol' ? (k + 1) + '. ' : '- ') + t).join('\n')); }
|
|
54
|
+
else if (m[3] != null) { flush(); const t = inlineMd(m[3]); if (t) out.push('### ' + t); }
|
|
55
|
+
else if (m[4] != null) { flush(); const t = inlineMd(m[4]); if (t) out.push(t); }
|
|
56
|
+
else if (m[5] === '<br>') { flush(); }
|
|
57
|
+
else run += m[5] || '';
|
|
58
|
+
}
|
|
59
|
+
flush();
|
|
60
|
+
return out.join('\n\n');
|
|
61
|
+
}
|
|
62
|
+
const inlineHtml = (t) => esc(t).replace(/\*\*(.+?)\*\*/g, '<b>$1</b>').replace(/(^|[\s(])_(.+?)_(?=$|[\s).,;:!?])/g, '$1<i>$2</i>');
|
|
63
|
+
/** Markdown text as item html. A table or image line belongs to its own item and is left out here. */
|
|
64
|
+
export function mdToHtml(md) {
|
|
65
|
+
const out = []; let list = null;
|
|
66
|
+
const close = () => { if (list) { out.push(`</${list}>`); list = null; } };
|
|
67
|
+
for (const raw of String(md || '').split('\n')) {
|
|
68
|
+
const l = raw.trimEnd(); let m;
|
|
69
|
+
if (/^\s*\|/.test(l) || /^\s*<!--.*-->\s*$/.test(l) || /^!\[[^\]]*\]\([^)]*\)\s*$/.test(l.trim())) { close(); continue; }
|
|
70
|
+
if ((m = /^\s*[-*+] (.*)/.exec(l))) { if (list !== 'ul') { close(); out.push('<ul>'); list = 'ul'; } out.push(`<li>${inlineHtml(m[1])}</li>`); }
|
|
71
|
+
else if ((m = /^\s*\d+[.)] (.*)/.exec(l))) { if (list !== 'ol') { close(); out.push('<ol>'); list = 'ol'; } out.push(`<li>${inlineHtml(m[1])}</li>`); }
|
|
72
|
+
else if ((m = /^#{3,6} (.*)/.exec(l))) { close(); out.push(`<h3>${inlineHtml(m[1])}</h3>`); }
|
|
73
|
+
else if ((m = /^> ?(.*)/.exec(l))) { close(); if (m[1].trim()) out.push(`<p>${inlineHtml(m[1])}</p>`); }
|
|
74
|
+
else if (l.trim()) { close(); out.push(`<p>${inlineHtml(l.trim())}</p>`); }
|
|
75
|
+
else close();
|
|
76
|
+
}
|
|
77
|
+
close();
|
|
78
|
+
return out.join('');
|
|
79
|
+
}
|
|
80
|
+
const plain = (h) => inlineMd(String(h || '').replace(/<\/(p|div|li|h3)>/g, ' '));
|
|
81
|
+
|
|
82
|
+
/* ── items ── */
|
|
83
|
+
const num = (v, lo, hi, d) => { const n = Math.round(Number(v)); return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : d; };
|
|
84
|
+
const cell = (v) => cleanHtml(v, true).slice(0, 400);
|
|
85
|
+
/** An item as the file may hold it: known kinds and keys only, numbers on the canvas, text through the allow-list, an image path inside the workspace. Null when it cannot be one. */
|
|
86
|
+
export function cleanEl(e) {
|
|
87
|
+
if (!e || typeof e !== 'object') return null;
|
|
88
|
+
const g = { x: num(e.x, -W, 2 * W, 72), y: num(e.y, -H, 2 * H, 60), w: num(e.w, 20, 2 * W, 300), h: num(e.h, 20, 2 * H, 120) };
|
|
89
|
+
const k = typeof e.k === 'string' && /^(title|body|body2|kicker|big|chart|img)$/.test(e.k) ? { k: e.k } : {};
|
|
90
|
+
if (e.t === 'text') return { t: 'text', ...k, role: has(ROLES, e.role) ? e.role : 'body', ...g, html: cleanHtml(e.html), align: /^(left|center|right)$/.test(e.align) ? e.align : 'left', ...(has(COLORS, e.color) && e.color ? { color: e.color } : {}) };
|
|
91
|
+
if (e.t === 'shape') return { t: 'shape', ...g, fill: has(FILLS, e.fill) ? e.fill : 'acc', ...(e.round ? { round: true } : {}) };
|
|
92
|
+
if (e.t === 'img') { const src = okSrc(e.src) ? String(e.src) : ''; return { t: 'img', ...k, ...g, src, alt: String(e.alt || '').slice(0, 200) }; }
|
|
93
|
+
if (e.t === 'chart') {
|
|
94
|
+
const data = (Array.isArray(e.data) ? e.data : []).slice(0, 24).map((r) => [String((r && r[0]) == null ? '' : r[0]).slice(0, 40), Number.isFinite(Number(r && r[1])) ? Number(r[1]) : 0]);
|
|
95
|
+
return { t: 'chart', ...k, ...g, kind: e.kind === 'line' ? 'line' : 'bar', data: data.length ? data : [['', 0]] };
|
|
96
|
+
}
|
|
97
|
+
if (e.t === 'table') {
|
|
98
|
+
const rows = (Array.isArray(e.rows) ? e.rows : []).slice(0, 12).map((r) => (Array.isArray(r) ? r : []).slice(0, 8).map(cell));
|
|
99
|
+
const n = Math.max(1, ...rows.map((r) => r.length));
|
|
100
|
+
return rows.length ? { t: 'table', ...g, rows: rows.map((r) => r.concat(Array(n - r.length).fill(''))) } : null;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
/** An image path the page may show through /api/asset: relative, inside the workspace, an image name. */
|
|
105
|
+
export const okSrc = (s) => typeof s === 'string' && s.length < 300 && /^[\w][\w./ -]*\.(png|jpe?g|gif|webp|svg|avif)$/i.test(s) && !/(^|\/)\.\.(\/|$)/.test(s);
|
|
106
|
+
|
|
107
|
+
export function mkLayout(l, c = {}) {
|
|
108
|
+
const T = (k, role, x, y, w, h, html, align) => ({ t: 'text', k, role, x, y, w, h, html, align: align || 'left' });
|
|
109
|
+
const ti = c.title != null ? c.title : '', bo = c.body != null ? c.body : '';
|
|
110
|
+
switch (l) {
|
|
111
|
+
case 'title': return [T('kicker', 'kicker', 72, 232, 816, 28, c.kicker || ''), T('title', 'title', 72, 272, 816, 140, ti), T('body', 'body', 72, 424, 816, 70, bo)];
|
|
112
|
+
case 'two': return [T('title', 'heading', 72, 60, 816, 56, ti), T('body', 'body', 72, 150, 390, 330, bo), T('body2', 'body', 498, 150, 390, 330, c.body2 || '')];
|
|
113
|
+
case 'chart': return [T('title', 'heading', 72, 60, 816, 56, ti), c.chart ? { ...c.chart, k: 'chart', x: 72, y: 150, w: 520, h: 320 } : { t: 'chart', k: 'chart', x: 72, y: 150, w: 520, h: 320, kind: 'bar', data: [['', 0]] }, T('body', 'body', 624, 160, 264, 310, bo)];
|
|
114
|
+
case 'big': return [T('big', 'big', 72, 96, 816, 170, c.big || ''), T('body', 'body', 72, 300, 700, 140, bo), ...(ti ? [T('title', 'small', 72, 470, 700, 40, ti)] : [])];
|
|
115
|
+
case 'image': return [c.img ? { ...c.img, k: 'img', x: 0, y: 0, w: 420, h: 540 } : { t: 'img', k: 'img', x: 0, y: 0, w: 420, h: 540, src: '', alt: '' }, T('title', 'heading', 476, 130, 420, 130, ti), T('body', 'body', 476, 290, 420, 200, bo)];
|
|
116
|
+
case 'quote': return [T('title', 'quote', 110, 140, 740, 220, ti), T('body', 'small', 110, 390, 740, 40, bo)];
|
|
117
|
+
case 'section': return [T('kicker', 'kicker', 72, 206, 816, 28, c.kicker || '', 'center'), T('title', 'title', 72, 246, 816, 130, ti, 'center')];
|
|
118
|
+
default: return [T('title', 'heading', 72, 60, 816, 56, ti), T('body', 'body', 72, 150, 816, 330, bo)];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* ── the slide's text, as markdown ── */
|
|
123
|
+
const titleEl = (s) => s.els.find((e) => e.t === 'text' && e.k === 'title') || s.els.find((e) => e.t === 'text');
|
|
124
|
+
const mdTable = (rows) => rows.length ? [rows[0], rows[0].map(() => '---'), ...rows.slice(1)].map((r) => '| ' + r.map((c) => inlineMd(c).replace(/\|/g, '\\|') || ' ').join(' | ') + ' |').join('\n') : '';
|
|
125
|
+
/** The heading and the body a slide writes below its block. */
|
|
126
|
+
export function slideText(s) {
|
|
127
|
+
const t = titleEl(s), parts = [];
|
|
128
|
+
for (const e of s.els) {
|
|
129
|
+
if (e === t) continue;
|
|
130
|
+
if (e.t === 'text') { const m = htmlToMd(e.html); if (m) parts.push(m); }
|
|
131
|
+
else if (e.t === 'table') parts.push(mdTable(e.rows));
|
|
132
|
+
else if (e.t === 'chart') parts.push(mdTable([['Label', 'Value'], ...e.data.map((d) => [esc(d[0]), String(d[1])])]));
|
|
133
|
+
else if (e.t === 'img' && e.src) parts.push(`![${(e.alt || '').replace(/[[\]]/g, '')}](${e.src})`);
|
|
134
|
+
}
|
|
135
|
+
return { head: t ? plain(t.html) : '', body: parts.join('\n\n') };
|
|
136
|
+
}
|
|
137
|
+
const textHash = (head, body) => hash(head.trim() + '\n' + body.replace(/\s+$/g, '').trim());
|
|
138
|
+
|
|
139
|
+
/* ── reading ── */
|
|
140
|
+
function splitFront(md) {
|
|
141
|
+
const m = /^---\n([\s\S]*?)\n---\n?/.exec(md);
|
|
142
|
+
return m ? { front: m[1], rest: md.slice(m[0].length) } : { front: null, rest: md };
|
|
143
|
+
}
|
|
144
|
+
const frontVal = (front, key) => { const m = front && new RegExp('^' + key + ':\\s*"?([^"\\n]*)"?\\s*$', 'm').exec(front); return m ? m[1].trim() : ''; };
|
|
145
|
+
function parseTable(lines) {
|
|
146
|
+
const rows = lines.filter((l) => !/^\s*\|?\s*:?-{3,}/.test(l)).map((l) => l.trim().replace(/^\||\|$/g, '').split(/(?<!\\)\|/).map((c) => inlineHtml(c.trim().replace(/\\\|/g, '|'))));
|
|
147
|
+
return rows.length >= 1 ? rows : null;
|
|
148
|
+
}
|
|
149
|
+
/** A section with no block, as a slide: its first table becomes a table item and the rest is the text. */
|
|
150
|
+
function fromSection(head, body, l) {
|
|
151
|
+
const lines = body.split('\n'); let tbl = null, i0 = -1;
|
|
152
|
+
for (let i = 0; i < lines.length; i++) if (/^\s*\|/.test(lines[i])) { let j = i; while (j < lines.length && /^\s*\|/.test(lines[j])) j++; if (j - i >= 2) { tbl = parseTable(lines.slice(i, j)); i0 = i; } break; }
|
|
153
|
+
const text = i0 >= 0 ? lines.filter((x, k) => !(k >= i0 && /^\s*\|/.test(x))).join('\n') : body;
|
|
154
|
+
const els = mkLayout(l, { title: inlineHtml(head), body: mdToHtml(text) }).filter((e) => !(l === 'title' && e.k !== 'title' && !plain(e.html)));
|
|
155
|
+
if (tbl) { const b = els.find((e) => e.k === 'body'); if (b && plain(b.html)) { b.h = 120; } els.push({ t: 'table', x: 72, y: b && plain(b.html) ? 290 : 150, w: 816, h: 190, rows: tbl }); }
|
|
156
|
+
return { l, notes: '', els: els.map(cleanEl).filter(Boolean) };
|
|
157
|
+
}
|
|
158
|
+
/** The file as a deck. A file with no blocks (a report) is read as its title slide and one slide per section, as the report reader does. */
|
|
159
|
+
export function parseDeck(md, fallbackTitle) {
|
|
160
|
+
const { front, rest } = splitFront(String(md || '').replace(/\r\n/g, '\n'));
|
|
161
|
+
const theme = has(THEMES, frontVal(front, 'deck_theme')) ? frontVal(front, 'deck_theme') : 'ember';
|
|
162
|
+
const secs = []; let cur = null, pre = [];
|
|
163
|
+
for (const line of rest.split('\n')) {
|
|
164
|
+
const h1 = /^# (?!#)(.*)/.exec(line), h2 = /^## (?!#)(.*)/.exec(line);
|
|
165
|
+
if (h1 && !cur && !secs.length) { cur = { h1: true, head: h1[1].trim(), lines: [] }; secs.push(cur); continue; }
|
|
166
|
+
if (h2) { cur = { head: h2[1].trim(), lines: [] }; secs.push(cur); continue; }
|
|
167
|
+
if (cur) cur.lines.push(line); else pre.push(line);
|
|
168
|
+
}
|
|
169
|
+
const title = (secs[0] && secs[0].h1 ? secs[0].head : '') || frontVal(front, 'title') || fallbackTitle || 'Slides';
|
|
170
|
+
if (!secs.length || !secs[0].h1) { secs.unshift({ h1: true, head: title, lines: pre, synth: true }); pre = []; }
|
|
171
|
+
const lead = pre.join('\n').trim(); // text above the `# ` title stays where it is
|
|
172
|
+
let blocks = 0;
|
|
173
|
+
const slides = secs.map((s) => {
|
|
174
|
+
let blk = null; const lines = s.lines.slice(), keep = [];
|
|
175
|
+
const at = lines.findIndex((l) => l.trim());
|
|
176
|
+
if (at >= 0) { const m = BLOCK.exec(lines[at].trim()); if (m) { try { blk = JSON.parse(m[1]); } catch { blk = null; } if (!blk) keep.push(lines[at].trim()); lines.splice(at, 1); } } // a block that does not read is kept as it was
|
|
177
|
+
const body = lines.join('\n').replace(KEEP, (m) => { keep.push(m.trim()); return ''; }).replace(/\n{3,}/g, '\n\n').replace(/^\n+|\s+$/g, '');
|
|
178
|
+
const kept = keep.length ? { keep } : {};
|
|
179
|
+
if (!blk || !Array.isArray(blk.els)) return { ...fromSection(s.head, body, s.h1 ? 'title' : 'content'), ...kept, ...(s.h1 ? { h1: true } : {}), ...(s.synth ? { synth: true } : {}) };
|
|
180
|
+
blocks++;
|
|
181
|
+
const sl = { l: has(LAYOUTS, blk.l) ? blk.l : 'content', notes: String(blk.notes || '').slice(0, 4000), els: blk.els.map(cleanEl).filter(Boolean), ...kept, ...(s.h1 ? { h1: true } : {}) };
|
|
182
|
+
if (blk.md && blk.md !== textHash(s.head, body)) return { ...applyText(sl, s.head, body), changed: true };
|
|
183
|
+
return sl;
|
|
184
|
+
});
|
|
185
|
+
return { front, title, theme, slides, blocks, ...(lead ? { pre: lead } : {}) };
|
|
186
|
+
}
|
|
187
|
+
/** The file's text wins over the block's: the title item takes the heading and the text items give way to one body with the file's text. */
|
|
188
|
+
function applyText(sl, head, body) {
|
|
189
|
+
const els = sl.els.map((e) => ({ ...e }));
|
|
190
|
+
const t = titleEl({ els });
|
|
191
|
+
if (t) t.html = inlineHtml(head); else els.unshift(mkLayout('content', { title: inlineHtml(head) })[0]);
|
|
192
|
+
const texts = els.filter((e) => e.t === 'text' && e !== (t || els[0]));
|
|
193
|
+
const html = mdToHtml(body);
|
|
194
|
+
if (texts.length) { texts[0].html = html; for (const x of texts.slice(1)) x.html = ''; }
|
|
195
|
+
else if (plain(html)) els.push(mkLayout('content', { body: html })[1]);
|
|
196
|
+
return { ...sl, els: els.filter((e) => !(e.t === 'text' && e !== t && e !== texts[0] && !plain(e.html))) };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* ── writing ── */
|
|
200
|
+
const blockJson = (o) => JSON.stringify(o).replace(/--/g, '-\\u002d');
|
|
201
|
+
function setFront(front, theme) {
|
|
202
|
+
if (front == null) return null;
|
|
203
|
+
return /^deck_theme:/m.test(front) ? front.replace(/^deck_theme:.*$/m, 'deck_theme: ' + theme) : front + '\ndeck_theme: ' + theme;
|
|
204
|
+
}
|
|
205
|
+
/** The deck as the file: front matter (with deck_theme), the title slide as `# `, every other slide as `## `, each with its block and its text. */
|
|
206
|
+
export function writeDeck(deck) {
|
|
207
|
+
const out = [];
|
|
208
|
+
const front = setFront(deck.front, deck.theme);
|
|
209
|
+
out.push(front != null ? '---\n' + front + '\n---\n' : '---\ndeck_theme: ' + deck.theme + '\n---\n');
|
|
210
|
+
if (deck.pre) out.push(deck.pre + '\n');
|
|
211
|
+
deck.slides.forEach((s, i) => {
|
|
212
|
+
const els = s.els.map(cleanEl).filter(Boolean), { head, body } = slideText({ els });
|
|
213
|
+
const h = (head || (i === 0 ? deck.title : '') || 'Slide ' + (i + 1)).replace(/\n/g, ' ');
|
|
214
|
+
const blk = { l: s.l, ...(s.notes ? { notes: s.notes } : {}), md: textHash(h, body), els };
|
|
215
|
+
out.push(`${i === 0 ? '#' : '##'} ${h}\n<!-- pmos:slide ${blockJson(blk)} -->\n` + (body ? '\n' + body + '\n' : '') + (s.keep && s.keep.length ? '\n' + s.keep.join('\n\n') + '\n' : ''));
|
|
216
|
+
});
|
|
217
|
+
return out.join('\n');
|
|
218
|
+
}
|
|
@@ -8,6 +8,7 @@ import { pmPost } from './http.js';
|
|
|
8
8
|
import { mountDocSheet } from './premium-doc-sheet.js';
|
|
9
9
|
import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, kv, H2, CHECK, CHEV, crumbHtml, wireCrumb, AI, openAddDoc, setPageGaps } from './premium-shell.js';
|
|
10
10
|
import { barHtml, onBar, closeMenu } from './premium-acts.js';
|
|
11
|
+
import { openWorkItem, recordPress } from './premium-vw-item.js';
|
|
11
12
|
import { openTicket } from './premium-vw-jira.js';
|
|
12
13
|
|
|
13
14
|
let M = null; // the model
|
|
@@ -133,7 +134,8 @@ function openTask(t) {
|
|
|
133
134
|
const rows = [['Type', t.kind || (taskKind(t) === 'req' ? 'PRD requirement' : 'Task')], ['Reference', t.ref], ['Source', t.src], ['Owner', t.owner], ['Starts', t.start ? when(t.start) : ''], ['Due', t.end ? when(t.end) : ''], ['Status', t.state || 'No result recorded']];
|
|
134
135
|
const say = t.title + (t.state ? ' is ' + t.state.toLowerCase() + '.' : ' has no result recorded. The repository records none for a PRD requirement.');
|
|
135
136
|
const act = t.pmos ? `<div class="tkact"><span class="label">Status</span><div class="seg tkst" role="group" aria-label="Status"><i class="pill"></i>${STATES.map((s) => `<button data-tks="${esc(s)}" aria-pressed="${t.state === s}">${s}</button>`).join('')}</div></div><p class="note" style="margin-top:12px">A PMOS task is kept on the board. Jira tickets are read-only here: Jira owns their status and dates.</p>` : `<p class="xn">${t.src === 'PRD requirement' ? 'Read from the initiative’s PRD. Nothing on this page changes it.' : 'Read from the board. Jira owns its status and dates.'}</p>`;
|
|
136
|
-
openDlg({ eye: 'Task · real data', title: t.title, sub: M.title, say, stream: turnA(ptx(say)), noteKey: null, pane: `<article class="paper doc">${kv(rows)}${act}</article>`, label: 'Task' });
|
|
137
|
+
openDlg({ eye: 'Task · real data', title: t.title, sub: M.title, say, stream: turnA(ptx(say)), noteKey: null, pane: `<article class="paper doc">${kv(rows)}${act}${recordPress('Open the initiative')}</article>`, label: 'Task' });
|
|
138
|
+
wireRecord();
|
|
137
139
|
$('#askF').hidden = true; if ($('#oMain .tkst')) pillOf($('#oMain .tkst'));
|
|
138
140
|
if (taskKind(t) === 'jira' && t.ref) openTicket({ ws: M.board.ws, board: M.board.id, initiative: M.id, ref: t.ref }); // the ticket beside its facts (premium-viewer S5)
|
|
139
141
|
$$('#oMain [data-tks]').forEach((b) => { b.onclick = async () => {
|
|
@@ -143,6 +145,8 @@ function openTask(t) {
|
|
|
143
145
|
toast('Status changed to ' + b.dataset.tks.toLowerCase() + '.'); closeDlg(); await load();
|
|
144
146
|
}; });
|
|
145
147
|
}
|
|
148
|
+
/** The pane's press that opens this initiative's record, checks, tasks and links as a viewer tab beside the dialog (premium-viewer S7). */
|
|
149
|
+
function wireRecord() { const b = $('#oMain [data-vwopen]'); if (b) b.onclick = () => openWorkItem({ kind: 'initiative', id: M.id, title: M.crumbTitle || M.title, ws: M.board.ws, board: M.board.id }); }
|
|
146
150
|
function openAddTask() {
|
|
147
151
|
const prefs = ['Research plan', 'Release plan', 'UAT', 'Rollback plan', 'Support briefing', 'Legal review'];
|
|
148
152
|
const form = `<div class="addf"><p class="note" style="margin:0">Use a task for work that is not a Jira ticket, such as a research plan, a release plan or UAT. It is kept on the board and it is not a Jira ticket.</p>
|
|
@@ -224,7 +228,8 @@ async function draft(b) {
|
|
|
224
228
|
/* ── the initiative's own dialog: the read-only agent about this initiative, with an optional first question ─────────────────────── */
|
|
225
229
|
function openAsk(q) {
|
|
226
230
|
const r = M.rows[0]; if (!r) return;
|
|
227
|
-
openDlg({ eye: 'Initiative · real data', title: r.title, sub: r.sub, say: r.dialog.say, stream: turnA(logHtml({ logTitle: 'Read from the repository', log: ['Read the initiative from the board and its sheet', 'Read its workflow steps from the workflow engine', 'Changed nothing'] })) + turnA(ptx(r.dialog.say)), noteKey: r.key, pane: `<article class="paper doc">${kv(r.dialog.facts)}<p class="xn">The initiative as the board holds it. Ask the agent anything about it; it reads this repository and changes nothing.</p
|
|
231
|
+
openDlg({ eye: 'Initiative · real data', title: r.title, sub: r.sub, say: r.dialog.say, stream: turnA(logHtml({ logTitle: 'Read from the repository', log: ['Read the initiative from the board and its sheet', 'Read its workflow steps from the workflow engine', 'Changed nothing'] })) + turnA(ptx(r.dialog.say)), noteKey: r.key, pane: `<article class="paper doc">${kv(r.dialog.facts)}<p class="xn">The initiative as the board holds it. Ask the agent anything about it; it reads this repository and changes nothing.</p>${recordPress()}</article>`, label: 'Initiative' });
|
|
232
|
+
wireRecord();
|
|
228
233
|
loadThread(r.key);
|
|
229
234
|
if (q) { const i = $('#askIn'); i.value = q; $('#askF').dispatchEvent(new Event('submit', { cancelable: true, bubbles: true })); }
|
|
230
235
|
setMode('chat');
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* The Today / This week switch, the week list and the meeting dialog. Reads GET /api/calendar-views?view=week, GET /api/meeting-replay, GET /api/meeting-material and
|
|
3
3
|
* GET /api/meeting-material/suggest. The writes are "Link it" (POST /api/calendar-links), Add and Remove material (POST /api/meeting-material) and Make task
|
|
4
4
|
* (POST /api/plan-items). Every word is a field of a record: the pure half (weekView, meetingView, the body builders) takes the routes' answers and returns what the page
|
|
5
|
-
* draws or sends, so a test reads it without a DOM. Recording and Focus are slice 3.
|
|
5
|
+
* draws or sends, so a test reads it without a DOM. Recording and Focus are slice 3.
|
|
6
|
+
* The dialog's detail is laid out as the console's note sheet (initiative premium-viewer, S3): a head with Before, During and After, what the meeting is about and its
|
|
7
|
+
* series line; the parts that come from the meeting's note (GET /api/notes/one) are drawn by premium-vw-meet.js. */
|
|
8
|
+
import { noteSheet, phaseOf, phaseHtml, seriesHtml, stageHtml, wireStage, PHASES, notesTablesHtml, openNoteTab, vmStyle } from './premium-vw-meet.js';
|
|
6
9
|
|
|
7
10
|
const pad = (n) => String(n).padStart(2, '0');
|
|
8
11
|
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
|
|
@@ -110,12 +113,14 @@ export function meetingView(row, replay, material, extra) {
|
|
|
110
113
|
const keys = rep && Array.isArray(rep.keys) ? rep.keys : [];
|
|
111
114
|
const pick = (k) => keys.filter((x) => x.k === k).map((x) => ({ id: x.id == null ? '' : String(x.id), text: clip(x.text, 240), owner: x.owner || '', due: x.due || '', open: x.state === 'open' || x.state === 'owner' }));
|
|
112
115
|
const ini = rep && rep.note && rep.note.initiative && rep.note.initiative.id ? rep.note.initiative : null, nws = rep && rep.note ? (ini && ini.ws) || rep.note.ws || '' : '';
|
|
113
|
-
const
|
|
116
|
+
const S = extra && extra.sheet;
|
|
117
|
+
const notes = S ? { title: S.title, id: S.id, initiative: S.initiative, decisions: S.decisions, actions: S.actions, questions: S.questions, whyCol: S.whyCol }
|
|
118
|
+
: rep ? { title: clip((rep.note && rep.note.title) || '', 120), id: (rep.note && rep.note.id) || '', initiative: ini ? { id: ini.id, name: clip(ini.title || ini.name || ini.id, 70), ws: nws } : null, decisions: pick('decision'), actions: pick('action'), questions: pick('question'), whyCol: false } : null;
|
|
114
119
|
const heard = rep && Number(rep.length_ms) > 0 ? Math.round(rep.length_ms / 60000) : 0;
|
|
115
120
|
return {
|
|
116
121
|
people,
|
|
117
|
-
notes, notesState: replay ? replay.state : 'none',
|
|
118
|
-
notesLine: !replay ? 'Reading the notes.' : replay.state === 'error' ? 'The notes could not be read: ' + clip(replay.error, 120) : replay.state === 'none' ? 'No notes for this meeting.' : '',
|
|
122
|
+
notes, notesState: S ? 'ok' : replay ? replay.state : 'none', sheet: S || null,
|
|
123
|
+
notesLine: S ? '' : !replay ? 'Reading the notes.' : replay.state === 'error' ? 'The notes could not be read: ' + clip(replay.error, 120) : replay.state === 'none' ? 'No notes for this meeting.' : '',
|
|
119
124
|
replay: rep && (rep.audio || heard) ? { minutes: heard, keyPoints: keys.length, lines: Array.isArray(rep.lines) ? rep.lines.length : 0 } : null,
|
|
120
125
|
material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', topic: clip(i.topic, 80), scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i) })) : null,
|
|
121
126
|
...prepOf(row, people, material, extra, aboutOf(row.level)),
|
|
@@ -471,35 +476,39 @@ export function mountMeeting(d) {
|
|
|
471
476
|
const IC = { spark: '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>', clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', scale: '<path d="M12 4v16M6 20h12M5 8h14M5 8l-2 6a3 3 0 0 0 4 0zM19 8l-2 6a3 3 0 0 0 4 0z"/>', doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>', link: '<path d="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"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>', plus: '<path d="M12 5v14M5 12h14"/>', x: '<path d="M6 6l12 12M18 6 6 18"/>', check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>' };
|
|
472
477
|
const ic = (n) => `<svg class="i" viewBox="0 0 24 24">${IC[n]}</svg>`;
|
|
473
478
|
const secH = (t, tag, extra) => `<h4 class="sh">${esc(t)}${tag ? ` <small>${esc(tag)}</small>` : ''}${extra || ''}</h4>`;
|
|
474
|
-
const items = (L, task) => `<ul class="mtg-l">${L.map((x, i) => `<li>${esc(x.text)}${x.owner || x.due ? `<em>${esc([x.owner, x.due].filter(Boolean).join(' · '))}</em>` : ''}${task ? `<button class="mtg-b mtg-task" data-task="${i}"${task.done.has(i) ? ' disabled' : ''}>${task.done.has(i) ? 'Task made' : 'Make task'}</button>` : ''}</li>`).join('')}</ul>`;
|
|
475
479
|
const pickLi = (it, key, on) => `<li class="mtg-pick"><span>${esc(clip(it.title, 120))}<em>${esc([it.kind, it.meta].filter(Boolean).join(' · '))}</em></span>${on ? '<span class="mtg-on">Picked</span>' : `<button class="mtg-b" data-pick="${esc(key)}">Pick</button>`}</li>`;
|
|
476
480
|
|
|
477
481
|
function detailHtml(v, boards, inis, saved, ui) {
|
|
478
|
-
const r = v.row, lv = r.level, note = noteOfRow(NR, r);
|
|
482
|
+
const r = v.row, lv = r.level, note = noteOfRow(NR, r), S = v.sheet;
|
|
479
483
|
const aboutNow = lv ? aboutOf(lv) : saved || '';
|
|
480
484
|
const opts = [['', aboutNow ? 'Change what it is about' : 'Choose what it is about'], ['portfolio', 'Portfolio']].concat(boards.map((b) => ['board|' + b.ws + '|' + b.id, 'Board: ' + b.name]), inis.map((i) => ['initiative|' + i.id, 'Initiative: ' + i.name]), [['none', 'Remove the link']]);
|
|
481
485
|
const link = `<div class="mtg-link"><select id="mtgSel" aria-label="What this meeting is about">${opts.map(([val, t]) => `<option value="${esc(val)}">${esc(t)}</option>`).join('')}</select><button class="addb pri" id="mtgLink" disabled>Link it</button></div>
|
|
482
486
|
<p class="note" id="mtgMsg" role="status">The link applies to every occurrence of “${esc(r.title)}”. The calendar itself is never written.</p>`;
|
|
483
487
|
const n = v.notes;
|
|
484
|
-
const task = n && n.actions.length ? { done: ui.tasked } : null;
|
|
485
|
-
const notes = v.notesLine ? `<p class="mut">${esc(v.notesLine)}</p>` : [n.title ? `<p><b>${esc(n.title)}</b></p>` : '',
|
|
486
|
-
n.decisions.length ? `<h4 class="mtg-h">Decisions ${n.decisions.length}</h4>${items(n.decisions)}` : '', n.actions.length ? `<h4 class="mtg-h">Next steps ${n.actions.length}</h4>${items(n.actions, task)}` : '',
|
|
487
|
-
n.questions.length ? `<h4 class="mtg-h">Open questions ${n.questions.length}</h4>${items(n.questions)}` : '', (n.decisions.length + n.actions.length + n.questions.length) ? '' : '<p class="mut">The note holds no decisions, next steps or questions yet.</p>'].join('');
|
|
488
488
|
const person = (nm) => `<span class="pp"><i class="av2">${esc(String(nm).trim().charAt(0).toUpperCase())}</i>${esc(clip(nm, 40))}</span>`;
|
|
489
|
-
const prow = (x) => `<div class="prow"><span class="pi${x.ok ? '' : ' w'}">${ic(x.ic)}</span><div><b>${esc(x.l)}</b><div class="pv">${x.about && aboutNow ? '<span>It is about <b>' + esc(aboutNow) + '</b
|
|
489
|
+
const prow = (x) => `<div class="prow"><span class="pi${x.ok ? '' : ' w'}">${ic(x.ic)}</span><div><b>${esc(x.l)}</b><div class="pv">${x.about && aboutNow ? '<span>It is about <b>' + esc(aboutNow) + '</b>.</span>' : x.people ? x.people.map(person).join('') : x.chips && x.chips.length ? x.chips.map((c) => `<span class="chp sm">${ic('doc')}${esc(c)}</span>`).join('') : '<span>' + esc(x.text) + '</span>'}</div></div>${x.ok ? '<span class="chp ok sm"><i></i>Ready</span>' : '<span class="chp warn sm"><i></i>Not yet</span>'}</div>`;
|
|
490
490
|
const ready = v.prepReady;
|
|
491
491
|
const prep = secH('Prepared for you', ready === v.prep.length ? 'all ready' : ready + ' of ' + v.prep.length + ' ready') + `<div class="prows">${v.prep.map(prow).join('')}</div>`;
|
|
492
492
|
const mats = v.materialLine ? `<p class="mut">${esc(v.materialLine)}</p>` : `<div class="mats">${v.material.map((m) => `<div class="mat"><span class="kd">${esc(m.kind || 'link')}</span><div><b>${esc(m.title)}</b><small>${esc([m.topic, 'for ' + m.scope].filter(Boolean).join(' · '))}</small></div><span class="mb">${m.removable ? `<button class="ib2 mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">${ic('x')}</button>` : ''}</span></div>`).join('')}</div>`;
|
|
493
493
|
const mat = secH('Material', v.material && v.material.length ? v.material.length + ' linked' : '', `<button class="addb" id="mmAdd" title="Your calendar invite is not changed.">${ic('plus')}Add material</button>`) + mats;
|
|
494
494
|
const prev = secH('Previous meetings', v.prev.length ? v.prev.length + ' before this' : '') + (v.prev.length ? `<div class="prevs">${v.prev.map((p) => `<div class="pvx"><div class="pvh"><time>${esc(p.date)}</time><span>${p.decided} decided</span><span>${p.steps} new next ${p.steps === 1 ? 'step' : 'steps'}</span></div></div>`).join('')}</div>` : '<p class="mut">No earlier notes of this meeting are kept.</p>');
|
|
495
495
|
const tops = secH('Topics', v.planned.length ? 'planned' : '') + (v.planned.length ? `<div class="tops">${v.planned.map((t, i) => `<div class="tp plan"><i>${i + 1}</i><span>${esc(clip(t.text, 120))}</span><small>planned</small></div>`).join('')}</div>` : '<p class="mut">The meeting has no topics yet.</p>');
|
|
496
|
-
|
|
497
|
-
const
|
|
496
|
+
/* After: from the note's own record when the meeting has one (premium-vw-meet.js), else the decisions, steps and questions the replay answer holds */
|
|
497
|
+
const task = { has: (i) => ui.tasked.has(i) };
|
|
498
|
+
const sx = { esc, tasked: task, replayBtn: !!v.replay, where: 'meeting', id: S ? S.id : null };
|
|
499
|
+
const after = S ? stageHtml('after', S, sx)
|
|
500
|
+
: secH('Notes', v.notesLine ? '' : 'from the meeting note') + (v.notesLine ? `<p class="mut">${esc(v.notesLine)}</p>` : (n.title ? `<p><b>${esc(n.title)}</b></p>` : '') + notesTablesHtml(n, esc, task) + ((n.decisions.length + n.actions.length + n.questions.length) ? '' : '<p class="mut">The note holds no decisions, next steps or questions yet.</p>'))
|
|
501
|
+
+ (v.replay ? secH('Replay', 'kept on this machine') + `<p>A recording is kept: ${v.replay.minutes ? v.replay.minutes + ' min, ' : ''}${v.replay.keyPoints} key ${v.replay.keyPoints === 1 ? 'point' : 'points'}.</p><div class="mtg-foot"><button class="addb pri" data-m3="replay">Replay</button><span class="note">Plays the note’s audio kept on this machine, with the transcript and the key points.</span></div>` : '');
|
|
498
502
|
const chips = statusChips(r, note).map((c) => `<span class="chp${c.kind ? ' ' + c.kind : ''}"><i></i>${esc(c.text)}</span>`).join('');
|
|
499
|
-
const done = !!(note && note.state === 'ended') || (r.past && !!v.replay);
|
|
500
503
|
const status = ui.status ? `<p class="note mtg-status" id="mtgStatus" role="status">${esc(ui.status.text)}${ui.status.undo ? ' <button class="mtg-b" id="mtgUndo">Undo</button>' : ''}</p>` : '<p class="note mtg-status" id="mtgStatus" role="status" hidden></p>';
|
|
501
|
-
const
|
|
502
|
-
|
|
504
|
+
const when = esc(r.day) + ' · ' + esc(r.time) + (r.end && hasTime(r.end) ? ' to ' + esc(hhmm(r.end)) : '') + (r.len ? ' · ' + esc(r.len) : '');
|
|
505
|
+
const hdr = `<div class="mh2"><div><h3 class="d1">${esc(r.title)}</h3>${v.people.length ? `<p class="mt">With ${esc(v.people.join(', '))}</p>` : ''}</div><div class="chs">${chips}</div></div>`;
|
|
506
|
+
const lines = `<div class="vm-ln">${ic('clock')}<span>${when}</span></div><div class="vm-ln">${ic('link')}${aboutNow ? `<span>It is about <b>${esc(aboutNow)}</b>.${lv && lv.why ? ' ' + esc(lv.why) + '.' : ''}</span>` : `<span class="mut">${r.past ? 'The calendar answer holds no link for an earlier meeting.' : 'Not linked yet.'}</span>`}<button type="button" class="vm-lk" data-vm="about" aria-expanded="${!!ui.about}">${aboutNow ? 'Change' : 'Link it'}</button></div><div class="vm-about"${ui.about ? '' : ' hidden'}>${link}</div>`;
|
|
507
|
+
const ph = ui.phase || 'before', part = (k, html) => `<div class="vm-body" data-part="${k}"${ph === k ? '' : ' hidden'}>${html}</div>`;
|
|
508
|
+
return `<article class="paper doc mtg vm">${status}${hdr}${lines}${seriesHtml(S, esc)}${actsHtml(r, ui)}${phaseHtml(ph, esc)}`
|
|
509
|
+
+ part('before', stageHtml('before', S, sx) + [prep, mat, prev, tops].join(''))
|
|
510
|
+
+ part('during', stageHtml('during', S, sx))
|
|
511
|
+
+ part('after', after) + '</article>';
|
|
503
512
|
}
|
|
504
513
|
function sheetHtml(row) {
|
|
505
514
|
return `<article class="paper doc mtg mtg-sheet"><button class="mtg-b" id="mmBack">Back to the meeting</button>
|
|
@@ -508,9 +517,25 @@ export function mountMeeting(d) {
|
|
|
508
517
|
${sec('Or paste a link', '<input class="mtg-in" id="mmLinkIn" type="url" placeholder="Any https address" aria-label="Paste a link" autocomplete="off"><div id="mmPaste"></div>')}<div id="mmOpts"></div></article>`;
|
|
509
518
|
}
|
|
510
519
|
|
|
520
|
+
/** Make task: the step goes into the first stage of the note's initiative (POST /api/plan-items). Answers { ok, text, undo? }. */
|
|
521
|
+
async function planTask(n, step) {
|
|
522
|
+
if (!n || !n.initiative) return { ok: false, text: taskEvent(n, step, null).reason };
|
|
523
|
+
const lay = await d.pmGet('/api/plan-items?ladder=0&ws=' + encodeURIComponent(n.initiative.ws) + '&id=' + encodeURIComponent(n.initiative.id));
|
|
524
|
+
const plan = taskEvent(n, step, lay && lay.ok && (lay.stages || [])[0]);
|
|
525
|
+
if (!plan.ok) return { ok: false, text: 'The task was not made: ' + plan.reason };
|
|
526
|
+
const res = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
|
|
527
|
+
if (!res || res.ok !== true) return { ok: false, text: 'The task was not made' + (res && res.error ? ': ' + res.error : '.') };
|
|
528
|
+
const item = res.written && res.written[0] && res.written[0].item;
|
|
529
|
+
return { ok: true, text: `Added to ${n.initiative.name}, under ${(lay.stages[0].label || lay.stages[0].id)}.`, undo: item ? async () => {
|
|
530
|
+
const u = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: n.initiative.id }] });
|
|
531
|
+
return u && u.ok === true ? { ok: true } : { ok: false, text: 'The task was not withdrawn' + (u && u.error ? ': ' + u.error : '.') };
|
|
532
|
+
} : null };
|
|
533
|
+
}
|
|
534
|
+
|
|
511
535
|
async function openRow(row, via) {
|
|
536
|
+
delete $('#oMain').dataset.ready;
|
|
512
537
|
let replay = null, material = null, extra = { prev: [], topics: [] }, boards = W ? W.boards : [], inis = W ? W.initiatives : [], saved = '';
|
|
513
|
-
const ui = { view: 'detail', status: null, tasked: new Set() }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0, topics: [], topic: null };
|
|
538
|
+
const ui = { view: 'detail', status: null, tasked: new Set(), phase: 'before', picked: false }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0, topics: [], topic: null };
|
|
514
539
|
let stT = null, findT = null, undoFn = null;
|
|
515
540
|
const view = () => meetingView(row, replay, material, extra);
|
|
516
541
|
const say = (text, undo) => { clearTimeout(stT); undoFn = undo || null; ui.status = { text, undo: undo || null }; if (ui.view === 'detail') { paint(); stT = setTimeout(() => { ui.status = null; if (ui.view === 'detail') paint(); }, 9000); } else d.toast(text); };
|
|
@@ -518,6 +543,7 @@ export function mountMeeting(d) {
|
|
|
518
543
|
const pane = $('#dOut'), top = pane ? pane.scrollTop : 0, same = ui.last === ui.view; ui.last = ui.view;
|
|
519
544
|
$('#oMain').innerHTML = ({ add: () => sheetHtml(row), focus: focusHtml, replay: replayHtml }[ui.view] || (() => detailHtml(view(), boards, inis, saved, ui)))();
|
|
520
545
|
if (ui.view === 'add') paintSheet();
|
|
546
|
+
else if (ui.view === 'detail') { const S = view().sheet, sx = { esc, tasked: { has: (i) => ui.tasked.has(i) }, replayBtn: !!view().replay, where: 'meeting', id: S ? S.id : null, reread: async () => { await readSheet(); paint(); } }; for (const [k] of PHASES) wireStage(k, $(`#oMain .vm-body[data-part="${k}"]`), S, sx); }
|
|
521
547
|
if (pane && same) pane.scrollTop = top;
|
|
522
548
|
};
|
|
523
549
|
const alive = (v) => ui.view === v && $('#dlg').classList.contains('on') && $('#dTitle').textContent === row.title;
|
|
@@ -676,7 +702,20 @@ export function mountMeeting(d) {
|
|
|
676
702
|
const mt = await d.pmGet(matPath());
|
|
677
703
|
material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
|
|
678
704
|
}
|
|
705
|
+
/* The meeting's note, as the console's note sheet reads it (GET /api/notes/one): Before, During and After draw its parts. */
|
|
706
|
+
async function readSheet() {
|
|
707
|
+
const nt = noteOfRow(NR, row);
|
|
708
|
+
const one = nt ? await d.pmGet('/api/notes/one?id=' + encodeURIComponent(nt.id)) : null;
|
|
709
|
+
extra = { ...extra, sheet: noteSheet(one) };
|
|
710
|
+
}
|
|
711
|
+
/* The stage the head opens on, until the PM picks one: During while the note records, After once there are notes, else Before. */
|
|
712
|
+
function pickPhase() {
|
|
713
|
+
if (ui.picked) return;
|
|
714
|
+
const v = view(), n = v.notes, nt = noteOfRow(NR, row);
|
|
715
|
+
ui.phase = phaseOf({ noteState: nt && nt.state, hasNotes: !!(v.sheet && v.sheet.overview) || !!v.replay || !!(n && n.decisions.length + n.actions.length + n.questions.length) });
|
|
716
|
+
}
|
|
679
717
|
const matPath = () => '/api/meeting-material?event=' + encodeURIComponent(row.id) + '&title=' + encodeURIComponent(row.title) + (row.series ? '&series=' + encodeURIComponent(row.series) : '') + '&date=' + row.day;
|
|
718
|
+
vmStyle();
|
|
680
719
|
d.openDlg({ eye: 'Calendar · real data', title: row.title, sub: [row.day, row.time, row.len, row.who && row.who.length ? row.who.join(', ') : ''].filter(Boolean).join(' · '), noteKey: via === 'today' ? 'ev:meeting:' + Date.parse(row.at) : null,
|
|
681
720
|
stream: d.turnA(d.ptx('This meeting is in the calendar PMOS holds. Its notes, material and recording appear here only if PMOS holds them.')), pane: detailHtml(meetingView(row, null, null), boards, inis, '', ui), label: 'Meeting' });
|
|
682
721
|
if (via !== 'today') $('#askF').hidden = true;
|
|
@@ -686,11 +725,13 @@ export function mountMeeting(d) {
|
|
|
686
725
|
material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
|
|
687
726
|
await readNotes();
|
|
688
727
|
if ($('#dTitle').textContent !== row.title) return;
|
|
689
|
-
|
|
728
|
+
await readSheet();
|
|
729
|
+
if ($('#dTitle').textContent !== row.title) return;
|
|
730
|
+
pickPhase(); paint(); if (HOLD) tickClock(); mark();
|
|
690
731
|
{
|
|
691
732
|
const sk = (noteOfRow(NR, row) || {}).series, [sr, tp] = await Promise.all([sk && sk.key ? d.pmGet('/api/notes/series?key=' + encodeURIComponent(sk.key)) : null, d.pmGet(matPath() + '&topics=1')]);
|
|
692
733
|
if ($('#dTitle').textContent !== row.title) return;
|
|
693
|
-
extra = { prev: prevOf(sr, row), topics: tp && tp.ok && Array.isArray(tp.topics) ? tp.topics.filter((t) => t && t.text).slice(0, 8) : [] };
|
|
734
|
+
extra = { ...extra, prev: prevOf(sr, row), topics: tp && tp.ok && Array.isArray(tp.topics) ? tp.topics.filter((t) => t && t.text).slice(0, 8) : [] };
|
|
694
735
|
if (ui.view === 'detail') paint();
|
|
695
736
|
}
|
|
696
737
|
|
|
@@ -704,19 +745,20 @@ export function mountMeeting(d) {
|
|
|
704
745
|
}
|
|
705
746
|
async function makeTask(i) {
|
|
706
747
|
const n = view().notes, step = n && n.actions[i]; if (!step) return;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const plan = taskEvent(n, step, lay && lay.ok && (lay.stages || [])[0]);
|
|
710
|
-
if (!plan.ok) return say('The task was not made: ' + plan.reason);
|
|
711
|
-
const res = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
|
|
712
|
-
if (!res || res.ok !== true) return say('The task was not made' + (res && res.error ? ': ' + res.error : '.'));
|
|
748
|
+
const res = await planTask(n, step);
|
|
749
|
+
if (!res.ok) return say(res.text);
|
|
713
750
|
ui.tasked.add(i);
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
if (u && u.ok === true) { ui.tasked.delete(i); say('The task is withdrawn.'); } else say('The task was not withdrawn' + (u && u.error ? ': ' + u.error : '.'));
|
|
751
|
+
say(res.text, res.undo ? async () => {
|
|
752
|
+
const u = await res.undo();
|
|
753
|
+
if (u.ok) { ui.tasked.delete(i); say('The task is withdrawn.'); } else say(u.text);
|
|
718
754
|
} : null);
|
|
719
755
|
}
|
|
756
|
+
async function member(key) {
|
|
757
|
+
const S = view().sheet; if (!S) return;
|
|
758
|
+
const r = await d.pmPost('/api/notes/series-member', { id: S.id, key });
|
|
759
|
+
if (!r || r.ok !== true) return say('Not saved' + (r && r.error ? ': ' + r.error : '.'));
|
|
760
|
+
await readSheet(); say(key === 'off' ? 'Taken out of the series.' : 'Back in its series.');
|
|
761
|
+
}
|
|
720
762
|
async function openSheet() {
|
|
721
763
|
ui.view = 'add'; SH.sug = null; SH.found = []; SH.pick = null; SH.q = ''; SH.link = ''; SH.topics = []; SH.topic = null; paint();
|
|
722
764
|
$('#mmBack').focus();
|
|
@@ -736,10 +778,21 @@ export function mountMeeting(d) {
|
|
|
736
778
|
findT = setTimeout(async () => { const r = await d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { q: SH.q, ws: d.ws() })); if (my !== SH.token || ui.view !== 'add') return; SH.foundBusy = false; SH.found = r && r.ok && Array.isArray(r.found) ? r.found : []; paintSheet(); }, 220);
|
|
737
779
|
}
|
|
738
780
|
};
|
|
781
|
+
$('#oMain').dataset.ready = 'meeting'; // the dialog's answers are read and its presses are live (the Before / During / After switch holds from here)
|
|
739
782
|
$('#oMain').onchange = (e) => { if (e.target.id === 'mtgSel') $('#mtgLink').disabled = !e.target.value; };
|
|
740
783
|
$('#oMain').onclick = async (e) => {
|
|
741
784
|
const t = e.target.closest('button'); if (!t) return;
|
|
742
785
|
if (t.dataset.m3) return m3Press(t.dataset.m3, t);
|
|
786
|
+
if (t.dataset.ph) {
|
|
787
|
+
ui.phase = t.dataset.ph; ui.picked = true;
|
|
788
|
+
$$('#oMain .vm-ph [data-ph]').forEach((b) => b.setAttribute('aria-pressed', String(b === t)));
|
|
789
|
+
$$('#oMain .vm-body[data-part]').forEach((x) => { x.hidden = x.dataset.part !== ui.phase; });
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if ((t.dataset.vm === 'prev' || t.dataset.vm === 'next') && t.dataset.id) return openNoteTab({ pmGet: d.pmGet, pmPost: d.pmPost, esc, toast: d.toast, task: planTask }, t.dataset.id);
|
|
793
|
+
if (t.dataset.vm === 'about') { ui.about = !ui.about; t.setAttribute('aria-expanded', String(ui.about)); const x = $('#oMain .vm-about'); if (x) x.hidden = !ui.about; if (ui.about) $('#mtgSel').focus(); return; }
|
|
794
|
+
if (t.dataset.vm === 'serout') return member('off');
|
|
795
|
+
if (t.dataset.vm === 'serback') return member(null);
|
|
743
796
|
if (t.id === 'mmAdd') return openSheet();
|
|
744
797
|
if (t.id === 'mmBack' || t.id === 'mmCancel') return closeSheet(true);
|
|
745
798
|
if (t.dataset.pick) { SH.pick = pickOf(t.dataset.pick); paintSheet(); return; }
|
|
@@ -764,7 +817,7 @@ export function mountMeeting(d) {
|
|
|
764
817
|
t.disabled = true;
|
|
765
818
|
const res = await d.pmPost('/api/calendar-links', body);
|
|
766
819
|
if (!res || res.ok !== true) { t.disabled = false; $('#mtgMsg').textContent = (res && res.error) || 'The link could not be saved.'; return; }
|
|
767
|
-
saved = body.kind === 'none' ? '' : $('#mtgSel').selectedOptions[0].textContent;
|
|
820
|
+
saved = body.kind === 'none' ? '' : $('#mtgSel').selectedOptions[0].textContent; ui.about = false;
|
|
768
821
|
d.toast(body.kind === 'none' ? 'The link is removed for every occurrence of this meeting.' : 'Linked. It applies to every occurrence of this meeting.');
|
|
769
822
|
await readWeek(); paint(); if (other()) draw();
|
|
770
823
|
};
|
|
@@ -784,5 +837,5 @@ export function mountMeeting(d) {
|
|
|
784
837
|
$('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
|
|
785
838
|
readNotes().then(() => mark());
|
|
786
839
|
{ const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
|
|
787
|
-
return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote, openRow: (row) => openRow(row, 'week') }; // openRow: the full calendar (premium-vw-cal.js)
|
|
840
|
+
return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote, task: planTask, openRow: (row) => openRow(row, 'week') }; // openRow: the full calendar (premium-vw-cal.js)
|
|
788
841
|
}
|
|
@@ -59,6 +59,7 @@ export function slideHtml(lines) {
|
|
|
59
59
|
let list = [];
|
|
60
60
|
const flush = () => { if (list.length) { out.push('<ul>' + list.map((x) => '<li>' + inline(x) + '</li>').join('') + '</ul>'); list = []; } };
|
|
61
61
|
for (const l of lines || []) {
|
|
62
|
+
if (/^\s*<!--.*-->\s*$/.test(l)) continue; // a comment line (a slide block, a note marker) is not words
|
|
62
63
|
const b = /^\s*[-*]\s+(.*)$/.exec(l), h = /^#{3,6}\s+(.*)$/.exec(l);
|
|
63
64
|
if (b) { list.push(b[1]); continue; }
|
|
64
65
|
flush();
|
|
@@ -150,7 +151,7 @@ function statusHtml() {
|
|
|
150
151
|
function barHtml() {
|
|
151
152
|
const dm = R.dm ? `<div class="dsmn rpm" role="menu" aria-label="Download"><p class="label">Download a file</p>${DL.map(([k, l, s]) => `<a role="menuitem" data-rr="dl|${k}" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: k }))}" download>${DLI}<span>${esc(l)}<small>${esc(s)}</small></span></a>`).join('')}<button role="menuitem" data-rr="md">${DLI}<span>Markdown (.md)<small>The file, as written.</small></span></button><p class="note rpmn">The files carry the words, not the look. Print or save as PDF keeps the look.</p></div>` : '';
|
|
152
153
|
const item = (k, l, ico, on) => `<button type="button" role="menuitem" data-rr="${k}"${on === undefined ? '' : ` aria-current="${on}"`}>${ico}${l}${on ? CHK : ''}</button>`;
|
|
153
|
-
return `<div class="dsvr rdbar">${mnuHtml('rm', 'Read', EYE, item('present', 'Present', PLAY) + item('print', 'Print or save as PDF', PRI))}`
|
|
154
|
+
return `<div class="dsvr rdbar">${mnuHtml('rm', 'Read', EYE, item('present', 'Present', PLAY) + item('slides', R.issued ? 'Open the slides' : 'Edit the slides', ICO('<path d="M4 5h16v11H4zM8 20h8M12 16v4"/>')) + item('print', 'Print or save as PDF', PRI))}`
|
|
154
155
|
+ `<span class="rdsp">${mnuHtml('fm', R.view === 'deck' ? 'Slide deck' : 'Document', ICO('<path d="M12 3 3 8l9 5 9-5-9-5zM3 13l9 5 9-5"/>'), item('view|deck', 'Slide deck', '', R.view === 'deck') + item('view|doc', 'Document', '', R.view === 'doc'))}`
|
|
155
156
|
+ `<span class="dsvw"><button type="button" class="dsvb" data-rr="dm" aria-haspopup="menu" aria-expanded="${!!R.dm}">${DLI}Download${CHV}</button>${dm}</span>`
|
|
156
157
|
+ (R.issued ? '' : `<button type="button" class="dsvb" data-rr="page" title="Read and edit the words as a page">${PEN}Edit</button>`) + '</span></div>';
|
|
@@ -234,6 +235,7 @@ async function act(a) {
|
|
|
234
235
|
if (k === 'md') { R.dm = false; saveMd(); draw(); return; }
|
|
235
236
|
if (k === 'print') { R.mn = ''; draw(); printIt(); return; }
|
|
236
237
|
if (k === 'present') { R.mn = ''; draw(); present(true); return; }
|
|
238
|
+
if (k === 'slides') { R.mn = ''; draw(); openSlidesOf(R); return; }
|
|
237
239
|
if (k === 'page') { openPage(); return; }
|
|
238
240
|
if (k === 'pick') { const f = $('#rdFile'); if (f) f.click(); return; }
|
|
239
241
|
if (k === 'ver') {
|
|
@@ -265,9 +267,9 @@ function openPage() {
|
|
|
265
267
|
const me = R;
|
|
266
268
|
openDocPage({ path: R.row.path, title: R.name + (R.row.slot ? ' · ' + R.row.slot : '') }, {
|
|
267
269
|
ws: () => me.ws,
|
|
268
|
-
extras: () => [{ k: 'present', label: 'Present', icon: PLAY }, { k: 'print', label: 'Print', icon: PRI },
|
|
270
|
+
extras: () => [{ k: 'present', label: 'Present', icon: PLAY }, { k: 'slides', label: me.issued ? 'Open the slides' : 'Edit the slides', icon: ICO('<path d="M4 5h16v11H4zM8 20h8M12 16v4"/>') }, { k: 'print', label: 'Print', icon: PRI },
|
|
269
271
|
{ k: 'dl', label: 'Download', icon: DLI, note: 'The files carry the words, not the look. Print or save as PDF keeps the look.', menu: DL.map(([f, l, sub]) => ({ label: l, sub, icon: DLI, download: true, href: '/api/report-export?' + q({ ws: me.ws, path: me.row.path, fmt: f }) })).concat([{ k: 'md', label: 'Markdown (.md)', sub: 'The file, as written.', icon: DLI }]) }],
|
|
270
|
-
onExtra: (k) => { if (R !== me) return; if (k === 'present') { vwShow('main'); act(['present']); } else if (k === 'print') printIt(); else if (k === 'md') saveMd(); },
|
|
272
|
+
onExtra: (k) => { if (R !== me) return; if (k === 'present') { vwShow('main'); act(['present']); } else if (k === 'slides') openSlidesOf(me); else if (k === 'print') printIt(); else if (k === 'md') saveMd(); },
|
|
271
273
|
onWrite: async () => { if (R !== me) return; try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: R.row.path })); R.W = wordsOf(R.text, R.name); } catch { /* the reader keeps what it had */ } if (R === me) draw(); },
|
|
272
274
|
});
|
|
273
275
|
}
|
|
@@ -330,6 +332,12 @@ function printIt() {
|
|
|
330
332
|
w.focus(); setTimeout(() => { try { w.print(); } catch { /* the PM prints from the window */ } }, 300);
|
|
331
333
|
}
|
|
332
334
|
|
|
335
|
+
/* ── the slide editor (premium-viewer R-SL1): the same file, in a Slides tab of the viewer; a save reads the words again ── */
|
|
336
|
+
async function openSlidesOf(at) {
|
|
337
|
+
const m = await import('./premium-vw-slides.js');
|
|
338
|
+
m.openSlides({ ws: at.ws, path: at.row.path, title: at.name, readOnly: at.issued, onSaved: (text) => { if (R !== at) return; R.text = text; R.W = wordsOf(text, R.name); draw(); } });
|
|
339
|
+
}
|
|
340
|
+
|
|
333
341
|
/* ── reading the cycle ── */
|
|
334
342
|
async function readCycle() {
|
|
335
343
|
const c = await Promise.resolve(pmGet('/api/report-design/cycle?' + q({ ws: R.ws, path: R.row.path }))).catch(() => null);
|
|
@@ -202,6 +202,7 @@ $('#dExpand').onclick = () => setFull(!$('#dlg').classList.contains('full'));
|
|
|
202
202
|
$('#dTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-t]'); if (b) setTab(b.dataset.t); });
|
|
203
203
|
addEventListener('keydown', (e) => {
|
|
204
204
|
if (e.key !== 'Escape' || !$('#dlg').classList.contains('on')) return;
|
|
205
|
+
if (document.querySelector('[data-esc-layer]')) return; // a layer open over the dialog (a viewer menu, Present) closes itself first
|
|
205
206
|
if ($('#dlg').classList.contains('full')) { setFull(false); e.stopImmediatePropagation(); return; }
|
|
206
207
|
closeDlg();
|
|
207
208
|
}, true);
|