create-pmos 0.609.0 → 0.611.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 +69 -27
- 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/board-columns-test.js +2 -1
- package/workspace/board-deliveries-test.js +2 -1
- package/workspace/board-programs-test.js +9 -5
- package/workspace/board-publish-ui-test.js +2 -1
- package/workspace/board-shared-ui-test.js +2 -1
- package/workspace/board-workflows-test.js +2 -1
- package/workspace/briefing-premium-adddoc-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +10 -9
- package/workspace/briefing-premium-doc-edit-test.js +2 -1
- package/workspace/briefing-premium-initiative-test.js +7 -6
- package/workspace/briefing-premium-insights-test.js +12 -11
- package/workspace/briefing-premium-products-test.js +4 -2
- package/workspace/briefing-premium-sources-test.js +1 -1
- package/workspace/briefing-premium-test.js +6 -5
- package/workspace/briefing-premium-work-test.js +1 -1
- package/workspace/calm-timeline-test.js +2 -1
- package/workspace/changelog.json +68 -0
- package/workspace/core-docs-workflow-test.js +2 -1
- package/workspace/ev-everywhere-test.js +11 -10
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +4 -0
- package/workspace/guide/layout.md +92 -11
- package/workspace/guide/programs.md +16 -2
- package/workspace/guide/routine.md +50 -0
- package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/home-other-product-test.js +2 -1
- package/workspace/home-railcard-test.js +2 -1
- package/workspace/impact-screens-test.js +3 -1
- package/workspace/ini-workflow-test.js +2 -1
- package/workspace/lib/beside-page.js +15 -0
- package/workspace/lib/classic-board.js +15 -0
- package/workspace/lib/events-place.js +216 -0
- package/workspace/lib/library-items.js +78 -0
- package/workspace/lib/notes.js +6 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-events-place.js +166 -0
- package/workspace/lib/routes-library.js +89 -0
- package/workspace/lib/routes-pop-work.js +39 -0
- package/workspace/lib/routes-report-setups.js +20 -0
- package/workspace/lib/routes-today-log.js +48 -0
- package/workspace/lib/routine-reports.js +52 -0
- package/workspace/lib/today-log.js +131 -0
- package/workspace/live-pill-round-test.js +11 -9
- package/workspace/metric-drafts-ui-test.js +3 -1
- package/workspace/milestone-pins-test.js +2 -1
- package/workspace/milestone-suggest-test.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +6 -4
- package/workspace/premium-board-actions-test.js +3 -1
- package/workspace/premium-chat-context-test.js +6 -6
- package/workspace/premium-chat-line-test.js +1 -1
- package/workspace/premium-chat-notes-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +2 -1
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-backlog-test.js +3 -1
- package/workspace/premium-vw-cal-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +2 -1
- package/workspace/premium-vw-item-test.js +3 -1
- package/workspace/premium-vw-jira-test.js +3 -1
- package/workspace/product-lane-test.js +2 -1
- package/workspace/program-charter-test.js +3 -1
- package/workspace/program-leave-test.js +3 -1
- package/workspace/program-order-test.js +2 -1
- package/workspace/program-panel-test.js +5 -3
- package/workspace/public/pm/bd-ini-panel.js +75 -8
- package/workspace/public/pm/bd-prog-panel.js +55 -8
- package/workspace/public/pm/bd-scroll.js +4 -2
- package/workspace/public/pm/bd-work.css +130 -0
- package/workspace/public/pm/bd-work.js +356 -0
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-ev.css +52 -0
- package/workspace/public/pm/cozy-events-view.js +142 -0
- package/workspace/public/pm/cozy-events.css +107 -0
- package/workspace/public/pm/cozy-events.js +210 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-library.css +36 -0
- package/workspace/public/pm/cozy-live-pill.js +3 -1
- package/workspace/public/pm/cozy-nav.js +70 -7
- package/workspace/public/pm/cozy-panels.js +1 -1
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pick.js +6 -2
- package/workspace/public/pm/cozy-pop-work.css +165 -0
- package/workspace/public/pm/cozy-pop-work.js +427 -0
- package/workspace/public/pm/cozy-popup.css +113 -0
- package/workspace/public/pm/cozy-popup.js +408 -0
- package/workspace/public/pm/cozy-routine-model.js +111 -0
- package/workspace/public/pm/cozy-routine-pop.js +196 -0
- package/workspace/public/pm/cozy-routine.css +102 -0
- package/workspace/public/pm/cozy-routine.js +156 -0
- package/workspace/public/pm/cozy-schedwork.js +6 -5
- package/workspace/public/pm/cozy-settings.js +10 -1
- package/workspace/public/pm/cozy-today-app.js +236 -0
- package/workspace/public/pm/cozy-today-model.js +176 -0
- package/workspace/public/pm/cozy-today-page.css +100 -0
- package/workspace/public/pm/cozy-today-view.js +76 -0
- package/workspace/public/pm/cozy-viewer.js +66 -18
- package/workspace/public/pm/home-app.js +29 -6
- package/workspace/public/pm/home-ini.js +39 -7
- package/workspace/public/pm/library-model.js +69 -0
- package/workspace/public/pm/library-open.js +34 -0
- package/workspace/public/pm/page-chat.js +16 -4
- package/workspace/public/pm/pop-sessions.js +65 -0
- package/workspace/public/pm/pop-work-model.js +335 -0
- package/workspace/public/pm/premium-board.js +137 -11
- package/workspace/public/pm/premium-insights.js +14 -2
- package/workspace/public/pm/premium-library.js +122 -0
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-events.html +42 -0
- package/workspace/public/premium-library.html +31 -0
- package/workspace/public/premium-routine.html +31 -0
- package/workspace/public/today.html +50 -0
- package/workspace/ready-dash-ui-test.js +3 -1
- package/workspace/rename-test.js +2 -1
- package/workspace/run-tests.js +4 -1
- package/workspace/server.js +3 -2
- package/workspace/sort-order-test.js +2 -1
- package/workspace/split-merge-ui-test.js +3 -1
- package/workspace/stage-card-tasks-test.js +5 -3
- package/workspace/stage-card-test.js +2 -1
- package/workspace/task-card-test.js +2 -1
- package/workspace/task-delete-test.js +3 -1
- package/workspace/task-links-test.js +4 -2
- package/workspace/task-milestones-test.js +4 -2
- package/workspace/task-plans-test.js +3 -1
- package/workspace/task-press-test.js +3 -1
- package/workspace/task-views-test.js +10 -8
- package/workspace/test-lists/events-place.json +11 -0
- package/workspace/test-lists/library-place.json +9 -0
- package/workspace/test-lists/one-popup.json +9 -0
- package/workspace/test-lists/pop-work.json +9 -0
- package/workspace/test-lists/routine-place.json +9 -0
- package/workspace/test-lists/today-log.json +9 -0
- package/workspace/test-lists/work-view.json +9 -0
- package/workspace/timeline-holds-test.js +3 -1
- package/workspace/tk-tasks-test.js +3 -1
- package/workspace/viewer-trail-test.js +1 -1
- package/workspace/workflows-setup-test.js +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/* pm/cozy-today-app.js — Today on a desk (slice 5 of the six-place navigation; board 1 on Exploring 2; initiative today-log-page).
|
|
2
|
+
*
|
|
3
|
+
* mountToday(ctx) once, from home-app.js on today.html (body[data-today]). ctx is what Home already has:
|
|
4
|
+
* { S, VW, POP, pmGet, pmPost, toast, toastUndo, isPhone, now(), rank() → rankMove's answer, rows() → Home's rows by id (a Map),
|
|
5
|
+
* titleOf(ini), hasIni(ini), boardWs(), boardId(), goIni(id), select(id), movePress(btn), openFinished(f), openReviewVw(), openMeeting(m),
|
|
6
|
+
* openCalendar(), openInbox(), openLab(l), reload(), review() → the weekly review's model, meetings() → today's meetings, news() → how
|
|
7
|
+
* many are new for you, chatNow() → the chat's target }
|
|
8
|
+
* → { on() → Today is drawn, draw(), read() }
|
|
9
|
+
*
|
|
10
|
+
* Today draws into #tdPage, the only thing on the white page panel; Home's list and chat column are not drawn (cozy-today-page.css), so the
|
|
11
|
+
* Viewer no longer floats over a chat on a laptop. A row's press opens its work in the one popup (cozy-popup.js) with Home's chat beside it.
|
|
12
|
+
* The capture line adds a row and does nothing else: no popup, no session. Every write is a press: today-log marks and own entries
|
|
13
|
+
* (POST /api/today-log/*), a task's state or due day (the Board's own routes), an item's done, defer, due or remove (POST /api/pm-items/*),
|
|
14
|
+
* a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log. */
|
|
15
|
+
import * as TM from './cozy-today-model.js';
|
|
16
|
+
import * as TP from './cozy-today-view.js';
|
|
17
|
+
|
|
18
|
+
const ASK_SEND = new Set(['session']);
|
|
19
|
+
export function mountToday(ctx) {
|
|
20
|
+
const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set() };
|
|
21
|
+
const el = document.getElementById('tdPage');
|
|
22
|
+
const on = () => !!el && !ctx.isPhone();
|
|
23
|
+
const day = () => TM.dayKey(ctx.now());
|
|
24
|
+
|
|
25
|
+
async function read() {
|
|
26
|
+
const r = await ctx.pmGet('/api/today-log?day=' + day()).catch(() => null);
|
|
27
|
+
if (r && r.ok) X.log = { entries: r.entries || [], marks: r.marks || {} };
|
|
28
|
+
X.read = true;
|
|
29
|
+
draw();
|
|
30
|
+
}
|
|
31
|
+
const tdItems = () => {
|
|
32
|
+
const tabs = (ctx.S.D.work && ctx.S.D.work.queue && ctx.S.D.work.queue.tabs) || [];
|
|
33
|
+
return ((tabs.find((t) => t.key === 'today') || { groups: [] }).groups || []).flatMap((g) => g.rows || []);
|
|
34
|
+
};
|
|
35
|
+
function models() {
|
|
36
|
+
const S = ctx.S, D = S.D, now = ctx.now(), byId = ctx.rows();
|
|
37
|
+
// Your move's rows, with what Home's own rows know of each (its task and its due day): a late task is dated, a next step is not
|
|
38
|
+
const move = ((S.M && S.M.move) || []).map((r) => { const f = byId.get(r.id) || {}; return { ...r, ini: f.ini || r.ini || null, task: f.task || null, due: f.due || (f.task && f.task.end) || '' }; });
|
|
39
|
+
const PD = D.phoneDay || null;
|
|
40
|
+
const drafts = (PD && Array.isArray(PD.finished) ? PD.finished : []).filter((x) => x && !x.seen && x.status !== 'sent').map((x) => ({ id: x.id || x.key || x.title, title: x.title, ini: x.initiative || null, fin: x }));
|
|
41
|
+
const R = ctx.review();
|
|
42
|
+
const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
|
|
43
|
+
const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
|
|
44
|
+
own: X.log.entries, marks: X.log.marks, lab, titleOf: ctx.titleOf, now });
|
|
45
|
+
const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, now,
|
|
46
|
+
iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
|
|
47
|
+
return { L, A };
|
|
48
|
+
}
|
|
49
|
+
function draw() {
|
|
50
|
+
document.body.classList.toggle('cz-today', on());
|
|
51
|
+
if (!el) return;
|
|
52
|
+
if (!on()) { el.hidden = true; return; }
|
|
53
|
+
el.hidden = false;
|
|
54
|
+
if (!ctx.S.ready) { if (!el.firstChild) el.innerHTML = '<p class="td-none">Reading your day.</p>'; return; }
|
|
55
|
+
const { L, A } = models();
|
|
56
|
+
X.model = L; X.agenda = A;
|
|
57
|
+
const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
|
|
58
|
+
const html = TP.pageHtml(L, A, { news: ctx.news(), draft });
|
|
59
|
+
if (html === X.html && el.firstChild) return;
|
|
60
|
+
X.html = html;
|
|
61
|
+
const st = el.parentNode ? el.parentNode.scrollTop : 0;
|
|
62
|
+
el.innerHTML = html;
|
|
63
|
+
if (el.parentNode) el.parentNode.scrollTop = st;
|
|
64
|
+
const c2 = document.getElementById('tdCap'); if (c2 && focus) { c2.focus(); c2.setSelectionRange(c2.value.length, c2.value.length); }
|
|
65
|
+
}
|
|
66
|
+
const rowOf = (key) => (X.model ? X.model.rows.find((r) => r.key === key) : null);
|
|
67
|
+
const snap = (r) => ({ title: r.title, work: r.work, job: r.job });
|
|
68
|
+
async function mark(key, act, extra = {}) {
|
|
69
|
+
const r = await ctx.pmPost('/api/today-log/mark', { key, act, day: day(), ...extra }).catch(() => null);
|
|
70
|
+
return r && r.ok ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
|
|
71
|
+
}
|
|
72
|
+
/** After a write: read the log again, and Home's own lists when the source changed. */
|
|
73
|
+
const after = async (src) => { if (src) await ctx.reload(); await read(); };
|
|
74
|
+
const pop = (r) => ctx.VW.popNext({ keep: true, id: r.ini || r.key, kind: r.ini ? 'initiative' : 'item', title: r.ini ? ctx.titleOf(r.ini) : r.title });
|
|
75
|
+
/** A chat-only press (a session that asks): the popup with that chat and the sessions on its left. */
|
|
76
|
+
const chatPop = () => setTimeout(() => { if (!ctx.VW.popOpen()) { ctx.VW.popNext(null); const t = ctx.chatNow(); if (t) ctx.POP.openCos(t); } }, 120);
|
|
77
|
+
|
|
78
|
+
function open(r) {
|
|
79
|
+
if (!r) return;
|
|
80
|
+
const ref = r.ref || {};
|
|
81
|
+
if (r.src === 'ask') {
|
|
82
|
+
if (ref.kind === 'call') { const c = ref.call || {}; if (c.ini && ctx.hasIni(c.ini) && !ASK_SEND.has(c.kind)) { ctx.goIni(c.ini); return; } pop(r); ctx.select(c.id); if (ASK_SEND.has(c.kind)) chatPop(); return; }
|
|
83
|
+
pop(r); ctx.movePress({ dataset: { yd: 'mv-open', key: ref.key }, disabled: false }); return;
|
|
84
|
+
}
|
|
85
|
+
if (r.src === 'move') { if (ref.kind === 'task' && r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); ctx.select(r.key); if (ref.kind === 'session') chatPop(); return; }
|
|
86
|
+
if (r.src === 'item') { if (r.ini && ctx.hasIni(r.ini)) { ctx.goIni(r.ini); return; } pop(r); import('./home-work.js').then((M) => M.openWorkItem(ref.key)).catch(() => {}); return; }
|
|
87
|
+
if (r.src === 'draft') { pop(r); ctx.openFinished(ref.fin); return; }
|
|
88
|
+
if (r.src === 'review') { pop(r); ctx.openReviewVw(); return; }
|
|
89
|
+
if (r.src === 'lab') { pop(r); ctx.openLab(ref); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function done(r) {
|
|
93
|
+
const ref = r.ref || {};
|
|
94
|
+
if (r.src === 'move' && ref.task && ref.task.uid) {
|
|
95
|
+
const t = ref.task, w = { ws: t.ws || ctx.boardWs(), board: t.board || ctx.boardId(), task: t.uid };
|
|
96
|
+
const res = await ctx.pmPost('/api/boards/tasks/state', { ...w, state: 'Done' }).catch(() => null);
|
|
97
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It was not marked done. Nothing changed.');
|
|
98
|
+
await mark(r.key, 'done', { snap: snap(r) });
|
|
99
|
+
ctx.toastUndo('Done: ' + r.title + '.', async () => { const u = await ctx.pmPost('/api/boards/tasks/state', { ...w, state: t.status || 'To do' }).catch(() => null); await mark(r.key, 'undone'); after(true); return u || { ok: false }; });
|
|
100
|
+
return after(true);
|
|
101
|
+
}
|
|
102
|
+
if (r.src === 'item') {
|
|
103
|
+
const res = await ctx.pmPost('/api/pm-items/done', { id: ref.id }).catch(() => null);
|
|
104
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It was not marked done. Nothing changed.');
|
|
105
|
+
await mark(r.key, 'done', { snap: snap(r) });
|
|
106
|
+
ctx.toastUndo('Done: ' + r.title + '.', async () => { const u = await ctx.pmPost('/api/pm-items/reopen', { id: ref.id }).catch(() => null); await mark(r.key, 'undone'); after(true); return u || { ok: false }; });
|
|
107
|
+
return after(true);
|
|
108
|
+
}
|
|
109
|
+
const m = await mark(r.key, 'done', { snap: snap(r) });
|
|
110
|
+
if (!m.ok) return ctx.toast('It was not marked done: ' + m.error + '.');
|
|
111
|
+
ctx.toastUndo('Done: ' + r.title + '.', async () => { const u = await mark(r.key, 'undone'); after(false); return u; });
|
|
112
|
+
return after(false);
|
|
113
|
+
}
|
|
114
|
+
async function later(r, until) {
|
|
115
|
+
const ref = r.ref || {}, tomorrow = until === TM.addDays(day(), 1), word = tomorrow ? 'tomorrow' : until;
|
|
116
|
+
if (r.src === 'item' && tomorrow) {
|
|
117
|
+
const res = await ctx.pmPost('/api/pm-items/defer', { id: ref.id, until }).catch(() => null);
|
|
118
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It was not moved. Nothing changed.');
|
|
119
|
+
ctx.toastUndo('Moved to ' + word + '.', async () => { const u = await ctx.pmPost('/api/pm-items/defer', { id: ref.id, until: null }).catch(() => null); after(true); return u || { ok: false }; });
|
|
120
|
+
return after(true);
|
|
121
|
+
}
|
|
122
|
+
const m = await mark(r.key, 'later', { until });
|
|
123
|
+
if (!m.ok) return ctx.toast('It was not moved: ' + m.error + '.');
|
|
124
|
+
ctx.toastUndo('Moved to ' + word + '.', async () => { const u = await mark(r.key, 'now'); after(false); return u; });
|
|
125
|
+
return after(false);
|
|
126
|
+
}
|
|
127
|
+
/** Set a date: a task's or an item's own due day; any other row leaves the log until that day. */
|
|
128
|
+
async function setDate(r, d) {
|
|
129
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(d)) return;
|
|
130
|
+
const ref = r.ref || {};
|
|
131
|
+
if (r.src === 'move' && ref.task && ref.task.uid) {
|
|
132
|
+
const t = ref.task, w = { ws: t.ws || ctx.boardWs(), board: t.board || ctx.boardId(), task: t.uid };
|
|
133
|
+
const res = await ctx.pmPost('/api/boards/tasks/edit', { ...w, due: d }).catch(() => null);
|
|
134
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'The date was not changed. Nothing changed.');
|
|
135
|
+
ctx.toastUndo('Due ' + d + '.', async () => { const u = await ctx.pmPost('/api/boards/tasks/edit', { ...w, due: t.end || '' }).catch(() => null); after(true); return u || { ok: false }; });
|
|
136
|
+
return after(true);
|
|
137
|
+
}
|
|
138
|
+
if (r.src === 'item') {
|
|
139
|
+
const res = await ctx.pmPost('/api/pm-items/edit', { id: ref.id, fields: { due: d } }).catch(() => null);
|
|
140
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'The date was not changed. Nothing changed.');
|
|
141
|
+
ctx.toastUndo('Due ' + d + '.', async () => { const u = await ctx.pmPost('/api/pm-items/edit', { id: ref.id, fields: { due: ref.due || null } }).catch(() => null); after(true); return u || { ok: false }; });
|
|
142
|
+
return after(true);
|
|
143
|
+
}
|
|
144
|
+
if (d <= day()) return ctx.toast('It is in today’s log already.');
|
|
145
|
+
return later(r, d);
|
|
146
|
+
}
|
|
147
|
+
async function drop(r) {
|
|
148
|
+
const ref = r.ref || {};
|
|
149
|
+
if (r.src === 'item') {
|
|
150
|
+
const res = await ctx.pmPost('/api/pm-items/remove', { id: ref.id }).catch(() => null);
|
|
151
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It was not dropped. Nothing changed.');
|
|
152
|
+
ctx.toastUndo('Dropped: ' + r.title + '.', async () => { const u = await ctx.pmPost('/api/pm-items/undo', { id: ref.id }).catch(() => null); after(true); return u || { ok: false }; });
|
|
153
|
+
return after(true);
|
|
154
|
+
}
|
|
155
|
+
const m = await mark(r.key, 'drop');
|
|
156
|
+
if (!m.ok) return ctx.toast('It was not dropped: ' + m.error + '.');
|
|
157
|
+
ctx.toastUndo('Dropped from your log.', async () => { const u = await mark(r.key, 'undrop'); after(false); return u; });
|
|
158
|
+
return after(false);
|
|
159
|
+
}
|
|
160
|
+
async function keep(r) {
|
|
161
|
+
const m = await mark(r.key, 'keep');
|
|
162
|
+
if (!m.ok) return ctx.toast('It was not kept: ' + m.error + '.');
|
|
163
|
+
ctx.toast('Kept. PMOS will not suggest it again for a month.');
|
|
164
|
+
return after(false);
|
|
165
|
+
}
|
|
166
|
+
async function lab(r, yes) {
|
|
167
|
+
const f = r.ref || {};
|
|
168
|
+
const res = await ctx.pmPost(yes ? '/api/lab/keep' : '/api/lab/drop', { ws: f.ws || undefined, id: f.id }).catch(() => null);
|
|
169
|
+
if (!res || !res.ok) return ctx.toast((res && res.error) || 'It did not go through. Nothing changed.');
|
|
170
|
+
const undo = res.batch ? async () => { const u = await ctx.pmPost('/api/lab/undo', { ws: f.ws || undefined, batch: res.batch }).catch(() => null); after(true); return u || { ok: false }; } : null;
|
|
171
|
+
const said = yes ? res.said || 'Kept. The initiative is on its board.' : 'Dropped.';
|
|
172
|
+
if (undo) ctx.toastUndo(said, undo); else ctx.toast(said);
|
|
173
|
+
return after(true);
|
|
174
|
+
}
|
|
175
|
+
/** The date chooser beside a row: one date field; Enter or a change sets it, Escape or a press outside closes it. */
|
|
176
|
+
function chooseDate(r, btn) {
|
|
177
|
+
document.querySelectorAll('.td-dp').forEach((x) => x.remove());
|
|
178
|
+
const box = document.createElement('div');
|
|
179
|
+
box.className = 'td-dp'; box.setAttribute('role', 'dialog'); box.setAttribute('aria-label', 'Set a date: ' + r.title);
|
|
180
|
+
const due = (r.ref && (r.ref.due || (r.ref.task && r.ref.task.end))) || TM.addDays(day(), 1);
|
|
181
|
+
box.innerHTML = `<input type="date" aria-label="Date" value="${TP.esc(due)}" min="${TP.esc(day())}" />`;
|
|
182
|
+
document.body.appendChild(box);
|
|
183
|
+
const b = btn.getBoundingClientRect();
|
|
184
|
+
box.style.top = Math.min(innerHeight - 64, b.bottom + 6) + 'px'; box.style.left = Math.max(12, b.right - box.offsetWidth) + 'px';
|
|
185
|
+
const i = box.querySelector('input');
|
|
186
|
+
const close = () => { box.remove(); removeEventListener('pointerdown', out, true); if (btn.isConnected) btn.focus(); };
|
|
187
|
+
const out = (e) => { if (!box.contains(e.target)) close(); };
|
|
188
|
+
addEventListener('pointerdown', out, true);
|
|
189
|
+
const go = () => { const v = i.value; close(); if (v && v !== due) setDate(r, v); };
|
|
190
|
+
i.addEventListener('change', go);
|
|
191
|
+
i.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); close(); } if (e.key === 'Enter') { e.preventDefault(); go(); } });
|
|
192
|
+
i.focus();
|
|
193
|
+
try { i.showPicker(); } catch { /* the field itself is the chooser */ }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (el) {
|
|
197
|
+
el.addEventListener('click', async (e) => {
|
|
198
|
+
const b = e.target.closest('[data-td]'); if (!b || b.disabled) return;
|
|
199
|
+
const act = b.dataset.td, key = b.dataset.key || '';
|
|
200
|
+
if (act === 'cal') { ctx.openCalendar(); return; }
|
|
201
|
+
if (act === 'news') { ctx.VW.popNext({ keep: true, id: 'news', kind: 'item', title: 'New for you' }); ctx.openInbox(); return; }
|
|
202
|
+
if (act === 'ev') {
|
|
203
|
+
const x = X.agenda && X.agenda.items.find((y) => y.key === key); if (!x) return;
|
|
204
|
+
if (x.ini && ctx.hasIni(x.ini)) { ctx.goIni(x.ini); return; }
|
|
205
|
+
ctx.VW.popNext({ keep: true, id: x.key, kind: 'meeting', title: x.title }); ctx.openMeeting(x.ref); return;
|
|
206
|
+
}
|
|
207
|
+
const r = rowOf(key); if (!r) return;
|
|
208
|
+
if (act === 'open') { open(r); return; }
|
|
209
|
+
if (act === 'date') { chooseDate(r, b); return; }
|
|
210
|
+
if (X.busy.has(key)) return;
|
|
211
|
+
X.busy.add(key); b.disabled = true;
|
|
212
|
+
try {
|
|
213
|
+
if (act === 'done') await done(r);
|
|
214
|
+
else if (act === 'tomorrow') await later(r, TM.addDays(day(), 1));
|
|
215
|
+
else if (act === 'drop') await drop(r);
|
|
216
|
+
else if (act === 'keep') await keep(r);
|
|
217
|
+
else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
|
|
218
|
+
} finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
|
|
219
|
+
});
|
|
220
|
+
// the first line: Enter adds the row, and nothing else happens (no popup, no session)
|
|
221
|
+
el.addEventListener('submit', async (e) => {
|
|
222
|
+
if (e.target.id !== 'tdCapF') return;
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
const i = document.getElementById('tdCap'); if (!i || !i.value.trim() || i.disabled) return;
|
|
225
|
+
i.disabled = true;
|
|
226
|
+
const r = await ctx.pmPost('/api/today-log/add', { text: i.value, day: day() }).catch(() => null);
|
|
227
|
+
i.disabled = false;
|
|
228
|
+
if (!r || !r.ok) { ctx.toast((r && r.error) || 'It was not logged. Nothing changed.'); i.focus(); return; }
|
|
229
|
+
X.log.entries = X.log.entries.concat(r.entry);
|
|
230
|
+
i.value = '';
|
|
231
|
+
draw();
|
|
232
|
+
const j = document.getElementById('tdCap'); if (j) j.focus();
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return { on, draw, read };
|
|
236
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* pm/cozy-today-model.js — Today, the model (slice 5 of the six-place navigation; board 1 "Today: your log and today's agenda" on Exploring 2,
|
|
2
|
+
* page "Navigation: Today, Work, Goals, Events, Library, Routine"; build plan /mnt/project-files/nav-structure/build-plan.md; initiative
|
|
3
|
+
* today-log-page). Pure: Node imports it (today-log.test.js).
|
|
4
|
+
*
|
|
5
|
+
* The job of Today: show the few things only the PM can move today, and let them finish or move each one here, so nothing is left hanging.
|
|
6
|
+
*
|
|
7
|
+
* logModel(o) → { rows, done, counts, line } Today's log, kept the Bullet Journal way
|
|
8
|
+
* agendaModel(o) → { items, from, to, now, sub, empty } today's agenda, one column of hours
|
|
9
|
+
* dayKey(ms) · addDays(day, n) · whenWord(...)
|
|
10
|
+
*
|
|
11
|
+
* WHERE THE ROWS COME FROM. Nothing here is invented: every row is a record PMOS already reads, or a line the PM typed.
|
|
12
|
+
* ask the ranked asks of Your move (pm/move-rank.js rankMove: rows, then Can wait), every product Today reads. A call only the PM can
|
|
13
|
+
* make (a session that asks, a decision, blocked work) is one of them (kind 'call'). Job: Send for a draft to send (the outbox, a
|
|
14
|
+
* conversation that waits on a reply, the weekly update), else Decide.
|
|
15
|
+
* move the rest of Your move that is no call: the PM's own late tasks and the next steps (home-list.js move rows). Job: Do.
|
|
16
|
+
* item the PM's own items placed in Today (GET /api/my-work-premium, its Today tab). Job: Do.
|
|
17
|
+
* draft what PMOS drafted today and the PM has not seen (GET /api/phone-day finished). Job: Send.
|
|
18
|
+
* review the weekly review while it is open. Job: Do.
|
|
19
|
+
* own what the PM typed in the first line (GET /api/today-log entries): • a task (Do), ○ an event, – a note.
|
|
20
|
+
* lab a finding that fits no initiative (GET /api/lab loose, the old Lab): a ✦ suggestion; ✓ keeps it and starts an initiative, ✕ drops it.
|
|
21
|
+
* The PM's marks (GET /api/today-log marks) hide a row moved to a later day or dropped, and keep a row done today with its × bullet.
|
|
22
|
+
*
|
|
23
|
+
* MIGRATION. What is not finished is carried to the next day and says for how long: an ask from the day PMOS filed it, a task from the day
|
|
24
|
+
* it was due, an item from its due day (else the day it was added), an own entry from the day it was written. Carried CARRY_DROP days or
|
|
25
|
+
* more, PMOS suggests to drop it (one ✦ line under the row, ✓ ✕), unless the PM kept it in the last CARRY_DROP days.
|
|
26
|
+
* FIRST ("!"). What the PM marked first, a verdict or a grill finding on shipped or late work (move-rank's ranks 1 and 2), and a send that
|
|
27
|
+
* goes out today. The rest follow in the rank's order. Done rows close the table. */
|
|
28
|
+
|
|
29
|
+
export const CARRY_DROP = 30; // days carried before PMOS suggests to drop it
|
|
30
|
+
export const LATE_DAYS = 14; // a row carried this long reads late (the one colour in the When column)
|
|
31
|
+
const DAY = 864e5;
|
|
32
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
33
|
+
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
34
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
35
|
+
const DAY_RE = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
36
|
+
|
|
37
|
+
/** The PM's local day of a time: YYYY-MM-DD. */
|
|
38
|
+
export const dayKey = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
39
|
+
const dayMs = (k) => { const m = DAY_RE.exec(String(k || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]).getTime() : null; };
|
|
40
|
+
/** The day n days after a YYYY-MM-DD day. */
|
|
41
|
+
export const addDays = (k, n) => { const t = dayMs(k); return t == null ? '' : dayKey(new Date(t).setDate(new Date(t).getDate() + n)); };
|
|
42
|
+
/** Whole days from day a to day b (b later is positive). */
|
|
43
|
+
const between = (a, b) => { const x = dayMs(a), y = dayMs(b); return x == null || y == null ? null : Math.round((y - x) / DAY); };
|
|
44
|
+
/** "2 Nov", or "2 Nov 2025" outside this year. */
|
|
45
|
+
const dm = (k, today) => { const m = DAY_RE.exec(String(k || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] + (m[1] !== String(today).slice(0, 4) ? ' ' + m[1] : '') : ''; };
|
|
46
|
+
|
|
47
|
+
/** The words of the When column. o: { late (days late of a dated task), due, carried (days), time, send } */
|
|
48
|
+
export function whenWord(o, today) {
|
|
49
|
+
if (o.time) return o.time;
|
|
50
|
+
if (o.late > 0) return dm(o.due, today) + ', ' + plural(o.late, 'day', 'days') + ' late';
|
|
51
|
+
if (o.carried > 0) return 'carried ' + plural(o.carried, 'day', 'days');
|
|
52
|
+
if (o.send) return o.send;
|
|
53
|
+
if (o.due && o.due === today) return 'today';
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const SEND_KINDS = new Set(['outbox', 'mention']);
|
|
58
|
+
const jobOfAsk = (r) => (r.kind === 'call' ? (r.call && r.call.kind === 'update' ? 'Send' : 'Decide') : SEND_KINDS.has(r.kind) ? 'Send' : 'Decide');
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* o: { rank: { rows, wait } (rankMove), move: home-list move rows, items: my-work-premium Today rows ({ key, id, title, ini, at, due?, overdue }),
|
|
62
|
+
* drafts: [{ id, title, ini? }], review: { title } | null, own: today-log entries, marks: today-log marks, lab: [{ ws, board, id, title, why }],
|
|
63
|
+
* titleOf(ini) → the initiative's name, now }
|
|
64
|
+
* A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
|
|
65
|
+
*/
|
|
66
|
+
export function logModel(o = {}) {
|
|
67
|
+
const now = o.now || Date.now(), today = dayKey(now);
|
|
68
|
+
const marks = o.marks || {}, titleOf = typeof o.titleOf === 'function' ? o.titleOf : () => '';
|
|
69
|
+
const out = [], seen = new Set();
|
|
70
|
+
const work = (ini, fallback) => (ini ? titleOf(ini) || fallback || '' : fallback || '');
|
|
71
|
+
const put = (r) => {
|
|
72
|
+
if (!r.key || seen.has(r.key)) return;
|
|
73
|
+
seen.add(r.key);
|
|
74
|
+
const m = marks[r.key] || {};
|
|
75
|
+
if (m.dropped) return;
|
|
76
|
+
if (m.until && m.until > today) return;
|
|
77
|
+
const done = !!m.done || !!r.done;
|
|
78
|
+
const drop = !done && r.carried >= CARRY_DROP && !(m.kept && between(m.kept, today) < CARRY_DROP) && r.src !== 'lab';
|
|
79
|
+
out.push({ first: false, bullet: 'task', work: '', ini: null, ws: '', job: '', when: '', late: false, carried: 0, dates: 'mark', ...r, done, drop });
|
|
80
|
+
};
|
|
81
|
+
// the asks, in the rank's order: the first five, then Can wait
|
|
82
|
+
const rank = o.rank || {};
|
|
83
|
+
const asks = (rank.rows || []).concat(rank.wait || []);
|
|
84
|
+
const callIds = new Set();
|
|
85
|
+
for (const r of asks) {
|
|
86
|
+
if (!r || !r.key || r.kind === 'extra' && r.go === 'lab') continue; // the Lab's findings are their own rows (below)
|
|
87
|
+
const c = r.kind === 'call' ? r.call || {} : null;
|
|
88
|
+
if (c) callIds.add(c.id);
|
|
89
|
+
const carried = c ? 0 : Math.max(0, r.days || 0);
|
|
90
|
+
const send = c && c.when ? 'goes out ' + c.when : '';
|
|
91
|
+
put({ key: c ? 'call:' + c.id : r.key, src: 'ask', bullet: 'task', title: r.title || (c && c.name) || '', ini: r.ini || (c && c.ini) || null, ws: r.ws || '',
|
|
92
|
+
work: work(r.ini || (c && c.ini), c ? c.sub : (r.shared || [])[0] || ''), job: jobOfAsk(r), carried, late: carried >= LATE_DAYS,
|
|
93
|
+
when: whenWord({ carried, send }, today), first: r.rank <= 2 || (c && c.kind === 'update' && /^(today|now)/i.test(String(c.when || ''))) || false, ref: r });
|
|
94
|
+
}
|
|
95
|
+
// the rest of Your move: the PM's own late tasks and the next steps (a call is in the asks already; an item is in the items)
|
|
96
|
+
for (const r of o.move || []) {
|
|
97
|
+
if (!r || !r.id || callIds.has(r.id) || r.call || r.kind === 'item' || r.kind === 'update' || r.kind === 'session') continue;
|
|
98
|
+
const due = r.due || (r.task && r.task.end) || '';
|
|
99
|
+
const late = r.kind === 'task' && due && due < today ? between(due, today) : 0;
|
|
100
|
+
put({ key: r.id, src: 'move', bullet: 'task', title: r.name, ini: r.ini || null, work: work(r.ini, r.sub), job: 'Do', late: late > 0, carried: late,
|
|
101
|
+
when: whenWord({ late, due }, today), dates: r.kind === 'task' ? 'task' : 'mark', ref: r });
|
|
102
|
+
}
|
|
103
|
+
// the PM's own items placed in Today
|
|
104
|
+
for (const it of o.items || []) {
|
|
105
|
+
if (!it || !it.id) continue;
|
|
106
|
+
const from = it.due && it.due < today ? it.due : !it.due && it.at ? dayKey(Date.parse(it.at)) : '';
|
|
107
|
+
const carried = from && from < today ? between(from, today) : 0;
|
|
108
|
+
put({ key: 'work:' + it.id, src: 'item', bullet: 'task', title: it.title, ini: it.ini || null, work: work(it.ini, ''), job: 'Do', carried, late: !!it.overdue || carried >= LATE_DAYS,
|
|
109
|
+
when: whenWord({ carried, due: it.due }, today), dates: 'item', ref: it });
|
|
110
|
+
}
|
|
111
|
+
for (const d of o.drafts || []) if (d && d.id) put({ key: 'draft:' + d.id, src: 'draft', bullet: 'task', title: d.title, ini: d.ini || null, work: work(d.ini, ''), job: 'Send', ref: d });
|
|
112
|
+
if (o.review && o.review.title) put({ key: 'review:' + today, src: 'review', bullet: 'task', title: o.review.title, job: 'Do', ref: o.review });
|
|
113
|
+
// what the PM typed: a task, an event or a note, carried from the day it was written until it is done
|
|
114
|
+
for (const e of o.own || []) {
|
|
115
|
+
if (!e || !e.key) continue;
|
|
116
|
+
const carried = e.day && e.day < today && !e.done ? between(e.day, today) : 0;
|
|
117
|
+
put({ key: e.key, src: 'own', bullet: e.bullet, first: !!e.first, title: e.text, job: e.bullet === 'task' ? 'Do' : '', carried, late: carried >= LATE_DAYS,
|
|
118
|
+
when: whenWord({ carried, time: e.bullet === 'event' && !carried ? e.time : '' }, today), done: !!e.done, ref: e });
|
|
119
|
+
}
|
|
120
|
+
for (const f of o.lab || []) if (f && f.id) put({ key: 'lab:' + (f.ws || '') + ':' + f.id, src: 'lab', bullet: 'lab', title: f.title, work: '', job: 'Decide', why: f.why || '', ref: f });
|
|
121
|
+
// a row done today whose source has let it go keeps its × from what it said when it was done
|
|
122
|
+
for (const [k, m] of Object.entries(marks)) {
|
|
123
|
+
if (!m || !m.done || seen.has(k) || !m.snap) continue;
|
|
124
|
+
seen.add(k);
|
|
125
|
+
out.push({ key: k, src: 'gone', bullet: 'task', first: false, title: m.snap.title || '', work: m.snap.work || '', ini: null, ws: '', job: m.snap.job || '', when: '', late: false, carried: 0, done: true, drop: false, dates: 'mark', ref: null });
|
|
126
|
+
}
|
|
127
|
+
const open = out.filter((r) => !r.done), done = out.filter((r) => r.done);
|
|
128
|
+
const rows = open.filter((r) => r.first).concat(open.filter((r) => !r.first));
|
|
129
|
+
const n = (j) => open.filter((r) => r.job === j).length;
|
|
130
|
+
const counts = { decide: n('Decide'), do: n('Do'), send: n('Send'), notes: open.filter((r) => r.bullet === 'note').length, events: open.filter((r) => r.bullet === 'event').length };
|
|
131
|
+
// one quiet line counts the log; a part that is zero is left out
|
|
132
|
+
const line = [counts.decide && counts.decide + ' to decide', counts.do && counts.do + ' to do', counts.send && counts.send + ' to send'].filter(Boolean).join(' · ');
|
|
133
|
+
return { rows: rows.concat(done), open: rows.length, done: done.length, counts, line, today };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ── today's agenda ── */
|
|
137
|
+
const span = (m) => { const a = Date.parse(m.start); const b = m.end ? Date.parse(m.end) : a + (m.minutes || 30) * 60000; return { a, b: b > a ? b : a + 30 * 60000 }; };
|
|
138
|
+
const hm = (ms) => { const d = new Date(ms); return String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
|
|
139
|
+
/** The free stretches of 30 minutes or more between now (or 09:00) and 18:00, between the agenda's items. Minutes, summed. */
|
|
140
|
+
function freeMinutes(items, now) {
|
|
141
|
+
const d0 = new Date(now); d0.setHours(9, 0, 0, 0); const d1 = new Date(now); d1.setHours(18, 0, 0, 0);
|
|
142
|
+
let at = Math.max(now, d0.getTime()), free = 0;
|
|
143
|
+
for (const x of items.slice().sort((p, q) => p.a - q.a)) { if (x.b <= at) continue; if (x.a - at >= 30 * 60000) free += Math.min(x.a, d1.getTime()) - at; at = Math.max(at, x.b); }
|
|
144
|
+
if (d1.getTime() - at >= 30 * 60000) free += d1.getTime() - at;
|
|
145
|
+
return Math.max(0, Math.round(free / 60000));
|
|
146
|
+
}
|
|
147
|
+
const durWord = (mins) => (mins >= 60 ? (Math.round(mins / 30) / 2).toString().replace(/\.0$/, '') + ' h' : mins + ' min');
|
|
148
|
+
|
|
149
|
+
/** o: { meetings: brief-page today rows ({ id, title, start, end?, minutes?, state, initiative? }), own: today-log events of today with a
|
|
150
|
+
* time, iniOf(m) → the meeting's initiative id or null, now }.
|
|
151
|
+
* → { items: [{ key, kind: 'meeting' | 'own', title, sub, a, b, top, h, ini, ref, past, nowOn }], from, to (whole hours), now (ms or null
|
|
152
|
+
* outside the hours), sub ("Wed 18 Nov · 2 h free"), empty } */
|
|
153
|
+
export function agendaModel(o = {}) {
|
|
154
|
+
const now = o.now || Date.now(), today = dayKey(now), iniOf = typeof o.iniOf === 'function' ? o.iniOf : () => null;
|
|
155
|
+
const items = [];
|
|
156
|
+
for (const m of o.meetings || []) {
|
|
157
|
+
if (!m || !m.start || Number.isNaN(Date.parse(m.start)) || dayKey(Date.parse(m.start)) !== today) continue;
|
|
158
|
+
const s = span(m);
|
|
159
|
+
items.push({ key: 'm:' + (m.id || m.start + m.title), kind: 'meeting', title: m.title || 'Meeting', sub: hm(s.a) + ' to ' + hm(s.b), a: s.a, b: s.b, ini: iniOf(m) || null, ref: m });
|
|
160
|
+
}
|
|
161
|
+
for (const e of o.own || []) {
|
|
162
|
+
if (!e || e.bullet !== 'event' || !e.time || e.day !== today || e.done) continue;
|
|
163
|
+
const [h, mi] = e.time.split(':').map(Number); const a = new Date(now); a.setHours(h, mi, 0, 0);
|
|
164
|
+
items.push({ key: e.key, kind: 'own', title: e.text, sub: e.time + ' · your event', a: a.getTime(), b: a.getTime() + 30 * 60000, ini: null, ref: e });
|
|
165
|
+
}
|
|
166
|
+
items.sort((x, y) => x.a - y.a);
|
|
167
|
+
const first = items.length ? new Date(items[0].a).getHours() : 8, last = items.length ? Math.max(...items.map((x) => new Date(x.b - 1).getHours() + 1)) : 18;
|
|
168
|
+
const from = Math.min(8, first), to = Math.max(18, Math.min(24, last));
|
|
169
|
+
const base = new Date(now); base.setHours(from, 0, 0, 0);
|
|
170
|
+
const H = 60 * 60000;
|
|
171
|
+
for (const x of items) { x.top = (x.a - base.getTime()) / H; x.h = Math.max(0.5, (x.b - x.a) / H); x.past = x.b <= now; x.nowOn = x.a <= now && now < x.b; }
|
|
172
|
+
const t = (now - base.getTime()) / H;
|
|
173
|
+
const d = new Date(now), free = freeMinutes(items, now);
|
|
174
|
+
const sub = DOW[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()] + (free ? ' · ' + durWord(free) + ' free' : '');
|
|
175
|
+
return { items, from, to, now: t >= 0 && t <= to - from ? t : null, sub, empty: !items.length };
|
|
176
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* pm/cozy-today-page.css — Today, the place (slice 5 of the six-place navigation; board 1 on Exploring 2; pm/cozy-today-view.js draws it).
|
|
2
|
+
* today.html on a desk: the white page panel (#hmDesk) holds Today only. Home's list and chat column are not drawn; the chat is the
|
|
3
|
+
* popup's (pm/cozy-popup.js). One container: the log is one card with a thin border, the agenda one grey box on the right.
|
|
4
|
+
* Token vars only (cozy.css :root holds every raw value, and its dark block the dark ones). Nothing animates. The phone keeps Home. */
|
|
5
|
+
|
|
6
|
+
@media (min-width: 761px) {
|
|
7
|
+
body.cz-today #hmDesk > .hm-list, body.cz-today #hmDesk > .hm-chat, body.cz-today #hmDesk > .cz-pn-div, body.cz-today #hmUnfold, body.cz-today .hm-top { display: none !important; }
|
|
8
|
+
/* the white page panel: the only big container, beside the rail (as the Board's) */
|
|
9
|
+
body.cz-home.cz-today #hmDesk { display: block; overflow: auto; top: 16px; right: 16px; bottom: 16px; left: var(--cz-railx, 16px); padding: 28px 32px 32px; background: var(--cz-card); border-radius: 28px; box-shadow: var(--cz-lift); }
|
|
10
|
+
body.cz-today .td-page { display: block; max-width: 1360px; margin: 0 auto; }
|
|
11
|
+
/* a thing that still opens beside the page (the PM's "open work beside the page", a deep link) slides over Today on the right:
|
|
12
|
+
the one slide-over of the panel rule, so Today is never squeezed or covered by a column it does not own */
|
|
13
|
+
body.cz-today #hmDesk > .hm-vw { position: fixed; top: 16px; right: 16px; bottom: 16px; z-index: 40; border-radius: 24px; box-shadow: var(--cz-lift); background: var(--cz-card); }
|
|
14
|
+
body.cz-today #hmDesk > .hm-vw .cz-vw { width: min(520px, calc(100vw - var(--cz-railx, 16px) - 120px)); flex-basis: auto; }
|
|
15
|
+
}
|
|
16
|
+
.td-page[hidden] { display: none !important; }
|
|
17
|
+
|
|
18
|
+
.td { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; font-family: var(--cz-sans); color: var(--cz-ink); }
|
|
19
|
+
@media (max-width: 1100px) { .td { grid-template-columns: minmax(0, 1fr); } }
|
|
20
|
+
.td h2 { margin: 0; font-size: var(--fs-section); font-weight: var(--fw-strong); line-height: var(--lh-section); color: var(--cz-ink); }
|
|
21
|
+
.td-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
22
|
+
.td button { font-family: var(--cz-sans); }
|
|
23
|
+
|
|
24
|
+
/* the title and its one quiet line */
|
|
25
|
+
.td-h { display: flex; align-items: baseline; gap: 12px; margin: 0 0 12px; }
|
|
26
|
+
.td-sum { font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
27
|
+
|
|
28
|
+
/* the capture line */
|
|
29
|
+
.td-in { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: 14px; background: var(--cz-well); margin: 0 0 12px; box-sizing: border-box; }
|
|
30
|
+
.td-in:focus-within { box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
31
|
+
.td-in-l { display: inline-flex; color: var(--cz-ink3); cursor: text; }
|
|
32
|
+
.td-in input { flex: 1 1 auto; min-width: 0; border: 0; background: none; font: inherit; font-size: var(--fs-row); color: var(--cz-ink); outline: none; }
|
|
33
|
+
.td-in input::placeholder { color: var(--cz-ink3); }
|
|
34
|
+
.td-key { flex: none; font-size: var(--fs-meta); color: var(--cz-ink3); letter-spacing: .02em; white-space: nowrap; }
|
|
35
|
+
.td-key em { font-style: normal; margin: 0 10px 0 3px; }
|
|
36
|
+
.td-key em:last-child { margin-right: 0; }
|
|
37
|
+
@media (max-width: 980px) { .td-key { display: none; } }
|
|
38
|
+
|
|
39
|
+
/* the log: one card, one row height, one text size */
|
|
40
|
+
.td-tt { border-radius: 16px; box-shadow: inset 0 0 0 1px var(--cz-hair); background: var(--cz-card); overflow: hidden; }
|
|
41
|
+
.td-r { display: grid; grid-template-columns: 18px 20px minmax(0, 1fr) minmax(0, 160px) 56px 128px 92px; align-items: center; column-gap: 8px; min-height: 44px; padding: 0 12px; font-size: var(--fs-row); line-height: var(--lh-row); }
|
|
42
|
+
.td-r + .td-r { box-shadow: inset 0 1px 0 var(--cz-hair); }
|
|
43
|
+
.td-hd { min-height: 36px; background: var(--cz-well); font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
44
|
+
.td-p b { color: var(--cz-late); font-weight: var(--fw-strong); display: block; text-align: center; }
|
|
45
|
+
.td-b i { font-style: normal; display: block; text-align: center; font-size: var(--fs-panel); line-height: 1; color: var(--cz-ink); }
|
|
46
|
+
.td-r.lab .td-b i { color: var(--cz-blueink); font-size: var(--fs-badge); }
|
|
47
|
+
.td-wt { min-width: 0; }
|
|
48
|
+
.td-t { display: block; max-width: 100%; text-align: left; border: 0; background: none; padding: 0; font: inherit; font-weight: var(--fw-strong); color: var(--cz-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
|
|
49
|
+
button.td-t { cursor: pointer; }
|
|
50
|
+
button.td-t:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
|
|
51
|
+
.td-r.note .td-t { font-weight: var(--fw-regular); color: var(--cz-ink2); }
|
|
52
|
+
.td-w { font-size: var(--fs-meta); color: var(--cz-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
53
|
+
.td-k { font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
54
|
+
.td-d { font-size: var(--fs-meta); color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
55
|
+
.td-d.late { color: var(--cz-late); font-weight: var(--fw-strong); }
|
|
56
|
+
.td-a { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; }
|
|
57
|
+
.td-r:hover, .td-r:focus-within { background: var(--cz-well); }
|
|
58
|
+
.td-hd:hover { background: var(--cz-well); }
|
|
59
|
+
.td-r:hover .td-a, .td-r:focus-within .td-a { opacity: 1; }
|
|
60
|
+
@media (hover: none) { .td-a { opacity: 1; } }
|
|
61
|
+
.td-ib { width: 28px; height: 28px; border-radius: 8px; border: 0; padding: 0; background: none; color: var(--cz-ink2); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
|
|
62
|
+
.td-ib:hover { background: var(--cz-card); color: var(--cz-ink); }
|
|
63
|
+
.td-ib:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
|
|
64
|
+
.td-ib:disabled { opacity: .45; cursor: default; }
|
|
65
|
+
.td-r.done .td-t, .td-r.done .td-w, .td-r.done .td-k { color: var(--cz-ink3); font-weight: var(--fw-regular); text-decoration: line-through; text-decoration-color: var(--cz-hair); }
|
|
66
|
+
.td-r.done .td-b i { color: var(--cz-ink3); }
|
|
67
|
+
|
|
68
|
+
/* a suggestion under its row: ✦ and one sentence, ✓ ✕ */
|
|
69
|
+
.td-sg { grid-column: 3 / -1; display: flex; align-items: center; gap: 8px; padding: 0 0 10px; font-size: var(--fs-meta); color: var(--cz-ink2); }
|
|
70
|
+
.td-sg b { color: var(--cz-blueink); font-weight: var(--fw-strong); }
|
|
71
|
+
.td-sg .td-ib { width: 26px; height: 26px; border-radius: 999px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); }
|
|
72
|
+
.td-sg.lab { color: var(--cz-ink3); }
|
|
73
|
+
.td-none { margin: 6px 2px; font-size: var(--fs-row); color: var(--cz-ink3); }
|
|
74
|
+
.td-more { margin-top: 10px; border: 0; background: none; padding: 4px 2px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-blueink); cursor: pointer; }
|
|
75
|
+
|
|
76
|
+
/* today's agenda: one grey box */
|
|
77
|
+
.td-ag { border-radius: 20px; background: var(--cz-well); padding: 16px 16px 14px; box-sizing: border-box; }
|
|
78
|
+
.td-agh { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; }
|
|
79
|
+
.td-agh small { font-size: var(--fs-meta); color: var(--cz-ink3); margin-right: auto; }
|
|
80
|
+
.td-agh .td-ib { align-self: center; }
|
|
81
|
+
.td-tl { position: relative; height: calc(var(--rows) * var(--px)); margin: 6px 0 4px 46px;
|
|
82
|
+
background-image: repeating-linear-gradient(to bottom, var(--cz-hair) 0, var(--cz-hair) 1px, transparent 1px, transparent var(--px)); }
|
|
83
|
+
.td-hr { position: absolute; left: -46px; top: var(--y); transform: translateY(-50%); font-size: var(--fs-badge); color: var(--cz-ink3); }
|
|
84
|
+
.td-ev { position: absolute; left: 4px; right: 0; top: var(--y); height: var(--h); box-sizing: border-box; overflow: hidden; border: 0; border-radius: 10px; padding: 5px 9px; text-align: left;
|
|
85
|
+
background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); font: inherit; color: var(--cz-ink); display: flex; flex-direction: column; gap: 1px; }
|
|
86
|
+
button.td-ev { cursor: pointer; }
|
|
87
|
+
button.td-ev:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
|
|
88
|
+
.td-ev b { font-size: var(--fs-meta); font-weight: var(--fw-strong); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
89
|
+
.td-ev small { font-size: var(--fs-badge); color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
90
|
+
.td-ev.short { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 0; padding-bottom: 0; }
|
|
91
|
+
.td-ev.short small { flex: none; }
|
|
92
|
+
.td-ev.own { background: none; box-shadow: inset 0 0 0 1.5px var(--cz-hair); }
|
|
93
|
+
.td-ev.on { box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
94
|
+
.td-ev.past b { color: var(--cz-ink3); }
|
|
95
|
+
.td-now { position: absolute; left: -6px; right: 0; top: var(--y); height: 2px; background: var(--cz-late); }
|
|
96
|
+
.td-now::before { content: ''; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-late); }
|
|
97
|
+
|
|
98
|
+
/* the date chooser beside a row (set a date) */
|
|
99
|
+
.td-dp { position: fixed; z-index: 80; display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 14px; background: var(--cz-card); box-shadow: var(--cz-lift); }
|
|
100
|
+
.td-dp input { font: inherit; font-size: var(--fs-row); color: var(--cz-ink); background: var(--cz-well); border: 0; border-radius: 10px; padding: 6px 8px; color-scheme: light dark; }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* pm/cozy-today-view.js — Today, the markup (slice 5 of the six-place navigation; board 1 on Exploring 2; initiative today-log-page).
|
|
2
|
+
* Pure: it turns pm/cozy-today-model.js into HTML, and Node imports it (today-log.test.js). home-app.js draws it into #tdPage on today.html
|
|
3
|
+
* and handles every press (data-td="…").
|
|
4
|
+
*
|
|
5
|
+
* One page, no views (one container rule): the title and the quiet count line sit on the panel; Today's log is one card with a thin
|
|
6
|
+
* border; today's agenda is one grey box on the right.
|
|
7
|
+
* The first line captures a task, an event or a note. Enter only adds the row: it opens no popup and starts no session.
|
|
8
|
+
* A row: "!" when it comes first, its bullet (• task, ○ event, – note, × done, ✦ a PMOS suggestion), What, Work, Job, When, and on
|
|
9
|
+
* hover or focus three plain icons: done, move to tomorrow, set a date. A Lab finding has ✓ (keep: start an initiative) and ✕ (drop).
|
|
10
|
+
* Carried too long, a ✦ line under the row: PMOS suggests to drop it, ✓ ✕.
|
|
11
|
+
* Press a row or an agenda event: the popup on its work (home-app.js).
|
|
12
|
+
* Every icon-only button has an aria-label. The UI says PMOS. Text from records goes through esc(). */
|
|
13
|
+
|
|
14
|
+
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
15
|
+
const svg = (d, w = 15, sw = 1.9) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
16
|
+
export const I = {
|
|
17
|
+
done: 'M5 12.5l4.5 4.5L19 7.5', tomorrow: 'M5 12h14M13 6l6 6-6 6', date: 'M4 5.5h16v14H4zM4 10h16M8.5 3.5v4M15.5 3.5v4', plus: 'M12 6v12M6 12h12',
|
|
18
|
+
yes: 'M5 12.5l4.5 4.5L19 7.5', no: 'M6 6l12 12M18 6L6 18', cal: 'M4 5.5h16v14H4zM4 10h16M8.5 3.5v4M15.5 3.5v4',
|
|
19
|
+
};
|
|
20
|
+
const BULLET = { task: ['•', 'Task'], event: ['○', 'Event'], note: ['–', 'Note'], lab: ['✦', 'PMOS suggests'] };
|
|
21
|
+
const ib = (act, label, d, key, extra = '') => `<button type="button" class="td-ib" data-td="${act}" data-key="${esc(key)}" aria-label="${esc(label)}" title="${esc(label)}"${extra}>${svg(d)}</button>`;
|
|
22
|
+
|
|
23
|
+
/** One row of the log. */
|
|
24
|
+
export function rowHtml(r) {
|
|
25
|
+
const [b, bl] = r.done ? ['×', 'Done'] : BULLET[r.bullet] || BULLET.task;
|
|
26
|
+
const acts = r.done ? '' : r.src === 'lab'
|
|
27
|
+
? ib('lab-keep', 'Keep it: start an initiative from ' + r.title, I.yes, r.key) + ib('lab-drop', 'Drop it: ' + r.title, I.no, r.key)
|
|
28
|
+
: ib('done', 'Done: ' + r.title, I.done, r.key) + ib('tomorrow', 'Move to tomorrow: ' + r.title, I.tomorrow, r.key) + ib('date', 'Set a date: ' + r.title, I.date, r.key, ' aria-haspopup="dialog"');
|
|
29
|
+
const cls = ['td-r', r.done ? 'done' : '', r.bullet === 'note' ? 'note' : '', r.src === 'lab' ? 'lab' : ''].filter(Boolean).join(' ');
|
|
30
|
+
// a note, an own event and a done row open nothing: their words are the whole of it
|
|
31
|
+
const opens = !r.done && r.src !== 'own' && r.src !== 'gone';
|
|
32
|
+
const title = opens ? `<button type="button" class="td-t" data-td="open" data-key="${esc(r.key)}">${esc(r.title)}</button>` : `<span class="td-t">${esc(r.title)}</span>`;
|
|
33
|
+
const sug = r.drop ? `<div class="td-sg" role="group" aria-label="PMOS suggests"><b aria-hidden="true">✦</b><span>Carried ${esc(r.carried)} days. PMOS suggests: drop it from your log.</span>`
|
|
34
|
+
+ ib('drop', 'Drop it', I.yes, r.key) + ib('keep', 'Keep it', I.no, r.key) + '</div>' : '';
|
|
35
|
+
const why = r.src === 'lab' && r.why ? `<div class="td-sg lab"><span>${esc(r.why)}</span></div>` : '';
|
|
36
|
+
return `<div class="${cls}" data-key="${esc(r.key)}" role="row"><span class="td-p" role="cell">${r.first && !r.done ? '<b aria-label="First">!</b>' : ''}</span>`
|
|
37
|
+
+ `<span class="td-b" role="cell"><i role="img" aria-label="${esc(bl)}">${b}</i></span><span role="cell" class="td-wt">${title}</span>`
|
|
38
|
+
+ `<span class="td-w" role="cell">${esc(r.work)}</span><span class="td-k" role="cell">${esc(r.job)}</span>`
|
|
39
|
+
+ `<span class="td-d${r.late && !r.done ? ' late' : ''}" role="cell">${esc(r.when)}</span><span class="td-a" role="cell">${acts}</span>${sug}${why}</div>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Today's log: the title and its count line, the capture line, the one card. L: logModel(). o: { news: N new for you, draft: the line being typed } */
|
|
43
|
+
export function logHtml(L, o = {}) {
|
|
44
|
+
const head = `<div class="td-h"><h2>Today’s log</h2>${L.line ? `<span class="td-sum">${esc(L.line)}</span>` : ''}</div>`;
|
|
45
|
+
const cap = `<form class="td-in" id="tdCapF" autocomplete="off"><label class="td-in-l" for="tdCap">${svg(I.plus, 16)}<span class="td-vh">Log a task, an event or a note</span></label>`
|
|
46
|
+
+ `<input id="tdCap" name="line" type="text" maxlength="240" placeholder="Log a task, an event or a note" value="${esc(o.draft || '')}" aria-describedby="tdCapKey" />`
|
|
47
|
+
+ `<span class="td-key" id="tdCapKey" aria-label="Start with o for an event, a dash for a note, ! for first">•<em>task</em>o<em>event</em>–<em>note</em>!<em>first</em></span></form>`;
|
|
48
|
+
const rows = L.rows.length ? L.rows.map(rowHtml).join('') : '';
|
|
49
|
+
const table = rows ? `<div class="td-tt" role="table" aria-label="Today’s log"><div class="td-r td-hd" role="row"><span role="columnheader"></span><span role="columnheader"><span class="td-vh">Bullet</span></span><span role="columnheader">What</span><span role="columnheader">Work</span><span role="columnheader">Job</span><span role="columnheader">When</span><span role="columnheader"><span class="td-vh">Actions</span></span></div>${rows}</div>`
|
|
50
|
+
: '<p class="td-none">Nothing waits on you today.</p>';
|
|
51
|
+
const news = o.news > 0 ? `<button type="button" class="td-more" data-td="news">${esc(o.news)} new for you</button>` : '';
|
|
52
|
+
return `<section class="td-log" aria-label="Today’s log">${head}${cap}${table}${news}</section>`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Today's agenda in one grey box: the hours, the meetings and the PM's own events, the line for now. A: agendaModel(). */
|
|
56
|
+
export function agendaHtml(A) {
|
|
57
|
+
const PX = 56;
|
|
58
|
+
const hours = [];
|
|
59
|
+
for (let h = A.from; h <= A.to; h += 2) hours.push(`<span class="td-hr" style="--y:${(h - A.from) * PX}px">${String(h).padStart(2, '0')}:00</span>`);
|
|
60
|
+
const ev = A.items.map((x) => {
|
|
61
|
+
const short = x.h * PX < 46; // a short slot says its time and title on one line
|
|
62
|
+
const st = `--y:${Math.round(x.top * PX) + 1}px;--h:${Math.max(30, Math.round(x.h * PX) - 3)}px`;
|
|
63
|
+
const cls = ['td-ev', x.kind, short ? 'short' : '', x.past ? 'past' : '', x.nowOn ? 'on' : ''].filter(Boolean).join(' ');
|
|
64
|
+
const label = x.title + ', ' + x.sub;
|
|
65
|
+
return x.kind === 'own' ? `<div class="${cls}" style="${st}" aria-label="${esc(label)}"><b>${esc(x.title)}</b><small>${esc(x.sub)}</small></div>`
|
|
66
|
+
: `<button type="button" class="${cls}" style="${st}" data-td="ev" data-key="${esc(x.key)}" aria-label="${esc(label)}"><b>${esc(x.title)}</b><small>${esc(x.sub)}</small></button>`;
|
|
67
|
+
}).join('');
|
|
68
|
+
const nowLine = A.now != null ? `<i class="td-now" style="--y:${Math.round(A.now * PX)}px" aria-hidden="true"></i>` : '';
|
|
69
|
+
const grid = A.empty ? '<p class="td-none">No meeting today.</p>'
|
|
70
|
+
: `<div class="td-tl" style="--rows:${A.to - A.from};--px:${PX}px">${hours.join('')}${ev}${nowLine}</div>`;
|
|
71
|
+
return `<aside class="td-ag" aria-label="Today’s agenda"><div class="td-agh"><h2>Today</h2><small>${esc(A.sub)}</small>`
|
|
72
|
+
+ `<button type="button" class="td-ib" data-td="cal" aria-label="Open the calendar" title="Open the calendar">${svg(I.cal, 16)}</button></div>${grid}</aside>`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The whole page. */
|
|
76
|
+
export function pageHtml(L, A, o = {}) { return `<div class="td">${logHtml(L, o)}${agendaHtml(A)}</div>`; }
|