create-pmos 0.321.0 → 0.323.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 +4 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-viewer-test.js +1 -1
- package/workspace/premium-vw-cal-test.js +155 -0
- package/workspace/premium-vw-jira-test.js +156 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-initiative.js +2 -0
- package/workspace/public/pm/premium-meeting.js +1 -1
- package/workspace/public/pm/premium-vw-cal.css +96 -0
- package/workspace/public/pm/premium-vw-cal.js +197 -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/public/pm/premium.js +2 -0
- package/workspace/test-lists/premium-vw-cal.json +13 -0
- package/workspace/test-lists/premium-vw-jira.json +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.323.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -119,6 +119,8 @@ Above the list, with today picked, a ring shows how many of the meetings still a
|
|
|
119
119
|
|
|
120
120
|
With another day picked, the card lists that day's meetings from the calendar PMOS holds, and the items due that day. It reads the week once when the page opens. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. Picking a day changes only what the card shows and records nothing.
|
|
121
121
|
|
|
122
|
+
**The full calendar.** The button beside the filter in the card's title row opens the calendar in a dialog. **Day**, **Week** and **Month** each read the calendar PMOS holds for that range; the arrows move one day, week or month, and **Today** comes back. Week is a timeline from Monday to Friday, with Saturday and Sunday only when they hold something; meetings at the same time sit side by side, and the all-day row shows the dated marks the Calendar reads (a promised date, a plan item, a release, a report, your own due items). In a narrow dialog, such as on a phone, Day and Week are a list of days. In Month, press a day to open it. Press a meeting to open its meeting dialog; the calendar stays as a **Calendar** tab beside it, at the same view. An empty range says "No meetings in this week" (or day, or month), and a calendar that cannot be read says "Calendar not read" with the reason.
|
|
123
|
+
|
|
122
124
|
Press a meeting, from today or from another day, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
|
|
123
125
|
|
|
124
126
|
When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. The **Material** part has **Add material** and a **Remove** on each row. Add material opens a sheet in the dialog with three ways to pick: **Suggested** (the documents of the meeting's initiative and the newest report cycles), **Find in PMOS** (type two letters or more) and **Paste a link** (an https address). A **For** choice says whether the material belongs to this meeting or to every meeting in the series. Before you press Add, the sheet says what it records: one line in PMOS's own record of the meeting. The calendar invite is never changed. After a write, the list is read again from the record. Remove names its scope and says the document itself is not changed. A few seconds of **Undo** put a removed item back.
|
|
@@ -258,7 +260,7 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
|
|
|
258
260
|
- **List** shows the late and at-risk initiatives first, then the board's now view, up to 100 loaded and 25 on screen at a time. A row shows the owner and lane, a status chip when it is not on track, how far through the workflow it is (and "derived" when the workflow engine placed it), a progress bar only when a record holds progress, and the planned finish only when an end date was set ("Not planned" otherwise). "Do this first" appears only when the first row is late.
|
|
259
261
|
- **By stage** has one column for each stage of the board's workflow with the board's own count and its first five initiatives.
|
|
260
262
|
- **List** and **Timeline** show ten tasks a page with Previous and Next; **By stage** shows six cards a column with Show more. **Timeline** draws a bar for each initiative that has both a start and an end date, with the days left or over, and counts the rest. With no dates on record it says so and draws nothing.
|
|
261
|
-
- **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. **Coming up** shows the next release, from the releases ledger.
|
|
263
|
+
- **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. Press it to open the sprint's facts, with the sprint as a board in a second tab: **To do**, **In progress** and **Done** columns from the last Jira read, with the goal, the dates, the days left and the points. When the board has more than one sprint, you can switch to another one. Press a card to open its ticket in another tab. A card that is on no initiative of this board is drawn, but it does not open. The board is read only: Jira owns each ticket's status and sprint, so you move tickets in Jira. Tickets with no sprint are not in this read. **Coming up** shows the next release, from the releases ledger.
|
|
262
264
|
- **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine, which keeps no history. From the first day the card is read, PMOS keeps their counts once a day in the workspace's state folder (`board-metric-history.jsonl`), so their charts start on that day and their caption says **history starts today** (later, the date). Earlier weeks read **Not kept yet**. Move over a chart, or use the arrow keys, to read a week. A tile that cannot be counted says **Not read** and why; a repository with no run log says **No runs yet**. The line above the tiles starts with how many tiles need a look, and those tiles have a **Needs a look** chip and an orange outline. The line ends with **open Insights**, which opens the same board's Insights page. Press a tile for its definition and values, with the read-only agent beside it. A target is set on Insights, not here. A measure with a target shows it under the value, draws it as a dashed line, and carries **On target** or its gap (for example **2 short**); off target, it also has the orange outline. A measure without a target draws no line. Day and Month are off. It was tested only on made-up repositories, not on a real IDPF or microsite repository.
|
|
263
265
|
- **The top bar** names the page and the board. With more than one board a menu switches between them, and **Chat** opens the board in the dialog with the read-only agent.
|
|
264
266
|
- **Core documents** lists the board's documents with their state, cadence and writer, a summary (drafts to review, not started, up to date), a progress bar, a filter and a search. A document with a file opens in the dialog, read only, with its path and state; a draft there has **Issue it**, which marks it issued through the console's own route and sends nothing, and **Draft it again**, which starts a new draft that replaces this one (a board draft has no Edit tab). **Draft it** starts the existing read-only run that writes a draft and sends nothing; **Draft the N not started** does that for each document that can be drafted. **Set it up** and **Open** go to the console. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
|
|
@@ -279,7 +281,7 @@ The initiative page is at `/premium-initiative.html?id=<initiative>`. A click on
|
|
|
279
281
|
- **The header** shows a status chip, the owner and the planned finish. Each appears only when a record holds it. Under it, the stage strip shows how far through the board's workflow the initiative is.
|
|
280
282
|
- **Overview** shows the description (the part of the record's title after " — "), then the next step with its reason, its action and what happens if you wait, as the workflow engine states them, and who it waits on. **PMOS can help** offers up to three presses that do something real: a draft of the first core document not started (the existing read-only run) and a question for the read-only agent. The health reasons and the board's warnings are shown as written.
|
|
281
283
|
- **Overview** is one full-width card, as in the mockup; there is no separate Checks card. A blocked step shows as a note, and "All N workflow steps" lists every step of the engine with the evidence each states.
|
|
282
|
-
- **Tasks** lists the PRD requirements and the board's tracker items for this initiative. The repository records no result for each requirement, so a requirement says "No result" and is never drawn as done or open. **By stage** groups them by state. **Timeline** draws a bar for each task that has both a start and a due date, and lists the rest. Press a task to read its record; every Core documents row opens too: a document with no file shows what it is for, who writes it and what a draft will contain, with Draft it where a draft can run; for a PMOS task you can change its status. **Add a task** writes a PMOS task to the board's own record; with no dates the board plans it from tomorrow for a week. Jira tickets stay read-only. **Add a document** works as on the Board, with a phase as well, and saves on the initiative's record.
|
|
284
|
+
- **Tasks** lists the PRD requirements and the board's tracker items for this initiative. The repository records no result for each requirement, so a requirement says "No result" and is never drawn as done or open. **By stage** groups them by state. **Timeline** draws a bar for each task that has both a start and a due date, and lists the rest. Press a task to read its record; every Core documents row opens too: a document with no file shows what it is for, who writes it and what a draft will contain, with Draft it where a draft can run; for a PMOS task you can change its status. **Add a task** writes a PMOS task to the board's own record; with no dates the board plans it from tomorrow for a week. Jira tickets stay read-only. A Jira task also opens its ticket in a second tab. The tab shows the key, the title, the status, the sprint, the points, the priority and size, the ticket's text from the Jira draft, how many subtasks are done, the links to other tickets and the PRD, and **Open in Jira**. The assignee, comments, history and the other fields stay in Jira, because the Jira read holds no people. A ticket with no record says what is missing. **Add a document** works as on the Board, with a phase as well, and saves on the initiative's record.
|
|
283
285
|
- **Core documents** has the same counts, filter and search as the Board's card, for this initiative. **Draft it** starts the existing read-only run that writes a draft and sends nothing. Technical documents (the record, the rubric, the stories, the review and the explainer) are grouped and not counted.
|
|
284
286
|
- **The document sheet.** A document that has a file opens in a dialog with **Read** (the file's text, its front matter as a grid and an outline), **Edit** (the file as plain Markdown, a reason, and **Save**), **Proposals** (**Ask the agent**, the open proposals with **Accept** and **Reject**, and the closed ones), **Edit log** (the revisions and other entries of the document sheet; **Show change** on a revision marks the words it added and removed against the revision before), **Health** (the document-health checks; a check with no input is not counted) and **Relations** (the documents it draws on, its goals, and the documents that use it, from the document library; a related file opens in the same sheet, and a goal or a missing file is listed but cannot be opened). The status line also names each **copy in another tool** (a Confluence page or Google Doc, with its state: in step, behind, both changed and so on), or offers **Link a copy**. Pressing it opens a panel with each copy's state, a link to open it, **Check now** (one agent session reads the copies with your connectors) and a box to paste a link. The sheet never writes to a copy; updating one is in the console. The file changes only when you press Save or Accept, and every change is kept in the Edit log with its reason. Save and Reject need a reason. A proposal made on text that has since changed shows which sections are out of date and cannot take them. The agent beside the sheet still only reads. A draft shows a bar above its text: **Issue it** marks the draft issued, through the console's own route, and sends nothing; it refuses while the Edit tab holds unsaved changes. Bold and undo buttons and Drop are not built on this page.
|
|
285
287
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.323.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.323.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -104,7 +104,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
|
104
104
|
await page.click('.vcf [data-a="1"]');
|
|
105
105
|
ok('R1 vwConfirm resolves true on the yes button and removes the card', (await yes) === true && !(await page.$('.vcf')));
|
|
106
106
|
await page.evaluate(() => window.__premiumViewer.vwStyle('none-such'));
|
|
107
|
-
ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x');
|
|
107
|
+
ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); const l = document.querySelectorAll('link[data-vw-css="none-such"]'); return l.length === 1 && l[0].getAttribute('href') === '/pm/premium-vw-none-such.css' && !document.querySelector('link[href*="/x.css"]'); }));
|
|
108
108
|
await page.keyboard.press('Escape');
|
|
109
109
|
await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
|
|
110
110
|
await openDialog(page);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-cal-test.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8; planning/prd/premium-viewer-prd.md R6, R7).
|
|
4
|
+
* Serves the real Briefing page from the real server. The Briefing model and GET /api/calendar-views are answered by stand-ins; the stand-in
|
|
5
|
+
* buckets its meetings with the repo's own calendar model (scripts/calendar-model.js), so each view gets the cells the real route would send.
|
|
6
|
+
* R8 the card's button opens the grid · Day, Week, Month · previous, next, Today · a month day opens that day · a meeting opens its detail with the
|
|
7
|
+
* calendar as a tab · R6 an empty range and a failed answer say so · R7 390px day list, 44px targets, no sideways scroll, dark theme
|
|
8
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { spawn } = require('child_process');
|
|
11
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
12
|
+
const T = require('./test-run').configure({ name: 'premium-vw-cal' });
|
|
13
|
+
const B = require('./lib/briefing-premium.js');
|
|
14
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
15
|
+
const model = require('../scripts/calendar-model.js');
|
|
16
|
+
|
|
17
|
+
const BASE = T.BASE;
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
20
|
+
const results = [];
|
|
21
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
22
|
+
let srv = null; let browser = null;
|
|
23
|
+
const finish = async (code) => {
|
|
24
|
+
if (browser) await browser.close().catch(() => {});
|
|
25
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
26
|
+
T.killTmux();
|
|
27
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
28
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-cal assertions passed`);
|
|
29
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
30
|
+
};
|
|
31
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
32
|
+
|
|
33
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
34
|
+
const key = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
35
|
+
const TODAY = key(new Date());
|
|
36
|
+
const plus = (k, n) => { const [y, m, d] = k.split('-').map(Number); return key(new Date(y, m - 1, d + n)); };
|
|
37
|
+
/* today's meetings: two that overlap and one later; one more in five days, so it falls in a later week of the same or the next month */
|
|
38
|
+
const EVENTS = [
|
|
39
|
+
{ id: 'ev-sync', title: 'Onboarding weekly sync', at: `${TODAY}T10:00:00`, end: `${TODAY}T11:00:00`, attendees: ['Sam', 'Lee'] },
|
|
40
|
+
{ id: 'ev-over', title: 'Billing meter review', at: `${TODAY}T10:30:00`, end: `${TODAY}T11:30:00`, attendees: ['Ana'] },
|
|
41
|
+
{ id: 'ev-late', title: 'Customer call', at: `${TODAY}T15:00:00`, end: `${TODAY}T15:45:00` },
|
|
42
|
+
{ id: 'ev-next', title: 'Sprint planning', at: `${plus(TODAY, 8)}T13:00:00`, end: `${plus(TODAY, 8)}T14:30:00` },
|
|
43
|
+
];
|
|
44
|
+
const answer = (url, mode) => {
|
|
45
|
+
const q = new URL(url).searchParams, view = q.get('view') || 'week', date = q.get('date') || TODAY;
|
|
46
|
+
if (mode === 'fail') return { status: 500, body: { ok: false, error: 'the calendar reader stopped' } };
|
|
47
|
+
const b = model.bucketEvents(mode === 'empty' ? [] : EVENTS, view, date);
|
|
48
|
+
return { status: 200, body: { ok: true, view, range: b.range, unit: b.unit, cells: b.cells, gantt: [], events_source: 'calendar-memory', today: TODAY,
|
|
49
|
+
layers: mode === 'empty' ? [] : [{ id: 'ini:x', date: TODAY, kind: 'initiative', layer: 'initiatives', title: 'Self-serve v2 promised', tone: 'warn' }], context: {}, link_boards: [] } };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
(async () => {
|
|
53
|
+
const exe = findBrowser();
|
|
54
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
55
|
+
let chromium;
|
|
56
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
57
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
58
|
+
await T.waitForServer(BASE);
|
|
59
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
60
|
+
|
|
61
|
+
const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
|
|
62
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
63
|
+
const page = await ctx.newPage();
|
|
64
|
+
const S = { errors: [], mode: 'full', asks: [] };
|
|
65
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
66
|
+
await page.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }) }));
|
|
67
|
+
await page.route('**/api/calendar-views*', (r) => { S.asks.push(r.request().url()); const a = answer(r.request().url(), S.mode); r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
|
|
68
|
+
await page.goto(BASE + '/premium.html?theme=' + theme);
|
|
69
|
+
S.up = await until(() => page.evaluate(() => !!document.querySelector('#todayCard .vc-open') && !!window.__premiumViewer), 20000);
|
|
70
|
+
return { page, ctx, S };
|
|
71
|
+
};
|
|
72
|
+
const vis = (page, sel) => page.evaluate((s) => [...document.querySelectorAll(s)].filter((e) => e.getClientRects().length && getComputedStyle(e).visibility !== 'hidden').length, sel);
|
|
73
|
+
const ready = (page) => until(() => page.evaluate(() => !!document.querySelector('#vcMain .vc-w .vc-h') || !!document.querySelector('.obody.vw[data-vw="cal"] .vc-w .vc-h')));
|
|
74
|
+
const pressed = (page) => page.evaluate(() => { const b = document.querySelector('#dOut .vc-seg [aria-pressed="true"]:not([hidden])'); return b && b.dataset.cv; });
|
|
75
|
+
const title = (page) => page.evaluate(() => { const t = [...document.querySelectorAll('#dOut .vc-t')].find((x) => x.getClientRects().length); return t ? t.textContent : ''; });
|
|
76
|
+
|
|
77
|
+
/* R8 desktop */
|
|
78
|
+
{
|
|
79
|
+
const { page, ctx, S } = await open();
|
|
80
|
+
ok('R8 the Briefing\'s Calendar card has a button that opens the calendar', S.up);
|
|
81
|
+
await page.click('#todayCard .vc-open');
|
|
82
|
+
ok('R8 the button opens a dialog with the calendar as its detail', await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dTitle').textContent === 'Calendar')) && await ready(page));
|
|
83
|
+
await until(() => vis(page, '#vcMain .vc-ev'));
|
|
84
|
+
ok('R8 it opens on this week, read from GET /api/calendar-views?view=week', (await pressed(page)) === 'week' && S.asks.some((u) => /view=week&date=/.test(u)), S.asks.join(' '));
|
|
85
|
+
ok('R8 the week draws today\'s three meetings as blocks', (await vis(page, '#vcMain .vc-ev')) === 3, String(await vis(page, '#vcMain .vc-ev')));
|
|
86
|
+
const lanes = await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].filter((b) => /sync|meter/.test(b.textContent)).map((b) => b.getBoundingClientRect()));
|
|
87
|
+
ok('R8 two meetings that overlap sit side by side', lanes.length === 2 && Math.abs(lanes[0].left - lanes[1].left) > 20 && lanes[0].width < 200, JSON.stringify(lanes.map((r) => [r.left, r.width])));
|
|
88
|
+
ok('R8 the all-day row carries the dated layer as a mark', await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-adc .vc-ad')].some((x) => /promised/.test(x.textContent) && x.tagName === 'SPAN')));
|
|
89
|
+
ok('R8 the now line is drawn on today', (await vis(page, '#vcMain .vc-now')) <= 1);
|
|
90
|
+
const wk = await title(page);
|
|
91
|
+
await page.click('#vcMain [data-cn="1"]');
|
|
92
|
+
await until(async () => (await title(page)) !== wk);
|
|
93
|
+
ok('R8 Next moves a week on', (await title(page)) !== wk && S.asks.some((u) => u.includes('date=' + plus(TODAY, 7))), S.asks.slice(-1)[0]);
|
|
94
|
+
await page.click('#vcMain [data-cn="0"]');
|
|
95
|
+
await until(async () => (await title(page)) === wk);
|
|
96
|
+
ok('R8 Today comes back to this week', (await title(page)) === wk);
|
|
97
|
+
await page.click('#vcMain [data-cv="month"]');
|
|
98
|
+
await until(async () => (await pressed(page)) === 'month' && (await vis(page, '#vcMain .vc-md')) >= 28);
|
|
99
|
+
ok('R8 Month draws whole weeks of days', (await vis(page, '#vcMain .vc-md')) % 7 === 0 && (await vis(page, '#vcMain .vc-md')) >= 28 && /\d{4}$/.test(await title(page)), await title(page));
|
|
100
|
+
ok('R8 today\'s cell lists its meetings', await page.evaluate(() => { const c = document.querySelector('#vcMain .vc-md.now'); return !!c && c.querySelectorAll('.vc-me').length === 3; }));
|
|
101
|
+
await page.click('#vcMain .vc-md.now .vc-dn');
|
|
102
|
+
await until(async () => (await pressed(page)) === 'day');
|
|
103
|
+
await until(() => vis(page, '#vcMain .vc-ev'));
|
|
104
|
+
ok('R8 a month day opens that day', (await pressed(page)) === 'day' && S.asks.some((u) => u.includes('view=day&date=' + TODAY)) && (await vis(page, '#vcMain .vc-dh')) === 1);
|
|
105
|
+
await page.click('#vcMain [data-cv="week"]');
|
|
106
|
+
await until(() => vis(page, '#vcMain .vc-ev'));
|
|
107
|
+
await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].find((b) => /weekly sync/.test(b.textContent)).click());
|
|
108
|
+
ok('R8 a meeting opens its detail, the meeting dialog', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Onboarding weekly sync')));
|
|
109
|
+
const tabs = await page.evaluate(() => ({ ...window.__premiumViewer.vwState(), main: !document.querySelector('#oMain').hidden }));
|
|
110
|
+
ok('R8 the calendar stays as a tab beside the meeting, the meeting shown', JSON.stringify(tabs.ids) === '["cal"]' && tabs.on === 'main' && tabs.main, JSON.stringify(tabs));
|
|
111
|
+
await page.click('#vTabs .vtab[data-vw="cal"]');
|
|
112
|
+
await until(() => vis(page, '.obody.vw[data-vw="cal"] .vc-ev'));
|
|
113
|
+
ok('R8 the Calendar tab shows the grid at the same view', (await vis(page, '.obody.vw[data-vw="cal"] .vc-ev')) === 3 && (await pressed(page)) === 'week');
|
|
114
|
+
await page.evaluate(() => [...document.querySelectorAll('.obody.vw[data-vw="cal"] .vc-ev')].find((b) => /Customer call/.test(b.textContent)).click());
|
|
115
|
+
ok('R8 a meeting from the tab opens that meeting, with the tab again', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Customer call' && JSON.stringify(window.__premiumViewer.vwState().ids) === '["cal"]')));
|
|
116
|
+
|
|
117
|
+
/* R6 honesty */
|
|
118
|
+
await page.keyboard.press('Escape');
|
|
119
|
+
await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
|
|
120
|
+
S.mode = 'empty';
|
|
121
|
+
await page.click('#todayCard .vc-open');
|
|
122
|
+
await until(() => page.evaluate(() => /No meetings in this week/.test((document.querySelector('#vcMain') || {}).textContent || '')));
|
|
123
|
+
ok('R6 a week with no meetings says so', await page.evaluate(() => /No meetings in this week\./.test(document.querySelector('#vcMain').textContent) && !document.querySelector('#vcMain .vc-ev')));
|
|
124
|
+
S.mode = 'fail';
|
|
125
|
+
await page.click('#vcMain [data-cv="month"]');
|
|
126
|
+
await until(() => page.evaluate(() => /Calendar not read/.test(document.querySelector('#vcMain').textContent)));
|
|
127
|
+
ok('R6 a calendar that did not answer says it was not read, and why', await page.evaluate(() => /Calendar not read\. the calendar reader stopped/.test(document.querySelector('#vcMain').textContent)));
|
|
128
|
+
ok('R8 no page error', S.errors.length === 0, S.errors.join(' | '));
|
|
129
|
+
await ctx.close();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* R7 phone and dark theme */
|
|
133
|
+
{
|
|
134
|
+
const { page, ctx, S } = await open({ w: 390, h: 844, theme: 'dark' });
|
|
135
|
+
await page.click('#todayCard .vc-open');
|
|
136
|
+
await until(() => vis(page, '#vcMain .vc-ar'));
|
|
137
|
+
ok('R7 at 390px the week is a day list, not the timeline', (await vis(page, '#vcMain .vc-ar')) === 3 && (await vis(page, '#vcMain .vc-g')) === 0, String(await vis(page, '#vcMain .vc-ar')));
|
|
138
|
+
const m = async () => page.evaluate(() => {
|
|
139
|
+
const bs = [...document.querySelectorAll('#vcMain button')].filter((b) => b.getClientRects().length).map((b) => b.getBoundingClientRect());
|
|
140
|
+
return { minH: Math.min(...bs.map((r) => r.height)), minW: Math.min(...bs.map((r) => r.width)), over: document.documentElement.scrollWidth > window.innerWidth,
|
|
141
|
+
right: Math.max(...bs.map((r) => r.right)) <= window.innerWidth + 1, bg: getComputedStyle(document.querySelector('#vcMain .vc-w')).backgroundColor };
|
|
142
|
+
});
|
|
143
|
+
let x = await m();
|
|
144
|
+
ok('R7 every control of the week is at least 44px', x.minH >= 44 && x.minW >= 44, JSON.stringify(x));
|
|
145
|
+
ok('R7 the week fits the width, no sideways scroll', x.right && !x.over, JSON.stringify(x));
|
|
146
|
+
ok('R7 in the dark theme the calendar is not a light card', (() => { const c = (x.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), x.bg);
|
|
147
|
+
await page.click('#vcMain [data-cv="month"]');
|
|
148
|
+
await until(() => vis(page, '#vcMain .vc-md'));
|
|
149
|
+
x = await m();
|
|
150
|
+
ok('R7 the month at 390px: day buttons of 44px, no sideways scroll', x.minH >= 44 && x.minW >= 40 && x.right && !x.over && (await vis(page, '#vcMain .vc-me')) === 0, JSON.stringify(x));
|
|
151
|
+
ok('R7 no page error', S.errors.length === 0, S.errors.join(' | '));
|
|
152
|
+
await ctx.close();
|
|
153
|
+
}
|
|
154
|
+
finish();
|
|
155
|
+
})();
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-jira-test.js — the Jira tabs of the premium viewer in a real browser (initiative premium-viewer S5; planning/prd/premium-viewer-prd.md R5 to R7).
|
|
4
|
+
* A real server; the Board page's model and the two Jira reads are route stand-ins (GET /api/board-premium, /api/boards/sprints, /api/jira/tickets), since
|
|
5
|
+
* Jira readings are written only by an agent session holding the PM's Atlassian connection.
|
|
6
|
+
* B the Board's Sprint card opens the sprint as a board by status in a viewer tab · K a card opens its ticket · N no Jira data says so
|
|
7
|
+
* F floors: 390 px with no sideways scroll, 44 px targets, light and dark, no write */
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const { spawn } = require('child_process');
|
|
10
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
11
|
+
const T = require('./test-run').configure({ name: 'premium-vw-jira' });
|
|
12
|
+
const BP = require('./lib/board-premium.js');
|
|
13
|
+
const F = require('./fixtures/board-premium-facts.js');
|
|
14
|
+
|
|
15
|
+
const BASE = T.BASE;
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
const until = async (fn, ms = 15000, step = 120) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
18
|
+
const results = [];
|
|
19
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
|
|
20
|
+
let srv = null; let browser = null;
|
|
21
|
+
const finish = async (code) => {
|
|
22
|
+
if (browser) await browser.close().catch(() => {});
|
|
23
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
24
|
+
T.killTmux();
|
|
25
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
26
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-jira assertions passed`);
|
|
27
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
28
|
+
};
|
|
29
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
30
|
+
|
|
31
|
+
const SECTIONS = [['story', 'User Story'], ['acceptance', 'Acceptance Criteria']].map(([key, name]) => ({ key, name }));
|
|
32
|
+
const SP = { name: 'Sprint 14', state: 'active', start: '2026-10-07', end: '2026-10-21' };
|
|
33
|
+
const SPRINTS = {
|
|
34
|
+
ok: true, ws: 'w1', board: 'w1', source: 'jira', readAt: new Date().toISOString(), velocity: [],
|
|
35
|
+
sprints: [
|
|
36
|
+
{ ...SP, goal: { from: 'tickets', text: 'Ship guided setup to new workspaces' }, points: { committed: 10, done: 3, unestimated: 0 }, pace: { daysLeft: 2 }, counts: { todo: 2, doing: 1, done: 1 },
|
|
37
|
+
issues: [
|
|
38
|
+
{ key: 'PMOS-142', summary: 'Migration check for older workspaces', status: 'To Do', category: 'todo', initiative: 'self-serve-v2', flagged: true, reason: 'Flagged in Jira', points: 5 },
|
|
39
|
+
{ key: 'PMOS-141', summary: 'Setup drops custom fields', status: 'Code review', category: 'doing', initiative: 'self-serve-v2', flagged: false, reason: null, points: 2 },
|
|
40
|
+
{ key: 'PMOS-138', summary: 'Guided setup copy', status: 'Done', category: 'done', initiative: 'self-serve-v2', flagged: false, reason: null, points: 3 },
|
|
41
|
+
{ key: 'OPS-9', summary: 'Rotate keys', status: 'To Do', category: 'todo', initiative: null, flagged: false, reason: null, points: null }] },
|
|
42
|
+
{ name: 'Sprint 15', state: 'future', start: '2026-10-22', end: '2026-11-04', goal: null, jiraGoal: null, points: null, counts: { todo: 0, doing: 0, done: 0 }, issues: [] }],
|
|
43
|
+
};
|
|
44
|
+
const TICKETS = {
|
|
45
|
+
ok: true, initiative: 'self-serve-v2', title: 'Self-serve onboarding v2', prd: 'planning/prd/self-serve-v2-prd.md', checkedAt: new Date().toISOString(),
|
|
46
|
+
epic: { mode: 'existing', key: 'PMOS-100', summary: 'Self-serve v2' }, sectionNames: SECTIONS,
|
|
47
|
+
tickets: [
|
|
48
|
+
{ id: 'TD-01', summary: 'Migration check for older workspaces', type: 'Story', priority: 'High', estimate: 'M', depends: [], key: 'PMOS-142',
|
|
49
|
+
sections: { story: 'As an admin I keep my **custom fields**.<img src=x onerror="window.__pwned=1">', acceptance: '- [ ] Runs on every older workspace\n- [ ] A report lists the failures' },
|
|
50
|
+
jira: { status: 'To Do', category: 'todo', sprint: SP, subtasks: { done: 1, total: 3 }, flagged: true, reason: 'Flagged in Jira', url: 'https://acme.atlassian.net/browse/PMOS-142', stale: false } },
|
|
51
|
+
{ id: 'TD-02', summary: 'Release to existing workspaces', type: 'Task', priority: 'Medium', estimate: null, depends: ['TD-01'], key: 'PMOS-152', sections: { story: 'Ship it.' },
|
|
52
|
+
jira: { status: 'In Progress', category: 'doing', sprint: null, subtasks: { done: 0, total: 0 }, flagged: false, reason: null, url: 'https://acme.atlassian.net/browse/PMOS-152', stale: false } }],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
(async () => {
|
|
56
|
+
const exe = findBrowser();
|
|
57
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
58
|
+
let chromium;
|
|
59
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
60
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_NO_OPEN: '1' }) });
|
|
61
|
+
await T.waitForServer(BASE);
|
|
62
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
63
|
+
|
|
64
|
+
const model = (sprints) => BP.build(F.facts({ sprints }));
|
|
65
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', sprints = SPRINTS, tickets = TICKETS } = {}) => {
|
|
66
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme });
|
|
67
|
+
await ctx.addInitScript((t) => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); localStorage.setItem('pmos.c3.theme', t); } catch { /* none */ } }, theme);
|
|
68
|
+
const page = await ctx.newPage(), errors = [], posts = [], reads = [];
|
|
69
|
+
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
70
|
+
page.on('request', (rq) => { const u = new URL(rq.url()); if (rq.method() === 'POST') posts.push(u.pathname); if (/^\/api\/(jira|boards\/sprints)/.test(u.pathname)) reads.push(u.pathname + u.search); });
|
|
71
|
+
const json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) });
|
|
72
|
+
await page.route('**/api/board-premium*', (r) => json(r, { ok: true, state: 'ready', model: model(sprints), as_of: Date.now() }));
|
|
73
|
+
await page.route('**/api/boards/sprints*', (r) => json(r, sprints));
|
|
74
|
+
await page.route('**/api/jira/tickets*', (r) => json(r, tickets));
|
|
75
|
+
await page.goto(BASE + '/premium-board.html');
|
|
76
|
+
await until(() => page.evaluate(() => !!document.querySelector('#cSpr [data-open="board:sprint"]') || /No sprint/.test((document.querySelector('#cSpr') || {}).textContent || '')));
|
|
77
|
+
return { ctx, page, errors, posts, reads };
|
|
78
|
+
};
|
|
79
|
+
const tabIds = (p) => p.evaluate(() => [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.dataset.vw));
|
|
80
|
+
const paneText = (p, id) => p.evaluate((x) => { const e = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(x)}"]`); return e && !e.hidden ? e.textContent : null; }, id);
|
|
81
|
+
|
|
82
|
+
/* B the sprint */
|
|
83
|
+
const A = await open();
|
|
84
|
+
const p = A.page;
|
|
85
|
+
await p.click('#cSpr [data-open="board:sprint"]');
|
|
86
|
+
const board = await until(async () => { const t = await paneText(p, 'sprint:w1'); return t && /Migration check/.test(t) ? t : null; });
|
|
87
|
+
ok('B1 the Sprint card opens the dialog with the sprint as a second tab', !!board && (await tabIds(p)).join() === 'main,sprint:w1', JSON.stringify(await tabIds(p)));
|
|
88
|
+
ok('B2 the board names the sprint, its dates, goal, days left and points from the read', /Sprint 14 · 7 Oct – 21 Oct/.test(board) && /Goal: Ship guided setup/.test(board) && /2 days left/.test(board) && /3 of 10 points done/.test(board), board);
|
|
89
|
+
const cols = await p.evaluate(() => [...document.querySelectorAll('.jcol')].map((c) => c.querySelector('.jcolh').textContent + ':' + c.querySelectorAll('.jcrd').length).join());
|
|
90
|
+
ok('B3 the cards sit in To do, In progress and Done by the reading\'s category', cols === 'To do2:2,In progress1:1,Done1:1', cols);
|
|
91
|
+
ok('B4 a card shows its own Jira status where it differs from the column, a flag, and points', await p.evaluate(() => { const c = [...document.querySelectorAll('.jcrd')]; const r = c.find((x) => /PMOS-141/.test(x.textContent)), f = c.find((x) => /PMOS-142/.test(x.textContent)); return /Code review/.test(r.textContent) && /2/.test(r.querySelector('.jpts').textContent) && f.classList.contains('risk') && /Flagged in Jira/.test(f.textContent); }));
|
|
92
|
+
ok('B5 a ticket on no initiative of the board is drawn but not a button, and the note counts it', await p.evaluate(() => { const o = [...document.querySelectorAll('.jcrd')].find((x) => /OPS-9/.test(x.textContent)); return o.tagName === 'DIV' && o.classList.contains('off'); }) && /1 ticket is in this sprint but on no initiative/.test(board));
|
|
93
|
+
ok('B6 the view says it is read-only and moves nothing', /Read-only: Jira owns each ticket's status and sprint/.test(board) && !(await p.$('#dOut .obody.vw [draggable="true"]')));
|
|
94
|
+
await p.click('.jseg [data-sp="Sprint 15"]');
|
|
95
|
+
ok('B7 the other sprint is one press away, and an empty one draws empty columns', !!(await until(async () => { const t = await paneText(p, 'sprint:w1'); return t && /Sprint 15 · 22 Oct – 4 Nov/.test(t) && /No sprint goal on record/.test(t) && (t.match(/None/g) || []).length === 3; })));
|
|
96
|
+
await p.click('.jseg [data-sp="Sprint 14"]');
|
|
97
|
+
await until(() => p.$('.jcrd[data-k="PMOS-142"]'));
|
|
98
|
+
|
|
99
|
+
/* K the ticket */
|
|
100
|
+
await p.click('.jcrd[data-k="PMOS-142"]');
|
|
101
|
+
const tk = await until(async () => { const t = await paneText(p, 'jira:PMOS-142'); return t && /Acceptance Criteria/.test(t) ? t : null; });
|
|
102
|
+
ok('K1 a card opens its ticket as a third tab', !!tk && (await tabIds(p)).join() === 'main,sprint:w1,jira:PMOS-142', JSON.stringify(await tabIds(p)));
|
|
103
|
+
ok('K2 the ticket shows key, title, status, sprint, points and priority', /PMOS-142/.test(tk) && /Migration check for older workspaces/.test(tk) && /To Do/.test(tk) && /Sprint 14 · active/.test(tk) && /5 pt/.test(tk) && /High/.test(tk), tk);
|
|
104
|
+
ok('K3 the description is the draft\'s sections, rendered as markdown with nothing run', /User Story/.test(tk) && await p.evaluate(() => !!document.querySelector('.jmd strong') && !document.querySelector('.jmd img[onerror]') && !window.__pwned));
|
|
105
|
+
ok('K4 subtasks are the reading\'s count, and links come from the draft', /Subtasks · 1 of 3 done/.test(tk) && /blocks/.test(tk) && /PMOS-152/.test(tk) && /planning\/prd\/self-serve-v2-prd.md/.test(tk));
|
|
106
|
+
ok('K5 no comments, history or fields panel: a line sends the rest to Jira with a real link', /Assignee, comments, history and the other fields stay in Jira/.test(tk) && !/Comments \(/.test(tk)
|
|
107
|
+
&& await p.evaluate(() => [...document.querySelectorAll('#dOut .obody.vw:not([hidden]) a[href]')].every((a) => a.href === 'https://acme.atlassian.net/browse/PMOS-142' && a.target === '_blank' && /noopener/.test(a.rel))));
|
|
108
|
+
await p.click('#dOut .obody.vw:not([hidden]) [data-jt="PMOS-152"]');
|
|
109
|
+
ok('K6 a linked ticket opens in its own tab', !!(await until(async () => { const t = await paneText(p, 'jira:PMOS-152'); return t && /Release to existing workspaces/.test(t) && /No sprint/.test(t); })));
|
|
110
|
+
await p.click('#vTabs .vtab[data-vw="main"]');
|
|
111
|
+
const k7 = await until(() => p.evaluate(() => { const m = document.querySelector('#oMain'); return !m.hidden && /Ship guided setup/.test(m.textContent) ? m.textContent : null; }));
|
|
112
|
+
ok('K7 the first tab is the sprint dialog\'s own facts, as before', !!k7, await p.evaluate(() => [document.querySelector('#oMain').hidden, document.querySelector('#oMain').textContent.slice(0, 300)].join(' | ')));
|
|
113
|
+
ok('K8 the views read the two Jira routes only, and wrote nothing', A.posts.filter((x) => !/thread|note/.test(x)).length === 0 && A.reads.every((r) => /^\/api\/(jira\/tickets|boards\/sprints)\?/.test(r)) && A.reads.some((r) => /jira\/tickets\?.*initiative=self-serve-v2/.test(r)), JSON.stringify([A.posts, A.reads]));
|
|
114
|
+
ok('K9 no page error', A.errors.length === 0, A.errors.join(' | '));
|
|
115
|
+
await A.ctx.close();
|
|
116
|
+
|
|
117
|
+
/* N no Jira data */
|
|
118
|
+
{
|
|
119
|
+
const N = await open({ sprints: { ok: true, source: 'none', readAt: null, sprints: [], velocity: [] }, tickets: { ok: false, error: 'no such initiative' } });
|
|
120
|
+
const r = await N.page.evaluate(async () => { const m = await import('/pm/premium-vw-jira.js'); m.openSprint({ ws: 'w1', board: 'w1' }); return true; }).catch(() => false);
|
|
121
|
+
const t = r && await until(async () => { const x = await paneText(N.page, 'sprint:w1'); return x && /Nothing to show/.test(x) ? x : null; });
|
|
122
|
+
ok('N1 with no Jira read the sprint tab says what is missing', !!t && /No sprint is on record for this board/.test(t), t);
|
|
123
|
+
await N.page.evaluate(async () => { const m = await import('/pm/premium-vw-jira.js'); m.openTicket({ ws: 'w1', board: 'w1', initiative: 'gone', ref: 'PMOS-1' }); });
|
|
124
|
+
const k = await until(async () => { const x = await paneText(N.page, 'jira:PMOS-1'); return x && /Nothing to show/.test(x) ? x : null; });
|
|
125
|
+
ok('N2 a ticket that cannot be read says why, and invents nothing', !!k && /no such initiative/.test(k), k);
|
|
126
|
+
await N.ctx.close();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* I the initiative page loads the ticket view for its Jira tasks */
|
|
130
|
+
{
|
|
131
|
+
const I = await open();
|
|
132
|
+
await I.page.goto(BASE + '/premium-initiative.html');
|
|
133
|
+
ok('I1 the initiative page loads the Jira view module without a page error', !!(await until(() => I.page.evaluate(() => !!window.__premiumVwJira))) && I.errors.length === 0, I.errors.join(' | '));
|
|
134
|
+
await I.ctx.close();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* F floors */
|
|
138
|
+
for (const theme of ['light', 'dark']) {
|
|
139
|
+
const S = await open({ w: 390, h: 844, theme });
|
|
140
|
+
await S.page.click('#cSpr [data-open="board:sprint"]');
|
|
141
|
+
await until(() => S.page.$('.jcrd[data-k="PMOS-142"]'));
|
|
142
|
+
await S.page.evaluate(() => { const d = document.querySelector('#dlg'); if (d) d.classList.add('vopen'); const b = document.querySelector('#dTabs button[data-t="out"]'); if (b) b.click(); });
|
|
143
|
+
await sleep(400);
|
|
144
|
+
const f = await S.page.evaluate(() => {
|
|
145
|
+
const pane = document.querySelector('#dOut .obody.vw:not([hidden])');
|
|
146
|
+
const small = [...pane.querySelectorAll('button.jcrd,.jseg button,.jbtn')].filter((b) => b.getBoundingClientRect().height && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 30));
|
|
147
|
+
const crd = getComputedStyle(pane.querySelector('.jcrd')).backgroundColor, ink = getComputedStyle(pane.querySelector('.jcrd b')).color;
|
|
148
|
+
return { wide: document.documentElement.scrollWidth > innerWidth + 1, paneWide: pane.scrollWidth > pane.clientWidth + 1, small, crd, ink };
|
|
149
|
+
});
|
|
150
|
+
ok(`F1 ${theme}: 390 px has no sideways scroll and every target is 44 px or more`, !f.wide && !f.paneWide && !f.small.length, JSON.stringify(f));
|
|
151
|
+
const lum = (c) => { const m = c.match(/\d+(\.\d+)?/g).map(Number); return (m[0] * 299 + m[1] * 587 + m[2] * 114) / 1000; };
|
|
152
|
+
ok(`F2 ${theme}: cards follow the theme`, theme === 'dark' ? lum(f.ink) > lum(f.crd) : lum(f.ink) < lum(f.crd), JSON.stringify(f));
|
|
153
|
+
await S.ctx.close();
|
|
154
|
+
}
|
|
155
|
+
await finish();
|
|
156
|
+
})();
|
|
@@ -8,6 +8,7 @@ import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, l
|
|
|
8
8
|
import { issueBody } from './premium-doc-edit.js';
|
|
9
9
|
import { mountDocSheet } from './premium-doc-sheet.js';
|
|
10
10
|
import * as MT from './premium-metric-tiles.js';
|
|
11
|
+
import { openSprint } from './premium-vw-jira.js';
|
|
11
12
|
import { dotsBtn, openMenu, closeMenu, menuKey, asksHtml, onAsks, openIniForm } from './premium-acts.js';
|
|
12
13
|
|
|
13
14
|
const MODE_KEY = 'pmos.premium.openAs';
|
|
@@ -188,6 +189,7 @@ function openRow(r) {
|
|
|
188
189
|
const d = r.dialog;
|
|
189
190
|
openDlg({ eye: d.eye + ' · real data', title: r.title, sub: r.sub + (r.statusLabel ? ' · ' + r.statusLabel : ''), say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
|
|
190
191
|
loadThread(r.key);
|
|
192
|
+
if (r.key === 'board:sprint') openSprint({ ws: M.board.ws, board: M.board.id, name: r.title }); // the sprint as a board by status, beside its facts (premium-viewer S5)
|
|
191
193
|
setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
|
|
192
194
|
}
|
|
193
195
|
$('#dBody').addEventListener('click', (e) => { const lt = e.target.closest('#logT'); if (lt) { const c = $('#alog').classList.toggle('col'); lt.setAttribute('aria-expanded', !c); } });
|
|
@@ -8,6 +8,7 @@ import { pmPost } from './http.js';
|
|
|
8
8
|
import { mountDocSheet } from './premium-doc-sheet.js';
|
|
9
9
|
import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, kv, H2, CHECK, CHEV, crumbHtml, wireCrumb, AI, openAddDoc, setPageGaps } from './premium-shell.js';
|
|
10
10
|
import { barHtml, onBar, closeMenu } from './premium-acts.js';
|
|
11
|
+
import { openTicket } from './premium-vw-jira.js';
|
|
11
12
|
|
|
12
13
|
let M = null; // the model
|
|
13
14
|
let taskView = 'list', taskPage = 0;
|
|
@@ -134,6 +135,7 @@ function openTask(t) {
|
|
|
134
135
|
const act = t.pmos ? `<div class="tkact"><span class="label">Status</span><div class="seg tkst" role="group" aria-label="Status"><i class="pill"></i>${STATES.map((s) => `<button data-tks="${esc(s)}" aria-pressed="${t.state === s}">${s}</button>`).join('')}</div></div><p class="note" style="margin-top:12px">A PMOS task is kept on the board. Jira tickets are read-only here: Jira owns their status and dates.</p>` : `<p class="xn">${t.src === 'PRD requirement' ? 'Read from the initiative’s PRD. Nothing on this page changes it.' : 'Read from the board. Jira owns its status and dates.'}</p>`;
|
|
135
136
|
openDlg({ eye: 'Task · real data', title: t.title, sub: M.title, say, stream: turnA(ptx(say)), noteKey: null, pane: `<article class="paper doc">${kv(rows)}${act}</article>`, label: 'Task' });
|
|
136
137
|
$('#askF').hidden = true; if ($('#oMain .tkst')) pillOf($('#oMain .tkst'));
|
|
138
|
+
if (taskKind(t) === 'jira' && t.ref) openTicket({ ws: M.board.ws, board: M.board.id, initiative: M.id, ref: t.ref }); // the ticket beside its facts (premium-viewer S5)
|
|
137
139
|
$$('#oMain [data-tks]').forEach((b) => { b.onclick = async () => {
|
|
138
140
|
if (b.getAttribute('aria-pressed') === 'true') return;
|
|
139
141
|
const res = await pmPost('/api/boards/tasks/state', { ws: M.board.ws, board: M.board.id, task: t.uid, state: b.dataset.tks });
|
|
@@ -784,5 +784,5 @@ export function mountMeeting(d) {
|
|
|
784
784
|
$('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
|
|
785
785
|
readNotes().then(() => mark());
|
|
786
786
|
{ const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
|
|
787
|
-
return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote };
|
|
787
|
+
return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote, openRow: (row) => openRow(row, 'week') }; // openRow: the full calendar (premium-vw-cal.js)
|
|
788
788
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
@font-face{font-family:"Space Grotesk";src:url(/vendor/space-grotesk-var.woff2) format("woff2");font-weight:300 700;font-display:swap}
|
|
2
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-400.woff2) format("woff2");font-weight:400;font-display:swap}
|
|
3
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-500.woff2) format("woff2");font-weight:500;font-display:swap}
|
|
4
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-700.woff2) format("woff2");font-weight:600 700;font-display:swap}
|
|
5
|
+
:root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
|
|
6
|
+
/* pm/premium-vw-cal.css — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8; premium-vw-cal.js).
|
|
7
|
+
* Loaded once by vwStyle('cal'). Sizes are only var(--fs-1..6), weights 400/500/600 (premium-console-type.test.js).
|
|
8
|
+
* The pane's own width picks the layout: the timeline from 560px, the day list below it (the mockup's Week and Agenda). */
|
|
9
|
+
.vc-open{width:36px;height:36px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink-2);flex:none}
|
|
10
|
+
.vc-open .i{width:16px;height:16px}
|
|
11
|
+
.vc{container-type:inline-size}
|
|
12
|
+
.vc .vc-w{background:var(--card-solid);border:1px solid var(--hair);border-radius:8px;box-shadow:var(--card-shadow);overflow:hidden}
|
|
13
|
+
.vc .vc-h{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--hair);flex-wrap:wrap}
|
|
14
|
+
.vc .vc-t{font-size:var(--fs-3);font-weight:600;color:var(--ink)}
|
|
15
|
+
.vc .vc-cap{flex:1;min-width:0;font:400 var(--fs-2) var(--mono);color:var(--ink-3)}
|
|
16
|
+
.vc .vc-ib{width:36px;height:36px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink)}
|
|
17
|
+
.vc .vc-ib .i{width:16px;height:16px}
|
|
18
|
+
.vc .vc-tdy{min-height:36px;padding:0 12px;border-radius:6px;border:1px solid var(--hair);font-size:var(--fs-2);font-weight:500;color:var(--ink)}
|
|
19
|
+
.vc .vc-seg{display:flex;gap:2px;padding:3px;border-radius:8px;background:var(--well)}
|
|
20
|
+
.vc .vc-seg button{min-height:32px;padding:0 12px;border-radius:6px;font-size:var(--fs-2);font-weight:500;color:var(--ink-2)}
|
|
21
|
+
.vc .vc-seg button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
22
|
+
.vc button:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
23
|
+
.vc .vc-empty{margin:0;padding:12px 14px;font-size:var(--fs-2);color:var(--ink-3);border-bottom:1px solid var(--hair)}
|
|
24
|
+
.vc .vc-w>.vc-empty:last-child{border-bottom:0}
|
|
25
|
+
/* the timeline (Day and Week) */
|
|
26
|
+
.vc .vc-g{display:grid;grid-template-columns:48px repeat(var(--tl-n),minmax(0,1fr))}
|
|
27
|
+
.vc .vc-dh{padding:8px 6px 6px;font-size:var(--fs-2);color:var(--ink-3);border-left:1px solid var(--hair);text-align:center}
|
|
28
|
+
.vc .vc-dh b{display:grid;place-items:center;margin:2px auto 0;width:30px;height:30px;border-radius:6px;font-size:var(--fs-4);font-weight:600;color:var(--ink)}
|
|
29
|
+
.vc .vc-dh.now b{background:var(--solid);color:var(--on-solid)}
|
|
30
|
+
.vc .vc-adl{border-top:1px solid var(--hair);font:400 var(--fs-1) var(--mono);color:var(--ink-3);padding:6px 4px 0;text-align:right}
|
|
31
|
+
.vc .vc-adc{min-height:28px;border-left:1px solid var(--hair);border-top:1px solid var(--hair);padding:3px;display:grid;gap:2px;align-content:start}
|
|
32
|
+
.vc .vc-ad{display:block;min-width:0;border-radius:6px;padding:1px 6px;font-size:var(--fs-1);font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;
|
|
33
|
+
border-left:3px solid var(--ec,var(--ember));background:color-mix(in oklab,var(--ec,var(--ember)) 12%,transparent);color:var(--ink)}
|
|
34
|
+
.vc .vc-ad.meet{--ec:var(--sky)}
|
|
35
|
+
.vc .vc-ad.t-warn{--ec:var(--ember)}.vc .vc-ad.t-bad{--ec:var(--bad)}.vc .vc-ad.t-ok{--ec:var(--ok)}
|
|
36
|
+
.vc .vc-gut{border-top:1px solid var(--hair);font:400 var(--fs-1) var(--mono);color:var(--ink-3)}
|
|
37
|
+
.vc .vc-gut i{display:block;height:44px;font-style:normal;text-align:right;padding-right:6px;transform:translateY(-7px)}
|
|
38
|
+
.vc .vc-gut i:first-child{visibility:hidden}
|
|
39
|
+
.vc .vc-day{position:relative;height:var(--tl-hh);border-left:1px solid var(--hair);border-top:1px solid var(--hair);background:repeating-linear-gradient(to bottom,transparent 0 43px,var(--hair) 43px 44px)}
|
|
40
|
+
.vc .vc-day.past{background-color:color-mix(in oklab,var(--well) 40%,transparent)}
|
|
41
|
+
.vc .vc-ev{position:absolute;top:var(--tl-t);height:var(--tl-h);left:calc(var(--tl-l) + 3px);width:calc(var(--tl-w) - 6px);border-radius:6px;padding:3px 7px;font-size:var(--fs-1);line-height:1.3;overflow:hidden;text-align:left;
|
|
42
|
+
border-left:3px solid var(--sky);background:color-mix(in oklab,var(--sky) 14%,var(--card-solid));color:var(--ink);z-index:1}
|
|
43
|
+
.vc .vc-ev b{display:block;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
44
|
+
.vc .vc-ev small{display:block;font-size:var(--fs-1);color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
45
|
+
.vc .vc-ev.sh{padding:0 7px;display:flex;align-items:center}.vc .vc-ev.sh small{display:none}
|
|
46
|
+
.vc .vc-ev.past{opacity:.7}
|
|
47
|
+
.vc .vc-now{position:absolute;top:var(--tl-t);left:0;right:0;height:2px;background:var(--bad);z-index:2;pointer-events:none}
|
|
48
|
+
.vc .vc-now::before{content:"";position:absolute;left:-4px;top:-3px;width:8px;height:8px;border-radius:6px;background:var(--bad)}
|
|
49
|
+
/* the day list (Day and Week in a narrow pane) */
|
|
50
|
+
.vc .vc-ag{display:none}
|
|
51
|
+
.vc .vc-ag h4{margin:0;padding:10px 14px 4px;font-size:var(--fs-2);font-weight:600;color:var(--ink-3);border-top:1px solid var(--hair)}
|
|
52
|
+
.vc .vc-ag h4:first-child{border-top:0}
|
|
53
|
+
.vc .vc-ag h4.now{color:var(--ember-ink)}
|
|
54
|
+
.vc .vc-ag>.vc-ad{margin:2px 10px}
|
|
55
|
+
.vc .vc-ar{display:flex;gap:10px;align-items:baseline;width:calc(100% - 20px);min-height:44px;margin:3px 10px;padding:8px 10px;border-radius:8px;text-align:left;
|
|
56
|
+
border-left:3px solid var(--sky);background:color-mix(in oklab,var(--sky) 12%,transparent);color:var(--ink);font-size:var(--fs-3)}
|
|
57
|
+
.vc .vc-ar time{width:48px;flex:none;font:400 var(--fs-2) var(--mono);color:var(--ink-2)}
|
|
58
|
+
.vc .vc-ar span{min-width:0}
|
|
59
|
+
.vc .vc-ar b{display:block;font-weight:500}
|
|
60
|
+
.vc .vc-ar small{display:block;font-size:var(--fs-2);color:var(--ink-3)}
|
|
61
|
+
.vc .vc-ar.past{opacity:.7}
|
|
62
|
+
.vc .vc-none{margin:0;padding:4px 14px 10px;font-size:var(--fs-2);color:var(--ink-3)}
|
|
63
|
+
@container (max-width:559px){.vc .vc-g{display:none}.vc .vc-ag{display:block;padding-bottom:8px}}
|
|
64
|
+
/* the month */
|
|
65
|
+
.vc .vc-mh{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));border-bottom:1px solid var(--hair)}
|
|
66
|
+
.vc .vc-mh span{padding:6px 8px;font:400 var(--fs-1) var(--mono);text-transform:uppercase;letter-spacing:.06em;color:var(--ink-3)}
|
|
67
|
+
.vc .vc-mb{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
|
|
68
|
+
.vc .vc-md{min-width:0;min-height:96px;padding:4px;border-left:1px solid var(--hair);border-top:1px solid var(--hair);display:flex;flex-direction:column;gap:2px}
|
|
69
|
+
.vc .vc-md:nth-child(7n+1){border-left:0}
|
|
70
|
+
.vc .vc-md:nth-child(-n+7){border-top:0}
|
|
71
|
+
.vc .vc-md.out{background:color-mix(in oklab,var(--well) 50%,transparent)}
|
|
72
|
+
.vc .vc-md.out .vc-dn b{color:var(--ink-3)}
|
|
73
|
+
.vc .vc-dn{display:flex;align-items:center;gap:6px;min-height:28px;padding:0 4px;border-radius:6px;text-align:left}
|
|
74
|
+
.vc .vc-dn b{display:grid;place-items:center;min-width:24px;height:24px;border-radius:6px;font-size:var(--fs-2);font-weight:600;color:var(--ink)}
|
|
75
|
+
.vc .vc-md.now .vc-dn b{background:var(--solid);color:var(--on-solid)}
|
|
76
|
+
.vc .vc-dn i{display:none;font-style:normal;font:500 var(--fs-1) var(--mono);color:var(--ink-3)}
|
|
77
|
+
.vc .vc-me{display:block;min-width:0;border-radius:6px;padding:2px 6px;font-size:var(--fs-1);line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;color:var(--ink);
|
|
78
|
+
background:color-mix(in oklab,var(--sky) 12%,transparent)}
|
|
79
|
+
.vc .vc-me time{font:400 var(--fs-1) var(--mono);color:var(--ink-2);margin-right:4px}
|
|
80
|
+
.vc .vc-md>.vc-ad{font-size:var(--fs-1)}
|
|
81
|
+
.vc .vc-more{align-self:flex-start;padding:1px 6px;border-radius:6px;font-size:var(--fs-1);font-weight:500;color:var(--ink-3)}
|
|
82
|
+
@container (max-width:559px){
|
|
83
|
+
.vc .vc-md{min-height:48px;padding:2px}
|
|
84
|
+
.vc .vc-md>.vc-me,.vc .vc-md>.vc-more,.vc .vc-md>.vc-ad{display:none}
|
|
85
|
+
.vc .vc-dn{flex:1;flex-direction:column;justify-content:center;gap:2px;min-height:44px;padding:0}
|
|
86
|
+
.vc .vc-dn i{display:block}
|
|
87
|
+
.vc .vc-mh span{padding:6px 2px;text-align:center}
|
|
88
|
+
}
|
|
89
|
+
@media (max-width:640px){.vc-open,.vc .vc-ib{width:44px;height:44px}.vc .vc-tdy,.vc .vc-seg button{min-height:44px}}
|
|
90
|
+
@media (hover:hover){
|
|
91
|
+
.vc-open:hover{color:var(--ink)}
|
|
92
|
+
.vc .vc-ev:hover{background:color-mix(in oklab,var(--sky) 24%,var(--card-solid))}
|
|
93
|
+
.vc .vc-dn:hover{background:var(--well)}
|
|
94
|
+
.vc .vc-me:hover{background:color-mix(in oklab,var(--sky) 22%,transparent)}
|
|
95
|
+
.vc .vc-more:hover{color:var(--ink);background:var(--well)}
|
|
96
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/* pm/premium-vw-cal.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8).
|
|
2
|
+
* Reads GET /api/calendar-views?view=day|week|month&date=YYYY-MM-DD only, the same answer the console's Calendar draws (pm/calendar-views.js).
|
|
3
|
+
* Meetings come from the answer's cells; the all-day row also carries the answer's dated layers (an initiative's promised date, a plan item,
|
|
4
|
+
* a release, a report, your own due items). Nothing is invented: a range with no meeting says so, and a calendar that did not answer says why.
|
|
5
|
+
* Pressing a meeting opens its detail (premium-meeting.js openRow, the meeting dialog of slice S3) with the calendar as a tab beside it.
|
|
6
|
+
* The mockup is the iteration-3 calendar of prototype/premium-conversation-shell/index.html (.calw, .cg, .ev, .agd).
|
|
7
|
+
* calModel(r, view, date, today) pure · calHtml(M, esc) pure · mountCal(el, st, d) · openCalendar(d, st?) */
|
|
8
|
+
import { weekView } from './premium-meeting.js';
|
|
9
|
+
import { vwOpen, vwShow, vwStyle } from './premium-viewer.js';
|
|
10
|
+
|
|
11
|
+
export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
|
|
12
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
13
|
+
const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
14
|
+
const DOW = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
15
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
16
|
+
const parts = (k) => k.split('-').map(Number);
|
|
17
|
+
const keyOf = (t) => `${t.getUTCFullYear()}-${pad(t.getUTCMonth() + 1)}-${pad(t.getUTCDate())}`;
|
|
18
|
+
const addDays = (k, n) => { const [y, m, d] = parts(k); return keyOf(new Date(Date.UTC(y, m - 1, d + n))); };
|
|
19
|
+
const wd = (k) => { const [y, m, d] = parts(k); return (new Date(Date.UTC(y, m - 1, d)).getUTCDay() + 6) % 7; }; // Monday is 0
|
|
20
|
+
const hasTime = (s) => /T\d{2}:\d{2}/.test(String(s || ''));
|
|
21
|
+
const minOf = (s) => Number(String(s).slice(11, 13)) * 60 + Number(String(s).slice(14, 16)); // the wall clock as written, like premium-meeting.js hhmm
|
|
22
|
+
const hh = (m) => `${pad(Math.floor(m / 60))}:${pad(m % 60)}`;
|
|
23
|
+
export const todayKey = () => { const t = new Date(); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
|
|
24
|
+
|
|
25
|
+
/** The date one step before (-1) or after (1) `date` in `view`. */
|
|
26
|
+
export function shift(view, date, dir) {
|
|
27
|
+
const [y, m, d] = parts(date);
|
|
28
|
+
if (view === 'day') return addDays(date, dir);
|
|
29
|
+
if (view === 'week') return addDays(date, 7 * dir);
|
|
30
|
+
return keyOf(new Date(Date.UTC(y, m - 1 + dir, 1)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The range's name: "Mon 19 Oct 2026", "19 – 25 Oct 2026" (or "28 Sep – 4 Oct 2026"), "October 2026". */
|
|
34
|
+
export function titleOf(view, range) {
|
|
35
|
+
const [y1, m1, d1] = parts(range.start), [y2, m2, d2] = parts(range.end);
|
|
36
|
+
if (view === 'month') return `${MONTH[m1 - 1]} ${y1}`;
|
|
37
|
+
if (view === 'day') return `${DOW[wd(range.start)]} ${d1} ${MON[m1 - 1]} ${y1}`;
|
|
38
|
+
if (y1 !== y2) return `${d1} ${MON[m1 - 1]} ${y1} – ${d2} ${MON[m2 - 1]} ${y2}`;
|
|
39
|
+
return m1 === m2 ? `${d1} – ${d2} ${MON[m2 - 1]} ${y2}` : `${d1} ${MON[m1 - 1]} – ${d2} ${MON[m2 - 1]} ${y2}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Side by side lanes for meetings that overlap on one day. Mutates each block with lane and lanes. */
|
|
43
|
+
function lanes(blocks) {
|
|
44
|
+
blocks.sort((a, b) => a.s - b.s || b.e - a.e);
|
|
45
|
+
let group = [], end = -1;
|
|
46
|
+
const close = () => { const n = Math.max(1, ...group.map((b) => b.lane + 1)); group.forEach((b) => { b.lanes = n; }); group = []; };
|
|
47
|
+
for (const b of blocks) {
|
|
48
|
+
if (b.s >= end && group.length) close();
|
|
49
|
+
const taken = new Set(group.filter((g) => g.e > b.s).map((g) => g.lane));
|
|
50
|
+
let l = 0; while (taken.has(l)) l++;
|
|
51
|
+
b.lane = l; group.push(b); end = Math.max(end, b.e);
|
|
52
|
+
}
|
|
53
|
+
if (group.length) close();
|
|
54
|
+
return blocks;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The grid as drawn. `r` is the answer of GET /api/calendar-views for `view`, or { ok:false, error }. Every block is a meeting row of
|
|
58
|
+
* weekView (premium-meeting.js), so pressing it opens the same meeting dialog the Briefing's card opens. */
|
|
59
|
+
export function calModel(r, view, date, today) {
|
|
60
|
+
const W = weekView(r, today);
|
|
61
|
+
const range = (r && r.range) || { start: date, end: date };
|
|
62
|
+
const base = { view, date, today, title: r && r.range ? titleOf(view, r.range) : '' };
|
|
63
|
+
if (W.state !== 'ok') return { ...base, state: 'error', reason: W.reason, days: [], total: 0, caption: 'Calendar not read' };
|
|
64
|
+
const layers = Array.isArray(r.layers) ? r.layers.filter((x) => x && x.title && /^\d{4}-\d{2}-\d{2}/.test(String(x.date))) : [];
|
|
65
|
+
const byKey = new Map(W.days.map((x) => [x.key, x]));
|
|
66
|
+
let from = 8 * 60, to = 18 * 60;
|
|
67
|
+
const dayOf = (key) => {
|
|
68
|
+
const src = byKey.get(key), rows = src ? src.rows : [];
|
|
69
|
+
const timed = [], allday = [];
|
|
70
|
+
rows.forEach((row, i) => {
|
|
71
|
+
const ref = key + '|' + i;
|
|
72
|
+
if (hasTime(row.at) && String(row.at).slice(0, 10) === key) {
|
|
73
|
+
const s = minOf(row.at), endSame = row.end && hasTime(row.end) && String(row.end).slice(0, 10) === key;
|
|
74
|
+
const e = Math.max(s + 15, endSame ? minOf(row.end) : row.end ? 24 * 60 : s + 30);
|
|
75
|
+
from = Math.min(from, Math.floor(s / 60) * 60); to = Math.max(to, Math.min(24 * 60, Math.ceil(e / 60) * 60));
|
|
76
|
+
timed.push({ ref, s, e, title: row.title, time: `${hh(s)}–${hh(e)}`, sub: row.sub, about: row.about, past: row.past, row });
|
|
77
|
+
} else allday.push({ ref, title: row.title, sub: row.sub, kind: 'meet', row });
|
|
78
|
+
});
|
|
79
|
+
for (const x of layers) {
|
|
80
|
+
const a = String(x.date).slice(0, 10), b = x.end && /^\d{4}-\d{2}-\d{2}/.test(String(x.end)) ? String(x.end).slice(0, 10) : a;
|
|
81
|
+
if (a <= key && key <= b) allday.push({ title: x.title, kind: x.kind || x.layer || 'mark', tone: x.tone || null });
|
|
82
|
+
}
|
|
83
|
+
const [, m, d] = parts(key);
|
|
84
|
+
return { key, dow: DOW[wd(key)], n: d, mon: MON[m - 1], label: `${DOW[wd(key)]} ${d} ${MON[m - 1]}`, today: key === today, past: key < today,
|
|
85
|
+
inRange: key >= range.start && key <= range.end, timed: lanes(timed), allday, meetings: rows.length };
|
|
86
|
+
};
|
|
87
|
+
let keys = [];
|
|
88
|
+
if (view === 'month') {
|
|
89
|
+
const first = addDays(range.start, -wd(range.start)), last = addDays(range.end, 6 - wd(range.end));
|
|
90
|
+
for (let k = first; k <= last; k = addDays(k, 1)) keys.push(k);
|
|
91
|
+
} else for (let k = range.start; k <= range.end; k = addDays(k, 1)) keys.push(k);
|
|
92
|
+
let days = keys.map(dayOf);
|
|
93
|
+
// the week shows Saturday and Sunday only when they hold something, or one is today
|
|
94
|
+
if (view === 'week') days = days.filter((x) => wd(x.key) < 5 || x.today || x.meetings || x.allday.length);
|
|
95
|
+
const total = days.filter((x) => x.inRange).reduce((s, x) => s + x.meetings, 0);
|
|
96
|
+
const none = r.events_source === 'none' ? 'PMOS holds no calendar to read.' : `No meetings ${view === 'day' ? 'on this day' : 'in this ' + view}.`;
|
|
97
|
+
return { ...base, state: 'ok', days, from, to, total, caption: total ? `${total} ${total === 1 ? 'meeting' : 'meetings'}` : 'No meetings', empty: total ? '' : none };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ICON = {
|
|
101
|
+
back: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6',
|
|
102
|
+
};
|
|
103
|
+
const ic = (k) => `<svg class="i" viewBox="0 0 24 24"><path d="${ICON[k]}"/></svg>`;
|
|
104
|
+
|
|
105
|
+
/** The grid's markup. Both the timeline and the list are drawn for Day and Week; the pane's width picks one (premium-vw-cal.css). */
|
|
106
|
+
export function calHtml(M, esc, nowMin = null) {
|
|
107
|
+
const H = 44, top = (m) => ((m - M.from) / 60) * H;
|
|
108
|
+
const seg = `<div class="vc-seg" role="group" aria-label="Calendar view">${VIEWS.map(([k, l]) => `<button type="button" data-cv="${k}" aria-pressed="${M.view === k}">${l}</button>`).join('')}</div>`;
|
|
109
|
+
const step = M.view === 'day' ? 'day' : M.view === 'week' ? 'week' : 'month';
|
|
110
|
+
const head = `<div class="vc-h"><button type="button" class="vc-ib" data-cn="-1" aria-label="Previous ${step}">${ic('back')}</button><button type="button" class="vc-ib" data-cn="1" aria-label="Next ${step}">${ic('next')}</button><button type="button" class="vc-tdy" data-cn="0">Today</button><b class="vc-t">${esc(M.title)}</b><small class="vc-cap">${esc(M.caption)}</small>${seg}</div>`;
|
|
111
|
+
if (M.state !== 'ok') return `<div class="vc-w">${head}<p class="vc-empty" role="status">Calendar not read. ${esc(M.reason)}</p></div>`;
|
|
112
|
+
const chip = (a) => a.row ? `<button type="button" class="vc-ad meet" data-ev="${esc(a.ref)}" title="${esc(a.title)}">${esc(a.title)}</button>` : `<span class="vc-ad ${esc(a.kind)}${a.tone ? ' t-' + esc(a.tone) : ''}" title="${esc(a.title)}">${esc(a.title)}</span>`;
|
|
113
|
+
const empty = M.empty ? `<p class="vc-empty" role="status">${esc(M.empty)}</p>` : '';
|
|
114
|
+
if (M.view === 'month') {
|
|
115
|
+
const cells = M.days.map((x) => {
|
|
116
|
+
const ev = [...x.allday.filter((a) => a.row), ...x.timed].sort((a, b) => (a.s || 0) - (b.s || 0));
|
|
117
|
+
const say = `${x.label}${x.today ? ', today' : ''}: ${x.meetings ? x.meetings + (x.meetings === 1 ? ' meeting' : ' meetings') : 'no meetings'}`;
|
|
118
|
+
return `<div class="vc-md${x.inRange ? '' : ' out'}${x.today ? ' now' : ''}${x.past ? ' past' : ''}"><button type="button" class="vc-dn" data-day="${x.key}" aria-label="${esc(say)}"><b>${x.n}</b>${x.meetings ? `<i>${x.meetings}</i>` : ''}</button>${x.allday.filter((a) => !a.row).slice(0, 1).map(chip).join('')}${ev.slice(0, 3).map((e) => `<button type="button" class="vc-me" data-ev="${esc(e.ref)}" title="${esc(e.title)}">${e.s != null ? `<time>${hh(e.s)}</time>` : ''}${esc(e.title)}</button>`).join('')}${ev.length > 3 ? `<button type="button" class="vc-more" data-day="${x.key}">${ev.length - 3} more</button>` : ''}</div>`;
|
|
119
|
+
}).join('');
|
|
120
|
+
return `<div class="vc-w">${head}<div class="vc-mg"><div class="vc-mh">${DOW.map((d) => `<span>${d}</span>`).join('')}</div><div class="vc-mb">${cells}</div></div>${empty}</div>`;
|
|
121
|
+
}
|
|
122
|
+
const n = M.days.length, hours = [];
|
|
123
|
+
for (let m = M.from; m < M.to; m += 60) hours.push(m);
|
|
124
|
+
const blk = (e) => `<button type="button" class="vc-ev${e.past ? ' past' : ''}${e.e - e.s < 30 ? ' sh' : ''}" data-ev="${esc(e.ref)}" data-tl="${top(e.s) + 1}px ${Math.max(14, ((e.e - e.s) / 60) * H - 3)}px ${(e.lane / e.lanes) * 100}% ${100 / e.lanes}%" title="${esc(e.title + ' · ' + e.time)}"><b>${esc(e.title)}</b><small>${e.time}</small></button>`;
|
|
125
|
+
const grid = `<div class="vc-g" data-tl="${n}"><div class="vc-c"></div>${M.days.map((x) => `<div class="vc-dh${x.today ? ' now' : ''}">${x.dow}<b>${x.n}</b></div>`).join('')}<div class="vc-adl">all day</div>${M.days.map((x) => `<div class="vc-adc">${x.allday.map(chip).join('')}</div>`).join('')}<div class="vc-gut">${hours.map((m) => `<i>${hh(m)}</i>`).join('')}</div>${M.days.map((x) => `<div class="vc-day${x.past ? ' past' : ''}" data-tl="${hours.length * H}px">${x.today && nowMin != null && nowMin >= M.from && nowMin <= M.to ? `<span class="vc-now" data-tl="${top(nowMin)}px" aria-hidden="true"></span>` : ''}${x.timed.map(blk).join('')}</div>`).join('')}</div>`;
|
|
126
|
+
const list = `<div class="vc-ag">${M.days.map((x) => { const rows = [...x.allday.filter((a) => a.row), ...x.timed]; return `<h4${x.today ? ' class="now"' : ''}>${x.label}${x.today ? ' · today' : ''}</h4>${x.allday.filter((a) => !a.row).map(chip).join('')}${rows.length ? rows.map((e) => `<button type="button" class="vc-ar${e.past ? ' past' : ''}" data-ev="${esc(e.ref)}"><time>${e.s != null ? hh(e.s) : 'All day'}</time><span><b>${esc(e.title)}</b>${e.sub || e.about ? `<small>${esc([e.sub, e.about].filter(Boolean).join(' · '))}</small>` : ''}</span></button>`).join('') : '<p class="vc-none">No meetings</p>'}`; }).join('')}</div>`;
|
|
127
|
+
return `<div class="vc-w">${head}${empty}${grid}${list}</div>`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The run-time geometry of the timeline: data-tl on a block is "top height left width", on the grid its column count, on a day its height. */
|
|
131
|
+
export function placeAll(el) {
|
|
132
|
+
el.querySelectorAll('[data-tl]').forEach((n) => {
|
|
133
|
+
const v = n.dataset.tl.split(' ');
|
|
134
|
+
if (n.classList.contains('vc-ev')) ['--tl-t', '--tl-h', '--tl-l', '--tl-w'].forEach((k, i) => n.style.setProperty(k, v[i]));
|
|
135
|
+
else if (n.classList.contains('vc-g')) n.style.setProperty('--tl-n', v[0]);
|
|
136
|
+
else if (n.classList.contains('vc-day')) n.style.setProperty('--tl-hh', v[0]);
|
|
137
|
+
else n.style.setProperty('--tl-t', v[0]);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const S = new WeakMap(); // host -> { st, M, seq }
|
|
142
|
+
|
|
143
|
+
/** Draws the grid in `el` and keeps it live. st = { view, date }. d = { pmGet, esc, ws(), openRow(row) } */
|
|
144
|
+
export function mountCal(el, st, d) {
|
|
145
|
+
vwStyle('cal');
|
|
146
|
+
const me = { st: { view: (st && st.view) || 'week', date: (st && st.date) || todayKey() }, M: null, seq: 0 };
|
|
147
|
+
S.set(el, me); el.classList.add('vc');
|
|
148
|
+
const nowMin = () => { const t = new Date(); return t.getHours() * 60 + t.getMinutes(); };
|
|
149
|
+
const paint = () => { el.innerHTML = me.M ? calHtml(me.M, d.esc, nowMin()) : `<div class="vc-w"><p class="vc-empty" role="status">Reading the calendar PMOS holds.</p></div>`; placeAll(el); };
|
|
150
|
+
const read = async () => {
|
|
151
|
+
const n = ++me.seq, { view, date } = me.st, w = d.ws && d.ws();
|
|
152
|
+
const res = await d.pmGet(`/api/calendar-views?view=${view}&date=${date}${w ? '&ws=' + encodeURIComponent(w) : ''}`);
|
|
153
|
+
if (n !== me.seq || !el.isConnected) return;
|
|
154
|
+
me.M = calModel(res, view, date, todayKey()); paint();
|
|
155
|
+
};
|
|
156
|
+
const go = (view, date, focus) => { me.st = { view, date }; read().then(() => { if (!focus) return; const b = el.querySelector(focus); if (b) b.focus(); }); };
|
|
157
|
+
el.onclick = (e) => { // delegated: every control of the grid is a button inside el
|
|
158
|
+
const b = e.target.closest('button'); if (!b || !el.contains(b)) return;
|
|
159
|
+
if (b.dataset.cv) return go(b.dataset.cv, me.st.date, `[data-cv="${b.dataset.cv}"]`);
|
|
160
|
+
if (b.dataset.cn != null) { const dir = +b.dataset.cn; return go(me.st.view, dir ? shift(me.st.view, me.st.date, dir) : todayKey(), `[data-cn="${b.dataset.cn}"]`); }
|
|
161
|
+
if (b.dataset.day) return go('day', b.dataset.day, '[data-cv="day"]');
|
|
162
|
+
if (b.dataset.ev) {
|
|
163
|
+
const [k, i] = b.dataset.ev.split('|'), x = me.M && me.M.days.find((y) => y.key === k);
|
|
164
|
+
const hit = x && [...x.timed, ...x.allday].find((y) => y.ref === k + '|' + i);
|
|
165
|
+
if (hit && hit.row && d.openRow) d.openRow(hit.row, { ...me.st });
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
paint(); read();
|
|
169
|
+
return { state: () => ({ ...me.st }), reload: read };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The calendar on its own: a dialog whose detail is the grid. d = { openDlg, turnA, ptx, $, pmGet, esc, ws(), openRow(row) } where openRow
|
|
173
|
+
* opens the meeting dialog. After a meeting opens, the grid comes back as a tab beside it at the same view and date. */
|
|
174
|
+
export function openCalendar(d, st) {
|
|
175
|
+
const open = (row, at) => {
|
|
176
|
+
d.openRow(row); // openDlg runs at once inside, so the tab below belongs to the meeting's dialog
|
|
177
|
+
vwOpen({ id: 'cal', title: 'Calendar', icon: 'cal', render: (el) => { el.classList.add('vc'); mountCal(el, at, { ...d, openRow: open }); } });
|
|
178
|
+
vwShow('main');
|
|
179
|
+
};
|
|
180
|
+
d.openDlg({ eye: 'Calendar · real data', title: 'Calendar', stream: d.turnA(d.ptx('This is the calendar PMOS holds. Press a meeting to open its detail; the calendar stays as a tab beside it.')),
|
|
181
|
+
pane: '<div class="vc" id="vcMain"></div>', label: 'Calendar' });
|
|
182
|
+
const f = d.$('#askF'); if (f) f.hidden = true;
|
|
183
|
+
return mountCal(d.$('#vcMain'), st || { view: 'week', date: todayKey() }, { ...d, openRow: open });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** The Briefing's Calendar card gets a button that opens the full calendar. */
|
|
187
|
+
export function mountCalEntry(card, d) {
|
|
188
|
+
if (!card || card.querySelector('.vc-open')) return;
|
|
189
|
+
vwStyle('cal');
|
|
190
|
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'vc-open'; b.setAttribute('aria-label', 'Open the calendar'); b.title = 'Open the calendar';
|
|
191
|
+
b.innerHTML = '<svg class="i" viewBox="0 0 24 24"><path d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7"/></svg>';
|
|
192
|
+
const h = card.querySelector('.ch'), fold = h && h.querySelector('.foldb');
|
|
193
|
+
if (fold) fold.before(b); else if (h) h.append(b);
|
|
194
|
+
b.onclick = () => openCalendar(d);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (typeof window !== 'undefined') window.__premiumCal = { calModel, openCalendar };
|
|
@@ -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 };
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { pmPost, pmGet } from './http.js';
|
|
6
6
|
import { startAgent } from './page-agent.js';
|
|
7
7
|
import { mountMeeting } from './premium-meeting.js';
|
|
8
|
+
import { mountCalEntry } from './premium-vw-cal.js';
|
|
8
9
|
import { mountFirst } from './premium-first.js';
|
|
9
10
|
import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
|
|
10
11
|
import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
|
|
@@ -23,6 +24,7 @@ const pinned = new Set();
|
|
|
23
24
|
|
|
24
25
|
wireRail('brief');
|
|
25
26
|
const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => { if (M) drawTl(); } });
|
|
27
|
+
mountCalEntry($('#todayCard'), { $, esc, openDlg, turnA, ptx, pmGet, ws: () => new URLSearchParams(location.search).get('ws'), openRow: week.openRow }); // the full calendar: Day, Week and Month in the viewer
|
|
26
28
|
|
|
27
29
|
/* ── a day's baseline, kept on this device, so "N of M done" counts rows that cleared since the page first read today ────── */
|
|
28
30
|
const dayKey = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-viewer, R8: the calendar grid (Day, Week, Month) in the premium viewer, opened from the Briefing's Calendar card.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"premium-vw-cal.test.js"
|
|
5
|
+
],
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-vw-cal-test.js"
|
|
8
|
+
],
|
|
9
|
+
"seconds": {
|
|
10
|
+
"premium-vw-cal.test.js": 2,
|
|
11
|
+
"premium-vw-cal-test.js": 60
|
|
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
|
+
}
|