create-pmos 0.768.0 → 0.770.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 +200 -68
- 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/changelog.json +291 -27
- package/workspace/guide/cli.md +1 -0
- package/workspace/lib/engine/boards.js +11 -3
- package/workspace/lib/initiative-chat.js +1 -1
- package/workspace/lib/routes-boards.js +31 -1
- package/workspace/lib/task-cli.js +25 -2
- package/workspace/lib/task-store.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-task-pop.css +57 -17
- package/workspace/public/pm/cozy-task-pop.js +161 -20
- package/workspace/public/pm/task-card.js +113 -5
- package/workspace/public/pm/vw-ds.js +112 -38
- package/workspace/test-lists/task-detail-one-column.json +9 -0
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
* openIni(id), inis() → [{ id, title }], owners() → [names], groups() → [names] | null,
|
|
20
20
|
* sections() → [{ key, name, milestone }] | null, now?(), changed?(t),
|
|
21
21
|
* remove?() — the trash at the end of the Status row (batch 17 item 2; deleteEntry's on) }
|
|
22
|
+
* cardHtml(t, { layout: 'chips' }) the full task popup's ONE chip row (task-detail-one-column, board TjC): the Status
|
|
23
|
+
* button and its menu, the owner, Start → Due, one chip per field that has a value, +
|
|
24
|
+
* ownerLabel(o) → { name, agent, initials } a readable owner: You, a person, or an agent by its role (never 'agent:sess-…')
|
|
25
|
+
* fieldChips(t, o) → [{ key, label, value, press? }] the fields that HAVE a value, in the order of the task's kind (o.kind)
|
|
22
26
|
* boardSaver({ ws, board, t, post, layout }) → save the board's routes behind h.save: status → tasks/state, owner, notes, dates, the
|
|
23
27
|
* section and the initiative → tasks/edit, the group → /api/initiative-layout place,
|
|
24
28
|
* a Jira ticket's notes → tickets/note. Each answers { ok, from } so Undo is save(from). */
|
|
@@ -66,6 +70,10 @@ export function taskOf(row, extra = {}) {
|
|
|
66
70
|
jira: jira ? { key: r.ref || r.key || r.uid || '', readAt: r.readAt || extra.readAt || '' } : null,
|
|
67
71
|
// the task's description (initiative task-descriptions): its words, who wrote the last one ('pmos' | 'you') and PMOS's sources
|
|
68
72
|
description: typeof r.description === 'string' ? r.description : '', descBy: r.descBy || '', descSources: Array.isArray(r.descSources) ? r.descSources : [],
|
|
73
|
+
// the chip row's fields (task-detail-one-column): carried only as the row has them; the chips show the ones with a value
|
|
74
|
+
priority: r.priority || '', sprint: r.sprint || '', estimate: r.estimate != null ? r.estimate : '', labels: r.labels || '', reviewer: r.reviewer || '',
|
|
75
|
+
doneTest: r.doneTest || r.done_test || '', change: r.change || r.pr || '', moves: r.moves || '', parent: r.parent || '',
|
|
76
|
+
comments: Array.isArray(r.comments) ? r.comments : [],
|
|
69
77
|
};
|
|
70
78
|
}
|
|
71
79
|
|
|
@@ -149,8 +157,102 @@ function movePop(t, o) {
|
|
|
149
157
|
/** Can the move icon do anything here: a section to pick, a group, or another initiative. */
|
|
150
158
|
const canMove = (t, o) => !!((o.sections || []).length || (Array.isArray(o.groups) && o.groups.length) || (o.inis || []).some((x) => x && x.id && x.id !== t.ini));
|
|
151
159
|
|
|
160
|
+
/* ── the chip row (task-detail-one-column, board TjC: one column, the fields as chips under the title) ───────────────────────────── */
|
|
161
|
+
/** A readable owner: 'pm:<slug>' and 'you' are You, an agent is named by its role (a session is a Build agent; PMOS's own runs are PMOS),
|
|
162
|
+
* a person by name. Never the raw 'agent:sess-…' id. */
|
|
163
|
+
export function ownerLabel(o) {
|
|
164
|
+
const v = String(o == null ? '' : o).trim();
|
|
165
|
+
if (!v) return { name: '', agent: false, initials: '' };
|
|
166
|
+
if (/^pm:/.test(v) || /^you$/i.test(v)) return { name: 'You', agent: false, initials: 'Y' };
|
|
167
|
+
if (/^agent:(sess|session)\b/i.test(v) || /^agent:build\b/i.test(v)) return { name: 'Build agent', agent: true, initials: '' };
|
|
168
|
+
if (/^agent(:|$)/i.test(v) || /^pmos$/i.test(v) || /^agent:auto$/i.test(v)) return { name: 'PMOS', agent: true, initials: '' };
|
|
169
|
+
const m = /^(?:person|tracker):(.+)$/s.exec(v);
|
|
170
|
+
const name = m ? m[1].trim() : v;
|
|
171
|
+
return { name, agent: false, initials: initials(name) };
|
|
172
|
+
}
|
|
173
|
+
/** The fields a task carries beyond status, owner and dates, in the order its kind reads them (board TjKinds): a Project task leads with
|
|
174
|
+
* Sprint, Estimate and Priority; a Full ADLC task with Done test, Change and Reviewer; a Product task with the outcome it moves. Only
|
|
175
|
+
* the fields that HAVE a value: no empty chip and no "+N" (every set field shows). o: { kind, sections } */
|
|
176
|
+
const KIND_ORDER = {
|
|
177
|
+
project: ['stage', 'sprint', 'estimate', 'priority', 'labels', 'reviewer', 'jira', 'doneTest', 'change', 'moves', 'group', 'wbs', 'milestone'],
|
|
178
|
+
adlc: ['stage', 'doneTest', 'change', 'reviewer', 'priority', 'sprint', 'estimate', 'labels', 'moves', 'group', 'wbs', 'milestone'],
|
|
179
|
+
product: ['stage', 'moves', 'priority', 'sprint', 'estimate', 'labels', 'reviewer', 'doneTest', 'change', 'group', 'wbs', 'milestone'],
|
|
180
|
+
};
|
|
181
|
+
const listOf = (v) => (Array.isArray(v) ? v : typeof v === 'string' ? v.split(',') : []).map((x) => String(x).trim()).filter(Boolean);
|
|
182
|
+
export function fieldChips(t, o = {}) {
|
|
183
|
+
const kind = o.kind === 'project' || o.kind === 'adlc' ? o.kind : o.kind === 'full' || o.kind === 'full-adlc' ? 'adlc' : 'product';
|
|
184
|
+
const F = {};
|
|
185
|
+
const sec = sectionName(t, o.sections);
|
|
186
|
+
if (sec) F.stage = { label: 'Stage', value: sec, press: 'move' };
|
|
187
|
+
if (t.sprint) F.sprint = { label: 'Sprint', value: String(t.sprint) };
|
|
188
|
+
if (t.priority) F.priority = { label: 'Priority', value: String(t.priority), press: t.jira ? '' : 'prio' };
|
|
189
|
+
if (t.estimate != null && t.estimate !== '') F.estimate = { label: 'Estimate', value: String(t.estimate) };
|
|
190
|
+
const labels = listOf(t.labels);
|
|
191
|
+
if (labels.length) F.labels = { label: 'Labels', value: labels.join(', ') };
|
|
192
|
+
if (t.reviewer) { const r = ownerLabel(t.reviewer); if (r.name) F.reviewer = { label: 'Reviewer', value: r.name }; }
|
|
193
|
+
if (t.doneTest) F.doneTest = { label: 'Done test', value: String(t.doneTest).split('/').pop() };
|
|
194
|
+
if (t.change) F.change = { label: 'Change', value: String(t.change.label || t.change), href: t.change.url || '' };
|
|
195
|
+
if (t.moves) F.moves = { label: 'Moves', value: String(t.moves) };
|
|
196
|
+
// a Project task names its Jira key only when Jira's record differs from PMOS's (TjKinds: "Jira IDPF-412 · differs: Owner")
|
|
197
|
+
if (kind === 'project' && t.jiraDiffers && t.jiraKey) F.jira = { label: 'Jira', value: t.jiraKey + ' · differs: ' + t.jiraDiffers };
|
|
198
|
+
if (t.group) F.group = { label: 'Group', value: t.group, press: 'move' };
|
|
199
|
+
if (t.wbs && t.wbs.title) F.wbs = { label: 'Under', value: t.wbs.title };
|
|
200
|
+
if (t.milestone) F.milestone = { label: 'Milestone', value: 'Milestone', press: t.jira ? '' : 'ms' };
|
|
201
|
+
return KIND_ORDER[kind].filter((k) => F[k]).map((k) => ({ key: k, ...F[k] }));
|
|
202
|
+
}
|
|
203
|
+
const PRIOS = ['P1', 'P2', 'P3'];
|
|
204
|
+
const AGENT_GLYPH = '<path d="M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z"/>';
|
|
205
|
+
/** The chip row's markup. The pickers are the card's own (status menu, owner list, the one calendar, move, priority); + adds a field. */
|
|
206
|
+
function chipsHtml(t, o = {}) {
|
|
207
|
+
const now = o.now || Date.now(), sk = SKEY[t.status] || 'todo', open = o.open;
|
|
208
|
+
const anc = (inner, pop = '') => `<span class="anc">${inner}${pop}</span>`;
|
|
209
|
+
// Status: one button with a menu of every state (the five icons of the old row); the day it happened is asked after the pick
|
|
210
|
+
const sOpen = open === 'status';
|
|
211
|
+
const stMenu = sOpen ? listPop('Status', STATES.map((x) => ({ label: x, on: x === t.status, attr: `data-tkc-state="${esc(x)}"`, icon: ico(SICON[SKEY[x]]) }))) : '';
|
|
212
|
+
const status = anc(`<button type="button" class="tkc-chip st s-${sk}${sOpen ? ' open' : ''}" data-tkc="status" aria-haspopup="menu" aria-expanded="${sOpen}" aria-label="Status: ${esc(t.status)}${t.jira ? '. Jira owns it' : '. Change'}" title="Status"${t.jira ? ' disabled' : ''}>${ico(SICON[sk])}<span>${esc(t.status)}</span>${t.jira ? '' : ico('<path d="M7 10l5 5 5-5"/>', 14)}</button>`, stMenu);
|
|
213
|
+
// the owner, by a readable name; an agent by its role with the agent glyph
|
|
214
|
+
const oOpen = open === 'owner', ow = ownerLabel(t.owner);
|
|
215
|
+
const owners = [...new Set((o.owners || []).concat(t.owner ? [t.owner] : []).filter(Boolean))];
|
|
216
|
+
const ownerPop = oOpen ? listPop('Owner', owners.map((n) => { const L = ownerLabel(n); return { label: L.name || n, on: n === t.owner, attr: `data-tkc-owner="${esc(n)}"`, icon: L.agent ? ico(AGENT_GLYPH, 14) : `<span class="av">${esc(L.initials)}</span>` }; })
|
|
217
|
+
.concat(t.owner ? [{ sep: true }, { label: 'No owner', attr: 'data-tkc-owner=""' }] : []),
|
|
218
|
+
`<form class="tkc-new" data-tkc-form="owner"><input type="text" maxlength="80" placeholder="Someone else" aria-label="Owner's name" autocomplete="off"></form>`) : '';
|
|
219
|
+
const owner = anc(ow.name
|
|
220
|
+
? `<button type="button" class="tkc-chip own${ow.agent ? ' agent' : ''}${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Owner: ${esc(ow.name)}${t.jira ? '' : '. Change'}" title="Owner" aria-expanded="${oOpen}"${t.jira ? ' disabled' : ''}>${ow.agent ? ico(AGENT_GLYPH, 14) : `<span class="av">${esc(ow.initials)}</span>`}<span>${esc(ow.name)}</span></button>`
|
|
221
|
+
: `<button type="button" class="tkc-chip own ghost${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Choose an owner" title="Owner" aria-expanded="${oOpen}"${t.jira ? ' disabled' : ''}>${ico(I.user, 14)}<span>No owner</span></button>`, ownerPop);
|
|
222
|
+
// Start → Due on the one calendar (the agreed task-dates picker); the late text in amber
|
|
223
|
+
const dl = dueLine(t, now), dOpen = open === 'dates';
|
|
224
|
+
const dates = anc(`<button type="button" class="tkc-chip dt${dl.late ? ' late' : ''}${dl.none ? ' ghost' : ''}${dOpen ? ' open' : ''}" data-tkc="dates" aria-label="${dl.none ? 'Add dates' : esc(dl.text) + (dl.lateText ? ', ' + esc(dl.lateText) : '') + '. Change the dates'}" title="Start and due" aria-expanded="${dOpen}">${ico(I.cal, 14)}<span>${dl.none ? 'Dates' : esc(dl.text)}${dl.lateText ? ` · ${esc(dl.lateText)}` : ''}</span></button>`,
|
|
225
|
+
dOpen ? picker(t, { ...o, one: !!t.milestone }, now) : '');
|
|
226
|
+
// one chip per field that has a value; Stage and Group open the move list, Priority its menu, Milestone takes the flag off
|
|
227
|
+
const mOpen = open === 'move', pOpen = open === 'prio';
|
|
228
|
+
const prioPop = pOpen ? listPop('Priority', PRIOS.map((x) => ({ label: x, on: x === t.priority, attr: `data-tkc-prio="${x}"` })).concat(t.priority ? [{ sep: true }, { label: 'No priority', attr: 'data-tkc-prio=""' }] : [])) : '';
|
|
229
|
+
let movePlaced = false, prioPlaced = false;
|
|
230
|
+
const fields = fieldChips(t, o).map((f) => {
|
|
231
|
+
const word = `<span class="k">${esc(f.label)}</span><span>${esc(f.value)}</span>`;
|
|
232
|
+
if (f.href) return `<a class="tkc-chip fld" href="${esc(f.href)}" target="_blank" rel="noopener" aria-label="${esc(f.label + ': ' + f.value)}">${word}</a>`;
|
|
233
|
+
if (f.press === 'move' && canMove(t, o) && !movePlaced) { movePlaced = true; return anc(`<button type="button" class="tkc-chip fld${mOpen ? ' open' : ''}" data-tkc="move" aria-haspopup="menu" aria-expanded="${mOpen}" aria-label="${esc(f.label + ': ' + f.value)}. Move it">${word}</button>`, mOpen ? movePop(t, o) : ''); }
|
|
234
|
+
if (f.press === 'prio') { prioPlaced = true; return anc(`<button type="button" class="tkc-chip fld${pOpen ? ' open' : ''}" data-tkc="prio" aria-haspopup="menu" aria-expanded="${pOpen}" aria-label="Priority: ${esc(f.value)}. Change">${word}</button>`, prioPop); }
|
|
235
|
+
if (f.press === 'ms') return `<button type="button" class="tkc-chip fld" data-tkc-ms aria-pressed="true" aria-label="A milestone. Press to make it a plain task" title="Make it a plain task">${ico(I.dia, 14)}<span>Milestone</span></button>`;
|
|
236
|
+
return `<span class="tkc-chip fld ro" aria-label="${esc(f.label + ': ' + f.value)}">${word}</span>`;
|
|
237
|
+
}).join('');
|
|
238
|
+
// + adds an empty field: what is not set yet and has a write here, a note, a subtask (the host draws those two)
|
|
239
|
+
const aOpen = open === 'add';
|
|
240
|
+
const add = [];
|
|
241
|
+
if (!t.jira && !t.section && (o.sections || []).length) add.push({ label: 'Stage', attr: 'data-tkc-add="move"', icon: ico(I.drag, 14) });
|
|
242
|
+
if (!t.jira && !t.priority) add.push({ label: 'Priority', attr: 'data-tkc-add="prio"', icon: ico(I.flag, 14) });
|
|
243
|
+
if (o.addNote && !t.notes) add.push({ label: 'Note', attr: 'data-tkc-add="note"', icon: ico('<path d="M5 4h14v16H5zM9 9h6M9 13h6"/>', 14) });
|
|
244
|
+
if (o.addSub) add.push({ label: 'Subtask', attr: 'data-tkc-add="sub"', icon: ico('<path d="M6 4v10a3 3 0 0 0 3 3h9M15 14l3 3-3 3"/>', 14) });
|
|
245
|
+
// the move list and the priority menu open under + when their chip is not there yet (from + or from ⋯ Move)
|
|
246
|
+
// the + sits at the end of the row: its list opens to the left, inside the popup
|
|
247
|
+
const right = (h) => h.replace('class="tkc-pop"', 'class="tkc-pop r"');
|
|
248
|
+
const plusPop = right(aOpen ? listPop('Add a field', add) : mOpen && !movePlaced ? movePop(t, o) : pOpen && !prioPlaced ? prioPop : '');
|
|
249
|
+
const plus = add.length || (mOpen && !movePlaced) || (pOpen && !prioPlaced) ? anc(`<button type="button" class="tkc-chip plus${aOpen ? ' open' : ''}" data-tkc="add" aria-haspopup="menu" aria-expanded="${aOpen}" aria-label="Add a field" title="Add a field">${ico('<path d="M12 5v14M5 12h14"/>', 14)}</button>`, plusPop) : '';
|
|
250
|
+
return `<div class="tkc tkc-chips s-${sk}"><div class="tkc-row" role="group" aria-label="Fields">${status}${owner}${dates}${fields}${plus}</div><p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
|
|
251
|
+
}
|
|
252
|
+
|
|
152
253
|
/** The card's markup. o: { open: null | 'dates' | 'owner' | 'move', field, month, owners, groups, sections, inis, now, msg } */
|
|
153
254
|
export function cardHtml(t, o = {}) {
|
|
255
|
+
if (o.layout === 'chips') return chipsHtml(t, o);
|
|
154
256
|
const now = o.now || Date.now(), sk = SKEY[t.status] || 'todo';
|
|
155
257
|
// the facts card: Status, Due, Owner (canvas OvViewers "Task": the same shape as the Jira ticket's)
|
|
156
258
|
const seg = STATES.map((s) => { const k = SKEY[s], on = s === t.status;
|
|
@@ -223,6 +325,7 @@ const WORDS = {
|
|
|
223
325
|
dates: (t) => (dueLine(t).text || 'No dates'),
|
|
224
326
|
initiative: (t) => 'Moved to ' + (t.iniTitle || t.ini),
|
|
225
327
|
milestone: (t) => (t.milestone ? 'Milestone' : 'Not a milestone'),
|
|
328
|
+
priority: (t) => (t.priority ? 'Priority ' + t.priority : 'No priority'),
|
|
226
329
|
};
|
|
227
330
|
|
|
228
331
|
export function mountCard(el, t, h) {
|
|
@@ -233,7 +336,8 @@ export function mountCard(el, t, h) {
|
|
|
233
336
|
const keep = document.activeElement && el.contains(document.activeElement) && document.activeElement.matches('[data-tkc-notes]');
|
|
234
337
|
if (keep) return; // never redraw under the PM's typing
|
|
235
338
|
const inDp = !!(document.activeElement && document.activeElement.closest && document.activeElement.closest('.tkc-dp'));
|
|
236
|
-
el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, del: !!h.remove, now: h.now ? h.now() : Date.now()
|
|
339
|
+
el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, del: !!h.remove, now: h.now ? h.now() : Date.now(),
|
|
340
|
+
layout: h.layout || '', kind: h.kind ? h.kind() : '', addNote: !!h.add, addSub: !!(h.add && h.canSub && h.canSub()) });
|
|
237
341
|
const f = el.querySelector('.tkc-new input'); if (f && (st.open === 'owner' || st.open === 'group')) f.focus();
|
|
238
342
|
// the dates picker wires itself; each tap saves with Undo, and the second tap (the due day) closes it
|
|
239
343
|
const dp = el.querySelector('.tkc-dp');
|
|
@@ -268,16 +372,19 @@ export function mountCard(el, t, h) {
|
|
|
268
372
|
Promise.resolve(h.history.undo(d.tkcHundo)).catch(() => null).then((r) => { st.msg = r && r.ok !== false ? '' : (r && r.error) || 'The undo did not land.'; loadHist(); if (h.changed) h.changed(t); });
|
|
269
373
|
return;
|
|
270
374
|
}
|
|
271
|
-
if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
|
|
375
|
+
if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } else if (st.open === 'status') { st.open = null; draw(); } return; }
|
|
272
376
|
if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
|
|
273
377
|
if ('tkcDel' in d && h.remove) { st.open = null; b.disabled = true; Promise.resolve(h.remove()).catch(() => null).then(() => { if (b.isConnected) b.disabled = false; }); return; }
|
|
274
378
|
if (d.tkcOwner != null) { st.open = null; if (d.tkcOwner !== t.owner) change('owner', { owner: d.tkcOwner }); else draw(); return; }
|
|
275
379
|
if (d.tkcGroup != null) { st.open = null; if (d.tkcGroup !== t.group) change('group', { group: d.tkcGroup }); else draw(); return; }
|
|
276
380
|
if (d.tkcSection != null) { st.open = null; if (d.tkcSection !== t.section) change('section', { section: d.tkcSection }); else draw(); return; }
|
|
277
381
|
if (d.tkcMove) { st.open = null; change('initiative', { initiative: d.tkcMove }); return; }
|
|
382
|
+
// the chip row (task-detail-one-column): Priority's menu, and + (a field opens its own picker; a note or a subtask is the host's)
|
|
383
|
+
if (d.tkcPrio != null) { st.open = null; if (d.tkcPrio !== (t.priority || '')) change('priority', { priority: d.tkcPrio }); else draw(); return; }
|
|
384
|
+
if (d.tkcAdd) { const a = d.tkcAdd; st.open = a === 'move' || a === 'prio' ? a : null; draw(); if ((a === 'note' || a === 'sub') && h.add) h.add(a); return; }
|
|
278
385
|
const k = d.tkc;
|
|
279
386
|
if (k === 'ini') { if (h.openIni) h.openIni(t.ini); return; }
|
|
280
|
-
if (k === 'dates' || k === 'owner' || k === 'move') { st.open = st.open === k ? null : k; st.field = 'start'; st.month = ''; draw(); }
|
|
387
|
+
if (k === 'dates' || k === 'owner' || k === 'move' || k === 'status' || k === 'prio' || k === 'add') { st.open = st.open === k ? null : k; st.field = 'start'; st.month = ''; draw(); }
|
|
281
388
|
};
|
|
282
389
|
el.onsubmit = (e) => {
|
|
283
390
|
const f = e.target.closest('[data-tkc-form]'); if (!f) return;
|
|
@@ -304,7 +411,8 @@ export function mountCard(el, t, h) {
|
|
|
304
411
|
const loadHist = () => { if (h.history) Promise.resolve(h.history.load()).catch(() => null).then((L) => { st.hist = Array.isArray(L) ? L : []; draw(); }); };
|
|
305
412
|
draw();
|
|
306
413
|
loadHist();
|
|
307
|
-
|
|
414
|
+
// open(kind): a picker opened from outside the card (the full popup's ⋯ Move); null closes it
|
|
415
|
+
return { draw, setStatus: (s) => change('status', { status: s }), change, open: (k) => { st.open = k || null; st.field = 'start'; st.month = ''; draw(); }, task: t };
|
|
308
416
|
}
|
|
309
417
|
|
|
310
418
|
/** For the initiative's Tasks views (pm/ini-tasks.js, batch 9 item 5b): the same five status icons and the same start and due picker, opened
|
|
@@ -359,7 +467,7 @@ export function boardSaver(o) {
|
|
|
359
467
|
if (patch.status != null) return post('/api/boards/tasks/state', { ws, board, task: t.uid, state: patch.status });
|
|
360
468
|
if (patch.group != null) return post('/api/initiative-layout', { ws, kind: 'place', initiative: t.ini, task: t.key, group: patch.group });
|
|
361
469
|
const body = {};
|
|
362
|
-
for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative', 'milestone']) if (patch[k] != null) body[k] = patch[k];
|
|
470
|
+
for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative', 'milestone', 'priority']) if (patch[k] != null) body[k] = patch[k];
|
|
363
471
|
return post('/api/boards/tasks/edit', { ws, board, task: t.uid, ...body });
|
|
364
472
|
};
|
|
365
473
|
}
|
|
@@ -9,10 +9,21 @@
|
|
|
9
9
|
* descParts(text) → { what, why, done: [], rest } a description's What, Why and Done when (task-descriptions)
|
|
10
10
|
* descriptionHtml(t, o) → the Description block: PMOS writing it (o.busy), its parts, PMOS's sources with Undo, or the empty box to
|
|
11
11
|
* write in; o.edit draws the text box. Under Where it stands, so the task says what it is before anything else
|
|
12
|
-
* standsHtml · linkedHtml · activityHtml(hist, o) the
|
|
12
|
+
* standsHtml · linkedHtml · activityHtml(hist, o) the main-column blocks
|
|
13
|
+
*
|
|
14
|
+
* task-detail-one-column (board TjC, Wawan 2026-11-24 "Go with C"): the full popup is ONE column. The fields are chips under the title
|
|
15
|
+
* (task-card.js cardHtml layout 'chips'), so Where it stands says only what no field says: the risk and the next move, and a ✦ proposal
|
|
16
|
+
* when the state looks wrong. Then Description, Notes (only when there are notes), Subtasks, Linked (Waits on, Blocks, Subtask of,
|
|
17
|
+
* Change; never the initiative, the path carries it) and Activity (All · Comments · PMOS work log, the comment box at the bottom).
|
|
18
|
+
* ownerLabel · fieldChips re-exported from task-card.js: a readable owner, the chips of the fields that have a value
|
|
19
|
+
* proposalOf(t, o) → { to, why } | null ✦ when the state looks wrong (its subtasks say otherwise)
|
|
20
|
+
* notesHtml(t, o) → the Notes block, only when there are notes or o.open
|
|
21
|
+
* subtasksOf(items, uid) → [row] the task's children on the board (items with parent = uid)
|
|
22
|
+
* subtasksHtml(subs, o) → the Subtasks block: "1 of 3", a bar, a tick and the owner per child, the add box (o.adding)
|
|
13
23
|
*
|
|
14
24
|
* NOTHING HERE MAKES A FACT UP. A task with no due date says so; a task nobody has says so; zero is silence (no link, no Linked block). */
|
|
15
|
-
import { historyWords } from './task-card.js';
|
|
25
|
+
import { historyWords, ownerLabel, fieldChips } from './task-card.js';
|
|
26
|
+
export { ownerLabel, fieldChips };
|
|
16
27
|
|
|
17
28
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
18
29
|
const SV = (d, n = 16, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
@@ -27,8 +38,8 @@ const today = (now) => { const d = new Date(now); return Date.UTC(d.getFullYear(
|
|
|
27
38
|
export const dm = (v) => { const t = day(v); if (t == null) return ''; const d = new Date(t); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
|
|
28
39
|
const days = (n) => n + (n === 1 ? ' day' : ' days');
|
|
29
40
|
const done = (t) => /^(done|closed|resolved|won'?t do|archived)$/i.test(String(t.status || ''));
|
|
30
|
-
/** "pm:wawan" is the PM: "You". */
|
|
31
|
-
const who = (o) => (
|
|
41
|
+
/** "pm:wawan" is the PM: "You"; an agent by its role, never "agent:sess-…" (task-card.js ownerLabel). */
|
|
42
|
+
const who = (o) => ownerLabel(o).name;
|
|
32
43
|
|
|
33
44
|
export function metaOf(t) {
|
|
34
45
|
const d = t.due ? 'due ' + dm(t.due) : '', w = who(t.owner);
|
|
@@ -40,27 +51,69 @@ export function pathOf(t, o = {}) {
|
|
|
40
51
|
|
|
41
52
|
/* ── Where it stands ──────────────────────────────────────────────────────────────────────────────────────────── */
|
|
42
53
|
export function standsOf(t, o = {}) {
|
|
54
|
+
// only what no chip says (task-detail-one-column): the risk and the next move. Status, owner and the dates are chips above it
|
|
43
55
|
const now = o.now == null ? Date.now() : o.now, out = [], T = today(now), w = who(t.owner);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if (
|
|
56
|
+
const subs = o.subs || [], openSubs = subs.filter((x) => !done(x)).length;
|
|
57
|
+
if (done(t)) { if (openSubs) out.push(`${openSubs === 1 ? '1 subtask is' : openSubs + ' subtasks are'} still open.`); return out; }
|
|
58
|
+
const d = day(t.due), s = day(t.start), st = String(t.status || 'To do');
|
|
59
|
+
if (!w) out.push('Nobody has it yet, so nobody is moving it.');
|
|
60
|
+
if (d != null) {
|
|
61
|
+
const n = Math.round((d - T) / DAY);
|
|
62
|
+
if (n < 0) out.push(`It is ${days(-n)} late${openSubs ? `, with ${openSubs === 1 ? '1 subtask' : openSubs + ' subtasks'} open` : ''}.`);
|
|
63
|
+
else if (n === 0) out.push('It is due today.');
|
|
64
|
+
else if (n === 1) out.push('It is due tomorrow.');
|
|
65
|
+
} else if (/progress/i.test(st)) out.push('It has no due date, so nothing shows when it will finish.');
|
|
66
|
+
if (/^to do$/i.test(st) && s != null && s < T) { const n = Math.round((T - s) / DAY); out.push(`It was to start ${days(n)} ago and has not started.`); }
|
|
67
|
+
for (const x of (o.waitsOn || []).filter((y) => y && !done(y)).slice(0, 2)) out.push(`It waits on ${esc(x.title || x.uid)}, which is not done yet.`);
|
|
68
|
+
if (o.waits) out.push(`It waits on you: ${esc(String(o.waits).replace(/\.$/, ''))}.`);
|
|
57
69
|
return out;
|
|
58
70
|
}
|
|
71
|
+
/** ✦ when the state looks wrong: every subtask done and the task still open, or a subtask started while the task says To do. A proposal,
|
|
72
|
+
* never a change: ✓ moves it (the PM's press, with Undo), ✕ leaves it. */
|
|
73
|
+
export function proposalOf(t, o = {}) {
|
|
74
|
+
const subs = (o.subs || []).filter((x) => !/^archived$/i.test(String(x.status || '')));
|
|
75
|
+
if (!subs.length || done(t)) return null;
|
|
76
|
+
const n = subs.length, fin = subs.filter((x) => /^(done|won'?t do)$/i.test(String(x.status || ''))).length;
|
|
77
|
+
if (fin === n && subs.some((x) => /^done$/i.test(String(x.status || '')))) return { to: 'Done', why: n === 1 ? 'Its subtask is done' : `All ${n} subtasks are done` };
|
|
78
|
+
if (/^to do$/i.test(String(t.status || 'To do')) && subs.some((x) => /progress|^done$/i.test(String(x.status || '')))) return { to: 'In progress', why: 'A subtask has started' };
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
59
81
|
export function standsHtml(t, o = {}) {
|
|
60
|
-
const S = standsOf(t, o);
|
|
61
|
-
if (!S.length && !o.sug) return '';
|
|
82
|
+
const S = standsOf(t, o), P = o.noProp ? null : proposalOf(t, o);
|
|
83
|
+
if (!S.length && !P && !o.sug) return '';
|
|
84
|
+
const prop = P ? `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span class="say">${SV(I.star, 14, 'pm-star')} Move to ${esc(P.to)}? ${esc(P.why)}.</span>`
|
|
85
|
+
+ `<button type="button" class="pm-btn" data-ctp-prop="${esc(P.to)}" aria-label="Yes, move it to ${esc(P.to)}" title="Yes">${SV('M5 12.5l4.5 4.5L19 7.5')}</button>`
|
|
86
|
+
+ `<button type="button" class="pm-btn" data-ctp-propx aria-label="No, leave it" title="No">${SV('M6 6l12 12M18 6L6 18')}</button></div>` : '';
|
|
62
87
|
return `<section class="pm-block" aria-label="Where it stands"><h3 class="pm-h-sm pm-row">${SV(I.star, 16, 'pm-star')}Where it stands</h3>`
|
|
63
|
-
+ (S.length ? `<p class="ctp-say">${S.join(' ')}</p>` : '') + (o.sug || '') + '</section>';
|
|
88
|
+
+ (S.length ? `<p class="ctp-say">${S.join(' ')}</p>` : '') + prop + (o.sug || '') + '</section>';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ── Notes: no empty block (TjC). Added from + ; a note that exists shows under Description ─────────────────────────────────────────── */
|
|
92
|
+
export function notesHtml(t, o = {}) {
|
|
93
|
+
if (!t.notes && !o.open) return '';
|
|
94
|
+
return `<section class="pm-block ctp-notes" aria-label="Notes"><div class="head"><h3 class="pm-h-sm">Notes</h3></div>`
|
|
95
|
+
+ `<textarea class="ctp-dt" data-ctp-notes rows="3" maxlength="4000" aria-label="Notes" placeholder="Add a note">${esc(t.notes)}</textarea></section>`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ── Subtasks (initiative work-subtasks): the board's items whose parent is this task ──────────────────────────────────────────────── */
|
|
99
|
+
export function subtasksOf(items, uid) {
|
|
100
|
+
if (!uid) return [];
|
|
101
|
+
return (items || []).filter((x) => x && x.parent === uid && x.uid !== uid && !/^archived$/i.test(String(x.status || '')));
|
|
102
|
+
}
|
|
103
|
+
export function subtasksHtml(subs, o = {}) {
|
|
104
|
+
const L = subs || [];
|
|
105
|
+
if (!L.length && !o.adding) return '';
|
|
106
|
+
const n = L.length, fin = L.filter((x) => /^done$/i.test(String(x.status || ''))).length, pct = n ? Math.round((fin / n) * 100) : 0;
|
|
107
|
+
const row = (x) => {
|
|
108
|
+
const on = /^done$/i.test(String(x.status || '')), ow = ownerLabel(x.owner), jira = x.src === 'jira';
|
|
109
|
+
return `<div class="pm-li ctp-sub${on ? ' on' : ''}"><button type="button" class="pm-btn" data-ctp-stick="${esc(x.uid)}" role="checkbox" aria-checked="${on}" aria-label="${esc((on ? 'Mark not done: ' : 'Mark done: ') + x.title)}"${jira ? ' disabled title="Jira owns the status"' : ` title="${on ? 'Mark not done' : 'Mark done'}"`}>`
|
|
110
|
+
+ `${SV(on ? 'M12 4a8 8 0 1 0 0 16 8 8 0 1 0 0-16zM8.5 12.2l2.4 2.4 4.6-5' : 'M12 4a8 8 0 1 0 0 16 8 8 0 1 0 0-16z')}</button>`
|
|
111
|
+
+ `<button type="button" class="txt" data-ctp-open="${esc(x.uid)}"><span class="t">${esc(x.title)}</span>${ow.name ? `<span class="w">${esc(ow.name)}</span>` : ''}</button></div>`;
|
|
112
|
+
};
|
|
113
|
+
const head = `<div class="head"><h3 class="pm-h-sm">Subtasks</h3>${n ? `<span class="pm-meta">${fin} of ${n}</span>` : ''}</div>`;
|
|
114
|
+
const bar = n ? `<progress class="ctp-sbar" aria-label="Subtasks done" max="${n}" value="${fin}">${pct}%</progress>` : '';
|
|
115
|
+
const addBox = `<form class="ctp-sadd" data-ctp-sadd><input class="pm-input" type="text" maxlength="200" placeholder="Add a subtask" aria-label="New subtask" autocomplete="off"><button type="submit" class="pm-btn" aria-label="Add the subtask" title="Add">${SV('M12 5v14M5 12h14')}</button></form>`;
|
|
116
|
+
return `<section class="pm-block list ctp-subs" aria-label="Subtasks">${head}${bar}<div class="rows">${L.map(row).join('')}</div>${o.canAdd === false ? '' : addBox}</section>`;
|
|
64
117
|
}
|
|
65
118
|
|
|
66
119
|
/* ── Description (initiative task-descriptions) ───────────────────────────────────────────────────────────────── */
|
|
@@ -101,38 +154,59 @@ export function descriptionHtml(t, o = {}) {
|
|
|
101
154
|
/* ── Linked ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
102
155
|
const URL_RE = /\bhttps?:\/\/[^\s<>"')\]]+/g;
|
|
103
156
|
const shortUrl = (u) => { try { const x = new URL(u); const p = x.pathname.replace(/\/$/, ''); return x.host.replace(/^www\./, '') + (p.length > 32 ? p.slice(0, 31) + '…' : p); } catch { return u.slice(0, 48); } };
|
|
104
|
-
|
|
157
|
+
const PR_RE = /^https?:\/\/(?:www\.)?github\.com\/[^/\s]+\/[^/\s]+\/pull\/(\d+)/;
|
|
158
|
+
/** How the task relates (TjC): Waits on, Blocks, Subtask of, the Jira ticket, the change (a pull request in the notes or the task's own),
|
|
159
|
+
* then the other links in the notes. Never the initiative: the path carries it. o: { parent, waitsOn, blocks } — each { uid, title } */
|
|
160
|
+
export function linkedOf(t, o = {}) {
|
|
105
161
|
const out = [];
|
|
106
|
-
|
|
107
|
-
|
|
162
|
+
for (const x of o.waitsOn || []) out.push({ kind: 'task', title: x.title || x.uid, sub: 'Waits on' + (x.status ? ' · ' + String(x.status).toLowerCase() : ''), open: x.uid });
|
|
163
|
+
for (const x of o.blocks || []) out.push({ kind: 'task', title: x.title || x.uid, sub: 'Blocks', open: x.uid });
|
|
164
|
+
if (o.parent) out.push({ kind: 'task', title: o.parent.title || o.parent.uid, sub: 'Subtask of', open: o.parent.uid });
|
|
165
|
+
if (t.jira && t.jira.key) out.push({ kind: 'jira', title: t.jira.key, sub: 'Jira ticket' + (t.jira.readAt ? ' · read ' + dm(t.jira.readAt) : ''), href: t.jira.url || '' });
|
|
108
166
|
const seen = new Set();
|
|
109
|
-
|
|
167
|
+
const ch = t.change && (t.change.url || (typeof t.change === 'string' && /^https?:/.test(t.change) ? t.change : ''));
|
|
168
|
+
if (ch) { seen.add(ch); const m = PR_RE.exec(ch); out.push({ kind: 'change', title: m ? 'PR #' + m[1] : shortUrl(ch), sub: 'Change', href: ch }); }
|
|
169
|
+
for (const u of String(t.notes || '').match(URL_RE) || []) {
|
|
170
|
+
if (seen.has(u) || seen.size >= 5) continue; seen.add(u);
|
|
171
|
+
const m = PR_RE.exec(u);
|
|
172
|
+
out.push(m ? { kind: 'change', title: 'PR #' + m[1], sub: 'Change', href: u } : { kind: 'url', title: shortUrl(u), sub: 'link in the notes', href: u });
|
|
173
|
+
}
|
|
110
174
|
return out;
|
|
111
175
|
}
|
|
112
|
-
export function linkedHtml(t) {
|
|
113
|
-
const L = linkedOf(t);
|
|
176
|
+
export function linkedHtml(t, o = {}) {
|
|
177
|
+
const L = linkedOf(t, o);
|
|
114
178
|
if (!L.length) return '';
|
|
115
|
-
const icon = (k) => SV(k === '
|
|
179
|
+
const icon = (k) => SV(k === 'task' ? I.ini : k === 'jira' ? I.jira : k === 'change' ? 'M6 3v12M18 9v12M6 15a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 3a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 9c0 4-6 3-12 6' : I.link);
|
|
116
180
|
const row = (x) => {
|
|
117
|
-
const inner = `${icon(x.kind)}<span class="txt"><span class="
|
|
181
|
+
const inner = `${icon(x.kind)}<span class="txt"><span class="w">${esc(x.sub)}</span><span class="t">${esc(x.title)}</span></span>`;
|
|
118
182
|
return x.href ? `<a class="pm-li" href="${esc(x.href)}" target="_blank" rel="noopener">${inner}</a>`
|
|
119
|
-
: x.
|
|
183
|
+
: x.open ? `<button type="button" class="pm-li" data-ctp-open="${esc(x.open)}">${inner}</button>` : `<div class="pm-li">${inner}</div>`;
|
|
120
184
|
};
|
|
121
185
|
return `<section class="pm-block list" aria-label="Linked"><div class="head"><h3 class="pm-h-sm">Linked</h3><span class="pm-meta">${L.length}</span></div><div class="rows">${L.map(row).join('')}</div></section>`;
|
|
122
186
|
}
|
|
123
187
|
|
|
124
|
-
/* ── Activity: PMOS's kept changes
|
|
125
|
-
|
|
188
|
+
/* ── Activity: All · Comments · PMOS work log (TjC), the comment box at the bottom; PMOS's kept changes keep their Undo ─────────────── */
|
|
189
|
+
const byWord = (b) => (b === 'pmos' ? 'PMOS' : !b || b === 'you' ? 'You' : ownerLabel(b).name || 'You');
|
|
190
|
+
/** hist: GET /api/proposals/history entries (task-card.js historyFor). o: { now, open: the fold is open, first: rows before the fold (3),
|
|
191
|
+
* tab: 'all' | 'comments' | 'log', comments: [{ text, by, at }], draft: the box's text, box: false hides the box (a closed task keeps it) } */
|
|
126
192
|
export function activityHtml(hist, o = {}) {
|
|
127
|
-
const now = o.now == null ? Date.now() : o.now, first = o.first || 3;
|
|
128
|
-
const L = (hist || []).filter((x) => x && !x.undone);
|
|
129
|
-
|
|
130
|
-
const
|
|
193
|
+
const now = o.now == null ? Date.now() : o.now, first = o.first || 3, tab = o.tab === 'comments' || o.tab === 'log' ? o.tab : 'all';
|
|
194
|
+
const L = (hist || []).filter((x) => x && !x.undone).map((x) => ({ k: 'log', at: Date.parse(x.at) || 0, x }));
|
|
195
|
+
const C = (o.comments || []).filter((x) => x && x.text).map((x) => ({ k: 'c', at: Date.parse(x.at) || 0, x }));
|
|
196
|
+
const logRow = (x) => {
|
|
131
197
|
const w = historyWords(x), recent = now - (Date.parse(x.at) || 0) < 7 * DAY;
|
|
132
198
|
return `<div class="pm-li"><span class="code pm-meta ctp-ad">${esc(w.day)}</span><span class="txt"><span class="t">${esc(w.what)}</span><span class="w">${esc(w.by)}</span></span>`
|
|
133
199
|
+ (recent && x.batch ? `<button type="button" class="pm-btn" data-ctp-hundo="${esc(x.batch)}" aria-label="Undo this change" title="Undo">${SV(I.undo)}</button>` : '') + '</div>';
|
|
134
200
|
};
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
201
|
+
const md = (v) => { const t = day(v); if (t == null) return ''; const d = new Date(t); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); }; // "Nov 24", as the log rows say a day
|
|
202
|
+
const cRow = (x) => `<div class="pm-li ctp-cm"><span class="code pm-meta ctp-ad">${esc(md(x.at))}</span><span class="txt"><span class="w">${esc(byWord(x.by))}</span><span class="t ctp-ct">${esc(x.text).replace(/\n/g, '<br>')}</span></span></div>`;
|
|
203
|
+
const rows = (tab === 'log' ? L : tab === 'comments' ? C : L.concat(C)).sort((a, b) => b.at - a.at);
|
|
204
|
+
const shown = o.open ? rows : rows.slice(0, first), rest = rows.length - shown.length;
|
|
205
|
+
const tabBtn = (k, label, n) => `<button type="button" class="pm-tab" role="tab" data-ctp-atab="${k}" aria-selected="${tab === k}">${label}${n ? ` <span class="pm-meta">${n}</span>` : ''}</button>`;
|
|
206
|
+
const empty = !rows.length ? `<p class="pm-state empty">${tab === 'comments' ? 'No comments yet.' : tab === 'log' ? 'PMOS has changed nothing here yet.' : 'Nothing has happened here yet.'}</p>` : '';
|
|
207
|
+
const box = o.box === false ? '' : `<form class="ctp-cbox" data-ctp-cform><textarea class="pm-input ctp-ci" data-ctp-cbox rows="1" maxlength="2000" aria-label="Write a comment" placeholder="Write a comment">${esc(o.draft || '')}</textarea>`
|
|
208
|
+
+ `<button type="submit" class="pm-btn" aria-label="Send the comment" title="Send">${SV('M4 12l16-8-6 16-3-7z')}</button></form>`;
|
|
209
|
+
return `<section class="pm-block list ctp-actb" aria-label="Activity"><div class="head"><h3 class="pm-h-sm">Activity</h3><div class="pm-tabs" role="tablist" aria-label="Show">${tabBtn('all', 'All')}${tabBtn('comments', 'Comments', C.length)}${tabBtn('log', 'PMOS work log')}</div></div>`
|
|
210
|
+
+ `<div class="rows">${shown.map((r) => (r.k === 'c' ? cRow(r.x) : logRow(r.x))).join('')}</div>${empty}`
|
|
211
|
+
+ (rest > 0 ? `<button type="button" class="pm-fold" data-ctp-afold aria-expanded="false">Earlier <span class="pm-meta">${rest}</span></button>` : '') + box + '</section>';
|
|
138
212
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "The full task popup is one column with its fields as chips (task-detail-one-column, done test D1-D7): task-card.js chips layout, ownerLabel and fieldChips, vw-ds.js blocks, cozy-task-pop.js wiring, the task-comment line, route and pmos task comment. Node only, no browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"task-detail-one-column.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"task-detail-one-column.test.js": 3
|
|
8
|
+
}
|
|
9
|
+
}
|