create-pmos 0.398.0 → 0.399.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 +13 -13
- 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-adddoc-test.js +18 -14
- package/workspace/briefing-premium-board-test.js +80 -48
- package/workspace/briefing-premium-calendar-2-test.js +36 -36
- package/workspace/briefing-premium-calendar-3-test.js +39 -39
- package/workspace/briefing-premium-calendar-test.js +23 -24
- package/workspace/briefing-premium-doc-edit-test.js +6 -2
- package/workspace/briefing-premium-initiative-test.js +38 -16
- package/workspace/briefing-premium-insights-test.js +114 -37
- package/workspace/briefing-premium-metrics-test.js +6 -4
- package/workspace/briefing-premium-products-test.js +10 -7
- package/workspace/briefing-premium-sources-test.js +25 -22
- package/workspace/briefing-premium-test.js +46 -42
- package/workspace/briefing-premium-work-test.js +9 -9
- package/workspace/changelog.json +12 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
- package/workspace/guide/home.md +39 -18
- package/workspace/guide/index.md +1 -1
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +36 -5
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-premium.js +3 -2
- package/workspace/lib/insights-records.js +21 -7
- package/workspace/lib/meeting-points.js +52 -0
- package/workspace/lib/news-for-you.js +88 -0
- package/workspace/lib/notes-series.js +29 -6
- package/workspace/lib/report-confirm.js +48 -0
- package/workspace/lib/route-modules.js +8 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -0
- package/workspace/lib/routes-home-review.js +108 -0
- package/workspace/lib/routes-initiative-layout.js +57 -0
- package/workspace/lib/routes-insights-premium.js +4 -1
- package/workspace/lib/routes-insights-records.js +8 -4
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +2 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/search-index.js +176 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +86 -50
- package/workspace/premium-briefing-depth-test.js +55 -54
- package/workspace/premium-chat-chart-tab-test.js +4 -2
- package/workspace/premium-chat-report-tab-test.js +16 -2
- package/workspace/premium-core-doc-issue-test.js +15 -13
- package/workspace/premium-phone-card-test.js +5 -3
- package/workspace/premium-report-read-test.js +55 -18
- package/workspace/premium-vw-backlog-test.js +2 -2
- package/workspace/premium-vw-cal-test.js +50 -35
- package/workspace/premium-vw-doc-test.js +9 -3
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +2 -2
- package/workspace/premium-vw-meet-test.js +37 -40
- package/workspace/premium-vw-notes-test.js +21 -19
- package/workspace/premium-vw-rec-test.js +11 -12
- package/workspace/premium-welcome-test.js +3 -3
- package/workspace/premium-work-depth-test.js +3 -3
- package/workspace/public/pm/bd-acts.js +303 -225
- package/workspace/public/pm/bd-asks.js +261 -0
- package/workspace/public/pm/bd-pop.js +59 -0
- package/workspace/public/pm/bd-span.js +49 -13
- package/workspace/public/pm/bd-views.js +169 -0
- package/workspace/public/pm/cozy-board.css +301 -0
- package/workspace/public/pm/cozy-ev.css +228 -0
- package/workspace/public/pm/cozy-evmodel.js +106 -0
- package/workspace/public/pm/cozy-evui.js +47 -0
- package/workspace/public/pm/cozy-insights.css +148 -10
- package/workspace/public/pm/cozy-nav.js +103 -39
- package/workspace/public/pm/cozy-news.js +140 -0
- package/workspace/public/pm/cozy-search.js +203 -0
- package/workspace/public/pm/cozy-settings.js +198 -0
- package/workspace/public/pm/cozy-sources.js +89 -0
- package/workspace/public/pm/cozy-today.css +217 -0
- package/workspace/public/pm/cozy-viewer.js +1 -0
- package/workspace/public/pm/cozy-vw-mtg.css +350 -0
- package/workspace/public/pm/cozy-vw-rp.css +152 -0
- package/workspace/public/pm/home-adddoc.js +5 -5
- package/workspace/public/pm/home-app.js +329 -55
- package/workspace/public/pm/home-around.js +24 -126
- package/workspace/public/pm/home-chat.js +67 -14
- package/workspace/public/pm/home-data.js +6 -6
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +6 -6
- package/workspace/public/pm/home-ini-model.js +190 -0
- package/workspace/public/pm/home-ini.css +171 -0
- package/workspace/public/pm/home-ini.js +456 -0
- package/workspace/public/pm/home-list.js +276 -0
- package/workspace/public/pm/home-more.js +17 -134
- package/workspace/public/pm/home-phone-card.js +4 -4
- package/workspace/public/pm/home-review.js +104 -0
- package/workspace/public/pm/home-task.js +67 -0
- package/workspace/public/pm/home-today.js +144 -0
- package/workspace/public/pm/home-work.js +54 -26
- package/workspace/public/pm/premium-board.js +163 -39
- package/workspace/public/pm/premium-chart-tab.js +4 -5
- package/workspace/public/pm/premium-first.js +5 -7
- package/workspace/public/pm/premium-insights.js +499 -202
- package/workspace/public/pm/premium-mtg-present.js +138 -0
- package/workspace/public/pm/premium-mtg-replay.js +142 -0
- package/workspace/public/pm/premium-report-read.js +216 -52
- package/workspace/public/pm/premium-report-tab.js +44 -19
- package/workspace/public/pm/premium-shell.js +7 -7
- package/workspace/public/pm/premium-vw-cal.js +150 -60
- package/workspace/public/pm/premium-vw-mtg.js +488 -261
- package/workspace/public/pm/premium-vw-notes.js +61 -0
- package/workspace/public/pm/rp-parts.js +269 -0
- package/workspace/public/premium-board.html +4 -3
- package/workspace/public/premium-insights.html +10 -10
- package/workspace/public/premium.html +3 -1
- package/workspace/r/m1.png +0 -0
- package/workspace/r/m2.png +0 -0
- package/workspace/r/m3.png +0 -0
- package/workspace/r/nl.png +0 -0
- package/workspace/test-lists/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- package/workspace/test-lists/uf-everywhere.json +15 -0
- package/workspace/test-lists/uf-home.json +9 -0
- package/workspace/test-lists/uncovered-board.json +9 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* pm/home-review.js — the weekly review in the Viewer (initiative premium-uncovered-features, H1; canvas HmReview).
|
|
2
|
+
*
|
|
3
|
+
* Four short steps, each one keeping what the PM decided: Sort what came in, Check what you wait on, Look at untouched work, Pick next
|
|
4
|
+
* week's three. The ladder shows the steps done and the one on now; the step on now opens as a card with its rows. A step is done with
|
|
5
|
+
* POST /api/home-review/step (its note: "4 sorted · 1 kept"); an untouched initiative that was looked at is kept with
|
|
6
|
+
* POST /api/home-review/keep. The rows' own presses are the routes My work already uses (/api/pm-items/*) and the lifecycle route for
|
|
7
|
+
* a hold (POST /api/lifecycle, with the reason on the record). Every write is the PM's press. "My work" beside "Weekly review" switches the
|
|
8
|
+
* Viewer to My work (home-work.js).
|
|
9
|
+
* h: { VW, pmPost, toast, D() (Home's data), reload() (reads Home again), ws(), iniTitle(id), askAbout(stale), openWork(), now() } */
|
|
10
|
+
import { esc, svg, P } from './home-today.js';
|
|
11
|
+
import { reviewModel, staleInis } from './home-list.js';
|
|
12
|
+
|
|
13
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
14
|
+
const dayLabel = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
15
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
16
|
+
/** The seg over My work and the weekly review: which of the two the Viewer shows. */
|
|
17
|
+
export const tabsHtml = (on) => `<div class="cz-seg ut-tabs" role="group" aria-label="Show"><button type="button" data-ut-tab="work" aria-pressed="${on === 'work'}">My work</button><button type="button" data-ut-tab="review" aria-pressed="${on === 'review'}">Weekly review</button></div>`;
|
|
18
|
+
|
|
19
|
+
export function openReview(h) {
|
|
20
|
+
const st = { done: {}, picked: new Set(), msg: '', busy: false };
|
|
21
|
+
const work = () => h.D().work || null;
|
|
22
|
+
const tab = (k) => (((work() && work().queue && work().queue.tabs) || []).find((t) => t.key === k) || { groups: [] }).groups.flatMap((g) => g.rows || []);
|
|
23
|
+
function stepBody(s, R) {
|
|
24
|
+
const D = h.D(), kept = R.kept || {};
|
|
25
|
+
if (s.key === 'sort') {
|
|
26
|
+
const rows = tab('inbox').concat(tab('tray'));
|
|
27
|
+
return (rows.slice(0, 8).map((r) => `<div class="ut-trow"><span><b>${esc(r.title)}</b>${r.sub ? ` <span class="ut-mut">· ${esc(r.sub)}</span>` : ''}</span>${st.done[r.key] ? `<span class="cz-pill ${st.done[r.key] === 'kept' ? 'q' : 'ok'}">${st.done[r.key] === 'kept' ? 'Kept' : 'In Today'}</span>` : `<button type="button" class="ut-btn sm soft" data-rv-today="${esc(r.id)}" data-k="${esc(r.key)}">Today</button><button type="button" class="ut-btn sm ghost" data-rv-keep="${esc(r.id)}" data-k="${esc(r.key)}">Keep</button>`}</div>`).join('')
|
|
28
|
+
|| '<p class="ut-small ut-mut">Nothing came in that is not placed.</p>');
|
|
29
|
+
}
|
|
30
|
+
if (s.key === 'wait') {
|
|
31
|
+
const rows = (work() && work().waiting ? work().waiting.rows : []);
|
|
32
|
+
return rows.slice(0, 8).map((r) => `<div class="ut-trow"><span><b>${esc(r.title)}</b>${r.sub ? ` <span class="ut-mut">· ${esc(r.sub)}</span>` : ''}</span>${st.done[r.key] ? '<span class="cz-pill ok">Done</span>' : `<button type="button" class="ut-btn sm ghost" data-rv-done="${esc(r.id)}" data-k="${esc(r.key)}">It came in</button>`}</div>`).join('')
|
|
33
|
+
|| '<p class="ut-small ut-mut">Nobody owes you anything.</p>';
|
|
34
|
+
}
|
|
35
|
+
if (s.key === 'untouched') {
|
|
36
|
+
const rows = staleInis(D, h.now());
|
|
37
|
+
const items = (work() && work().review && work().review.ids) || [];
|
|
38
|
+
const iRows = ((work() && work().rows) || []).filter((r, i, a) => items.includes(r.id) && a.findIndex((x) => x.id === r.id) === i);
|
|
39
|
+
const pill = (k) => (k.how === 'asked' ? '<span class="cz-pill">Asked in chat</span>' : k.how === 'held' ? '<span class="cz-pill q">On hold</span>' : '<span class="cz-pill ok">Kept going</span>');
|
|
40
|
+
return rows.slice(0, 8).map((r) => `<div class="ut-trow"><span><b>${esc(r.title)}</b> <span class="ut-mut">· ${esc([r.stage, plural(r.days, 'day', 'days')].filter(Boolean).join(' ') + (r.owner ? '' : ' · no owner'))}</span></span>`
|
|
41
|
+
+ (kept[r.id] ? pill(kept[r.id]) : `<button type="button" class="ut-btn sm soft" data-rv-go="${esc(r.id)}">Keep going</button><button type="button" class="ut-btn sm ghost" data-rv-ask="${esc(r.id)}">Ask in chat</button>`) + '</div>').join('')
|
|
42
|
+
+ iRows.slice(0, 6).map((r) => `<div class="ut-trow"><span><b>${esc(r.title)}</b> <span class="ut-mut">· ${esc(r.sub || 'your list')}</span></span>${st.done[r.key] ? '<span class="cz-pill ok">Done</span>' : `<button type="button" class="ut-btn sm ghost" data-rv-done="${esc(r.id)}" data-k="${esc(r.key)}">Done</button>`}</div>`).join('')
|
|
43
|
+
|| '<p class="ut-small ut-mut">Nothing has sat untouched for 14 days.</p>';
|
|
44
|
+
}
|
|
45
|
+
const rows = tab('today').concat(tab('upcoming')).slice(0, 10);
|
|
46
|
+
return rows.map((r) => `<div class="ut-trow"><span><b>${esc(r.title)}</b>${r.sub ? ` <span class="ut-mut">· ${esc(r.sub)}</span>` : ''}</span><button type="button" class="cz-chip${st.picked.has(r.id) ? ' on' : ''}" data-rv-pick="${esc(r.id)}" aria-pressed="${st.picked.has(r.id)}"${!st.picked.has(r.id) && st.picked.size >= 3 ? ' disabled' : ''}>${st.picked.has(r.id) ? 'Picked' : 'Pick'}</button></div>`).join('')
|
|
47
|
+
+ (rows.length ? `<p class="ut-small ut-mut">${st.picked.size} of 3 picked. Each one becomes P1 on your list.</p>` : '<p class="ut-small ut-mut">Your list has nothing for next week yet.</p>');
|
|
48
|
+
}
|
|
49
|
+
function noteOf(key) {
|
|
50
|
+
const vals = Object.values(st.done);
|
|
51
|
+
if (key === 'sort') { const k = vals.filter((x) => x === 'kept').length, t = vals.filter((x) => x === 'today').length; return t + k ? plural(t + k, 'sorted', 'sorted') + (k ? ' · ' + k + ' kept' : '') : 'Nothing to sort'; }
|
|
52
|
+
if (key === 'wait') { const d = vals.filter((x) => x === 'done').length; return d ? d + ' came in' : 'Checked'; }
|
|
53
|
+
if (key === 'untouched') { const R = reviewModel(h.D(), h.now()); return plural(Object.keys(R.kept || {}).length, 'looked at', 'looked at'); }
|
|
54
|
+
return st.picked.size ? st.picked.size + ' picked' : 'None picked';
|
|
55
|
+
}
|
|
56
|
+
const draw = (b) => {
|
|
57
|
+
const R = reviewModel(h.D(), h.now());
|
|
58
|
+
const steps = R.steps.map((s) => {
|
|
59
|
+
if (s.done) return `<div class="ut-step"><span class="ut-chk on">${svg(P.check, 12)}</span><b>${esc(s.label)}</b><span class="ut-small ut-mut">${esc(s.note)}</span></div>`;
|
|
60
|
+
if (s.now) return `<div class="ut-step now" role="group" aria-label="${esc(s.label)}, now"><div class="h"><span class="ut-chk"></span><b>${esc(s.label)}</b><span class="ut-small ut-bl"><b>Now</b></span></div>`
|
|
61
|
+
+ `<div>${stepBody(s, R)}</div><div class="ut-acts"><button type="button" class="ut-btn sm pri" data-rv-step="${s.key}"${st.busy ? ' disabled' : ''}>Done with this step</button></div></div>`;
|
|
62
|
+
return `<div class="ut-step later"><span class="ut-chk"></span><b>${esc(s.label)}</b></div>`;
|
|
63
|
+
}).join('');
|
|
64
|
+
const last = R.last ? 'Last review: ' + dayLabel(R.last.week) + (R.last.minutes ? ' · ' + plural(R.last.minutes, 'minute', 'minutes') : '') : 'This is your first weekly review here.';
|
|
65
|
+
b.innerHTML = `<div class="ut-vc">${tabsHtml('review')}<div><h2 class="ut-h2">Weekly review · ${esc(R.label)}</h2><p class="ut-sub">${R.done ? 'Done for this week. Each step kept what you decided.' : 'Four short steps. Each one keeps what you decided.'}</p></div>`
|
|
66
|
+
+ `<div class="cz-ladder" role="img" aria-label="${R.steps.filter((x) => x.done).length} of 4 steps done">${R.steps.map((s) => `<i class="${s.done ? 'done' : s.now ? 'now' : ''}"></i>`).join('')}</div>`
|
|
67
|
+
+ `<div class="ut-steps">${steps}</div><p class="ut-small ut-mut" role="status" id="rvMsg">${esc(st.msg)}</p><p class="ut-small ut-mut ut-foot">${esc(last)}</p></div>`;
|
|
68
|
+
};
|
|
69
|
+
const body = h.VW.open({ id: 'review', kind: 'My work', title: 'Weekly review', icon: 'list', render: draw });
|
|
70
|
+
const say = (m) => { st.msg = m; const el = body.querySelector('#rvMsg'); if (el) el.textContent = m; };
|
|
71
|
+
const post = async (path, b) => { const r = await h.pmPost(path, b).catch(() => null); if (!r || r.ok !== true) { say((r && r.error) || 'Nothing was changed.'); return null; } return r; };
|
|
72
|
+
const redraw = async () => { await h.reload(); if (body.isConnected) draw(body); };
|
|
73
|
+
body.onclick = async (e) => {
|
|
74
|
+
const b = e.target.closest('button'); if (!b || b.disabled) return;
|
|
75
|
+
const d = b.dataset;
|
|
76
|
+
if (d.utTab === 'work') { h.openWork(); return; }
|
|
77
|
+
if (d.rvToday) { if (await post('/api/pm-items/flag', { id: d.rvToday, flagged: true })) { st.done[d.k] = 'today'; draw(body); } return; }
|
|
78
|
+
if (d.rvKeep) { if (await post('/api/pm-items/keep', { id: d.rvKeep })) { st.done[d.k] = 'kept'; draw(body); } return; }
|
|
79
|
+
if (d.rvDone) { if (await post('/api/pm-items/done', { id: d.rvDone })) { st.done[d.k] = 'done'; draw(body); } return; }
|
|
80
|
+
if (d.rvPick) { if (st.picked.has(d.rvPick)) st.picked.delete(d.rvPick); else if (st.picked.size < 3) st.picked.add(d.rvPick); draw(body); return; }
|
|
81
|
+
if (d.rvGo) { if (await post('/api/home-review/keep', { ws: h.ws(), initiative: d.rvGo, how: 'kept' })) { h.toast('Kept going. It is not asked about again this week.'); redraw(); } return; }
|
|
82
|
+
if (d.rvAsk) {
|
|
83
|
+
const s = staleInis(h.D(), h.now()).find((x) => x.id === d.rvAsk); if (!s) return;
|
|
84
|
+
if (await post('/api/home-review/keep', { ws: h.ws(), initiative: s.id, how: 'asked' })) { h.askAbout(s, { hold: () => hold(s), keep: () => post('/api/home-review/keep', { ws: h.ws(), initiative: s.id, how: 'kept' }).then(redraw) }); redraw(); }
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (d.rvStep) {
|
|
88
|
+
st.busy = true; draw(body);
|
|
89
|
+
if (d.rvStep === 'pick') for (const id of st.picked) await post('/api/pm-items/edit', { id, fields: { priority: 'P1' } });
|
|
90
|
+
const r = await post('/api/home-review/step', { ws: h.ws(), week: reviewModel(h.D(), h.now()).week || undefined, step: d.rvStep, note: noteOf(d.rvStep) });
|
|
91
|
+
st.busy = false; st.done = {};
|
|
92
|
+
if (r) { st.msg = ''; await redraw(); if (reviewModel(h.D(), h.now()).done) h.toast('The weekly review is done for this week.'); } else draw(body);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
async function hold(s) {
|
|
96
|
+
const r = await post('/api/lifecycle', { ws: h.ws(), initiative_id: s.id, state: 'on-hold', reason: 'Weekly review: no change for ' + s.days + ' days' });
|
|
97
|
+
if (!r) return false;
|
|
98
|
+
await post('/api/home-review/keep', { ws: h.ws(), initiative: s.id, how: 'held' });
|
|
99
|
+
h.toast('On hold. The reason is on the record.');
|
|
100
|
+
await redraw();
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return body;
|
|
104
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* pm/home-task.js — one task in the Viewer (initiative premium-uncovered-features, H1; canvas HmMyWork, the Viewer).
|
|
2
|
+
*
|
|
3
|
+
* A PMOS task of an initiative (GET /api/boards/items, src "pmos") opens here from the list: its check, its title and where it sits
|
|
4
|
+
* ("Session list v2 · task · due today"), its due chip, its status, what the PM needs for it (the initiative, its core documents and its
|
|
5
|
+
* Jira item), and the two presses of the canvas: talk it through in the chat, and Done. Every write is the board's own route
|
|
6
|
+
* (POST /api/boards/tasks/state) and is the PM's press; a refusal shows the route's reason and changes nothing.
|
|
7
|
+
* The PM's own items (a note, a mention made into a task) open in My work's item view (home-work.js), drawn in the same shape. */
|
|
8
|
+
import { esc, svg, P } from './home-today.js';
|
|
9
|
+
|
|
10
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
11
|
+
const STATES = ['To do', 'In progress', 'In review', 'Done'];
|
|
12
|
+
const dayDiff = (iso, now) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return null; const a = new Date(+m[1], +m[2] - 1, +m[3]); const t = new Date(now); t.setHours(0, 0, 0, 0); return Math.round((a - t) / 86400000); };
|
|
13
|
+
/** The due chip's words: "Due today", "Due tomorrow", "2 days late", "Due 30 Oct", or "No date". Pure. */
|
|
14
|
+
export function dueText(iso, now = Date.now()) {
|
|
15
|
+
const d = dayDiff(iso, now);
|
|
16
|
+
if (d == null) return 'No date';
|
|
17
|
+
if (d === 0) return 'Due today';
|
|
18
|
+
if (d === 1) return 'Due tomorrow';
|
|
19
|
+
if (d < 0) return -d + (d === -1 ? ' day late' : ' days late');
|
|
20
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso); return 'Due ' + +m[3] + ' ' + MON[+m[2] - 1];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** h: { VW, pmPost, toast, now, ws, board, iniTitle(id), docs(id) → [{ title, path }], openIni(id), openDoc(doc), askInChat(task), openRecord(task), onChange() } */
|
|
24
|
+
export function openTask(task, h) {
|
|
25
|
+
const st = { msg: '', busy: false };
|
|
26
|
+
const t = task;
|
|
27
|
+
const draw = (b) => {
|
|
28
|
+
const now = h.now ? h.now() : Date.now();
|
|
29
|
+
const done = t.status === 'Done';
|
|
30
|
+
const due = dueText(t.end, now);
|
|
31
|
+
const where = [h.iniTitle(t.ini), 'task', due === 'No date' ? '' : due.replace(/^Due /, '').toLowerCase(), t.owner && !/^(pm|you)(:|$)/i.test(t.owner) ? 'with ' + t.owner : ''].filter(Boolean).join(' · ');
|
|
32
|
+
const docs = (h.docs ? h.docs(t.ini) : []) || [];
|
|
33
|
+
const need = [`<div class="ut-trow">${svg(P.flag, 16)}<span>${esc(h.iniTitle(t.ini))} <span class="ut-mut">· the initiative</span></span><button type="button" class="ut-btn sm soft" data-tk="ini">Open</button></div>`]
|
|
34
|
+
.concat(docs.slice(0, 4).map((d, i) => `<div class="ut-trow">${svg(P.doc, 16)}<span>${esc(d.title)}</span><button type="button" class="ut-btn sm soft" data-tk-doc="${i}">Open</button></div>`))
|
|
35
|
+
.concat(t.ref && t.src !== 'pmos' ? [`<div class="ut-trow">${svg(P.ticket, 16)}<span>${esc(t.ref)}</span></div>`] : []);
|
|
36
|
+
b.innerHTML = `<div class="ut-vc">`
|
|
37
|
+
+ `<div class="ut-vh"><button type="button" class="hm-ck" data-tk="done" aria-label="${done ? 'Done' : 'Mark ' + esc(t.title) + ' done'}"${done ? ' disabled' : ''}><span class="ut-chk${done ? ' on' : ''}">${done ? svg(P.check, 12) : ''}</span></button>`
|
|
38
|
+
+ `<div><h2 class="ut-h2">${esc(t.title)}</h2><p class="ut-sub">${esc(where)}</p></div>`
|
|
39
|
+
+ `<button type="button" class="ut-ib" data-tk="record" aria-label="Open the task's record" title="The task's record">${svg(P.dots, 16, 'dots')}</button></div>`
|
|
40
|
+
+ `<div class="ut-chips"><span class="cz-chip${/late/.test(due) ? ' on' : ''}">${esc(due)}</span>${STATES.filter((x) => x !== 'Done').map((x) => `<button type="button" class="cz-chip${t.status === x ? ' on' : ' gh'}" data-tk-state="${esc(x)}" aria-pressed="${t.status === x}">${esc(x)}</button>`).join('')}</div>`
|
|
41
|
+
+ `<p class="ut-lbl">What you need for it</p><div>${need.join('')}</div>`
|
|
42
|
+
+ `<div class="ut-foot"><button type="button" class="ut-btn pri" data-tk="chat">Talk it through in chat</button><button type="button" class="ut-btn" data-tk="done"${done ? ' disabled' : ''}>Done</button></div>`
|
|
43
|
+
+ `<p class="ut-small ut-mut" role="status" id="tkMsg">${esc(st.msg)}</p></div>`;
|
|
44
|
+
};
|
|
45
|
+
const body = h.VW.open({ id: 'task:' + t.uid, kind: 'Task', title: t.title, icon: 'M5 12l5 5 9-10', render: draw });
|
|
46
|
+
const setState = async (state) => {
|
|
47
|
+
if (st.busy) return; st.busy = true;
|
|
48
|
+
const r = await h.pmPost('/api/boards/tasks/state', { ws: h.ws, board: t.board || h.board, task: t.uid, state }).catch(() => null);
|
|
49
|
+
st.busy = false;
|
|
50
|
+
if (!r || r.ok !== true) { st.msg = (r && r.error) || 'The status did not change.'; draw(body); return; }
|
|
51
|
+
t.status = state; st.msg = '';
|
|
52
|
+
h.toast(state === 'Done' ? 'Done. It leaves your list.' : 'Now ' + state.toLowerCase() + '.');
|
|
53
|
+
if (state === 'Done') h.VW.close(); else draw(body);
|
|
54
|
+
if (h.onChange) h.onChange();
|
|
55
|
+
};
|
|
56
|
+
body.onclick = (e) => {
|
|
57
|
+
const b = e.target.closest('button'); if (!b || b.disabled) return;
|
|
58
|
+
const k = b.dataset.tk;
|
|
59
|
+
if (b.dataset.tkState) { if (b.dataset.tkState !== t.status) setState(b.dataset.tkState); return; }
|
|
60
|
+
if (b.dataset.tkDoc != null && b.dataset.tkDoc !== '') { const d = (h.docs ? h.docs(t.ini) : [])[+b.dataset.tkDoc]; if (d && h.openDoc) h.openDoc(d); return; }
|
|
61
|
+
if (k === 'done') setState('Done');
|
|
62
|
+
else if (k === 'ini') h.openIni(t.ini);
|
|
63
|
+
else if (k === 'chat') h.askInChat(t);
|
|
64
|
+
else if (k === 'record' && h.openRecord) h.openRecord(t);
|
|
65
|
+
};
|
|
66
|
+
return body;
|
|
67
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* pm/home-today.js — draws Home's one list (initiative premium-uncovered-features, H1 and H2; canvas HmMyWork, HmReview, HmProducts,
|
|
2
|
+
* HmDay, HmMic, HmPhone, HmPhone2).
|
|
3
|
+
*
|
|
4
|
+
* The list column, top to bottom: the head (Today, the products picker when Home reads more than one product, New), the Today card through
|
|
5
|
+
* the day, the filters (Today, Waiting, Kept, Done), one group per product ("PMOS · 2 of 4 goals on track") with its own next steps and its
|
|
6
|
+
* initiatives (the ones where it is your turn first, each with its tasks, next steps, sessions and meetings nested under it), "Not in an
|
|
7
|
+
* initiative", the capture box ("Add a task. PMOS files it under its initiative") and "Untouched 14+ days". Another product's group can be
|
|
8
|
+
* closed: "Partner portal · 2 initiatives · 1 your turn".
|
|
9
|
+
* The model is home-list.js (pure). This file only turns it into HTML: every control is a <button> (or the capture form) with a data-hm-*
|
|
10
|
+
* press that home-app.js handles. Text from the records goes through esc(). */
|
|
11
|
+
|
|
12
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
13
|
+
export const P = {
|
|
14
|
+
chevR: 'M10 7l5 5-5 5', chevD: 'M7 10l5 5 5-5', plus: 'M12 5v14M5 12h14', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12l5 5 9-10',
|
|
15
|
+
mic: 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3M5 11a7 7 0 0 0 14 0M12 18v3', clock: 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 8v4l3 2',
|
|
16
|
+
pause: 'M8 5v14M16 5v14', stop: 'M7 7h10v10H7z', list: 'M9 6h11M9 12h11M9 18h11', doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
|
|
17
|
+
gate: 'M12 3l7 3v6c0 4-3 7-7 9-4-2-7-5-7-9V6z', flag: 'M5 21V4h11l-2 4 2 4H5', cal: 'M4 6h16v14H4zM4 10h16', pin: 'M9 4h6l-1 6 3 3H7l3-3zM12 13v7',
|
|
18
|
+
decide: 'M12 3v18M5 8l7-5 7 5', ret: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', back: 'M19 12H5M11 6l-6 6 6 6', warn: 'M12 4l9 16H3zM12 10v4M12 17v.5',
|
|
19
|
+
chat: 'M4 5h16v11H9l-5 4z', dots: 'M5 12h.01M12 12h.01M19 12h.01', send: 'M5 12h14M13 6l6 6-6 6', ticket: 'M3 5h18v4H3zM3 11h18v4H3z',
|
|
20
|
+
};
|
|
21
|
+
export const svg = (d, w = 16, cls = '') => `<svg aria-hidden="true"${cls ? ` class="${cls}"` : ''} width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
22
|
+
const ROW_ICON = { decision: P.decide, blocked: P.warn, waited: P.clock, src: P.doc, source: P.doc, ev: P.gate, run: P.ret, update: P.doc, meeting: P.cal };
|
|
23
|
+
const dotOf = (st) => ({ needs: 'you', blocked: 'late', working: 'ok', wait: 'none' }[st] || 'none');
|
|
24
|
+
const iconOfNeed = (r) => (r.kind === 'update' ? P.doc : r.row && r.row.dialog && r.row.dialog.write && r.row.dialog.write.kind === 'return' ? P.ret : ROW_ICON[(r.row && r.row.kind) || ''] || P.gate);
|
|
25
|
+
|
|
26
|
+
/* ── one row ── */
|
|
27
|
+
function tileHtml(r, o) {
|
|
28
|
+
if (r.kind === 'session') return o.avHtml(r.role || { initial: r.initial || 'C' }, 32, 'hm-tile');
|
|
29
|
+
if (r.kind === 'meeting') return `<span class="hm-tile">${svg(P.cal, 16)}</span>`;
|
|
30
|
+
return `<span class="hm-tile">${svg(r.kind === 'need' || r.kind === 'update' ? iconOfNeed(r) : P.chat, 16)}</span>`;
|
|
31
|
+
}
|
|
32
|
+
/** A row of the list: a next step, a task, a note, a mention, a session or a meeting. o: { sel, kid, flat, avHtml, pinned } */
|
|
33
|
+
export function rowHtml(r, o) {
|
|
34
|
+
const sel = o.sel === r.id;
|
|
35
|
+
const cls = ['hm-r', 'lr', o.kid ? 'kid' : '', sel ? 'sel' : '', 'st-' + (r.state || 'quiet'), r.kind === 'task' ? 'task' : '', r.kind === 'item' ? 'item' : '', r.done ? 'done' : ''].filter(Boolean).join(' ');
|
|
36
|
+
const hint = r.hint || '';
|
|
37
|
+
const quiet = r.kind === 'task' || r.kind === 'item' || r.kind === 'meeting' || r.kind === 'finished' || r.state === 'quiet' || r.state === 'wait';
|
|
38
|
+
let lead = '';
|
|
39
|
+
if (r.check || (r.kind === 'task' && r.mine)) lead = `<button type="button" class="hm-ck" data-hm-check="${esc(r.id)}" aria-label="Mark ${esc(r.name)} done" title="Done"><span class="ut-chk${r.done ? ' on' : ''}">${r.done ? svg(P.check, 12) : ''}</span></button>`;
|
|
40
|
+
else if (r.kind === 'task') lead = '<span class="hm-ck wait" aria-hidden="true"><i></i></span>';
|
|
41
|
+
else if (r.done) lead = `<span class="hm-ck wait" aria-hidden="true"><span class="ut-chk on">${svg(P.check, 12)}</span></span>`;
|
|
42
|
+
const dot = lead ? '' : `<i class="hm-dot ${dotOf(r.state)}" aria-hidden="true"></i>`;
|
|
43
|
+
const tile = lead || o.kid ? '' : tileHtml(r, o);
|
|
44
|
+
const end = r.kind === 'session' && r.sid ? `<button type="button" class="hm-x" data-hm-end="${esc(r.id)}" aria-label="End ${esc(r.name)}" title="End this session">${svg(P.x, 14)}</button>`
|
|
45
|
+
: r.kind === 'need' && r.row && r.row.kind !== 'source' ? `<button type="button" class="hm-x" data-hm-end="${esc(r.id)}" aria-label="Put off ${esc(r.name)} until tomorrow" title="Put off until tomorrow">${svg(P.x, 14)}</button>` : '';
|
|
46
|
+
const right = r.link && r.kind === 'loose-rec' ? '<span class="hm-rr">Link it</span>' : '';
|
|
47
|
+
return `<div class="${cls}" data-id="${esc(r.id)}">${lead}<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}>${dot}${tile}`
|
|
48
|
+
+ `<span class="hm-rt"><b>${esc(r.name)}</b>${hint ? `<em${quiet ? ' class="q"' : ''}>${esc(hint)}</em>` : ''}</span>${right}</button>${end}</div>`;
|
|
49
|
+
}
|
|
50
|
+
/** An initiative row: the chevron opens what sits under it, the title opens the initiative. */
|
|
51
|
+
function iniHtml(r, o) {
|
|
52
|
+
const open = o.isOpen(r.id);
|
|
53
|
+
const nest = open ? `<div class="hm-nest" role="group" aria-label="In ${esc(r.name)}">${r.kids.map((k) => rowHtml(k, { ...o, kid: true })).join('') || '<p class="hm-none">Nothing today.</p>'}</div>` : '';
|
|
54
|
+
return `<div class="hm-r lr ini st-${esc(r.state)}${o.sel === r.id ? ' sel' : ''}" data-id="${esc(r.id)}"><button type="button" class="hm-tg" data-hm-kids="${esc(r.id)}" aria-expanded="${open}" aria-label="${open ? 'Hide' : 'Show'} what is in ${esc(r.name)}">${svg(open ? P.chevD : P.chevR, 14)}</button>`
|
|
55
|
+
+ `<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"><span class="hm-rt"><b>${esc(r.name)}</b><em class="q">${esc(r.hint)}</em></span><span class="hm-rr${r.turn ? '' : ' q'}">${esc(r.right)}</span></button></div>${nest}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* ── a group ── */
|
|
59
|
+
function productHtml(g, o) {
|
|
60
|
+
const open = o.pOpen(g);
|
|
61
|
+
const head = open
|
|
62
|
+
? `<div class="hm-ghr2"><button type="button" class="hm-ghd" data-hm-pg="${esc(g.key)}" aria-expanded="true" aria-label="${esc(g.name)}: ${esc(g.goals ? g.goals.text : g.closedLine)}. Close the group">${esc(g.name)}</button>`
|
|
63
|
+
+ (g.goals ? (g.primary ? `<button type="button" class="hm-gn" data-hm-prod aria-label="${esc(g.goals.text)}. Open the product">${esc(g.goals.text)}</button>` : `<span class="hm-gn">${esc(g.goals.text)}</span>`) : `<span class="hm-gn">${esc(g.closedLine)}</span>`) + '</div>'
|
|
64
|
+
: `<button type="button" class="hm-ghd" data-hm-pg="${esc(g.key)}" aria-expanded="false">${svg(P.chevR, 14)}${esc(g.name)}<span class="n">${esc(g.closedLine)}</span></button>`;
|
|
65
|
+
if (!open) return `<section class="hm-pg" aria-label="${esc(g.name)}">${head}</section>`;
|
|
66
|
+
const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
|
|
67
|
+
const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
|
|
68
|
+
const QUIET = 3;
|
|
69
|
+
const restAll = o.restOpen(g.key);
|
|
70
|
+
const rest = restAll ? g.rest : g.rest.slice(0, Math.max(0, QUIET - g.inis.length));
|
|
71
|
+
const more = g.rest.length - rest.length;
|
|
72
|
+
const body = flat + g.inis.concat(rest).map((r) => iniHtml(r, o)).join('')
|
|
73
|
+
+ (more > 0 ? `<button type="button" class="hm-more2" data-hm-rest="${esc(g.key)}">${more} more ${more === 1 ? 'initiative' : 'initiatives'} with nothing today · Show</button>`
|
|
74
|
+
: restAll && g.rest.length > QUIET ? `<button type="button" class="hm-more2" data-hm-rest="${esc(g.key)}">Show fewer</button>` : '');
|
|
75
|
+
return `<section class="hm-pg" aria-label="${esc(g.name)}">${head}${body || `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</section>`;
|
|
76
|
+
}
|
|
77
|
+
function looseHtml(g, o) {
|
|
78
|
+
if (!g.rows.length) return '';
|
|
79
|
+
return `<section class="hm-pg" aria-label="${esc(g.name)}"><div class="hm-ghd">${esc(g.name)}<span class="n">${g.n}</span></div>${g.rows.map((r) => rowHtml(r, o)).join('')}</section>`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ── the Today card ── */
|
|
83
|
+
/** The card's HTML. T is todayCard(); greet the greeting; sub the line under it when the day has no meeting. */
|
|
84
|
+
export function todayHtml(T, o) {
|
|
85
|
+
if (T.mode === 'rec') {
|
|
86
|
+
return `<div class="hm-tc rec" role="group" aria-label="Recording"><span class="ut-rec" aria-hidden="true"></span><div><b>${T.paused ? 'Paused' : 'Recording'}${T.clock ? ' · ' + esc(T.clock) : ''}</b><p>${esc(T.sub)}</p></div>`
|
|
87
|
+
+ `<button type="button" class="ut-ib" data-hm-tc="${T.paused ? 'resume' : 'pause'}" aria-label="${T.paused ? 'Go on recording' : 'Pause the recording'}" title="${T.paused ? 'Go on' : 'Pause'}">${svg(T.paused ? P.mic : P.pause, 16)}</button>`
|
|
88
|
+
+ `<button type="button" class="ut-ib solid" data-hm-tc="stop" aria-label="Stop the recording" title="Stop">${svg(P.stop, 14, 'fill')}</button></div>`;
|
|
89
|
+
}
|
|
90
|
+
if (T.mode === 'soon') {
|
|
91
|
+
return `<div class="hm-tc soon" role="group" aria-label="${esc(T.time + ' ' + T.title + ', ' + T.in)}"><p class="hm-tch">${svg(P.clock, 18)}<b>${esc(T.time)} ${esc(T.title)}</b><span class="r">${esc(T.in)}</span></p>`
|
|
92
|
+
+ (T.sub ? `<p class="sub ut-small">${esc(T.sub)}</p>` : '')
|
|
93
|
+
+ `<p class="ut-acts"><button type="button" class="ut-btn sm pri" data-hm-tc="prep">Open prep</button>${T.link ? `<a class="ut-btn sm soft" href="${esc(T.link)}" target="_blank" rel="noopener noreferrer">Join</a>` : ''}</p></div>`;
|
|
94
|
+
}
|
|
95
|
+
if (T.mode === 'live') {
|
|
96
|
+
return `<div class="hm-tc live" role="group" aria-label="${esc(T.title)}, on now"><p class="hm-tch">${T.rec ? '<span class="ut-rec" aria-hidden="true"></span>' : svg(P.clock, 18)}<b>${esc(T.title)} · live</b><span class="r q">${esc(T.mins)}</span></p>`
|
|
97
|
+
+ `<p class="sub ut-small">${esc(T.sub)}</p><p class="ut-acts"><button type="button" class="ut-btn sm soft" data-hm-tc="open">Open</button>${T.rec ? '<button type="button" class="ut-btn sm ghost" data-hm-tc="hl">Highlight</button>' : '<button type="button" class="ut-btn sm ghost" data-hm-tc="record">Record</button>'}</p></div>`;
|
|
98
|
+
}
|
|
99
|
+
if (T.mode === 'eod') {
|
|
100
|
+
return `<div class="hm-tc eod" role="group" aria-label="End of day"><p class="hm-tch"><b>End of day</b><span class="r q">${esc(T.time)}</span><button type="button" class="ut-ib" data-hm-tc="hide" aria-label="Hide until tomorrow" title="Hide until tomorrow">${svg(P.x, 14)}</button></p>`
|
|
101
|
+
+ `<div class="ut-need"><span class="ut-small"><b>${esc(T.blockLine)}</b>${T.why ? ' ' + esc(T.why) : ''}</span><span class="ut-acts"><button type="button" class="ut-btn sm pri" data-hm-tc="now">Do it now</button>${T.later ? '<button type="button" class="ut-btn sm" data-hm-tc="tomorrow">Tomorrow 09:00</button>' : ''}</span></div>`
|
|
102
|
+
+ (T.lines.length ? `<div class="hm-eodl">${T.lines.map(([k, v]) => `<span><b>${esc(k)}</b><span>${esc(v)}</span></span>`).join('')}</div>` : '') + '</div>';
|
|
103
|
+
}
|
|
104
|
+
if (T.mode === 'clear') return `<div class="hm-tc clear" role="status">${esc(T.line)}</div>`;
|
|
105
|
+
if (T.mode === 'review') {
|
|
106
|
+
return `<button type="button" class="hm-tc" data-hm-review aria-label="${esc(T.big)} ${esc(T.sub)}. Open the review"><b class="big">${esc(T.big)}</b><span class="sub">${esc(T.sub)}</span></button>`;
|
|
107
|
+
}
|
|
108
|
+
const L = T.load || { segs: [] };
|
|
109
|
+
const sub = L.n ? L.sub : o.sub;
|
|
110
|
+
const bar = L.segs.length ? `<span class="hm-load" aria-hidden="true">${L.segs.map((s) => `<i class="${s.m ? 'm' : ''}${s.now ? ' n' : ''}" data-f="${Math.max(1, s.flex)}"></i>`).join('')}</span><span class="hm-lx" aria-hidden="true"><span>09</span><span>12</span><span>15</span><span>18</span></span>` : '';
|
|
111
|
+
return `<button type="button" class="hm-tc day" data-hm-tc="cal" aria-label="${esc(o.greet)} ${esc(sub)}. Open the calendar"><b class="big">${esc(o.greet)}</b><span class="sub">${esc(sub)}</span>${bar}</button>`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ── the whole column ── */
|
|
115
|
+
/** M is homeList(); T todayCard(); o: { sel, isOpen, pOpen, restOpen, pin, avHtml, ready, err, product (the picked key), review, sub, phone } */
|
|
116
|
+
export function listHtml(M, T, o) {
|
|
117
|
+
const many = M.products.length > 1;
|
|
118
|
+
const picked = o.product ? M.products.find((p) => p.key === o.product) : null;
|
|
119
|
+
const head = `<div class="hm-hd"><h1>Today</h1>`
|
|
120
|
+
+ (many ? `<button type="button" class="cz-pick hm-pk" data-hm-pick aria-haspopup="menu" aria-expanded="false">${esc(picked ? picked.name : 'All products')} ${svg(P.chevD, 14)}</button><button type="button" class="ut-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 16)}</button>`
|
|
121
|
+
: `<button type="button" class="hm-new" data-hm-new aria-haspopup="menu">${svg(P.plus, 14)}New</button>`) + '</div>';
|
|
122
|
+
const card = todayHtml(T, { greet: M.greet, sub: o.sub });
|
|
123
|
+
const flt = `<div class="hm-flt" role="group" aria-label="Show">${M.filters.map((f, i) => `<button type="button" class="cz-chip${f.key === M.filter ? ' on' : ' gh'}${i > 1 ? ' dk' : ''}" data-hm-filter="${f.key}" aria-pressed="${f.key === M.filter}">${esc(f.label)}${f.n ? ' ' + f.n : ''}</button>`).join('')}</div>`;
|
|
124
|
+
if (!o.ready) return head + card + '<p class="hm-none" role="status">Reading your work.</p>';
|
|
125
|
+
const errLine = `<p class="hm-none" role="status">Home could not read the repository: ${esc(o.err)}.</p>`;
|
|
126
|
+
if (o.err && !M.groups.some((g) => (g.kind === 'product' && g.count) || (g.rows && g.rows.length))) return head + card + errLine;
|
|
127
|
+
// the repository's read failed but sessions or notes still answered: say so above what did come back, never an empty product as if calm
|
|
128
|
+
let body = o.err && !M.groups.some((g) => g.kind === 'product' && (g.count || g.flat.length)) ? errLine : '';
|
|
129
|
+
if (M.list) {
|
|
130
|
+
body = `<section class="hm-pg" aria-label="${esc(M.list.title)}"><div class="hm-ghd">${esc(M.list.title)}<span class="n">${M.list.rows.length || ''}</span></div>`
|
|
131
|
+
+ (M.list.rows.map((r) => rowHtml(r, o)).join('') || `<p class="hm-none">${esc(M.list.empty)}</p>`) + '</section>';
|
|
132
|
+
} else {
|
|
133
|
+
const R = o.review;
|
|
134
|
+
if (R && R.open) body += `<section class="hm-pg" aria-label="This week"><div class="hm-ghd">This week<span class="n">Fri</span></div><div class="hm-r lr${o.sel === 'review' ? ' sel' : ''}" data-id="review"><button type="button" class="hm-rm" data-hm-review><span class="hm-tile wk">${svg(P.check, 16)}</span><span class="hm-rt"><b>Weekly review</b><em>${R.started ? 'Step ' + (R.at + 1) + ' of 4' : 'Four short steps'}</em></span></button></div></section>`;
|
|
135
|
+
body += M.groups.map((g) => (g.kind === 'product' ? productHtml(g, o) : looseHtml(g, o))).join('');
|
|
136
|
+
if (!M.groups.some((g) => (g.kind === 'product' && (g.count || g.flat.length)) || (g.rows && g.rows.length))) body += '<p class="hm-none">Nothing is open. A new initiative or a task you add shows here.</p>';
|
|
137
|
+
body += `<form class="hm-cap" id="hmCapF"><label class="vh" for="hmCap">Add a task</label><input id="hmCap" autocomplete="off" maxlength="250" placeholder="Add a task. PMOS files it under its initiative">`
|
|
138
|
+
+ (o.mic ? `<button type="button" class="ut-ib" data-hm-capmic aria-label="Say it instead" title="Say it instead">${svg(P.mic, 16)}</button>` : '') + '</form>';
|
|
139
|
+
if (M.untouched.n) body += `<button type="button" class="hm-un" data-hm-review><b>Untouched 14+ days · ${M.untouched.n}</b><span>Weekly review ${esc(M.untouched.day)}</span></button>`;
|
|
140
|
+
}
|
|
141
|
+
const waiting = (M.filters.find((f) => f.key === 'waiting') || {}).n || 0;
|
|
142
|
+
const all = `<div class="hm-r lr hm-all"><button type="button" class="hm-rm" data-hm-work><span class="hm-tile wk">${svg(P.list, 16)}</span><span class="hm-rt"><b>All of my work</b><em class="q">${esc([waiting + ' waiting', M.untouched.n + ' untouched'].join(' · '))}</em></span>${svg(P.chevR, 16)}</button></div>`;
|
|
143
|
+
return head + card + flt + body + all;
|
|
144
|
+
}
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
/* pm/home-work.js — My work in the Home Viewer (initiative premium-
|
|
2
|
-
*
|
|
3
|
-
* (lib/my-work-premium.js builds the model) and keeps every feature of the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
1
|
+
/* pm/home-work.js — My work in the Home Viewer (initiative premium-uncovered-features, H1; canvas HmMyWork; the depth of premium-work-depth).
|
|
2
|
+
* There is no separate list on Home: a task sits under its initiative, and the PM's own notes sit under "Not in an initiative". This card is
|
|
3
|
+
* the depth behind those rows. It reads GET /api/my-work-premium (lib/my-work-premium.js builds the model) and keeps every feature of the
|
|
4
|
+
* old My work page usable:
|
|
5
|
+
* "My work" beside "Weekly review" (the review is home-review.js, opened through the hm:review event Home answers)
|
|
6
|
+
* the filters: Open (the Work queue but Kept and Done, with the Focus chip and one add box), Waiting, Untouched, Kept, Done
|
|
7
|
+
* an item opens as the canvas's task card: its check, its title and where it sits, its chips (the due day, Edit with the fields,
|
|
8
|
+
* Keep for later), where it came from, the agent on the item (draft, stop, try again, edit, post after a confirm, send back), Done
|
|
7
9
|
* the Focus chip opens Focus and jobs in the same card: accept or dismiss a suggestion, clear one, add a job
|
|
8
|
-
* keys and swipe on the rows
|
|
10
|
+
* keys and swipe on the open rows: J and K move, the arrows (or a drag past 90 px) do what the row names; most presses offer Undo
|
|
9
11
|
* Every press is the PM's and goes to the Work page's own route under /api/pm-items, /api/pm-jobs or /api/my-work (pmPost carries the launch
|
|
10
12
|
* nonce); this file adds no writer. A refused press shows the route's reason and changes nothing. Text from the list goes through esc(). */
|
|
11
13
|
import { pmGet, pmPost } from './http.js';
|
|
12
14
|
import { open as vwOpen } from './cozy-viewer.js';
|
|
13
15
|
import { mdRender } from './markdown.js';
|
|
16
|
+
import { tabsHtml } from './home-review.js';
|
|
14
17
|
|
|
15
18
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
16
|
-
const
|
|
19
|
+
const BACK = SVB('<path d="M19 12H5M11 6l-6 6 6 6"/>');
|
|
17
20
|
const wsQ = () => { const w = new URLSearchParams(location.search).get('ws'); return w ? '?ws=' + encodeURIComponent(w) : ''; };
|
|
18
21
|
const WS = () => new URLSearchParams(location.search).get('ws') || '';
|
|
19
22
|
const RM = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
20
23
|
const SV = (p) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${p}</svg>`;
|
|
21
24
|
const CHECK = SV('<path d="M5 12l5 5 9-10"/>');
|
|
25
|
+
function SVB(p) { return `<svg viewBox="0 0 24 24" aria-hidden="true">${p}</svg>`; }
|
|
26
|
+
const DOTS = '<svg class="dots" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h.01M12 12h.01M19 12h.01"/></svg>';
|
|
22
27
|
const ICON = { sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2"/>', moon: '<path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/>', eye: '<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>' };
|
|
23
28
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
24
29
|
const dayLabel = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso || ''); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
@@ -36,7 +41,7 @@ function toastUndo(msg, undo, after) {
|
|
|
36
41
|
clearTimeout(toast.t); toast.t = setTimeout(() => t.classList.remove('on', 'act'), 8000);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
const TABS = [['yours', '
|
|
44
|
+
const TABS = [['yours', 'Open'], ['waiting', 'Waiting'], ['stale', 'Untouched'], ['kept', 'Kept'], ['done', 'Done']];
|
|
40
45
|
const AG_CHIP = { ready: 'Draft ready', queued: 'Agent working', working: 'Agent working', sending: 'Agent working', failed: 'Agent stopped' };
|
|
41
46
|
const NOTYET = [['later-today', 'Later today'], ['tomorrow', 'Tomorrow'], ['next-week', 'Next week']];
|
|
42
47
|
const WHO = [['you', 'You'], ['agent-drafts', 'Agent drafts'], ['agent-does', 'Agent does']];
|
|
@@ -47,8 +52,9 @@ const SAID = { done: 'Marked done.', notyet: 'Put off. It comes back by itself.'
|
|
|
47
52
|
const freshUi = () => ({ xp: null, ed: null, dd: '', sn: '', ask: null, body: null, editing: false, confirm: false, back: false, note: '', wo: '', pick: null, round: null, dpick: null, sheet: false, all: false, job: '' });
|
|
48
53
|
|
|
49
54
|
/** Open My work in the Viewer on one tab (yours | waiting | review | stale). */
|
|
50
|
-
export function openMyWork(tab = 'yours') {
|
|
51
|
-
|
|
55
|
+
export function openMyWork(tab = 'yours', o = {}) {
|
|
56
|
+
if (tab === 'review' && askReview()) return null;
|
|
57
|
+
const W = { r: null, M: null, tab: TABS.some((t) => t[0] === tab) || tab === 'review' ? tab : 'yours', msg: '', view: null, key: null, ui: freshUi(), refocus: null, want: o.item || null };
|
|
52
58
|
let body = null;
|
|
53
59
|
const rowOf = (key) => ((W.M && W.M.rows) || []).find((r) => r.key === key) || null;
|
|
54
60
|
const openR = () => (W.view === 'item' ? rowOf(W.key) : null);
|
|
@@ -83,8 +89,12 @@ export function openMyWork(tab = 'yours') {
|
|
|
83
89
|
if (W.tab === 'yours') {
|
|
84
90
|
const tabs = m.queue.tabs.filter((t) => t.key !== 'kept' && t.key !== 'done'); // Kept and Done are not on your list
|
|
85
91
|
const groups = tabs.filter((t) => t.n).map((t) => `<h4 class="mw-g">${esc(t.label)}</h4>` + t.groups.flatMap((g) => g.rows || []).map((r) => rowHtml(r)).join('')).join('');
|
|
86
|
-
return `<div class="mw-list"><div class="mw-head">${focusChip()}</div>${groups || '<p class="hx-n">Nothing
|
|
87
|
-
+ '<div class="hx-add"><input id="hxLine" placeholder="Add
|
|
92
|
+
return `<div class="mw-list"><div class="mw-head">${focusChip()}</div>${groups || '<p class="hx-n">Nothing is open. Add a task below.</p>'}`
|
|
93
|
+
+ '<div class="hx-add"><input id="hxLine" placeholder="Add a task, e.g. Call Ana tomorrow" aria-label="Add a task"><button type="button" class="hx-b pri" data-x="add">Add</button></div></div>';
|
|
94
|
+
}
|
|
95
|
+
if (W.tab === 'kept' || W.tab === 'done') {
|
|
96
|
+
const t = m.queue.tabs.find((x) => x.key === W.tab), rows = t ? t.groups.flatMap((g) => g.rows || []) : [];
|
|
97
|
+
return `<div class="mw-wait">${rows.length ? rows.map((r) => rowHtml(r, true)).join('') : `<p class="hx-n">${W.tab === 'kept' ? 'Nothing is kept for later.' : 'Nothing is done yet.'}</p>`}</div>`;
|
|
88
98
|
}
|
|
89
99
|
if (W.tab === 'waiting') return `<div class="mw-wait">${m.waiting.rows.length ? m.waiting.rows.map((r) => rowHtml(r, true)).join('') : '<p class="hx-n">Nobody owes you anything.</p>'}</div>`;
|
|
90
100
|
if (W.tab === 'review') {
|
|
@@ -205,9 +215,9 @@ export function openMyWork(tab = 'yours') {
|
|
|
205
215
|
+ (a.includes('waiting') || e.waiting_on ? fld('wait', 'Waiting on', e.waiting_on || 'Nobody', '') : '')
|
|
206
216
|
+ fld('steps', 'Who does it', whos.length ? whos.join(', ') : 'You', steps)
|
|
207
217
|
+ fld('edit', 'Priority · Due', e.priority || 'None', e.due ? 'due ' + dayLabel(e.due) : 'no date');
|
|
208
|
-
|
|
209
|
-
return `<div class="
|
|
210
|
-
+ '<button type="button" class="
|
|
218
|
+
const due = e.due ? 'Due ' + dayLabel(e.due) : when[0], late = !!e.due && e.due < W.M.today;
|
|
219
|
+
return `<div class="ut-chips"><span class="cz-chip${late ? ' on' : ''}">${esc(due)}</span><button type="button" class="cz-chip gh" id="iTog" data-p="sheet" aria-expanded="${!!ui.sheet}" aria-controls="iSheet" title="Edit when, who and priority">Edit <em class="isum">${esc(sum)}</em></button>`
|
|
220
|
+
+ `${a.includes('keep') ? '<button type="button" class="cz-chip gh" data-p="keep">Keep for later</button>' : ''}</div>`
|
|
211
221
|
+ `<div class="mw-sheet" id="iSheet" role="group" aria-label="Item fields"${ui.sheet ? '' : ' hidden'}>${f}</div>`
|
|
212
222
|
+ '<p class="hx-n mw-err" id="cardErr" role="alert" hidden></p>';
|
|
213
223
|
}
|
|
@@ -239,9 +249,13 @@ export function openMyWork(tab = 'yours') {
|
|
|
239
249
|
return h + `<section class="mw-rec">${kv}<p class="hx-n">The item as your list holds it · ${esc(p.file)}</p></section>`;
|
|
240
250
|
}
|
|
241
251
|
function itemHtml(r) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
+ `<div
|
|
252
|
+
const src = !!r.dialog.source;
|
|
253
|
+
return `<div class="mw-sub mw-it ut-vc" data-esc-layer><div><button type="button" class="ut-btn sm ghost" data-mw="back">${BACK}Back to My work</button></div>`
|
|
254
|
+
+ `<div class="ut-vh"><button type="button" class="hm-ck" data-p="done" aria-label="Mark ${esc(r.title)} done"><span class="ut-chk"></span></button><div><h2 class="ut-h2 mw-t">${esc(r.title)}</h2>${r.sub ? `<p class="ut-sub">${esc(r.sub)}</p>` : ''}</div>`
|
|
255
|
+
+ `<button type="button" class="ut-ib" data-p="sheet" aria-label="More for this item" title="When, who and priority">${DOTS}</button></div>`
|
|
256
|
+
+ `${r.dialog.say ? `<p class="mw-say">${esc(r.dialog.say)}</p>` : ''}<div id="card">${cardInner(r)}</div><div id="agCard">${agCardInner(r)}</div>`
|
|
257
|
+
+ `<p class="ut-lbl">${src ? 'Where it came from' : 'The record'}</p><div class="mw-pane">${paneHtml(r)}</div>`
|
|
258
|
+
+ '<div class="ut-foot"><button type="button" class="ut-btn pri" data-p="done">Done</button><button type="button" class="ut-btn ghost" data-p="remove">Drop it</button></div></div>';
|
|
245
259
|
}
|
|
246
260
|
|
|
247
261
|
/* ── Focus and jobs ── */
|
|
@@ -260,7 +274,7 @@ export function openMyWork(tab = 'yours') {
|
|
|
260
274
|
const rows = F.accepted.map((f) => card(f, 'acc')).concat(F.suggestions.map((f) => card(f, 'sug')), F.dismissed.map((k) => card({ key: k, title: titleOfKey(k), why: '', item_ids: [] }, 'no')));
|
|
261
275
|
const jobs = (W.M.jobs || []).map((j) => `<div class="mw-fc"><b>${esc(j.name)}</b><p class="hx-n">When ${esc(j.when)}, I want ${esc(j.want)}, so ${esc(j.so)}.</p><p class="hx-n">${j.open} open ${j.open === 1 ? 'item' : 'items'}</p></div>`).join('');
|
|
262
276
|
const okLine = /when .+,\s*i want .+,\s*so .+/i.test(W.ui.job || '');
|
|
263
|
-
return `<div class="mw-sub mw-fj" data-esc-layer
|
|
277
|
+
return `<div class="mw-sub mw-fj" data-esc-layer><div class="hx-top"><button type="button" class="ut-btn sm ghost" data-mw="back">${BACK}Back to My work</button></div>`
|
|
264
278
|
+ '<p class="hx-n">PMOS suggests at most three, from your Today list: overdue first, then due today. Rules only, no model call.</p>'
|
|
265
279
|
+ (rows.join('') || '<p class="hx-n">Nothing is in Today, so there is nothing to suggest.</p>')
|
|
266
280
|
+ `<h4>Your jobs</h4>${jobs || '<p class="hx-n">You have no jobs yet. A job is something that matters to you, which items can serve.</p>'}`
|
|
@@ -272,13 +286,14 @@ export function openMyWork(tab = 'yours') {
|
|
|
272
286
|
function draw(sel) {
|
|
273
287
|
if (!body || !body.isConnected) return;
|
|
274
288
|
const keep = body.scrollTop;
|
|
275
|
-
if (!W.r) body.innerHTML =
|
|
276
|
-
else if (!W.M) body.innerHTML =
|
|
289
|
+
if (!W.r) body.innerHTML = '<p class="hx-n">Reading My work.</p>';
|
|
290
|
+
else if (!W.M) body.innerHTML = `<p class="hx-n">My work could not be read${W.r.error ? ': ' + esc(W.r.error) : ''}.</p>`;
|
|
277
291
|
else if (W.view === 'item' && openR()) { body.innerHTML = itemHtml(openR()); setTitle(openR().title); }
|
|
278
292
|
else if (W.view === 'fjobs') { body.innerHTML = focusHtml(); setTitle('Focus and jobs'); }
|
|
279
293
|
else {
|
|
280
|
-
W.view = null; setTitle('
|
|
281
|
-
|
|
294
|
+
W.view = null; setTitle('My work');
|
|
295
|
+
const n = (k) => (k === 'waiting' ? W.M.waiting.rows.length : k === 'stale' ? (W.M.review && W.M.review.n) || 0 : 0);
|
|
296
|
+
body.innerHTML = `<div class="ut-vc">${tabsHtml('work')}<div class="hx-tabs ut-chips" role="tablist" aria-label="Filter">${TABS.map(([k, l]) => `<button type="button" class="cz-chip${k === W.tab ? ' on' : ' gh'}" role="tab" aria-selected="${k === W.tab}" data-tab="${k}">${esc(l)}${n(k) ? ' ' + n(k) : ''}</button>`).join('')}</div>` + listHtml() + `<p class="hx-n" role="status">${esc(W.msg)}</p></div>`;
|
|
282
297
|
}
|
|
283
298
|
body.scrollTop = keep;
|
|
284
299
|
if (sel) { const f = body.querySelector(sel); if (f) f.focus(); }
|
|
@@ -295,6 +310,7 @@ export function openMyWork(tab = 'yours') {
|
|
|
295
310
|
W.M = r && r.ok && r.model ? r.model : null;
|
|
296
311
|
if (r && r.state === 'reading') setTimeout(load, 3000);
|
|
297
312
|
if (W.view === 'item' && !openR()) W.view = null; // the item left the list
|
|
313
|
+
if (W.want && W.M) { const k = W.want; W.want = null; if (rowOf(k)) { openItem(k); return; } }
|
|
298
314
|
draw();
|
|
299
315
|
}
|
|
300
316
|
function openItem(key) { if (!rowOf(key)) return; W.view = 'item'; W.key = key; W.ui = freshUi(); draw('[data-mw="back"]'); }
|
|
@@ -409,6 +425,8 @@ export function openMyWork(tab = 'yours') {
|
|
|
409
425
|
if (Date.now() - sw.up < 120) return; // the click that ends a drag does nothing
|
|
410
426
|
const t = e.target.closest('button, a'); if (!t || t.disabled) return;
|
|
411
427
|
if (t.dataset.mw === 'back') { back(); return; }
|
|
428
|
+
if (t.dataset.utTab === 'review') { if (!askReview()) { W.tab = 'review'; W.view = null; draw(); } return; }
|
|
429
|
+
if (t.dataset.utTab === 'work') { if (W.tab === 'review') { W.tab = 'yours'; draw(); } return; }
|
|
412
430
|
if (t.dataset.tab) { W.tab = t.dataset.tab; W.msg = ''; draw(); return; }
|
|
413
431
|
if (t.dataset.xf) { W.view = 'fjobs'; W.ui = freshUi(); draw('[data-mw="back"]'); return; }
|
|
414
432
|
if (t.dataset.fx) {
|
|
@@ -454,7 +472,7 @@ export function openMyWork(tab = 'yours') {
|
|
|
454
472
|
else if (id === 'agNote') { ui.note = t.value; const g = body.querySelector('[data-p="ag-sendback"]'); if (g) g.disabled = !t.value.trim(); }
|
|
455
473
|
else if (id === 'xjIn') { ui.job = t.value; const g = body.querySelector('[data-fx="jadd"]'); if (g) g.disabled = !/when .+,\s*i want .+,\s*so .+/i.test(ui.job); }
|
|
456
474
|
}
|
|
457
|
-
/* keys on the rows
|
|
475
|
+
/* keys on the open rows: J and K move, the arrows do what the row names */
|
|
458
476
|
function onKey(e) {
|
|
459
477
|
const h = e.target.closest && e.target.closest('.mw-list .wrow:not(.sm) .wrh');
|
|
460
478
|
if (!h || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
|
|
@@ -504,7 +522,7 @@ export function openMyWork(tab = 'yours') {
|
|
|
504
522
|
back();
|
|
505
523
|
}
|
|
506
524
|
|
|
507
|
-
body = vwOpen({ id: 'more:work', kind: 'My work', title: '
|
|
525
|
+
body = vwOpen({ id: 'more:work', kind: 'My work', title: 'My work', icon: 'list', render: (b) => { b.classList.add('hx'); }, onClose: () => { removeEventListener('keydown', onEsc, true); clearInterval(timer); } });
|
|
508
526
|
// delegated, as the other Home cards do: every control in the card is a real <button>; the drag repeats what the arrow keys do
|
|
509
527
|
body.onclick = onClick;
|
|
510
528
|
body.oninput = onInput;
|
|
@@ -517,3 +535,13 @@ export function openMyWork(tab = 'yours') {
|
|
|
517
535
|
load();
|
|
518
536
|
return body;
|
|
519
537
|
}
|
|
538
|
+
|
|
539
|
+
/** Open one of the PM's own items (a note, a mention made into a task) as its card, from a row of Home's list: key "work:<id>". */
|
|
540
|
+
export function openWorkItem(key) { return openMyWork('yours', { item: key }); }
|
|
541
|
+
/* The weekly review lives on Home (home-review.js needs Home's data): Home answers the hm:review event. Elsewhere the old summary shows. */
|
|
542
|
+
function askReview() {
|
|
543
|
+
if (typeof CustomEvent !== 'function') return false;
|
|
544
|
+
const ev = new CustomEvent('hm:review', { cancelable: true });
|
|
545
|
+
dispatchEvent(ev);
|
|
546
|
+
return ev.defaultPrevented;
|
|
547
|
+
}
|