create-pmos 0.417.0 → 0.419.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 +25 -25
- 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-programs-test.js +82 -1
- package/workspace/briefing-premium-board-test.js +23 -21
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +2 -2
- package/workspace/guide/workflows.md +1 -0
- package/workspace/lib/board-cli.js +1 -1
- package/workspace/lib/coredoc-cli.js +2 -0
- package/workspace/lib/engine/boards.js +7 -2
- package/workspace/lib/initiative-chat.js +3 -1
- package/workspace/lib/initiative-premium.js +2 -1
- package/workspace/lib/routes-boards.js +55 -7
- package/workspace/lib/task-cli.js +27 -3
- package/workspace/lib/task-items.js +5 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-acts.js +3 -2
- package/workspace/public/pm/bd-scroll.js +164 -0
- package/workspace/public/pm/bd-span.js +156 -190
- package/workspace/public/pm/bd-stages.js +3 -25
- package/workspace/public/pm/cozy-board.css +93 -72
- package/workspace/public/pm/home-app.js +2 -0
- package/workspace/public/pm/home-data.js +17 -4
- package/workspace/public/pm/home-ini-model.js +5 -1
- package/workspace/public/pm/home-ini.js +4 -2
- package/workspace/public/pm/home-list.js +3 -3
- package/workspace/public/pm/home-task.js +4 -1
- package/workspace/public/pm/ini-view-model.js +4 -2
- package/workspace/public/pm/premium-board.js +48 -37
- package/workspace/public/pm/premium-vw-item.js +5 -2
- package/workspace/public/pm/task-card.js +12 -0
- package/workspace/public/premium-board.html +3 -2
- package/workspace/server.js +3 -0
- package/workspace/task-card-test.js +7 -0
|
@@ -27,14 +27,17 @@ const B = require(repoScript('boards.js'));
|
|
|
27
27
|
const TI = require('./task-items.js');
|
|
28
28
|
const rowsLib = require('./initiative-rows.js');
|
|
29
29
|
|
|
30
|
-
const COMMANDS = { task: ['add', 'list', 'state', 'set'] };
|
|
30
|
+
const COMMANDS = { task: ['add', 'list', 'state', 'set', 'remove'] };
|
|
31
31
|
const USAGE = [
|
|
32
|
-
'usage: pmos task add|list|state|set — an initiative\'s tasks, the ones the PM sees in its Tasks section',
|
|
32
|
+
'usage: pmos task add|list|state|set|remove — an initiative\'s tasks, the ones the PM sees in its Tasks section',
|
|
33
33
|
' pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]',
|
|
34
34
|
' Add a task. Every new task goes here; pmos item add is the older breakdown record.',
|
|
35
35
|
' pmos task set <task> [<task> …] [--stage <stage>|none] [--due YYYY-MM-DD|none] [--start YYYY-MM-DD|none] [--owner <who>] [--notes <text>]',
|
|
36
36
|
' Group tasks under a stage of the initiative\'s workflow (key or name; none takes it out), or change dates, owner or notes.',
|
|
37
37
|
' pmos task list <initiative> [--all] its open tasks; --all adds Done, Won\'t do and Archived',
|
|
38
|
+
' pmos task remove <task> [<task> …] [--why <text>]',
|
|
39
|
+
' Delete a task added by mistake (a placeholder, a duplicate) when the PM asks. It goes from every list; the page\'s Undo brings',
|
|
40
|
+
' it back. Work that stopped is Archived or Won\'t do instead. A breakdown item is not deleted: set it to Won\'t do.',
|
|
38
41
|
' pmos task state <task> [<task> …] --to <state> [--why <text>]',
|
|
39
42
|
' Set each task\'s state when the PM asks: To do, In progress, Done, Won\'t do or Archived. The page shows it at once.',
|
|
40
43
|
' Give --why with Done: it is the evidence the PM reads.',
|
|
@@ -45,7 +48,7 @@ const USAGE = [
|
|
|
45
48
|
];
|
|
46
49
|
const BOOL = new Set(['json', 'help', 'all']);
|
|
47
50
|
const VALUE = new Set(['to', 'why', 'root', 'due', 'start', 'owner', 'notes', 'stage']);
|
|
48
|
-
const ONLY = { add: ['due', 'start', 'owner', 'notes', 'stage'], list: ['all'], state: ['to', 'why'], set: ['due', 'start', 'owner', 'notes', 'stage'] };
|
|
51
|
+
const ONLY = { add: ['due', 'start', 'owner', 'notes', 'stage'], list: ['all'], state: ['to', 'why'], remove: ['why'], set: ['due', 'start', 'owner', 'notes', 'stage'] };
|
|
49
52
|
const OPEN = new Set(['To do', 'In progress']);
|
|
50
53
|
/** The PM's words for a state: any case, with or without the apostrophe or the space. */
|
|
51
54
|
function stateOf(s) {
|
|
@@ -206,6 +209,27 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
206
209
|
return refused.length ? 1 : 0;
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
if (verb === 'remove') {
|
|
213
|
+
// batch 7 item 5: a task added by mistake goes from every list (POST /api/boards/tasks/delete, the page's ⋯ Delete)
|
|
214
|
+
if (!pos.length) { say('usage: pmos task remove <task> [<task> …] [--why <text>]'); return 2; }
|
|
215
|
+
const folded = boards.foldOf(ctx, w);
|
|
216
|
+
const done = [], refused = [];
|
|
217
|
+
for (const id of pos) {
|
|
218
|
+
const t = findTask(folded, id);
|
|
219
|
+
if (!t) { refused.push({ task: id, error: `no task ${id}; pmos task list <initiative> --all names them` }); continue; }
|
|
220
|
+
const r = boards.taskDelete(ctx, { ws: w.id, board: t.board, task: id, ...(flags.why ? { why: flags.why } : {}) }, g);
|
|
221
|
+
if (!r.body || r.body.ok !== true) refused.push({ task: id, error: (r.body && r.body.error) || 'the write was refused' });
|
|
222
|
+
else done.push({ task: id, title: t.title });
|
|
223
|
+
}
|
|
224
|
+
if (json) say(JSON.stringify({ ok: !refused.length, done, refused }));
|
|
225
|
+
else {
|
|
226
|
+
for (const d of done) say(`✓ ${d.task} deleted: ${d.title}`);
|
|
227
|
+
for (const x of refused) say(`✗ ${x.task}: ${x.error}`);
|
|
228
|
+
if (done.length) say(' It is gone from the page. Nothing was sent.');
|
|
229
|
+
}
|
|
230
|
+
return refused.length ? 1 : 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
209
233
|
// state
|
|
210
234
|
if (!pos.length || !flags.to) { say('usage: pmos task state <task> [<task> …] --to <state> [--why <text>]'); return 2; }
|
|
211
235
|
const to = stateOf(flags.to);
|
|
@@ -37,6 +37,10 @@ function ownerOf(text) {
|
|
|
37
37
|
return 'person:' + t.slice(0, 60);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** Every breakdown item by id, read once (a Jira ticket drafted from an item takes its plan dates: batch 7 item 6). */
|
|
41
|
+
function itemsById(root) {
|
|
42
|
+
try { return planItems.readFold(root).items || {}; } catch { return {}; }
|
|
43
|
+
}
|
|
40
44
|
function itemOf(root, id) {
|
|
41
45
|
try { return planItems.readFold(root).items[id] || null; } catch { return null; }
|
|
42
46
|
}
|
|
@@ -85,4 +89,4 @@ function write(root, events, actor, cli) {
|
|
|
85
89
|
return planItems.appendFromUi(root, events, { actor: actor && actor.by ? { by: actor.by, via: 'ui' } : undefined });
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
module.exports = { STATE_OF, isItemId, ownerName, ownerOf, itemOf, rowsOf, stateEvents, editEvents, write };
|
|
92
|
+
module.exports = { STATE_OF, isItemId, ownerName, ownerOf, itemOf, itemsById, rowsOf, stateEvents, editEvents, write };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.419.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.419.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -185,7 +185,8 @@ function openFind(from) {
|
|
|
185
185
|
function pickFind() {
|
|
186
186
|
const b = $$('#bdQr .bd-mi')[findAt]; if (b) b.click();
|
|
187
187
|
}
|
|
188
|
-
/** The Filter's groups: owner, workflow and category (WfAElse: Kind became Workflow), sprint (from the Jira reading, and the backlog
|
|
188
|
+
/** The Filter's groups: owner, workflow and category (WfAElse: Kind became Workflow), sprint (from the Jira reading, and the backlog; on the
|
|
189
|
+
* timeline only on the Sprint span, TsSprintFilter).
|
|
189
190
|
* The workflow is one choice, the same one the chip row picks (pm/bd-wf.js); it shows only with more than one workflow on the board. */
|
|
190
191
|
function filterHtml() {
|
|
191
192
|
const rows = M().initiatives.list.rows, F = A.F;
|
|
@@ -200,7 +201,7 @@ function filterHtml() {
|
|
|
200
201
|
return grp + `<p class="bd-mlbl">Owner</p><div class="bd-fg">${owners.map((o) => chip('owners', o, (o === 'No owner' ? '' : V.avatar(o, 'xs')) + esc(o))).join('')}</div>`
|
|
201
202
|
+ (W.list.length > 1 ? `<p class="bd-mlbl">Workflow</p><div class="bd-fg" role="radiogroup" aria-label="Workflow">${W.list.map((w) => { const on = WF.narrowed(W.list) && W.cur.id === w.id; return `<button type="button" class="bd-chip${on ? ' on' : ''}" role="radio" aria-checked="${on}" data-fwf="${esc(w.id)}">${WF.wfIcon(w, 16)}${esc(w.name)}</button>`; }).join('')}</div>` : '')
|
|
202
203
|
+ (cats.length ? `<p class="bd-mlbl">Category</p><div class="bd-fg">${cats.map((k) => chip('cats', k, esc(WF.catLabel(k)))).join('')}</div>` : '')
|
|
203
|
-
+ (sprints.length ? `<p class="bd-mlbl">Sprint</p><div class="bd-fg">${sprints.map((s) => chip('sprints', s.name, esc(s.name + (s.now ? ' · now' : '')))).join('')}${chip('sprints', 'Backlog')}</div>` : '')
|
|
204
|
+
+ (sprints.length && (!A.sprintFilter || A.sprintFilter()) ? `<p class="bd-mlbl">Sprint</p><div class="bd-fg">${sprints.map((s) => chip('sprints', s.name, esc(s.name + (s.now ? ' · now' : '')))).join('')}${chip('sprints', 'Backlog')}</div>` : '')
|
|
204
205
|
+ `<div class="bd-arow bd-ffoot"><button type="button" class="bd-btn sm ghost" data-fclear>Clear</button><span class="bd-amut bd-push">Applies as you pick</span></div>`;
|
|
205
206
|
}
|
|
206
207
|
function openFilter(from) { Pop.open(filterHtml(), from, { label: 'Filter', width: 340, align: 'right', cls: 'bd-filter' }); }
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* pm/bd-scroll.js — the timeline's sideways scroll (feedback batch 7, timeline spans C: TsCOpen, TsCDesk, TsCPhone, TsCPhoneBack, TsCEdges,
|
|
2
|
+
* TsCGrill). pm/bd-span.js draws a track wider than the screen from Quarter on; this module moves it and keeps what sits at its edges true.
|
|
3
|
+
* · open: today sits 25% of the way in, on every span. Switching span keeps the date in the middle in the middle, or keeps today in place
|
|
4
|
+
* when it is in view. A redraw (a filter, the panel) keeps the place the same way. The scroll position is not remembered across visits.
|
|
5
|
+
* · scroll: trackpad, Shift + wheel, a drag on empty track (a drag that starts on a bar or a name still opens it), ← → by half a screen,
|
|
6
|
+
* T for today, a swipe on a phone. The name column stays pinned (CSS: position sticky).
|
|
7
|
+
* · Today: in view, the pill on the today line. Off screen, the back button beside "Initiative" (on the axis edge on a phone) with its arrow
|
|
8
|
+
* pointing the way back; a press scrolls back to today.
|
|
9
|
+
* · edge tabs: a row whose marks are all behind the view shows its left tab, all ahead its right tab; a program's next milestone past the
|
|
10
|
+
* view waits on the right. A press scrolls the bar into view.
|
|
11
|
+
* · the first column on screen carries the year; the fades show only on the side where there is more; the scroller names its range for
|
|
12
|
+
* a screen reader ("Timeline, Jan 2027 to Dec 2027").
|
|
13
|
+
* · reveal(key): Find scrolls an off-screen bar into view and tints its row for a moment.
|
|
14
|
+
* Sprint does not scroll (data-fixed). */
|
|
15
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
16
|
+
const monthYear = (d) => MON[d.getMonth()] + ' ' + d.getFullYear();
|
|
17
|
+
|
|
18
|
+
let cur = null; // the timeline on screen: { el, sc, from, to, tw, nw, span }
|
|
19
|
+
let keep = null; // its place before a redraw: { span, mid, todayAt }
|
|
20
|
+
let ro = null;
|
|
21
|
+
|
|
22
|
+
/** The place of the timeline on screen, kept for the next draw. */
|
|
23
|
+
function capture() {
|
|
24
|
+
if (!cur || !cur.el.isConnected || cur.fixed) return null;
|
|
25
|
+
const v = view(), now = +cur.el.dataset.now, tx = xOf(now);
|
|
26
|
+
return { span: cur.span, mid: dateAt(v.l + v.w / 2), todayAt: tx >= v.l && tx <= v.l + v.w ? (tx - v.l) / v.w : null };
|
|
27
|
+
}
|
|
28
|
+
/** Leaving the timeline: the next visit opens at today again. */
|
|
29
|
+
export function forget() { keep = null; cur = null; }
|
|
30
|
+
|
|
31
|
+
const xOf = (ms) => ((ms - cur.from) / (cur.to - cur.from)) * cur.tw;
|
|
32
|
+
const dateAt = (x) => cur.from + (x / cur.tw) * (cur.to - cur.from);
|
|
33
|
+
function view() { return { l: cur.sc.scrollLeft, w: Math.max(1, cur.sc.clientWidth - cur.nw) }; }
|
|
34
|
+
function scrollToX(x, smooth) { cur.sc.scrollTo({ left: Math.max(0, x), behavior: smooth ? 'smooth' : 'auto' }); }
|
|
35
|
+
/** Today 25% of the way in (TsCOpen). */
|
|
36
|
+
function toToday(smooth) { const v = view(); scrollToX(xOf(+cur.el.dataset.now) - v.w * 0.25, smooth); }
|
|
37
|
+
|
|
38
|
+
/** The track's width for the screen it is on: one screen holds the span's columns. */
|
|
39
|
+
function size() {
|
|
40
|
+
const ratio = +cur.el.dataset.ratio || 1, w = Math.max(1, cur.sc.clientWidth - cur.nw);
|
|
41
|
+
cur.tw = Math.round(w * ratio);
|
|
42
|
+
cur.sc.style.setProperty('--tw', cur.tw + 'px');
|
|
43
|
+
cur.sc.style.setProperty('--vw', cur.sc.clientWidth + 'px');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Wire the timeline just drawn in `host`. A different span than before opens where the rules say (see the head of this file). */
|
|
47
|
+
export function mount(host) {
|
|
48
|
+
const before = keep || capture();
|
|
49
|
+
keep = null;
|
|
50
|
+
if (ro) { ro.disconnect(); ro = null; }
|
|
51
|
+
const el = host && host.querySelector('.tg-s');
|
|
52
|
+
if (!el) { cur = null; return; }
|
|
53
|
+
const sc = el.querySelector('.tg-sc'), nameCell = el.querySelector('.tg-h > .tg-n');
|
|
54
|
+
cur = { el, sc, from: +el.dataset.from, to: +el.dataset.to, span: el.dataset.span, fixed: el.hasAttribute('data-fixed'), nw: nameCell ? nameCell.getBoundingClientRect().width : 0, tw: 0 };
|
|
55
|
+
size();
|
|
56
|
+
if (!cur.fixed) {
|
|
57
|
+
if (!before || before.span === 'sprint') toToday(false);
|
|
58
|
+
else if (before.todayAt != null) { const v = view(); scrollToX(xOf(+el.dataset.now) - v.w * before.todayAt); }
|
|
59
|
+
else { const v = view(); scrollToX(xOf(before.mid) - v.w / 2); }
|
|
60
|
+
}
|
|
61
|
+
sc.addEventListener('scroll', schedule, { passive: true });
|
|
62
|
+
sc.addEventListener('keydown', onKey);
|
|
63
|
+
sc.addEventListener('pointerdown', onDown);
|
|
64
|
+
el.addEventListener('click', onClick, true);
|
|
65
|
+
ro = new ResizeObserver(() => { if (!cur || cur.el !== el) return; const v = view(), mid = dateAt(v.l + v.w / 2); cur.nw = nameCell ? nameCell.getBoundingClientRect().width : 0; size(); scrollToX(xOf(mid) - view().w / 2); update(); });
|
|
66
|
+
ro.observe(sc);
|
|
67
|
+
update();
|
|
68
|
+
}
|
|
69
|
+
/** Before the page redraws the board: keep the timeline's place (a span switch, a filter, the panel). */
|
|
70
|
+
export function hold() { keep = capture(); }
|
|
71
|
+
|
|
72
|
+
let raf = 0;
|
|
73
|
+
function schedule() { if (!raf) raf = requestAnimationFrame(() => { raf = 0; if (cur && cur.el.isConnected) update(); }); }
|
|
74
|
+
|
|
75
|
+
function update() {
|
|
76
|
+
const v = view(), el = cur.el, max = cur.sc.scrollWidth - cur.sc.clientWidth;
|
|
77
|
+
el.classList.toggle('more-l', !cur.fixed && v.l > 1);
|
|
78
|
+
el.classList.toggle('more-r', !cur.fixed && v.l < max - 1);
|
|
79
|
+
cur.sc.setAttribute('aria-label', 'Timeline, ' + monthYear(new Date(dateAt(v.l))) + ' to ' + monthYear(new Date(dateAt(v.l + v.w))) + (cur.fixed ? '' : '. Left and right arrows move half a screen, T goes to today'));
|
|
80
|
+
// Today: the pill on the line in view, else the back button with its arrow pointing the way
|
|
81
|
+
const tx = xOf(+el.dataset.now), back = el.querySelector('.tg-tback'), off = tx < v.l ? 'l' : tx > v.l + v.w ? 'r' : '';
|
|
82
|
+
if (back) { back.hidden = !off || cur.fixed; back.classList.toggle('l', off === 'l'); back.classList.toggle('r', off === 'r'); }
|
|
83
|
+
// the first column on screen carries the year (TsCGrill 10)
|
|
84
|
+
const ticks = [...el.querySelectorAll('.tg-h .tg-p > span[data-y], .tgq-h .tg-p > span[data-y]')];
|
|
85
|
+
let first = null;
|
|
86
|
+
for (const t of ticks) { if (t.offsetLeft <= v.l + 2) first = t; else break; }
|
|
87
|
+
if (!first) first = ticks[0] || null;
|
|
88
|
+
for (const t of ticks) {
|
|
89
|
+
const pin = t === first && !cur.fixed, s = t.querySelector('small');
|
|
90
|
+
if (t.classList.contains('pin') !== pin || pin) {
|
|
91
|
+
t.classList.toggle('pin', pin);
|
|
92
|
+
if (s && !t.hasAttribute('data-plain')) { if (!('sub' in t.dataset)) t.dataset.sub = s.textContent; s.textContent = pin ? [t.dataset.base, t.dataset.y].filter(Boolean).join(' · ') : t.dataset.sub; }
|
|
93
|
+
const next = ticks[ticks.indexOf(t) + 1], room = (next ? next.offsetLeft : cur.tw) - t.offsetLeft - t.offsetWidth;
|
|
94
|
+
t.style.transform = pin && v.l > t.offsetLeft ? `translateX(${Math.max(0, Math.min(v.l - t.offsetLeft, room))}px)` : '';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// edge tabs (TsCDesk, TsCEdges 1): one per side at most, at the edge of the view
|
|
98
|
+
for (const b of el.querySelectorAll('.tg-edge')) {
|
|
99
|
+
let show = false;
|
|
100
|
+
if (b.dataset.edge === 'm') {
|
|
101
|
+
const ms = JSON.parse(b.dataset.ms || '[]'), next = ms.find(([p]) => (p / 100) * cur.tw > v.l + v.w);
|
|
102
|
+
show = !!next; if (next) { b.querySelector('span').textContent = next[1]; b.dataset.go = next[0]; b.setAttribute('aria-label', 'Next program milestone: ' + next[1] + '. Scroll to it'); }
|
|
103
|
+
} else {
|
|
104
|
+
const a = (+b.dataset.a / 100) * cur.tw, z = (+b.dataset.b / 100) * cur.tw;
|
|
105
|
+
show = b.dataset.edge === 'l' ? z < v.l - 4 : a > v.l + v.w + 4;
|
|
106
|
+
}
|
|
107
|
+
b.hidden = !show || cur.fixed; b.tabIndex = show ? 0 : -1;
|
|
108
|
+
if (show) b.style.left = b.dataset.edge === 'l' ? v.l + 6 + 'px' : v.l + v.w - 6 + 'px';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Scroll a stretch of the track into view: centred, or its near end in view when it is wider than the screen. */
|
|
113
|
+
function bring(a, b, side, smooth = true) {
|
|
114
|
+
const v = view();
|
|
115
|
+
if (b - a < v.w * 0.9) scrollToX((a + b) / 2 - v.w / 2, smooth);
|
|
116
|
+
else scrollToX(side === 'l' ? b - v.w * 0.85 : a - v.w * 0.15, smooth);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function onClick(e) {
|
|
120
|
+
if (dragged) { e.preventDefault(); e.stopPropagation(); dragged = false; return; }
|
|
121
|
+
const t = e.target.closest('.tg-tback, .tg-edge'); if (!t || !cur) return;
|
|
122
|
+
e.preventDefault(); e.stopPropagation();
|
|
123
|
+
if (t.classList.contains('tg-tback')) { toToday(true); return; }
|
|
124
|
+
if (t.dataset.edge === 'm') { const x = (+t.dataset.go / 100) * cur.tw; bring(x, x, 'r'); return; }
|
|
125
|
+
bring((+t.dataset.a / 100) * cur.tw, (+t.dataset.b / 100) * cur.tw, t.dataset.edge);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function onKey(e) {
|
|
129
|
+
if (!cur || cur.fixed || e.altKey || e.ctrlKey || e.metaKey || /^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName)) return;
|
|
130
|
+
const v = view();
|
|
131
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { e.preventDefault(); scrollToX(v.l + (e.key === 'ArrowLeft' ? -1 : 1) * v.w / 2, true); }
|
|
132
|
+
else if (e.key === 't' || e.key === 'T') { e.preventDefault(); toToday(true); }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// a drag on empty track scrolls (a mouse; touch and a trackpad scroll natively). A drag that starts on a bar, a name or a button does not.
|
|
136
|
+
let drag = null, dragged = false;
|
|
137
|
+
function onDown(e) {
|
|
138
|
+
if (!cur || cur.fixed || e.button !== 0 || e.pointerType !== 'mouse' || e.target.closest('button, a, .tg-bar, .tg-n, .tgq-n, .bd-prdb, .tg-psb')) return;
|
|
139
|
+
drag = { x: e.clientX, l: cur.sc.scrollLeft, id: e.pointerId }; dragged = false;
|
|
140
|
+
window.addEventListener('pointermove', onMove);
|
|
141
|
+
window.addEventListener('pointerup', onUp, { once: true });
|
|
142
|
+
}
|
|
143
|
+
function onMove(e) {
|
|
144
|
+
if (!drag || !cur) return;
|
|
145
|
+
const dx = e.clientX - drag.x;
|
|
146
|
+
if (!dragged && Math.abs(dx) < 4) return;
|
|
147
|
+
if (!dragged) { dragged = true; cur.el.classList.add('dragging'); }
|
|
148
|
+
cur.sc.scrollLeft = drag.l - dx;
|
|
149
|
+
}
|
|
150
|
+
function onUp() { window.removeEventListener('pointermove', onMove); drag = null; if (cur) cur.el.classList.remove('dragging'); setTimeout(() => { dragged = false; }, 0); }
|
|
151
|
+
|
|
152
|
+
/** Find (TsCEdges 4): scroll the row's bar into view when it is off screen, and tint the row for a moment. */
|
|
153
|
+
export function reveal(key) {
|
|
154
|
+
if (!cur || !cur.el.isConnected) return;
|
|
155
|
+
const row = [...cur.el.querySelectorAll('[data-row]')].find((r) => r.dataset.row === key); if (!row) return;
|
|
156
|
+
const p = row.querySelector('.tg-p[data-a]');
|
|
157
|
+
if (p && !cur.fixed) {
|
|
158
|
+
const a = (+p.dataset.a / 100) * cur.tw, b = (+p.dataset.b / 100) * cur.tw, v = view();
|
|
159
|
+
if (b < v.l || a > v.l + v.w) bring(a, b, b < v.l ? 'l' : 'r', false); // at once: Find opens the initiative next, and the redraw keeps the scroll it reads
|
|
160
|
+
}
|
|
161
|
+
row.scrollIntoView({ block: 'nearest' });
|
|
162
|
+
row.classList.remove('tint'); void row.offsetWidth; row.classList.add('tint');
|
|
163
|
+
setTimeout(() => row.classList.remove('tint'), 1600);
|
|
164
|
+
}
|