create-pmos 0.320.0 → 0.322.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/guide/briefing-premium.md +11 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +16 -1
- package/workspace/premium-vw-doc-test.js +218 -0
- package/workspace/premium-vw-jira-test.js +156 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-doc-sheet.js +9 -2
- package/workspace/public/pm/premium-initiative.js +2 -0
- package/workspace/public/pm/premium-report-read.js +20 -2
- package/workspace/public/pm/premium-vw-doc-model.js +184 -0
- package/workspace/public/pm/premium-vw-doc.css +171 -0
- package/workspace/public/pm/premium-vw-doc.js +477 -0
- package/workspace/public/pm/premium-vw-jira-model.js +118 -0
- package/workspace/public/pm/premium-vw-jira.css +79 -0
- package/workspace/public/pm/premium-vw-jira.js +109 -0
- package/workspace/test-lists/premium-viewer-doc.json +13 -0
- package/workspace/test-lists/premium-vw-jira.json +13 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* pm/premium-vw-jira-model.js — the pure half of the Jira views in the premium viewer (initiative premium-viewer, R5 and R6). No DOM, no
|
|
2
|
+
* request: it turns the answers of the two routes the views read into what they draw, so a node test loads it with import().
|
|
3
|
+
* GET /api/jira/tickets?ws&initiative → the initiative's ticket draft and the last Jira reading of each pushed ticket (lib/jira-tickets.js view)
|
|
4
|
+
* GET /api/boards/sprints?ws&board → the board's sprints from the cached Jira readings (scripts/boards.js sprintsOf)
|
|
5
|
+
* Every value comes from one of the two answers. The readings hold titles, statuses, sprints, subtask counts and points only (lib/jira-status.js:
|
|
6
|
+
* "never a description, a comment or a person"), so the ticket draws no assignee and no subtask list, and says that the rest stays in Jira.
|
|
7
|
+
* Nothing here writes to Jira: PMOS owns the ticket text and Jira owns its status (D88). */
|
|
8
|
+
|
|
9
|
+
export const COLS = [['todo', 'To do'], ['doing', 'In progress'], ['done', 'Done']];
|
|
10
|
+
const CAT = { todo: 'To do', doing: 'In progress', done: 'Done' };
|
|
11
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
12
|
+
const str = (s) => (typeof s === 'string' ? s.trim() : '');
|
|
13
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
14
|
+
|
|
15
|
+
/** 2026-10-07 → "7 Oct"; anything else → '' */
|
|
16
|
+
export function day(iso) {
|
|
17
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || ''));
|
|
18
|
+
return m ? +m[3] + ' ' + MON[+m[2] - 1] : '';
|
|
19
|
+
}
|
|
20
|
+
/** A link to Jira only when the reading holds an http(s) address. */
|
|
21
|
+
export const safeUrl = (u) => (/^https?:\/\/[^\s"'<>]+$/i.test(str(u)) ? str(u) : '');
|
|
22
|
+
/** The issue in a sprint read, by key, with the sprint it is in. */
|
|
23
|
+
function inSprints(sprints, key) {
|
|
24
|
+
for (const sp of (sprints && Array.isArray(sprints.sprints) ? sprints.sprints : [])) {
|
|
25
|
+
const i = (sp.issues || []).find((x) => x && x.key === key);
|
|
26
|
+
if (i) return { issue: i, sprint: sp };
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One ticket. view: the /api/jira/tickets answer (or null), ref: a Jira key or a draft ticket id, sprints: the /api/boards/sprints answer (or null).
|
|
33
|
+
* → { ok: true, ... } or { ok: false, why } when no record holds the ticket.
|
|
34
|
+
*/
|
|
35
|
+
export function ticketModel(view, ref, sprints = null) {
|
|
36
|
+
const r = str(ref);
|
|
37
|
+
const tickets = view && view.ok && Array.isArray(view.tickets) ? view.tickets : [];
|
|
38
|
+
const t = tickets.find((x) => x && (x.key === r || x.id === r)) || null;
|
|
39
|
+
const key = t ? t.key || '' : r;
|
|
40
|
+
const hit = key ? inSprints(sprints, key) : null;
|
|
41
|
+
if (!t && !hit) {
|
|
42
|
+
return { ok: false, ref: r, why: view && view.ok === false && view.error ? `The Jira tickets could not be read: ${view.error}.`
|
|
43
|
+
: `${r || 'This ticket'} is not in this initiative's ticket draft or in a sprint read, so there is nothing to show. It may be in Jira only.` };
|
|
44
|
+
}
|
|
45
|
+
const j = t && t.jira ? t.jira : null;
|
|
46
|
+
const sp = (j && j.sprint) || (hit && hit.sprint ? { name: hit.sprint.name, state: hit.sprint.state, start: hit.sprint.start, end: hit.sprint.end } : null);
|
|
47
|
+
const status = (j && j.status) || (hit && hit.issue.status) || '';
|
|
48
|
+
const category = (j && j.category) || (hit && hit.issue.category) || null;
|
|
49
|
+
const names = view && Array.isArray(view.sectionNames) ? view.sectionNames : [];
|
|
50
|
+
const sections = t && t.sections ? names.filter((n) => str(t.sections[n.key])).map((n) => ({ key: n.key, name: n.name, text: t.sections[n.key] })) : [];
|
|
51
|
+
const byId = new Map(tickets.map((x) => [x.id, x]));
|
|
52
|
+
const links = [];
|
|
53
|
+
for (const id of (t && Array.isArray(t.depends) ? t.depends : [])) {
|
|
54
|
+
const d = byId.get(id);
|
|
55
|
+
links.push({ rel: 'depends on', ref: d && d.key ? d.key : id, key: d ? d.key || '' : '', title: d ? d.summary || '' : '', open: !!d });
|
|
56
|
+
}
|
|
57
|
+
for (const x of tickets) if (t && x !== t && Array.isArray(x.depends) && x.depends.includes(t.id)) links.push({ rel: 'blocks', ref: x.key || x.id, key: x.key || '', title: x.summary || '', open: true });
|
|
58
|
+
const sub = j && j.subtasks && Number.isInteger(j.subtasks.total) && j.subtasks.total > 0 ? { done: Math.min(j.subtasks.done || 0, j.subtasks.total), total: j.subtasks.total } : null;
|
|
59
|
+
const epic = view && view.epic && view.epic.key ? { key: view.epic.key, title: view.epic.summary || '' } : null;
|
|
60
|
+
const points = hit && typeof hit.issue.points === 'number' ? hit.issue.points : null;
|
|
61
|
+
const flagged = !!((j && j.flagged) || (hit && hit.issue.flagged));
|
|
62
|
+
return {
|
|
63
|
+
ok: true, id: t ? t.id : '', key, inJira: !!key && (!t || !!t.key), title: (t && t.summary) || (hit && hit.issue.summary) || key,
|
|
64
|
+
type: (t && t.type) || '', priority: (t && t.priority) || '', estimate: (t && t.estimate) || '', points,
|
|
65
|
+
status: status || (t && !t.key ? 'Not in Jira yet' : ''), category: category || (t && !t.key ? 'draft' : 'todo'),
|
|
66
|
+
sprint: sp && sp.name ? { name: sp.name, state: sp.state || '', dates: [day(sp.start), day(sp.end)].filter(Boolean).join(' – ') } : null,
|
|
67
|
+
flagged, reason: flagged ? (j && j.reason) || (hit && hit.issue.reason) || 'Flagged in Jira' : '',
|
|
68
|
+
stale: !!(j && j.stale), sections, subtasks: sub, links, epic, prd: view && view.prd ? String(view.prd) : '',
|
|
69
|
+
initiative: view && view.title ? view.title : '', url: safeUrl(j && j.url),
|
|
70
|
+
readAt: (view && view.checkedAt) || (sprints && sprints.readAt) || null,
|
|
71
|
+
draftOnly: !t, readingOnly: !!t && !!t.key && !j,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The sprints a board can show, in the route's order (active, future, closed), each with what its tab is called. */
|
|
76
|
+
export function sprintList(sprints) {
|
|
77
|
+
const l = sprints && sprints.ok !== false && Array.isArray(sprints.sprints) ? sprints.sprints : [];
|
|
78
|
+
return l.filter((s) => s && s.name).map((s) => ({ name: s.name, state: s.state || '', n: (s.issues || []).length }));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* One sprint as a board by status. sprints: the /api/boards/sprints answer; name: the sprint (default the first, which the route orders active first).
|
|
83
|
+
* → { ok: true, name, ..., cols: [{ cat, label, cards }] } or { ok: false, why }.
|
|
84
|
+
*/
|
|
85
|
+
export function sprintModel(sprints, name, { today } = {}) {
|
|
86
|
+
if (!sprints || sprints.ok === false) return { ok: false, why: `The sprints could not be read${sprints && sprints.error ? ': ' + sprints.error : ''}.` };
|
|
87
|
+
if (sprints.source !== 'jira') return { ok: false, why: 'No sprint is on record for this board. A sprint appears when an agent session has read Jira for it.' };
|
|
88
|
+
const all = Array.isArray(sprints.sprints) ? sprints.sprints : [];
|
|
89
|
+
const sp = (name && all.find((s) => s.name === name)) || all[0];
|
|
90
|
+
if (!sp) return { ok: false, why: 'Jira was read, but none of this board\'s tickets is in a sprint.' };
|
|
91
|
+
const goal = sp.goal && typeof sp.goal === 'object' ? str(sp.goal.text) : str(sp.jiraGoal);
|
|
92
|
+
const pts = sp.points && Number.isFinite(sp.points.committed) ? { done: sp.points.done, committed: sp.points.committed, unestimated: sp.points.unestimated || 0 } : null;
|
|
93
|
+
const pace = sp.pace || null;
|
|
94
|
+
let left = '';
|
|
95
|
+
if (sp.state === 'active' && pace && Number.isInteger(pace.daysLeft)) left = pace.daysLeft === 0 ? 'ends today' : plural(pace.daysLeft, 'day', 'days') + ' left';
|
|
96
|
+
else if (sp.state === 'active' && sp.end && today) {
|
|
97
|
+
const a = Date.parse(String(sp.end).slice(0, 10)), b = Date.parse(String(today).slice(0, 10));
|
|
98
|
+
if (Number.isFinite(a) && Number.isFinite(b)) { const d = Math.round((a - b) / 864e5); left = d < 0 ? 'ended ' + plural(-d, 'day', 'days') + ' ago' : d === 0 ? 'ends today' : plural(d, 'day', 'days') + ' left'; }
|
|
99
|
+
}
|
|
100
|
+
const cards = (sp.issues || []).map((i) => ({ key: i.key, title: i.summary || i.key, status: i.status || CAT[i.category] || '', cat: CAT[i.category] ? i.category : 'todo',
|
|
101
|
+
points: typeof i.points === 'number' ? i.points : null, initiative: i.initiative || null, flagged: !!i.flagged, reason: i.flagged ? i.reason || 'Flagged in Jira' : '' }));
|
|
102
|
+
const cols = COLS.map(([cat, label]) => ({ cat, label, cards: cards.filter((c) => c.cat === cat) }));
|
|
103
|
+
const other = cards.filter((c) => !c.initiative).length;
|
|
104
|
+
return {
|
|
105
|
+
ok: true, name: sp.name, state: sp.state || '', dates: [day(sp.start), day(sp.end)].filter(Boolean).join(' – '), goal, left, points: pts,
|
|
106
|
+
counts: { todo: cols[0].cards.length, doing: cols[1].cards.length, done: cols[2].cards.length }, total: cards.length, cols, other,
|
|
107
|
+
readAt: sprints.readAt || null, sprints: sprintList(sprints),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** "read 14:05" or "read 17 Oct" from an ISO time, against now. */
|
|
112
|
+
export function readLine(iso, now = Date.now()) {
|
|
113
|
+
const t = Date.parse(String(iso || ''));
|
|
114
|
+
if (!Number.isFinite(t)) return 'no read time on record';
|
|
115
|
+
const d = new Date(t), n = new Date(now);
|
|
116
|
+
const same = d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth() && d.getDate() === n.getDate();
|
|
117
|
+
return 'read ' + (same ? String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0') : d.getDate() + ' ' + MON[d.getMonth()]);
|
|
118
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
:root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
|
|
2
|
+
/* pm/premium-vw-jira.css — the Jira ticket and sprint tabs of the premium viewer (initiative premium-viewer, S5). Loaded once by
|
|
3
|
+
* pm/premium-vw-jira.js. Console type only: sizes var(--fs-1..6), weights 400, 500 and 600. */
|
|
4
|
+
.jv{max-width:900px;margin:0 auto;display:grid;gap:12px;min-width:0}
|
|
5
|
+
.jv .i{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}
|
|
6
|
+
.jv .gap{flex:1}
|
|
7
|
+
.jk{font:500 var(--fs-2) var(--mono);color:var(--ink-3);white-space:nowrap}
|
|
8
|
+
.jnote{margin:0;font-size:var(--fs-2);color:var(--ink-3);line-height:1.5}
|
|
9
|
+
.jbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 6px 6px 10px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);font-size:var(--fs-2);color:var(--ink-2)}
|
|
10
|
+
.jbt{flex:1;min-width:0}
|
|
11
|
+
.jbt b{font-weight:600;color:var(--ink)}
|
|
12
|
+
.jlg{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;background:var(--solid);color:var(--on-solid);font:600 var(--fs-1) var(--sans);flex:none}
|
|
13
|
+
.jbtn{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 12px;border-radius:6px;border:1px solid var(--hair);background:transparent;color:var(--ink);font:500 var(--fs-2) var(--sans);text-decoration:none;cursor:pointer}
|
|
14
|
+
.jbtn:focus-visible,.jcrd:focus-visible,.jln button:focus-visible,.jseg button:focus-visible,.jfoot a:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
15
|
+
.jempty{padding:22px;border:1px dashed var(--hair);border-radius:8px;text-align:center;color:var(--ink-2)}
|
|
16
|
+
.jempty b{display:block;font-size:var(--fs-3);font-weight:600;color:var(--ink);margin-bottom:4px}
|
|
17
|
+
.jempty p{margin:0;font-size:var(--fs-2)}
|
|
18
|
+
/* ticket */
|
|
19
|
+
.jtk{background:var(--card-solid);border:1px solid var(--hair);border-radius:8px;padding:22px 24px;box-shadow:var(--card-shadow);min-width:0;overflow-wrap:anywhere}
|
|
20
|
+
.jbc{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:var(--fs-2);color:var(--ink-3);margin-bottom:6px}
|
|
21
|
+
.jtk h1{font-size:var(--fs-5);line-height:1.3;font-weight:600;margin:0 0 10px;color:var(--ink)}
|
|
22
|
+
.jtk h3{font-size:var(--fs-3);font-weight:600;margin:18px 0 6px;color:var(--ink)}
|
|
23
|
+
.jmeta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 6px}
|
|
24
|
+
.jst{display:inline-flex;align-items:center;height:28px;padding:0 10px;border-radius:6px;font:600 var(--fs-1) var(--sans);text-transform:uppercase;letter-spacing:.03em;background:var(--well);color:var(--ink-2)}
|
|
25
|
+
.jst.doing{background:color-mix(in oklab,var(--sky,rgb(29,122,252)) 16%,transparent);color:var(--ink)}
|
|
26
|
+
.jst.done{background:color-mix(in oklab,var(--ok) 16%,transparent);color:var(--ok)}
|
|
27
|
+
.jst.draft{background:transparent;border:1px dashed var(--hair);color:var(--ink-3)}
|
|
28
|
+
.jchip{display:inline-flex;align-items:center;height:28px;padding:0 10px;border-radius:6px;border:1px solid var(--hair);font-size:var(--fs-2);color:var(--ink-2)}
|
|
29
|
+
.jchip.mut{color:var(--ink-3)}
|
|
30
|
+
.jpts{min-width:22px;height:20px;padding:0 7px;border-radius:6px;background:var(--well);font:600 var(--fs-1)/20px var(--sans);text-align:center;color:var(--ink-2);flex:none}
|
|
31
|
+
.jmeta .jpts{height:28px;line-height:28px}
|
|
32
|
+
.jflag{display:flex;align-items:center;gap:6px;margin:8px 0 0;font-size:var(--fs-2);font-weight:500;color:var(--bad)}
|
|
33
|
+
.jbody{font-size:var(--fs-3);line-height:1.5;color:var(--ink)}
|
|
34
|
+
.jmd>:first-child{margin-top:0}.jmd>:last-child{margin-bottom:0}
|
|
35
|
+
.jmd p,.jmd ul,.jmd ol{margin:0 0 8px}
|
|
36
|
+
.jmd ul,.jmd ol{padding-left:20px}
|
|
37
|
+
.jmd code{font:400 var(--fs-2) var(--mono)}
|
|
38
|
+
.jprog{height:6px;border-radius:6px;background:var(--well);overflow:hidden;margin:0 0 6px}
|
|
39
|
+
.jprog i{display:block;height:100%;width:var(--bd-w,0);background:var(--ok);border-radius:6px}
|
|
40
|
+
.jlinks{display:grid}
|
|
41
|
+
.jln{display:flex;align-items:center;gap:8px;min-height:44px;border-top:1px solid var(--hair);font-size:var(--fs-3)}
|
|
42
|
+
.jln:first-child{border-top:0}
|
|
43
|
+
.jln em{font-style:normal;font-size:var(--fs-2);color:var(--ink-3);width:76px;flex:none}
|
|
44
|
+
.jln button,.jlx{display:flex;align-items:center;gap:7px;min-height:44px;min-width:0;padding:0;border:0;background:none;color:var(--ink);font:inherit;text-align:left}
|
|
45
|
+
.jln button{cursor:pointer}
|
|
46
|
+
.jln b{font-weight:500;min-width:0;overflow-wrap:anywhere}
|
|
47
|
+
.jfoot{margin:18px 0 0;padding-top:12px;border-top:1px solid var(--hair);font-size:var(--fs-2);color:var(--ink-3)}
|
|
48
|
+
.jfoot a{color:var(--ink);font-weight:500}
|
|
49
|
+
/* sprint */
|
|
50
|
+
.jseg{display:flex;gap:6px;flex-wrap:wrap}
|
|
51
|
+
.jseg button{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:0 12px;border-radius:6px;border:1px solid var(--hair);background:transparent;color:var(--ink-2);font:500 var(--fs-2) var(--sans);cursor:pointer}
|
|
52
|
+
.jseg button small{font-size:var(--fs-1);color:var(--ink-3)}
|
|
53
|
+
.jseg button[aria-pressed="true"]{background:var(--solid);border-color:var(--solid);color:var(--on-solid)}
|
|
54
|
+
.jseg button[aria-pressed="true"] small{color:inherit}
|
|
55
|
+
.jsh{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:var(--card-solid);border:1px solid var(--hair);border-radius:8px;padding:12px 16px;box-shadow:var(--card-shadow)}
|
|
56
|
+
.jsh h3{margin:0;font-size:var(--fs-4);font-weight:600;color:var(--ink)}
|
|
57
|
+
.jsh p{margin:2px 0 0;font-size:var(--fs-2);color:var(--ink-3)}
|
|
58
|
+
.jsh>div{min-width:0}
|
|
59
|
+
.jcap{display:flex;align-items:center;gap:8px;font-size:var(--fs-2);color:var(--ink-3)}
|
|
60
|
+
.jcap i{display:block;width:90px;height:6px;border-radius:6px;background:var(--well);overflow:hidden;position:relative}
|
|
61
|
+
.jcap i::after{content:"";position:absolute;inset:0;width:var(--bd-w,0);background:var(--ok);border-radius:6px}
|
|
62
|
+
.jbrd{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}
|
|
63
|
+
.jcol{background:color-mix(in oklab,var(--well) 80%,transparent);border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:7px;min-width:0}
|
|
64
|
+
.jcolh{display:flex;justify-content:space-between;font:600 var(--fs-1) var(--mono);letter-spacing:.07em;text-transform:uppercase;color:var(--ink-3);padding:4px 4px 2px}
|
|
65
|
+
.jnone{margin:0;padding:6px 4px;font-size:var(--fs-2);color:var(--ink-3)}
|
|
66
|
+
.jcrd{display:grid;gap:8px;min-height:44px;padding:9px 10px;border-radius:6px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink);font:inherit;text-align:left;box-shadow:0 1px 2px rgba(0,0,0,.04);min-width:0;overflow-wrap:anywhere}
|
|
67
|
+
button.jcrd{cursor:pointer}
|
|
68
|
+
.jcrd b{font-size:var(--fs-2);font-weight:500;line-height:1.4}
|
|
69
|
+
.jcrd.off{background:transparent;border-style:dashed}
|
|
70
|
+
.jcrd.risk{border-color:color-mix(in oklab,var(--bad) 45%,var(--hair))}
|
|
71
|
+
.jrk{display:flex;align-items:center;gap:5px;font-size:var(--fs-1);font-weight:600;color:var(--bad)}
|
|
72
|
+
.jft{display:flex;align-items:center;gap:6px;min-width:0}
|
|
73
|
+
.jsx{font-size:var(--fs-1);color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
74
|
+
@media (max-width:640px){
|
|
75
|
+
.jtk{padding:16px}
|
|
76
|
+
.jbtn,.jseg button{min-height:44px}
|
|
77
|
+
.jbrd{grid-template-columns:1fr}
|
|
78
|
+
}
|
|
79
|
+
@media (hover:hover){.jbtn:hover{background:var(--well)}.jln button:hover b{text-decoration:underline}button.jcrd:hover{box-shadow:0 6px 16px -10px rgba(0,0,0,.35)}}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* pm/premium-vw-jira.js — a Jira ticket and a sprint board as tabs of the premium viewer (initiative premium-viewer, S5, PRD R5 and R6).
|
|
2
|
+
* openTicket({ ws, board, initiative, ref }) a ticket of the initiative's Jira draft: key, title, status, sprint, points, its sections,
|
|
3
|
+
* subtasks and links, and a line that sends the rest to Jira (PM, 2026-10-19: no comments,
|
|
4
|
+
* history or fields panel; those stay in Jira)
|
|
5
|
+
* openSprint({ ws, board, name }) a sprint of the board as columns by status; a card of the board opens its ticket
|
|
6
|
+
* Reads GET /api/jira/tickets and GET /api/boards/sprints only; the model is pm/premium-vw-jira-model.js. Read-only: Jira owns status, sprint and
|
|
7
|
+
* assignee (D88), so nothing here moves a ticket. With no Jira data a view says what is missing. */
|
|
8
|
+
import { vwOpen, vwStyle } from './premium-viewer.js';
|
|
9
|
+
import { mdRender } from './markdown.js';
|
|
10
|
+
import { esc, toast } from './premium-shell.js';
|
|
11
|
+
import { ticketModel, sprintModel, readLine } from './premium-vw-jira-model.js';
|
|
12
|
+
|
|
13
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
14
|
+
const EXT = ICO('<path d="M14 4h6v6M20 4l-9 9M18 14v6H4V6h6"/>');
|
|
15
|
+
const LINK = ICO('<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>');
|
|
16
|
+
const DOC = ICO('<path d="M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5"/>');
|
|
17
|
+
const FLAG = ICO('<path d="M5 21V4M5 4h11l-2 4 2 4H5"/>');
|
|
18
|
+
|
|
19
|
+
async function getJson(p, q) {
|
|
20
|
+
const s = new URLSearchParams(Object.entries(q).filter(([, v]) => v)).toString();
|
|
21
|
+
try { const r = await fetch(p + (s ? '?' + s : ''), { credentials: 'same-origin' }); return await r.json(); } catch { return null; }
|
|
22
|
+
}
|
|
23
|
+
// mdRender builds nodes, never a string, so nothing in a ticket's text runs
|
|
24
|
+
const md = (t) => { try { const d = document.createElement('div'); d.append(...mdRender(String(t)).blocks.map((b) => b.node || b)); return d.innerHTML; } catch { return `<p>${esc(t)}</p>`; } };
|
|
25
|
+
const bar = (what, m) => `<div class="jbar"><span class="jlg" aria-hidden="true">J</span><span class="jbt"><b>From the last Jira read</b> · ${esc(what)} · ${esc(readLine(m.readAt))}</span>${m.url ? `<a class="jbtn" href="${esc(m.url)}" target="_blank" rel="noopener">${EXT}Open in Jira</a>` : ''}<button type="button" class="jbtn" data-jre>Read again</button></div>`;
|
|
26
|
+
// the bars' widths are run-time geometry, set as a property rather than an inline style
|
|
27
|
+
const bars = (el) => el.querySelectorAll('[data-pct]').forEach((i) => i.style.setProperty('--bd-w', Math.max(0, Math.min(100, +i.dataset.pct || 0)) + '%'));
|
|
28
|
+
const empty = (why) => `<div class="jv"><div class="jempty"><b>Nothing to show</b><p>${esc(why)}</p></div></div>`;
|
|
29
|
+
|
|
30
|
+
/* ── the ticket ─────────────────────────────────────────────────────────────────────────────────────────── */
|
|
31
|
+
function ticketHtml(m) {
|
|
32
|
+
if (!m.ok) return empty(m.why);
|
|
33
|
+
const chips = [
|
|
34
|
+
m.sprint ? `<span class="jchip" title="Sprint">${esc(m.sprint.name)}${m.sprint.state ? ` · ${esc(m.sprint.state)}` : ''}</span>` : '<span class="jchip mut" title="Sprint">No sprint</span>',
|
|
35
|
+
m.points != null ? `<span class="jpts" title="Story points">${esc(m.points)} pt</span>` : '',
|
|
36
|
+
m.priority ? `<span class="jchip" title="Priority">${esc(m.priority)}</span>` : '',
|
|
37
|
+
m.estimate ? `<span class="jchip" title="Estimate">Size ${esc(m.estimate)}</span>` : '',
|
|
38
|
+
m.type ? `<span class="jchip" title="Type">${esc(m.type)}</span>` : '',
|
|
39
|
+
].join('');
|
|
40
|
+
const sub = m.subtasks ? `<h3>Subtasks <span class="jk">· ${m.subtasks.done} of ${m.subtasks.total} done</span></h3><div class="jprog" role="img" aria-label="${m.subtasks.done} of ${m.subtasks.total} subtasks done"><i data-pct="${Math.round(m.subtasks.done / m.subtasks.total * 100)}"></i></div><p class="jnote">The Jira read holds the count, not the list. Open Jira for the subtasks.</p>` : '';
|
|
41
|
+
const links = m.links.length || m.prd ? `<h3>Linked</h3><div class="jlinks">${m.links.map((l) => `<div class="jln"><em>${esc(l.rel)}</em>${l.open
|
|
42
|
+
? `<button type="button" data-jt="${esc(l.ref)}">${LINK}<span class="jk">${esc(l.key || l.ref)}</span><b>${esc(l.title)}</b></button>`
|
|
43
|
+
: `<span class="jlx">${LINK}<span class="jk">${esc(l.ref)}</span></span>`}</div>`).join('')}${m.prd ? `<div class="jln"><em>from</em><span class="jlx">${DOC}<b>${esc(m.prd)}</b></span></div>` : ''}</div>` : '';
|
|
44
|
+
const body = m.sections.length ? m.sections.map((s) => `<h3>${esc(s.name)}</h3><div class="jmd">${md(s.text)}</div>`).join('')
|
|
45
|
+
: `<p class="jnote">${m.draftOnly ? 'This ticket is not in the initiative\'s ticket draft, so PMOS holds no text for it. Its title, status and points come from the sprint read.' : 'The ticket draft holds no text for this ticket.'}</p>`;
|
|
46
|
+
return `<div class="jv">${bar('ticket', m)}<article class="jtk">
|
|
47
|
+
<div class="jbc">${m.epic ? `<span class="jk">${esc(m.epic.key)}</span>${m.epic.title ? ` ${esc(m.epic.title)}` : ''} <span aria-hidden="true">/</span> ` : m.initiative ? `${esc(m.initiative)} <span aria-hidden="true">/</span> ` : ''}<span class="jk">${esc(m.key || m.id)}</span></div>
|
|
48
|
+
<h1>${esc(m.title)}</h1>
|
|
49
|
+
<div class="jmeta"><span class="jst ${esc(m.category)}">${esc(m.status || 'No status read')}</span>${chips}</div>
|
|
50
|
+
${m.flagged ? `<p class="jflag">${FLAG}${esc(m.reason)}</p>` : ''}
|
|
51
|
+
${m.stale ? '<p class="jnote">The last Jira check did not return this ticket, so this is an older reading.</p>' : ''}
|
|
52
|
+
${m.readingOnly ? '<p class="jnote">This ticket is in Jira, but no Jira check has read it yet.</p>' : ''}
|
|
53
|
+
<div class="jbody">${body}</div>${sub}${links}
|
|
54
|
+
<p class="jfoot">Assignee, comments, history and the other fields stay in Jira.${m.url ? ` <a href="${esc(m.url)}" target="_blank" rel="noopener">Open in Jira</a>` : m.inJira ? ' The reading holds no link to the ticket.' : ' This ticket is not in Jira yet; push it from the initiative\'s Jira tickets tab.'}</p>
|
|
55
|
+
</article></div>`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A ticket of the initiative's Jira draft in its own tab. ref is a Jira key or a draft ticket id. */
|
|
59
|
+
export async function openTicket(o) {
|
|
60
|
+
const { ws, board, initiative, ref } = o || {};
|
|
61
|
+
if (!ref) return null;
|
|
62
|
+
vwStyle('jira');
|
|
63
|
+
const id = 'jira:' + ref;
|
|
64
|
+
const draw = async (el) => {
|
|
65
|
+
el.innerHTML = '<div class="jv"><p class="jnote">Reading the ticket</p></div>';
|
|
66
|
+
const [view, sprints] = await Promise.all([initiative ? getJson('/api/jira/tickets', { ws, initiative }) : null, board ? getJson('/api/boards/sprints', { ws, board }) : null]);
|
|
67
|
+
const m = ticketModel(view, ref, sprints);
|
|
68
|
+
el.innerHTML = ticketHtml(m); bars(el);
|
|
69
|
+
el.querySelectorAll('[data-jt]').forEach((b) => { b.onclick = () => openTicket({ ws, board, initiative, ref: b.dataset.jt }); });
|
|
70
|
+
const re = el.querySelector('[data-jre]'); if (re) re.onclick = async () => { await draw(el); toast('Read the cached Jira reading again. A Jira check reads Jira itself.'); };
|
|
71
|
+
};
|
|
72
|
+
return vwOpen({ id, title: ref, icon: 'tk', render: (el) => { draw(el); } });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ── the sprint ─────────────────────────────────────────────────────────────────────────────────────────── */
|
|
76
|
+
function sprintHtml(m) {
|
|
77
|
+
if (!m.ok) return empty(m.why);
|
|
78
|
+
const pick = m.sprints.length > 1 ? `<div class="jseg" role="group" aria-label="Sprint">${m.sprints.map((s) => `<button type="button" data-sp="${esc(s.name)}" aria-pressed="${s.name === m.name}">${esc(s.name)}${s.state ? `<small>${esc(s.state)}</small>` : ''}</button>`).join('')}</div>` : '';
|
|
79
|
+
const pts = m.points ? `<span class="jcap"><i data-pct="${m.points.committed ? Math.round(m.points.done / m.points.committed * 100) : 0}"></i>${m.points.done} of ${m.points.committed} points done</span>`
|
|
80
|
+
: `<span class="jcap">${m.counts.done} of ${m.total} done · no points on record</span>`;
|
|
81
|
+
const card = (c) => {
|
|
82
|
+
const inner = `<b>${esc(c.title)}</b>${c.flagged ? `<span class="jrk">${FLAG}${esc(c.reason)}</span>` : ''}<span class="jft"><span class="jk">${esc(c.key)}</span>${c.status && c.status !== m.cols.find((x) => x.cat === c.cat).label ? `<span class="jsx">${esc(c.status)}</span>` : ''}<span class="gap"></span>${c.points != null ? `<span class="jpts">${esc(c.points)}</span>` : ''}</span>`;
|
|
83
|
+
return c.initiative ? `<button type="button" class="jcrd${c.flagged ? ' risk' : ''}" data-k="${esc(c.key)}" data-ini="${esc(c.initiative)}" aria-label="${esc(c.key)}: ${esc(c.title)}. Open the ticket">${inner}</button>`
|
|
84
|
+
: `<div class="jcrd off${c.flagged ? ' risk' : ''}" title="Not a ticket of this board">${inner}</div>`;
|
|
85
|
+
};
|
|
86
|
+
return `<div class="jv">${bar(m.name, m)}${pick}
|
|
87
|
+
<div class="jsh"><div><h3>${esc(m.name)}${m.dates ? ` · ${esc(m.dates)}` : ''}</h3><p>${[m.goal ? 'Goal: ' + m.goal : 'No sprint goal on record', m.left || m.state].filter(Boolean).map(esc).join(' · ')}</p></div><span class="gap"></span>${pts}</div>
|
|
88
|
+
<div class="jbrd">${m.cols.map((c) => `<section class="jcol" aria-label="${esc(c.label)}, ${c.cards.length}"><div class="jcolh"><span>${esc(c.label)}</span><span>${c.cards.length}</span></div>${c.cards.map(card).join('') || '<p class="jnone">None</p>'}</section>`).join('')}</div>
|
|
89
|
+
<p class="jnote">Read-only: Jira owns each ticket's status and sprint, so move a ticket in Jira.${m.other ? ` ${m.other} ${m.other === 1 ? 'ticket is' : 'tickets are'} in this sprint but on no initiative of this board, so ${m.other === 1 ? 'it has' : 'they have'} no ticket here.` : ''} Tickets with no sprint are not in this read.</p></div>`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The board's sprints as a board by status in one tab; name picks a sprint (default: the active one). */
|
|
93
|
+
export async function openSprint(o) {
|
|
94
|
+
const { ws, board } = o || {};
|
|
95
|
+
let name = (o && o.name) || '';
|
|
96
|
+
vwStyle('jira');
|
|
97
|
+
const draw = async (el) => {
|
|
98
|
+
el.innerHTML = '<div class="jv"><p class="jnote">Reading the sprint</p></div>';
|
|
99
|
+
const sprints = await getJson('/api/boards/sprints', { ws, board });
|
|
100
|
+
const m = sprintModel(sprints, name, { today: new Date().toISOString() });
|
|
101
|
+
el.innerHTML = sprintHtml(m); bars(el);
|
|
102
|
+
el.querySelectorAll('[data-sp]').forEach((b) => { b.onclick = () => { name = b.dataset.sp; draw(el); }; });
|
|
103
|
+
el.querySelectorAll('.jcrd[data-k]').forEach((b) => { b.onclick = () => openTicket({ ws, board, initiative: b.dataset.ini, ref: b.dataset.k }); });
|
|
104
|
+
const re = el.querySelector('[data-jre]'); if (re) re.onclick = async () => { await draw(el); toast('Read the cached Jira reading again. A Jira check reads Jira itself.'); };
|
|
105
|
+
};
|
|
106
|
+
return vwOpen({ id: 'sprint:' + (board || ''), title: 'Sprint', icon: 'list', render: (el) => { draw(el); } });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (typeof window !== 'undefined') window.__premiumVwJira = { openTicket, openSprint };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-viewer S2: a markdown document as a page in the premium viewer — read, edit in place or as Markdown, and an agent's edit applied and highlighted with Keep and Undo all (the model in node; the page against the real server with the /api/doc-sheet routes stood in).",
|
|
3
|
+
"modules": [
|
|
4
|
+
"premium-vw-doc.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"premium-vw-doc.test.js": 1,
|
|
8
|
+
"premium-vw-doc-test.js": 40
|
|
9
|
+
},
|
|
10
|
+
"panels": [
|
|
11
|
+
"premium-vw-doc-test.js"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-viewer S5: the Jira ticket and sprint tabs of the premium viewer. The pure model, and the views in a real browser with the Board model and the two Jira reads as route stand-ins.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"premium-vw-jira.test.js"
|
|
5
|
+
],
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-vw-jira-test.js"
|
|
8
|
+
],
|
|
9
|
+
"seconds": {
|
|
10
|
+
"premium-vw-jira.test.js": 1,
|
|
11
|
+
"premium-vw-jira-test.js": 40
|
|
12
|
+
}
|
|
13
|
+
}
|