create-pmos 0.443.0 → 0.444.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-board-test.js +8 -2
- package/workspace/briefing-premium-insights-test.js +40 -38
- package/workspace/briefing-premium-test.js +2 -1
- package/workspace/changelog.json +12 -0
- package/workspace/goals-clear-ui-test.js +34 -20
- package/workspace/guide/home.md +5 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/lib/board-premium.js +1 -1
- package/workspace/lib/engine/boards.js +9 -2
- package/workspace/lib/routes-boards.js +40 -1
- package/workspace/live-pill-round-test.js +178 -0
- package/workspace/okr-goals-ui-test.js +21 -19
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +231 -0
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-item-test.js +10 -2
- package/workspace/premium-vw-jira-test.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/cozy-adler.js +21 -0
- package/workspace/public/pm/cozy-divider.css +32 -0
- package/workspace/public/pm/cozy-divider.js +45 -0
- package/workspace/public/pm/cozy-insights.css +14 -0
- package/workspace/public/pm/cozy-live-pill.css +16 -22
- package/workspace/public/pm/cozy-live-pill.js +28 -17
- package/workspace/public/pm/cozy-panels.css +59 -0
- package/workspace/public/pm/cozy-panels.js +524 -0
- package/workspace/public/pm/cozy-viewer.js +146 -70
- package/workspace/public/pm/goals-clear.js +9 -2
- package/workspace/public/pm/home-app.js +22 -11
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/home-today.js +4 -2
- package/workspace/public/pm/ini-edit.js +401 -0
- package/workspace/public/pm/ini-tasks.js +42 -18
- package/workspace/public/pm/ini-versions.js +18 -4
- package/workspace/public/pm/ini-view-model.js +8 -4
- package/workspace/public/pm/ini-view.css +88 -1
- package/workspace/public/pm/ini-view.js +42 -11
- package/workspace/public/pm/premium-board.js +8 -6
- package/workspace/public/pm/premium-insights.js +205 -43
- package/workspace/public/pm/task-card.css +2 -0
- package/workspace/public/pm/task-card.js +4 -1
- package/workspace/stage-card-tasks-test.js +396 -0
- package/workspace/stage-card-test.js +1 -1
- package/workspace/task-delete-test.js +9 -1
- package/workspace/task-milestones-test.js +3 -3
- package/workspace/task-press-test.js +12 -4
- package/workspace/task-views-test.js +8 -4
- package/workspace/test-lists/batch18-live-pill-round.json +10 -0
- package/workspace/test-lists/batch18-panels.json +9 -0
- package/workspace/test-lists/stage-card-tasks.json +6 -0
|
@@ -282,13 +282,19 @@ function wirePage(b, id) {
|
|
|
282
282
|
addCancel: () => { ADDING = null; ADD_DATES = null; redrawView(); },
|
|
283
283
|
// the stage card's ⏸ or calendar on a hold (batch 11 item 21): what the hold says, and its return date set or changed here
|
|
284
284
|
hold: (i, btn) => holdPop(btn, id),
|
|
285
|
-
|
|
285
|
+
// opt (batch 18 item 16): the + on a stage: the task goes under that stage, with the dates its field picked; the toast offers Undo
|
|
286
|
+
addTask: async (title, inp, opt) => {
|
|
286
287
|
const M = curM(); if (!M) return;
|
|
287
288
|
inp.disabled = true;
|
|
288
|
-
const
|
|
289
|
+
const D = opt ? opt : ADD_DATES || {};
|
|
290
|
+
const r = await C.pmPost('/api/boards/tasks/add', { ...bw(M), initiative: id, title, ...(D.start ? { start: D.start } : {}), ...(D.due ? { due: D.due } : {}), ...(opt && opt.section != null ? { section: opt.section } : {}) });
|
|
289
291
|
inp.disabled = false;
|
|
290
292
|
if (!r || r.ok === false) { say((r && r.error) || 'The task was not added.'); return; }
|
|
291
|
-
|
|
293
|
+
const uid = r.item && r.item.uid;
|
|
294
|
+
if (opt && uid) undoToast('Added to ' + (opt.name || 'the stage') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/delete', { ...bw(M), task: uid, why: 'undo of add' }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
|
|
295
|
+
else say('Task added.');
|
|
296
|
+
await C.load(); redrawView();
|
|
297
|
+
if (opt) return;
|
|
292
298
|
const n = BODY && BODY.querySelector('#ivAddTask'); if (n) { n.value = ''; n.focus(); }
|
|
293
299
|
},
|
|
294
300
|
next: (btn) => { const M = curM(); if (M) popNext(btn, id, M); },
|
|
@@ -28,7 +28,7 @@ export const P = {
|
|
|
28
28
|
pause: 'M8 5v14M16 5v14', stop: 'M7 7h10v10H7z', list: 'M9 6h11M9 12h11M9 18h11', doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
|
|
29
29
|
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',
|
|
30
30
|
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',
|
|
31
|
-
chat: 'M4 5h16v11H9l-5 4z', prog: 'M4 5h7v5H4zM13 5h7v5h-7zM8.5 14h7v5h-7zM7.5 10v2h9v-2M12 12v2', dots: 'M5 12h.01M12 12h.01M19 12h.01', send: 'M5 12h14M13 6l6 6-6 6', ticket: 'M3 5h18v4H3zM3 11h18v4H3z',
|
|
31
|
+
chat: 'M4 5h16v11H9l-5 4z', fold: 'M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zM9 4v16', prog: 'M4 5h7v5H4zM13 5h7v5h-7zM8.5 14h7v5h-7zM7.5 10v2h9v-2M12 12v2', dots: 'M5 12h.01M12 12h.01M19 12h.01', send: 'M5 12h14M13 6l6 6-6 6', ticket: 'M3 5h18v4H3zM3 11h18v4H3z',
|
|
32
32
|
};
|
|
33
33
|
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>`;
|
|
34
34
|
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 };
|
|
@@ -320,7 +320,9 @@ export function listHtml(M, T, o) {
|
|
|
320
320
|
+ (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
|
|
321
321
|
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
|
|
322
322
|
+ SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
|
|
323
|
-
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button
|
|
323
|
+
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button>`
|
|
324
|
+
// fold the list to the rail (batch 18 item 15, TbT1Split): the rail's list button brings it back; a phone has no rail
|
|
325
|
+
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib" data-hm-fold aria-label="Fold the list to the rail" title="Fold the list to the rail">${svg(P.fold, 18)}</button>`) + '</span></div>'
|
|
324
326
|
+ (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
|
|
325
327
|
// the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
|
|
326
328
|
const card = MOMENT.has(T.mode) ? todayHtml(T, { greet: M.greet, sub: '', phone: o.phone }) : '';
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/* pm/ini-edit.js — a task changed where it sits in the Tasks List (feedback batch 18 item 16, agreed A; main canvas In development, frames
|
|
2
|
+
* StA1Rows to StA10bDragPhone, stickies stRules and stWhy). pm/ini-view.js draws the List and calls this file for the parts below; the
|
|
3
|
+
* Board's panel and Home's initiative page draw the same List, so both get them.
|
|
4
|
+
*
|
|
5
|
+
* openOf(id) / addOf(id) the task whose row is open in place, and the stage whose + field is open (one each per initiative)
|
|
6
|
+
* stagesSet(id, v) the stages a task can move to (the workflow's, then Not in a stage), from the view by stage
|
|
7
|
+
* rowHtml(x, o) the open row (StA2Edit): the name field (a Jira row: its title and "<Status> in Jira · read N min ago"),
|
|
8
|
+
* then ONE quiet line: the status icon chip, the date chips (Start – Due; a milestone: one ◇ chip; none: a
|
|
9
|
+
* dashed Dates chip) and ⋯ right after the dates (StA8Desk)
|
|
10
|
+
* ticketHtml(k, o) an unlinked Jira ticket's open row: the same, with Open the ticket in place of ⋯ (its place is Jira's)
|
|
11
|
+
* plusHtml(sec, id, o) the + on an open stage's header: "New task in <stage>" (StA5Add)
|
|
12
|
+
* addHtml(sec, id) the field at the top of that stage's list, with an optional Dates chip
|
|
13
|
+
* press(b, d, root, H, e) a press this file owns → true: a title (opens the row), ⋯ and its menu, the +, the field's Dates chip
|
|
14
|
+
* wire(body) once per body: the name field (Enter or blur saves, Esc closes), the add field (Enter adds and stays open),
|
|
15
|
+
* a press outside the open row closes it, and the drag (StA10Drag): a grip on hover on a desktop, a long press
|
|
16
|
+
* on the title on a phone; the target stage lights up and a blue line shows where the task lands
|
|
17
|
+
* writes(h) the host's handlers with the writes this file needs, where the host has none: h.rename(uid, title),
|
|
18
|
+
* h.move(uid, { to, from, ids, name }) (a stage, and the order inside it), each with Undo in the toast
|
|
19
|
+
*
|
|
20
|
+
* A move never changes a task's status or dates. Zero is silence: a row with no dates shows none. Icon-only presses carry their words in
|
|
21
|
+
* aria-label and title. */
|
|
22
|
+
import * as TV from './ini-tasks.js';
|
|
23
|
+
import { stateIcon, freshness } from './task-card.js';
|
|
24
|
+
import { pmPost } from './http.js';
|
|
25
|
+
|
|
26
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
27
|
+
const SVG = (d, w = 16, sw = 1.8) => `<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>`;
|
|
28
|
+
const P = {
|
|
29
|
+
more: 'M5 12h.01M12 12h.01M19 12h.01', plus: 'M12 5v14M5 12h14', check: 'M5 12l5 5 9-10', down: 'M7 10l5 5 5-5', right: 'M10 7l5 5-5 5', left: 'M14 7l-5 5 5 5',
|
|
30
|
+
dia: 'M12 4l8 8-8 8-8-8z', cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01',
|
|
31
|
+
open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', bin: 'M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/* ── what is open, per initiative ── */
|
|
35
|
+
const OPEN = new Map(); // initiative id → the uid of the row open in place
|
|
36
|
+
const ADD = new Map(); // initiative id → the stage key whose + field is open
|
|
37
|
+
const ADD_D = new Map(); // initiative id → { start, due } the add field's Dates chip picked
|
|
38
|
+
const STAGES = new Map(); // initiative id → [{ key, name }] the stages a task can move to
|
|
39
|
+
const VIEW = new Map(); // initiative id → the view the List drew last (the drag reads its stages' tasks)
|
|
40
|
+
export const openOf = (id) => OPEN.get(id) || '';
|
|
41
|
+
export const addOf = (id) => (ADD.has(id) ? ADD.get(id) : null);
|
|
42
|
+
/** For the tests: close every open row and field. */
|
|
43
|
+
export const reset = () => { OPEN.clear(); ADD.clear(); ADD_D.clear(); STAGES.clear(); VIEW.clear(); };
|
|
44
|
+
/** The stages of the view by stage (v0), in workflow order, then Not in a stage. Folded lines (past, Later) hold their stages inside.
|
|
45
|
+
* v: the view as the List draws it (grouped as the PM picked). */
|
|
46
|
+
export function stagesSet(id, v0, v) {
|
|
47
|
+
VIEW.set(id, v || v0);
|
|
48
|
+
v = v0;
|
|
49
|
+
const out = [];
|
|
50
|
+
const walk = (s) => { if (s.stages) { s.stages.forEach(walk); return; } if (s.kind === 'stage') out.push({ key: s.key, name: s.name }); };
|
|
51
|
+
for (const s of (v.tasks && v.tasks.sections) || []) walk(s);
|
|
52
|
+
out.push({ key: '', name: 'Not in a stage' });
|
|
53
|
+
STAGES.set(id, out);
|
|
54
|
+
}
|
|
55
|
+
const stageName = (id, key) => { const s = (STAGES.get(id) || []).find((x) => x.key === key); return s ? s.name : key || 'Not in a stage'; };
|
|
56
|
+
|
|
57
|
+
/* ── the open row (StA2Edit, StA6Jira, StA8Desk) ── */
|
|
58
|
+
const chip = (cls, attrs, inner, label) => `<button type="button" class="iv-edc ${cls}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${inner}</button>`;
|
|
59
|
+
/** The date chips: a milestone's one ◇ day; else Start – Due; with no dates one dashed Dates chip. The press opens the task card's picker. */
|
|
60
|
+
function datesHtml(x, uid) {
|
|
61
|
+
const base = `data-iv-date="${esc(uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" data-t="${esc(x.title)}"`;
|
|
62
|
+
if (x.ms && !x.jiraTk) {
|
|
63
|
+
return x.dueText ? chip('iv-edd ms', `${base} data-one="1"`, `${SVG(P.dia, 13, 2.2)}<b>${esc(x.dueText)}</b>`, 'Milestone date: ' + x.dueText + '. Change')
|
|
64
|
+
: chip('iv-edd ms dash', `${base} data-one="1"`, `${SVG(P.dia, 13, 2.2)}Date`, 'Set the milestone date');
|
|
65
|
+
}
|
|
66
|
+
if (!x.start && !x.end) return chip('iv-edd dash', `${base} data-f="start"`, `${SVG(P.cal, 14, 2)}Dates`, 'Add dates');
|
|
67
|
+
return chip('iv-edd', `${base} data-f="start"`, `<small>Start</small><b>${esc(x.startText || 'None')}</b>`, 'Start: ' + (x.startText || 'none') + '. Change')
|
|
68
|
+
+ '<span class="iv-eds" aria-hidden="true">–</span>'
|
|
69
|
+
+ chip('iv-edd', `${base} data-f="due"`, `<small>Due</small><b>${esc(x.dueText || 'None')}</b>`, 'Due: ' + (x.dueText || 'none') + '. Change');
|
|
70
|
+
}
|
|
71
|
+
/** "In Progress in Jira · read 4 min ago": a Jira row's status and title are Jira's (read-only here). */
|
|
72
|
+
const jiraLine = (st, at) => `<p class="iv-edj">${esc((st || 'To do') + ' in Jira')}${at ? `<span> · ${esc(freshness(at))}</span>` : ''}</p>`;
|
|
73
|
+
export function rowHtml(x, o, box, name) {
|
|
74
|
+
const jira = !!(x.jkey && !x.dr);
|
|
75
|
+
const field = jira ? `<b class="iv-tt">${name}</b>${jiraLine(x.jst || x.status, o.jiraRead)}`
|
|
76
|
+
: `<form class="iv-edf" data-iv-renf="${esc(x.uid)}"><input type="text" class="iv-edn" data-iv-ren="${esc(x.uid)}" value="${esc(x.title)}" maxlength="200" autocomplete="off" aria-label="Task name" data-was="${esc(x.title)}"></form>`;
|
|
77
|
+
const st = jira ? '' : chip('iv-edst', `data-iv-stat="${esc(x.uid)}" data-st="${esc(x.status)}" data-plain="1" aria-haspopup="dialog"`, `${stateIcon(x.status)}${SVG(P.down, 11, 2.4)}`, 'Status: ' + x.status + '. Change');
|
|
78
|
+
const more = `<button type="button" class="iv-ib iv-edm" data-iv-more="${esc(x.uid)}" aria-haspopup="menu" aria-expanded="false" aria-label="More for this task" title="More">${SVG(P.more, 18, 3)}</button>`;
|
|
79
|
+
return `<div class="iv-tr iv-ed${jira ? ' jr' : ''}" data-esc-layer data-iv-r="${esc(x.uid)}" data-iv-open="${esc(x.uid)}">${box}<span class="w">${field}<span class="iv-edl">${st}${datesHtml(x, x.uid)}${more}</span></span></div>`;
|
|
80
|
+
}
|
|
81
|
+
/** An unlinked Jira ticket's open row (StA6Jira): the start and due kept in PMOS change here; Open the ticket sits after them. */
|
|
82
|
+
export function ticketHtml(k, o) {
|
|
83
|
+
const r = TV.jiraRow(k), x = { ...r, jiraTk: true, startText: k.startText || '', dueText: k.dueText || '' };
|
|
84
|
+
const open = `<button type="button" class="iv-ib iv-edm" data-iv-ticket="${esc(k.key)}" aria-label="Open the ticket" title="Open the ticket">${SVG(P.open, 16, 2)}</button>`;
|
|
85
|
+
return `<div class="iv-tr iv-tkr iv-ed jr" data-esc-layer data-iv-open="${esc(k.key)}"><span class="iv-jq" aria-hidden="true"></span><span class="w"><b class="iv-tt"><em>${esc(k.key)}</em> ${esc(k.title)}</b>${jiraLine(k.status, o.jiraRead)}<span class="iv-edl">${datesHtml(x, k.key)}${open}</span></span></div>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* ── + on a stage, and its field (StA5Add) ── */
|
|
89
|
+
export function plusHtml(sec, id, o) {
|
|
90
|
+
if (!o.addIn) return '';
|
|
91
|
+
const nm = sec.name || 'Not in a stage', on = addOf(id) === (sec.key || '');
|
|
92
|
+
return `<button type="button" class="iv-ib iv-plus${on ? ' on' : ''}" data-iv-plus="${esc(sec.key || '')}" data-nm="${esc(nm)}" aria-pressed="${on}" aria-label="${esc('New task in ' + nm)}" title="${esc('New task in ' + nm)}">${SVG(P.plus, 16, 2.2)}</button>`;
|
|
93
|
+
}
|
|
94
|
+
const mdIso = (iso) => { const n = TV.dn(iso); return n == null ? '' : TV.md(n); };
|
|
95
|
+
export function addHtml(sec, id) {
|
|
96
|
+
if (addOf(id) !== (sec.key || '')) return '';
|
|
97
|
+
const nm = sec.name || 'Not in a stage', D = ADD_D.get(id) || {};
|
|
98
|
+
const dt = D.start || D.due ? [mdIso(D.start), mdIso(D.due)].filter(Boolean).join(' – ') : '';
|
|
99
|
+
return `<form class="iv-addf iv-addin" data-esc-layer data-iv-addin="${esc(sec.key || '')}" data-nm="${esc(nm)}"><span class="iv-cb" aria-hidden="true"></span>`
|
|
100
|
+
+ `<input type="text" data-iv-addinp maxlength="200" autocomplete="off" placeholder="${esc('New task in ' + nm)}" aria-label="${esc('New task in ' + nm)}">`
|
|
101
|
+
+ `<button type="submit" class="iv-go" aria-label="Add the task" title="Add (Enter). Esc closes.">${SVG(P.check, 16, 2.2)}</button></form>`
|
|
102
|
+
+ `<div class="iv-addd"><button type="button" class="iv-edc iv-edd${dt ? '' : ' dash'}" data-iv-adddt data-s="${esc(D.start || '')}" data-e="${esc(D.due || '')}" data-f="start" aria-label="${esc(dt ? 'Dates: ' + dt + '. Change' : 'Dates, optional')}" title="Dates, optional">${SVG(P.cal, 14, 2)}${esc(dt || 'Dates')}</button></div>`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ── the writes (Undo in the host's toast) ── */
|
|
106
|
+
async function post(H, route, body) {
|
|
107
|
+
const at = H.where ? H.where() : {};
|
|
108
|
+
return pmPost('/api/boards/tasks/' + route, { ws: at.ws, board: at.board, ...body }).catch(() => null);
|
|
109
|
+
}
|
|
110
|
+
const say = (H, m, undo) => { if (H.toast) H.toast(m, undo); };
|
|
111
|
+
const failed = (H, res, m) => { say(H, (res && res.error) || m || 'Nothing was changed.'); return false; };
|
|
112
|
+
const after = async (H) => { if (H.reload) await H.reload(); else if (H.redraw) H.redraw(); };
|
|
113
|
+
/** Add the writes the host does not have. The draft's own writes wrap these (pm/ini-versions.js). */
|
|
114
|
+
export function writes(h) {
|
|
115
|
+
const W = { ...h };
|
|
116
|
+
if (!W.rename) W.rename = async (uid, title) => {
|
|
117
|
+
const res = await post(W, 'rename', { task: uid, title });
|
|
118
|
+
if (!res || res.ok === false) return failed(W, res, 'The name was not changed.');
|
|
119
|
+
await after(W);
|
|
120
|
+
const was = res.from;
|
|
121
|
+
say(W, 'Renamed.', was ? async () => { const u = await post(W, 'rename', { task: uid, title: was }); if (!u || u.ok === false) failed(W, u, 'The undo did not land.'); await after(W); } : undefined);
|
|
122
|
+
return true;
|
|
123
|
+
};
|
|
124
|
+
if (!W.move) W.move = async (uid, m) => {
|
|
125
|
+
const id = W.__id ? W.__id() : '', moved = m.to !== m.from;
|
|
126
|
+
let sec = null, ord = null;
|
|
127
|
+
if (moved) { sec = await post(W, 'edit', { task: uid, section: m.to }); if (!sec || sec.ok === false) return failed(W, sec, 'The task was not moved.'); }
|
|
128
|
+
if (m.ids) { ord = await post(W, 'order', { initiative: id, section: m.to, tasks: m.ids }); if (!ord || ord.ok === false) { if (!moved) return failed(W, ord, 'The order was not saved.'); say(W, 'Moved, but not its place in the stage: ' + ((ord && ord.error) || 'the server did not say why') + '.'); ord = null; } }
|
|
129
|
+
await after(W);
|
|
130
|
+
say(W, moved ? 'Moved to ' + (m.name || stageName(id, m.to)) + '.' : 'Order saved.', async () => {
|
|
131
|
+
if (ord) { const u = await post(W, 'order', { initiative: id, section: m.to, tasks: ord.from || [] }); if (!u || u.ok === false) { failed(W, u, 'The undo did not land.'); await after(W); return; } }
|
|
132
|
+
if (moved) { const u = await post(W, 'edit', { task: uid, section: sec.from && typeof sec.from.section === 'string' ? sec.from.section : m.from }); if (!u || u.ok === false) failed(W, u, 'The undo did not land.'); }
|
|
133
|
+
await after(W);
|
|
134
|
+
});
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
return W;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ── the presses ── */
|
|
141
|
+
let SUPPRESS = 0; // a long press lifted the row: the click that follows is not a press on the title
|
|
142
|
+
let TOUCHED = 0; // this click opened or kept a row open: the document's own click does not close it
|
|
143
|
+
const rowOf = (v, uid) => {
|
|
144
|
+
for (const s of (v && v.tasks && v.tasks.sections) || []) for (const c of s.stages || [s]) {
|
|
145
|
+
for (const x of [...(c.top || []), ...(c.groups || []).flatMap((g) => g.rows), ...(c.done || []), ...(c.archived || [])]) if (x.uid === uid) return { x, sec: c };
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
};
|
|
149
|
+
/** The open (not closed) tasks of a stage, top to bottom, as the List draws them. */
|
|
150
|
+
const openIds = (v, key) => {
|
|
151
|
+
for (const s of (v && v.tasks && v.tasks.sections) || []) for (const c of s.stages || [s]) if (c.kind !== 'group' && (c.key || '') === key) return [...(c.top || []), ...(c.groups || []).flatMap((g) => g.rows)].filter((x) => !x.dr).map((x) => x.uid);
|
|
152
|
+
return [];
|
|
153
|
+
};
|
|
154
|
+
export function press(b, d, root, H, e) {
|
|
155
|
+
const id = root.dataset.iv, v = VIEW.get(id);
|
|
156
|
+
if (d.ivEdit) {
|
|
157
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
158
|
+
if (Date.now() - SUPPRESS < 350) return true;
|
|
159
|
+
OPEN.set(id, d.ivEdit); ADD.delete(id); if (H.redraw) H.redraw();
|
|
160
|
+
focusLater(root, `[data-iv-open="${cssq(d.ivEdit)}"] .iv-edn`, true);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (d.ivPlus != null) {
|
|
164
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
165
|
+
if (addOf(id) === d.ivPlus) { ADD.delete(id); ADD_D.delete(id); } else { ADD.set(id, d.ivPlus); ADD_D.delete(id); OPEN.delete(id); }
|
|
166
|
+
if (H.redraw) H.redraw();
|
|
167
|
+
focusLater(root, '[data-iv-addinp]');
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
if ('ivAdddt' in d) {
|
|
171
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
172
|
+
TV.datePop(b, '', { dates: (u, p) => { ADD_D.set(id, { ...(ADD_D.get(id) || {}), ...p }); const f = b.closest('.iv-wl'); redrawAdd(f, id); } });
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (d.ivMore) { e.preventDefault(); TOUCHED = Date.now(); moreMenu(b, d.ivMore, id, v, H); return true; }
|
|
176
|
+
if (b.closest('.iv-ed')) TOUCHED = Date.now();
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const cssq = (s) => String(s).replace(/["\\]/g, '\\$&');
|
|
180
|
+
function focusLater(root, sel, select) {
|
|
181
|
+
const body = root.parentElement;
|
|
182
|
+
// a host may draw after a read: try for a short while, until the field is there and holds the focus
|
|
183
|
+
let n = 0;
|
|
184
|
+
const go = () => {
|
|
185
|
+
const f = (body && body.isConnected ? body : document).querySelector(sel);
|
|
186
|
+
if (f && document.activeElement !== f) { f.focus({ preventScroll: true }); if (select && f.setSelectionRange) f.setSelectionRange(f.value.length, f.value.length); }
|
|
187
|
+
if ((!f || document.activeElement !== f) && ++n < 40) setTimeout(go, 50); // up to 2 s: a slow host draws late
|
|
188
|
+
};
|
|
189
|
+
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(go); else go();
|
|
190
|
+
}
|
|
191
|
+
/** The add field's Dates chip again, after a pick, without a redraw (the typed words stay). */
|
|
192
|
+
function redrawAdd(list, id) {
|
|
193
|
+
const f = list && list.querySelector('.iv-addd'); if (!f) return;
|
|
194
|
+
const D = ADD_D.get(id) || {}, dt = [mdIso(D.start), mdIso(D.due)].filter(Boolean).join(' – '), c = f.querySelector('[data-iv-adddt]');
|
|
195
|
+
if (!c) return;
|
|
196
|
+
c.dataset.s = D.start || ''; c.dataset.e = D.due || ''; c.classList.toggle('dash', !dt);
|
|
197
|
+
c.setAttribute('aria-label', dt ? 'Dates: ' + dt + '. Change' : 'Dates, optional');
|
|
198
|
+
c.innerHTML = SVG(P.cal, 14, 2) + esc(dt || 'Dates');
|
|
199
|
+
}
|
|
200
|
+
/** ⋯ of the open row (StA2bMore): Milestone (or Make it a plain task), Move to a stage, Open the task card (Open the ticket on a Jira row),
|
|
201
|
+
* Delete (only where the task can be deleted; never a Jira row). Move to a stage turns the menu into the workflow's stages, ← goes back. */
|
|
202
|
+
function moreMenu(b, uid, id, v, H) {
|
|
203
|
+
const f = rowOf(v, uid); if (!f) return;
|
|
204
|
+
const x = f.x, jira = !!(x.jkey && !x.dr), cur = f.sec.kind === 'stage' || f.sec.kind === 'none' ? f.sec.key || '' : null;
|
|
205
|
+
const del = !jira && !!H.remove && TV.deletable(uid);
|
|
206
|
+
const item = (attr, ico, label, extra = '') => `<button type="button" role="menuitem" class="o" ${attr}><span class="ck" aria-hidden="true">${SVG(ico, 15, 2)}</span><span>${esc(label)}</span>${extra}</button>`;
|
|
207
|
+
const main = () => `<div class="tkc-pop ivq-m ive-m" role="menu" aria-label="More for this task">`
|
|
208
|
+
+ item('data-ive-ms', P.dia, x.ms ? 'Make it a plain task' : 'Milestone')
|
|
209
|
+
+ item('data-ive-mv aria-haspopup="menu"', P.grip, 'Move to a stage', `<span class="k" aria-hidden="true">${SVG(P.right, 14, 2)}</span>`)
|
|
210
|
+
+ item('data-ive-card', P.open, jira ? 'Open the ticket' : 'Open the task card')
|
|
211
|
+
+ (del ? '<hr>' + item('data-ive-del class="o dl"', P.bin, 'Delete task') : '') + '</div>';
|
|
212
|
+
const stages = () => `<div class="tkc-pop ivq-m ive-m" role="menu" aria-label="Move to a stage"><button type="button" class="o ive-bk" data-ive-bk><span class="ck" aria-hidden="true">${SVG(P.left, 15, 2)}</span><span>Move to a stage</span></button><hr>`
|
|
213
|
+
+ (STAGES.get(id) || []).map((s) => `<button type="button" role="menuitemradio" class="o${s.key === cur ? ' hl' : ''}" aria-checked="${s.key === cur}" data-ive-to="${esc(s.key)}"><span class="ck" aria-hidden="true">${s.key === cur ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(s.name)}</span></button>`).join('') + '</div>';
|
|
214
|
+
const el = TV.openPop(b, main(), (o) => {
|
|
215
|
+
const d = o.dataset;
|
|
216
|
+
if ('iveMv' in d) { el.innerHTML = stages(); const c = el.querySelector('[aria-checked="true"], button'); if (c) c.focus({ preventScroll: true }); return; }
|
|
217
|
+
if ('iveBk' in d) { el.innerHTML = main(); return; }
|
|
218
|
+
TV.closePop();
|
|
219
|
+
if ('iveMs' in d) { milestone(H, x, !x.ms); return; }
|
|
220
|
+
if (d.iveTo != null) { if (d.iveTo !== cur && H.move) { OPEN.delete(id); H.move(uid, { to: d.iveTo, from: cur == null ? '' : cur, name: stageName(id, d.iveTo) }); } return; }
|
|
221
|
+
if ('iveCard' in d) { OPEN.delete(id); if (jira) { if (H.openTicket) H.openTicket(x.jkey, b); } else if (H.openTask) H.openTask(uid, b); return; }
|
|
222
|
+
if ('iveDel' in d && del) { OPEN.delete(id); H.remove(uid); }
|
|
223
|
+
}, { right: true });
|
|
224
|
+
}
|
|
225
|
+
/** A milestone has one date (StA4Milestone): turning ◇ on keeps the due day (or the start, when it has no due day) and clears the start; the
|
|
226
|
+
* host's Undo puts both back. */
|
|
227
|
+
function milestone(H, x, on) {
|
|
228
|
+
if (!H.dates) return;
|
|
229
|
+
const p = { milestone: on };
|
|
230
|
+
if (on && x.start) { p.start = ''; if (!x.end) p.due = x.start; }
|
|
231
|
+
H.dates(x.uid, p);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ── the fields, the outside press, the drag ── */
|
|
235
|
+
export function wire(body) {
|
|
236
|
+
if (!body || body.__iveWired) return;
|
|
237
|
+
body.__iveWired = true;
|
|
238
|
+
const H = () => body.__iv || {};
|
|
239
|
+
const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : ''; };
|
|
240
|
+
const close = (id) => { if (!id) return; const had = OPEN.has(id) || ADD.has(id); OPEN.delete(id); ADD.delete(id); ADD_D.delete(id); if (had && H().redraw) H().redraw(); };
|
|
241
|
+
// the name: Enter saves and closes the row; a blur saves (the row stays); Esc closes it as it was
|
|
242
|
+
const save = (inp) => {
|
|
243
|
+
const t = inp.value.trim(), was = inp.dataset.was || '';
|
|
244
|
+
if (!t || t === was) { inp.value = was; return false; }
|
|
245
|
+
inp.dataset.was = t;
|
|
246
|
+
if (H().rename) H().rename(inp.dataset.ivRen, t);
|
|
247
|
+
return true;
|
|
248
|
+
};
|
|
249
|
+
body.addEventListener('submit', (e) => {
|
|
250
|
+
const f = e.target.closest('[data-iv-renf], [data-iv-addin]'); if (!f) return;
|
|
251
|
+
e.preventDefault(); e.stopPropagation();
|
|
252
|
+
if (f.dataset.ivRenf != null) { const inp = f.querySelector('[data-iv-ren]'), id = idOf(); OPEN.delete(id); if (!save(inp) && H().redraw) H().redraw(); return; }
|
|
253
|
+
const inp = f.querySelector('[data-iv-addinp]'), t = inp ? inp.value.trim() : '', id = idOf();
|
|
254
|
+
if (!t || !H().addTask) return;
|
|
255
|
+
const D = ADD_D.get(id) || {};
|
|
256
|
+
inp.disabled = true;
|
|
257
|
+
Promise.resolve(H().addTask(t, inp, { section: f.dataset.ivAddin, name: f.dataset.nm, ...(D.start ? { start: D.start } : {}), ...(D.due ? { due: D.due } : {}) })).then(() => {
|
|
258
|
+
// Enter keeps the field open for the next one (StA5Add)
|
|
259
|
+
ADD_D.delete(id);
|
|
260
|
+
const n = body.querySelector('[data-iv-addinp]'); if (n) { if (n === inp) n.value = ''; n.disabled = false; n.focus({ preventScroll: true }); }
|
|
261
|
+
});
|
|
262
|
+
}, true);
|
|
263
|
+
body.addEventListener('focusout', (e) => { const inp = e.target.closest && e.target.closest('[data-iv-ren]'); if (inp && inp.isConnected) save(inp); });
|
|
264
|
+
body.addEventListener('keydown', (e) => {
|
|
265
|
+
if (e.key !== 'Escape') return;
|
|
266
|
+
const inp = e.target.closest && e.target.closest('[data-iv-ren], [data-iv-addinp]');
|
|
267
|
+
if (DRAG) { e.preventDefault(); e.stopPropagation(); dragStop(true); return; }
|
|
268
|
+
if (!inp && !(e.target.closest && e.target.closest('.iv-ed'))) return;
|
|
269
|
+
e.preventDefault(); e.stopPropagation();
|
|
270
|
+
if (inp && inp.dataset.was != null) inp.value = inp.dataset.was;
|
|
271
|
+
close(idOf());
|
|
272
|
+
});
|
|
273
|
+
// Esc with the focus outside the row (after a drill-in and Back, the row is drawn open again and the focus is on the page): the open row
|
|
274
|
+
// or + field is the top layer, so it closes here; the Viewer's own Esc steps aside while any layer is open (cozy-viewer.js)
|
|
275
|
+
window.addEventListener('keydown', (e) => {
|
|
276
|
+
if (e.key !== 'Escape' || e.defaultPrevented || !body.isConnected || DRAG) return;
|
|
277
|
+
const a = document.activeElement;
|
|
278
|
+
if (a && a !== document.body && a.closest && a.closest('[data-esc-layer]')) return; // a picker, a menu or the row itself has it
|
|
279
|
+
if ([...document.querySelectorAll('[data-esc-layer]')].some((l) => !body.contains(l))) return; // another layer is on top
|
|
280
|
+
if (!body.querySelector('.iv-ed, .iv-addin')) return;
|
|
281
|
+
e.preventDefault(); close(idOf());
|
|
282
|
+
});
|
|
283
|
+
// a press outside the open row (and outside its pickers) closes it
|
|
284
|
+
document.addEventListener('click', (e) => {
|
|
285
|
+
const id = idOf(); if (!id || !body.isConnected || (!OPEN.has(id) && !ADD.has(id)) || Date.now() - TOUCHED < 50) return;
|
|
286
|
+
const t = e.target; if (!t || !t.closest || t.closest('.iv-ed, .iv-addin, .iv-addd, .tkc.ivq, .vs-scrim, .cz-toast, [role="status"]')) return;
|
|
287
|
+
if (!t.isConnected) return;
|
|
288
|
+
close(id);
|
|
289
|
+
});
|
|
290
|
+
/* the drag (StA10Drag, StA10bDragPhone) */
|
|
291
|
+
body.addEventListener('pointerdown', (e) => {
|
|
292
|
+
const g = e.target.closest && e.target.closest('[data-iv-grip]');
|
|
293
|
+
if (g && e.button === 0) { e.preventDefault(); dragStart(body, g.closest('.iv-tr'), e); return; }
|
|
294
|
+
const t = e.target.closest && e.target.closest('[data-iv-edit][data-drag]');
|
|
295
|
+
if (t && (e.pointerType === 'touch' || coarse())) {
|
|
296
|
+
LP_off();
|
|
297
|
+
// a touch keeps sending its events to the element it began on: when a read draws the list again mid-press, that element leaves the
|
|
298
|
+
// page and its events no longer reach the document, so it hands them on itself while it is out of the page
|
|
299
|
+
const out = (fn) => (ev) => { if (!t.isConnected) fn(ev); };
|
|
300
|
+
const mv = out(docMove), up = out(docUp), cn = out(docCancel), tm = (ev) => { if (DRAG) ev.preventDefault(); }; // and the page does not scroll
|
|
301
|
+
const off = () => { t.removeEventListener('pointermove', mv); t.removeEventListener('pointerup', up); t.removeEventListener('pointercancel', cn); t.removeEventListener('touchmove', tm); };
|
|
302
|
+
t.addEventListener('pointermove', mv); t.addEventListener('touchmove', tm, { passive: false }); t.addEventListener('pointerup', (ev) => { up(ev); off(); }, { once: true }); t.addEventListener('pointercancel', (ev) => { cn(ev); off(); }, { once: true });
|
|
303
|
+
LP = { x: e.clientX, y: e.clientY, t: setTimeout(() => { LP = null; SUPPRESS = Date.now(); dragStart(body, t.closest('.iv-tr'), { clientX: LPX.x, clientY: LPX.y, pointerId: e.pointerId }); }, 450) };
|
|
304
|
+
LPX = { x: e.clientX, y: e.clientY };
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
body.addEventListener('contextmenu', (e) => { if (e.target.closest && e.target.closest('[data-iv-edit][data-drag]') && coarse()) e.preventDefault(); });
|
|
308
|
+
if (!wire.doc) {
|
|
309
|
+
wire.doc = true;
|
|
310
|
+
document.addEventListener('pointermove', docMove);
|
|
311
|
+
document.addEventListener('pointerup', docUp);
|
|
312
|
+
document.addEventListener('pointercancel', docCancel);
|
|
313
|
+
document.addEventListener('touchmove', (e) => { if (DRAG) e.preventDefault(); }, { passive: false });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function docMove(e) { if (LP) { LPX = { x: e.clientX, y: e.clientY }; if (Math.abs(e.clientX - LP.x) + Math.abs(e.clientY - LP.y) > 10) LP_off(); } if (DRAG) dragMove(e); }
|
|
317
|
+
function docUp() { LP_off(); if (DRAG) dragStop(false); }
|
|
318
|
+
function docCancel() { LP_off(); if (DRAG) dragStop(true); }
|
|
319
|
+
const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
320
|
+
let LP = null, LPX = { x: 0, y: 0 };
|
|
321
|
+
const LP_off = () => { if (LP) { clearTimeout(LP.t); LP = null; } };
|
|
322
|
+
|
|
323
|
+
let DRAG = null;
|
|
324
|
+
function dragStart(body, row, e) {
|
|
325
|
+
if (!row || DRAG) return;
|
|
326
|
+
if (!row.isConnected) { const u = row.dataset.ivR; row = u ? body.querySelector(`.iv-tr[data-iv-r="${cssq(u)}"]`) : null; if (!row) return; }
|
|
327
|
+
const wbs = row.closest('.iv-wbs'), list = row.closest('.iv-wl[data-iv-sec]'); if (!wbs || !list) return;
|
|
328
|
+
const r = row.getBoundingClientRect();
|
|
329
|
+
const fly = row.cloneNode(true);
|
|
330
|
+
fly.classList.add('iv-fly'); fly.removeAttribute('data-iv-r'); fly.setAttribute('aria-hidden', 'true'); fly.setAttribute('data-esc-layer', '');
|
|
331
|
+
fly.querySelectorAll('[id]').forEach((n) => n.removeAttribute('id'));
|
|
332
|
+
fly.style.setProperty('--fly-w', r.width + 'px');
|
|
333
|
+
document.body.appendChild(fly);
|
|
334
|
+
const line = document.createElement('div'); line.className = 'iv-dl'; line.hidden = true; wbs.appendChild(line);
|
|
335
|
+
const tip = document.createElement('div'); tip.className = 'iv-dtip'; tip.hidden = true; document.body.appendChild(tip);
|
|
336
|
+
row.classList.add('iv-ghost');
|
|
337
|
+
document.body.classList.add('iv-dragging');
|
|
338
|
+
DRAG = { body, row, wbs, fly, line, tip, uid: row.dataset.ivR, from: list.dataset.ivSec, dx: e.clientX - r.left, dy: e.clientY - r.top, to: null, before: null };
|
|
339
|
+
dragMove(e);
|
|
340
|
+
}
|
|
341
|
+
// a read that lands mid-drag draws the list again: the ghost and the line follow the new rows
|
|
342
|
+
function live(g) {
|
|
343
|
+
if (!g.wbs.isConnected) { const w = g.body.querySelector('.iv-wbs'); if (w) { g.wbs = w; w.appendChild(g.line); } }
|
|
344
|
+
if (!g.row.isConnected) { const r = g.body.querySelector(`.iv-tr[data-iv-r="${cssq(g.uid)}"]`); if (r) { g.row = r; r.classList.add('iv-ghost'); } }
|
|
345
|
+
}
|
|
346
|
+
function dragMove(e) {
|
|
347
|
+
const g = DRAG; if (!g) return;
|
|
348
|
+
live(g);
|
|
349
|
+
g.fly.style.setProperty('--fly-x', (e.clientX - g.dx) + 'px'); g.fly.style.setProperty('--fly-y', (e.clientY - g.dy) + 'px');
|
|
350
|
+
const el = document.elementFromPoint(e.clientX, e.clientY);
|
|
351
|
+
g.wbs.querySelectorAll('.iv-tgt').forEach((n) => n.classList.remove('iv-tgt'));
|
|
352
|
+
g.to = null; g.before = null; g.line.hidden = true; g.tip.hidden = true;
|
|
353
|
+
if (!el || !g.wbs.contains(el)) return;
|
|
354
|
+
const head = el.closest('.iv-ws[data-iv-sec]');
|
|
355
|
+
const row = el.closest('.iv-tr[data-iv-r]');
|
|
356
|
+
const list = (row && row.closest('.iv-wl[data-iv-sec]')) || el.closest('.iv-wl[data-iv-sec]');
|
|
357
|
+
const W = g.wbs.getBoundingClientRect();
|
|
358
|
+
const at = (y, x0) => { g.line.hidden = false; g.line.style.setProperty('--dl-y', (y - W.top + g.wbs.scrollTop) + 'px'); g.line.style.setProperty('--dl-x', (x0 - W.left) + 'px'); };
|
|
359
|
+
if (head && !row) {
|
|
360
|
+
// a stage's header: the task lands last in that stage
|
|
361
|
+
g.to = head.dataset.ivSec; g.before = null;
|
|
362
|
+
head.classList.add('iv-tgt');
|
|
363
|
+
const L = g.wbs.querySelector(`.iv-wl[data-iv-sec="${cssq(g.to)}"]`), rows = L ? [...L.querySelectorAll(':scope > .iv-tr[data-iv-r]')].filter((n) => n !== g.row) : [];
|
|
364
|
+
const last = rows[rows.length - 1], hr = head.getBoundingClientRect();
|
|
365
|
+
at(last ? last.getBoundingClientRect().bottom : hr.bottom, (last || head).getBoundingClientRect().left);
|
|
366
|
+
} else if (list) {
|
|
367
|
+
g.to = list.dataset.ivSec;
|
|
368
|
+
const h = g.wbs.querySelector(`.iv-ws[data-iv-sec="${cssq(g.to)}"]`); if (h) h.classList.add('iv-tgt');
|
|
369
|
+
const rows = [...list.querySelectorAll(':scope > .iv-tr[data-iv-r]')];
|
|
370
|
+
let y = null, x0 = list.getBoundingClientRect().left;
|
|
371
|
+
for (const n of rows) { const b = n.getBoundingClientRect(); if (e.clientY < b.top + b.height / 2) { g.before = n.dataset.ivR; y = b.top; x0 = b.left; break; } }
|
|
372
|
+
if (y == null) { const n = rows[rows.length - 1]; y = n ? n.getBoundingClientRect().bottom : list.getBoundingClientRect().top; if (n) x0 = n.getBoundingClientRect().left; }
|
|
373
|
+
if (g.before === g.uid) g.before = (() => { const i = rows.findIndex((n) => n.dataset.ivR === g.uid); const nx = rows[i + 1]; return nx ? nx.dataset.ivR : null; })();
|
|
374
|
+
at(y, x0);
|
|
375
|
+
}
|
|
376
|
+
if (g.to != null) {
|
|
377
|
+
const id = g.body.querySelector('[data-iv]').dataset.iv;
|
|
378
|
+
const nm = stageName(id, g.to), where = g.before ? 'in ' + nm : 'last in ' + nm;
|
|
379
|
+
g.tip.textContent = 'Drop: ' + where + '. Its dates stay; Undo puts it back';
|
|
380
|
+
g.tip.style.setProperty('--fly-x', (e.clientX + 18) + 'px'); g.tip.style.setProperty('--fly-y', (e.clientY + 14) + 'px');
|
|
381
|
+
g.tip.hidden = false;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function dragStop(cancel) {
|
|
385
|
+
const g = DRAG; DRAG = null; if (!g) return;
|
|
386
|
+
live(g);
|
|
387
|
+
g.fly.remove(); g.line.remove(); g.tip.remove(); g.row.classList.remove('iv-ghost');
|
|
388
|
+
document.body.classList.remove('iv-dragging');
|
|
389
|
+
g.wbs.querySelectorAll('.iv-tgt').forEach((n) => n.classList.remove('iv-tgt'));
|
|
390
|
+
SUPPRESS = Date.now();
|
|
391
|
+
if (cancel || g.to == null) return;
|
|
392
|
+
const H = g.body.__iv || {}, id = g.body.querySelector('[data-iv]').dataset.iv, v = VIEW.get(id);
|
|
393
|
+
const f = rowOf(v, g.uid), dr = f && f.x.dr;
|
|
394
|
+
const ids = openIds(v, g.to).filter((u) => u !== g.uid);
|
|
395
|
+
const i = g.before ? ids.indexOf(g.before) : -1;
|
|
396
|
+
ids.splice(i < 0 ? ids.length : i, 0, g.uid);
|
|
397
|
+
const was = openIds(v, g.from);
|
|
398
|
+
if (g.to === g.from && was.join('\n') === ids.join('\n')) return;
|
|
399
|
+
OPEN.delete(id);
|
|
400
|
+
if (H.move) H.move(g.uid, { to: g.to, from: g.from, ids: dr ? null : ids, name: stageName(id, g.to) });
|
|
401
|
+
}
|
|
@@ -87,9 +87,9 @@ export const setKanbanStage = (id, key) => { if (id && key != null) STAGE.set(id
|
|
|
87
87
|
|
|
88
88
|
/* ── days, as whole numbers (UTC, so a summer-time night never moves a bar) ── */
|
|
89
89
|
const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
90
|
-
const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
90
|
+
export const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
91
91
|
export const isoN = (n) => new Date(n * 864e5).toISOString().slice(0, 10);
|
|
92
|
-
const md = (n) => { const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
|
|
92
|
+
export const md = (n) => { const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
|
|
93
93
|
/** "Nov 4 → 13", "Nov 28 → Dec 3", "Nov 4": the tip while a bar drags, in the List's words. */
|
|
94
94
|
export function spanText(s, e) {
|
|
95
95
|
if (s == null && e == null) return '';
|
|
@@ -174,12 +174,12 @@ const tkOf = (sec) => (sec.stages ? sec.stages.flatMap((s) => tkOf(s)) : sec.tk
|
|
|
174
174
|
const tkMark = (t) => (t.inJira ? `<span class="ig-sq ${esc(t.cat || 'todo')}" role="img" aria-label="${esc('In Jira: ' + (t.status || 'To do'))}"></span>`
|
|
175
175
|
: `<span class="ig-tkd" role="img" aria-label="Jira ticket drafted, not sent" title="Drafted, not in Jira">${SVG(P.jira, 14, 2)}</span>`);
|
|
176
176
|
const tkTitle = (t) => `<button type="button" class="iv-tt" data-ig-tk="${esc(t.id)}">${t.inJira && t.key ? `<em>${esc(t.key)}</em> ` : ''}${esc(t.title)}</button>`;
|
|
177
|
-
/** A task linked to a Jira ticket it names (ini-view-model.js linkOf): the key once, in blue, then the rest of its title
|
|
178
|
-
* read stays plain text in the title (0.442.0 hotfix). */
|
|
177
|
+
/** A task linked to a Jira ticket it names (ini-view-model.js linkOf): the key once, in blue, then the rest of its title, the same in the List,
|
|
178
|
+
* the Timeline and the Kanban (class lk). A key PMOS has not read stays plain text in the title (0.442.0 hotfix). */
|
|
179
179
|
export function keyName(x) {
|
|
180
180
|
if (!x.jkey) return esc(x.title);
|
|
181
181
|
const rest = String(x.title || '').replace(new RegExp('[\\[(]?\\b' + x.jkey + '\\b[\\])]?\\s*[:\u2013\u2014-]?\\s*'), '').trim();
|
|
182
|
-
return `<em>${esc(x.jkey)}</em>${rest ? ' ' + esc(rest) : ''}`;
|
|
182
|
+
return `<em class="lk">${esc(x.jkey)}</em>${rest ? ' ' + esc(rest) : ''}`;
|
|
183
183
|
}
|
|
184
184
|
/** The Jira mark of a linked task, in place of its box: the status square the ticket rows draw (To do, In progress, Done). Jira owns the
|
|
185
185
|
* status, so it marks nothing here. */
|
|
@@ -210,14 +210,25 @@ export const jiraRow = (k) => ({ uid: k.key, start: k.start || '', end: k.due ||
|
|
|
210
210
|
const ttitle = (k) => `<button type="button" class="iv-tt" data-iv-ticket="${esc(k.key)}"><em>${esc(k.key)}</em> ${esc(k.title)}</button>`;
|
|
211
211
|
/** The date press: the task card's start and due picker opens right under it. No dates: a calendar icon, shown on hover. */
|
|
212
212
|
export function dateBtn(x, o) {
|
|
213
|
-
if (!o.quick || !x.uid) return x.days ? `<span class="${x.late ? 'w' : ''}">${
|
|
214
|
-
const
|
|
213
|
+
if (!o.quick || !x.uid) return x.days ? `<span class="${x.late ? 'w' : ''}">${daysHtml(x)}</span>` : '';
|
|
214
|
+
const one = x.ms && !x.jira ? ' data-one="1"' : '';
|
|
215
|
+
const a = `data-iv-date="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" data-t="${esc(x.title)}"${one} title="${one ? 'The milestone\'s date' : x.jira || x.jkey ? 'Start and due, kept in PMOS. Jira is not changed' : 'Start and due'}"`;
|
|
215
216
|
// a milestone with no due date: a dashed chip asks for it, shown always (canvas XmlA6Suggest)
|
|
216
217
|
if (msNoDate(x)) return `<button type="button" class="iv-dc ms" ${a} aria-label="${esc('Set the due date: ' + x.title)}">${SVG(P.cal, 13)}Set the due date</button>`;
|
|
217
|
-
return x.days ? `<button type="button" class="iv-dc${x.late ? ' w' : ''}" ${a} aria-label="${esc('Dates: ' + x.days + '. Change')}">${
|
|
218
|
+
return x.days ? `<button type="button" class="iv-dc${x.late ? ' w' : ''}" ${a} aria-label="${esc((one ? 'Milestone date: ' : 'Dates: ') + x.days + '. Change')}">${daysHtml(x)}</button>`
|
|
218
219
|
: `<button type="button" class="iv-dc none" ${a} aria-label="${esc('Add dates: ' + x.title)}">${SVG(P.cal, 14)}</button>`;
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
/** A row's days (batch 18 item 16, StA1Rows): a milestone's one day after its ◇ ("◇ Nov 14"); start – due with the start in its own span,
|
|
223
|
+
* which a phone hides (it shows the due day only). */
|
|
224
|
+
export function daysHtml(x) {
|
|
225
|
+
if (x.ms && x.dueText) return `<span class="iv-dms">${SVG(P.dia, 11, 2.4)}</span>${esc(x.dueText)}`;
|
|
226
|
+
if (x.startText && x.dueText && x.start !== x.end) return `<span class="iv-dst">${esc(x.startText)} – </span>${esc(x.dueText)}`;
|
|
227
|
+
return esc(x.days);
|
|
228
|
+
}
|
|
229
|
+
/** A milestone with its day shows ◇ in its date ("◇ Nov 14"), so its title does not repeat the ◇ (say it once). */
|
|
230
|
+
export const msInDate = (x) => !!(x && x.ms && x.dueText && !x.wont);
|
|
231
|
+
|
|
221
232
|
/* ── Timeline ── */
|
|
222
233
|
// Year, 2 years and 5 years show a fixed span: it fills the width the Timeline has (the panel, or the window in full width), never narrower
|
|
223
234
|
// than the zoom's own scale; the name column is the css --nw, clamp(150px, 36cqw, 320px)
|
|
@@ -273,6 +284,10 @@ export function timelineHtml(v, o, isOpen) {
|
|
|
273
284
|
const lw = LK.barWords(x, o.lk);
|
|
274
285
|
const at = `data-ivt-bar="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}"${o.quick && !x.closed ? drag : ''} aria-label="${esc(lbl + (lw ? ', ' + lw : '') + '. Change the dates')}"`;
|
|
275
286
|
if (a == null && b == null) return x.closed || !o.quick ? '' : `<button type="button" class="ivt-g" data-iv-date="${esc(x.uid)}" data-s="" data-e="" data-tlx="${X(today) - 18}" aria-label="${esc('No dates yet. Set dates: ' + x.title)}" title="Set dates">${SVG(P.cal, 13)}</button>`;
|
|
287
|
+
// a milestone is its ◇ on its date, with no bar (batch 18 item 16, StA9Timeline): dragging the ◇ moves the date; its press opens the
|
|
288
|
+
// one-date picker
|
|
289
|
+
if (x.ms && b != null && !x.wont) return `<button type="button" class="ivt-d ${cls} ms" ${at} data-only="due" data-one="1" data-t="${esc(x.title)}" data-tlx="${X(b + 1)}"></button>`
|
|
290
|
+
+ `<span class="ivt-ms lb${x.done ? ' dn' : x.late ? ' lt' : ''}" data-tlx="${X(b + 1)}" aria-hidden="true"><b>${esc(md(b))}</b></span>`;
|
|
276
291
|
// a milestone with a due day only is its ◇ (the guide drops through it), not the due-only circle
|
|
277
292
|
if (a == null) return `<button type="button" class="ivt-d ${cls}${x.ms && !x.wont ? ' ms' : ''}" ${at} data-only="due" data-tlx="${x.ms && !x.wont ? X(b + 1) : X(b) + Math.round(px / 2)}"></button>`;
|
|
278
293
|
const e = b == null ? a : Math.max(a, b);
|
|
@@ -426,7 +441,7 @@ export function allHtml(v, o, isOpen) {
|
|
|
426
441
|
const lb = esc((x.days || '') + (o.quick && x.uid && !x.closed ? '. Change the dates' : ''));
|
|
427
442
|
const at = o.quick && x.uid && !x.closed ? `data-ivt-bar="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}"` : '';
|
|
428
443
|
const tag = at ? 'button' : 'span', open0 = at ? 'button type="button"' : 'span';
|
|
429
|
-
if (x.ms && b != null) return `<${open0} class="iva-md${x.done ? ' dn' : x.late ? ' lt' : ''}" ${at} data-tlx="${pc(b)}" aria-label="${lb}"></${tag}>`;
|
|
444
|
+
if (x.ms && b != null) return `<${open0} class="iva-md${x.done ? ' dn' : x.late ? ' lt' : ''}" ${at}${at ? ` data-one="1" data-t="${esc(x.title)}"` : ''} data-tlx="${pc(b)}" aria-label="${lb}"></${tag}>`;
|
|
430
445
|
const s0 = a == null ? b : a, e0 = b == null ? a : Math.max(a, b);
|
|
431
446
|
return `<${open0} class="iva-tb ${cls}" ${at} data-tlx="${pc(s0)}" data-tlw="${pw(s0, e0)}" aria-label="${lb}"></${tag}>`;
|
|
432
447
|
};
|
|
@@ -477,7 +492,7 @@ export function kanbanHtml(v, o, isOpen) {
|
|
|
477
492
|
return `<div class="ivk-d jr">${jmark(t)}<div class="w">${ttitle(t)}<div class="ivk-m">${d != null ? `<span>${esc(md(d))}</span>` : ''}${t.av ? `<span class="ivt-av" aria-hidden="true">${esc(t.av)}</span>` : ''}</div></div></div>`;
|
|
478
493
|
}
|
|
479
494
|
const x = c.x;
|
|
480
|
-
return `<div class="ivk-d${x.closed ? ' x' : ''}${x.wont ? ' wo' : ''}${x.dr ? ' dr' : ''}${x.jkey ? ' jr' : ''}"${o.quick && x.uid && !x.jkey ? ` draggable="true" data-ivk-card="${esc(x.uid)}" data-st="${esc(x.status)}"` : ''}>${box(x, o)}<div class="w">${title(x, o)}`
|
|
495
|
+
return `<div class="ivk-d${x.closed ? ' x' : ''}${x.wont ? ' wo' : ''}${x.dr ? ' dr' : ''}${x.jkey ? ' jr' : ''}"${o.quick && x.uid && !x.jkey ? ` draggable="true" data-ivk-card="${esc(x.uid)}" data-st="${esc(x.status)}"` : ''}>${box(x, o)}<div class="w">${title(x, o, msInDate(x))}`
|
|
481
496
|
+ `<div class="ivk-m">${dateBtn(x, o)}${LK.metaHtml(x, o.lk, o.quick)}${x.av ? `<span class="ivt-av" aria-hidden="true">${esc(x.av)}</span>` : ''}</div></div></div>`;
|
|
482
497
|
};
|
|
483
498
|
const wop = isOpen('kb:wont', false), nW = by["Won't do"].length;
|
|
@@ -491,9 +506,9 @@ export function kanbanHtml(v, o, isOpen) {
|
|
|
491
506
|
|
|
492
507
|
/* ── the popovers: the task card's own status segment and date picker, opened right under the press ── */
|
|
493
508
|
let POP = null;
|
|
494
|
-
function closePop() { if (!POP) return; const { el, anchor, scrim } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
|
|
509
|
+
export function closePop() { if (!POP) return; const { el, anchor, scrim } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
|
|
495
510
|
/** o.sheet: a bottom sheet over a scrim (a phone); o.right: the popover's right edge under the press's right edge. */
|
|
496
|
-
function openPop(anchor, html, onPress, o = {}) {
|
|
511
|
+
export function openPop(anchor, html, onPress, o = {}) {
|
|
497
512
|
closePop(); cardStyle();
|
|
498
513
|
const el = document.createElement('div');
|
|
499
514
|
el.className = 'tkc ivq' + (o.sheet != null ? ' vs-pop' : '') + (o.sheet ? ' sheet' : ''); el.dataset.escLayer = ''; el.innerHTML = html; // data-esc-layer: Escape closes this first, not the Viewer
|
|
@@ -542,19 +557,28 @@ export function msToggleHtml(on, attr) {
|
|
|
542
557
|
const tip = on ? 'A milestone. Press to make it a plain task' : 'Make it a milestone: its due date shows as ◇ on the Board and the timeline';
|
|
543
558
|
return `<button type="button" class="ivq-ms${on ? ' on' : ''}" ${attr} aria-pressed="${!!on}" aria-label="${esc(on ? 'Milestone' : 'Make it a milestone')}" title="${esc(tip)}">${SVG(P.dia, 15, 2)}${on ? 'Milestone' : ''}</button>`;
|
|
544
559
|
}
|
|
545
|
-
function statusPop(anchor, uid, status, H) {
|
|
546
|
-
|
|
547
|
-
|
|
560
|
+
export function statusPop(anchor, uid, status, H) {
|
|
561
|
+
// the open row's status chip (batch 18 item 16, StA2cStatus) is the five icons only: its ⋯ holds the ◇ and Delete
|
|
562
|
+
const plain = anchor.dataset.plain === '1';
|
|
563
|
+
const ms = !plain && H.milestone && anchor.dataset.ms != null ? anchor.dataset.ms === '1' : null;
|
|
564
|
+
openPop(anchor, statusPopHtml(status, ms, !plain && !!H.remove && deletable(uid)), (b) => {
|
|
548
565
|
if ('ivqMs' in b.dataset) { closePop(); H.milestone(uid, !ms); return; }
|
|
549
566
|
if ('ivqDel' in b.dataset) { closePop(); H.remove(uid); return; }
|
|
550
567
|
const s = b.dataset.ivqState; if (!s) return; closePop(); if (s !== status && H.status) H.status(uid, s);
|
|
551
568
|
});
|
|
552
569
|
}
|
|
553
|
-
|
|
554
|
-
|
|
570
|
+
/** The date picker under a date press (a bottom sheet on a phone, batch 18 item 16 StA3Dates). The press says where it starts: data-f
|
|
571
|
+
* 'start' opens on the start (the open row's Start chip); data-one: a milestone's one day, "◇ Date" with no Start and Due tabs (StA4Milestone). */
|
|
572
|
+
export function datePop(anchor, uid, H) {
|
|
573
|
+
const one = anchor.dataset.one === '1', sheet = PHONE();
|
|
574
|
+
const t = { start: one ? '' : anchor.dataset.s || '', due: anchor.dataset.e || '' }, st = { field: !one && anchor.dataset.f === 'start' ? 'start' : 'due', month: '', one };
|
|
575
|
+
const nm = anchor.dataset.t || '';
|
|
576
|
+
if (sheet) st.head = `<div class="ivd-h">${one ? SVG(P.dia, 15, 2.2) : SVG(P.cal, 15, 2)}<b>${one ? 'Date' : 'Dates'}</b><button type="button" class="iv-ib" data-ivd-x aria-label="Close" title="Close">${SVG('M6 6l12 12M18 6L6 18', 16, 2)}</button></div>`
|
|
577
|
+
+ (nm ? `<p class="ivd-s">${esc(nm + (one ? ' · one date: the milestone' : ''))}</p>` : '');
|
|
555
578
|
const draw = () => { if (!POP || POP.anchor !== anchor) return; POP.el.innerHTML = datePickerHtml(t, st); };
|
|
556
579
|
openPop(anchor, datePickerHtml(t, st), (b) => {
|
|
557
580
|
const d = b.dataset;
|
|
581
|
+
if ('ivdX' in d) { closePop(); return; }
|
|
558
582
|
if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
|
|
559
583
|
if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
|
|
560
584
|
if (d.tkcDay == null) return;
|
|
@@ -565,7 +589,7 @@ function datePop(anchor, uid, H) {
|
|
|
565
589
|
if (H.dates) H.dates(uid, p);
|
|
566
590
|
// after the start, the next tap is the due day; after the due day the picker closes
|
|
567
591
|
if (f === 'start' && iso) { st.field = 'due'; st.month = ''; draw(); } else closePop();
|
|
568
|
-
});
|
|
592
|
+
}, sheet ? { sheet: true } : {});
|
|
569
593
|
}
|
|
570
594
|
function menuPop(anchor, label, items, go) {
|
|
571
595
|
const html = `<div class="tkc-pop ivq-m" role="menu" aria-label="${esc(label)}">${items.map((x, i) => `<button type="button" role="menuitemradio" class="o${x.on ? ' hl' : ''}" aria-checked="${!!x.on}" data-ivq-i="${i}"><span class="ck" aria-hidden="true">${x.on ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(x.label)}</span>${x.count ? `<span class="k">${esc(x.count)}</span>` : ''}</button>`).join('')}</div>`;
|