create-pmos 0.767.0 → 0.769.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.
Files changed (33) hide show
  1. package/package.json +33 -51
  2. package/payload/AGENTS.md +3 -1
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/planning/evals/eval-calibration.md +1 -1
  5. package/payload/planning/okrs/health-budgets.md +1 -1
  6. package/payload/scripts/kind-sync.js +112 -0
  7. package/payload/scripts/workflow-state.js +20 -2
  8. package/payload/scripts/workflows.js +374 -0
  9. package/payload/state/discoveries.md +1 -1
  10. package/workspace/changelog.json +32 -0
  11. package/workspace/guide/breakdown.md +5 -3
  12. package/workspace/guide/cli.md +1 -0
  13. package/workspace/lib/engine/boards.js +11 -3
  14. package/workspace/lib/engine/workflow-state.js +20 -2
  15. package/workspace/lib/engine/workflows.js +27 -3
  16. package/workspace/lib/initiative-chat.js +1 -1
  17. package/workspace/lib/initiative-writer.js +12 -1
  18. package/workspace/lib/routes-boards.js +49 -2
  19. package/workspace/lib/task-cli.js +25 -2
  20. package/workspace/lib/task-store.js +1 -1
  21. package/workspace/lib/vendor/scripts/workflow-state.js +20 -2
  22. package/workspace/lib/vendor/scripts/workflows.js +374 -0
  23. package/workspace/package-lock.json +2 -2
  24. package/workspace/package.json +1 -1
  25. package/workspace/public/pm/cozy-pop-work.css +7 -0
  26. package/workspace/public/pm/cozy-pop-work.js +27 -12
  27. package/workspace/public/pm/cozy-task-pop.css +57 -17
  28. package/workspace/public/pm/cozy-task-pop.js +161 -20
  29. package/workspace/public/pm/task-card.js +113 -5
  30. package/workspace/public/pm/vw-ds.js +112 -38
  31. package/workspace/public/pm/work-select.js +27 -5
  32. package/workspace/test-lists/gantt-drag-nest.json +9 -0
  33. package/workspace/test-lists/task-detail-one-column.json +9 -0
@@ -16,7 +16,14 @@
16
16
  * Inside: the kind (Task or Milestone, pressed to switch) and the title; the one task card (pm/task-card.js mountCard: status, due, owner, notes,
17
17
  * where it sits, what PMOS changed) whose status pick asks when it really happened (pm/cozy-status-when.js, point 18); ⋯ with Make it a
18
18
  * milestone, Archive and Delete (Undo). No chat inside: one level only, a second task replaces the content. On a phone it is a sheet from the bottom.
19
- * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
+ * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label.
20
+ *
21
+ * The full popup is ONE column (task-detail-one-column, board TjC, Wawan 2026-11-24: "Go with C, because when chat is open it'll be on the
22
+ * right side"): the head (←, the path with the Jira key, ↑ ↓, Ask PMOS, Open in Jira, ⋯, ×), the title, ONE chip row (the card in its
23
+ * 'chips' layout: Status with its menu and the day it happened, the owner, Start → Due, a chip per field that has a value, +), then
24
+ * Where it stands, Description, Notes (only when there are notes), Subtasks, Linked and Activity (All · Comments · PMOS work log, the
25
+ * comment box). Make it a milestone, Move, Copy link, Archive and Delete are in ⋯. On a phone (TjPhone) the same order, 44 px targets,
26
+ * the Description folded to its first line, Activity's latest two, the comment box pinned at the bottom; ↑ ↓ go into ⋯. */
20
27
  import { taskOf, mountCard, boardSaver, cardStyle, historyFor, chatAbout } from './task-card.js';
21
28
  import * as SWN from './cozy-status-when.js';
22
29
  import { linkPath, copyLink } from './short-link.js'; // Copy link in ⋯ (bet A428)
@@ -31,7 +38,7 @@ const SVG = (d) => `<svg aria-hidden="true" width="16" height="16" viewBox="0 0
31
38
  const P = {
32
39
  back: 'M19 12H5M11 6l-6 6 6 6',
33
40
  x: 'M6 6l12 12M18 6L6 18', up: 'M7 14l5-5 5 5', down: 'M7 10l5 5 5-5', chat: 'M4 5h16v11H9l-5 4z', more: 'M5 12h.01M12 12h.01M19 12h.01',
34
- dia: 'M12 4l8 8-8 8-8-8z', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
41
+ dia: 'M12 4l8 8-8 8-8-8z', out: 'M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
35
42
  };
36
43
  const ib = (attr, label, d) => `<button type="button" class="ctp-ib" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
37
44
 
@@ -43,6 +50,8 @@ async function rowOf(uid, ctx) {
43
50
  const I = ctx.board ? await fetch('/api/boards/items?' + q, { credentials: 'same-origin' }).then((x) => x.json()).catch(() => null) : null;
44
51
  const it = I && I.ok ? (I.items || []).find((x) => x.uid === uid) : null;
45
52
  const own = ctx.row ? ctx.row(uid) : null;
53
+ // the board's items and initiatives stay for the one column: the subtasks, the linked tasks' names, the stages a task can sit in
54
+ if (S) { S.items = I && I.ok ? I.items || [] : []; S.inis = I && I.ok ? I.initiatives || [] : []; }
46
55
  return it ? { ...(own || {}), ...it } : own || null;
47
56
  }
48
57
 
@@ -79,7 +88,9 @@ function onKey(e) {
79
88
  if (!S) return;
80
89
  if (e.key === 'Escape') {
81
90
  // a picker open inside the card closes first (its own Escape); then only the small popup
82
- if (e.target.closest && e.target.closest('.hi-pop, .dp-cal, [data-tkc-notes]')) return;
91
+ if (e.target.closest && e.target.closest('.hi-pop, .dp-cal, [data-tkc-notes], [data-ctp-notes], [data-ctp-cbox], .ctp-sadd')) return;
92
+ // the chip row's open menu or picker closes first (task-detail-one-column)
93
+ if (S.card && S.card.open && S.el.querySelector('.ctp-chips .tkc-pop')) { e.preventDefault(); e.stopPropagation(); S.card.open(null); const c = S.el.querySelector('.ctp-chips [aria-expanded]'); if (c) c.focus(); return; }
83
94
  e.preventDefault(); e.stopPropagation(); closeTask(); return;
84
95
  }
85
96
  if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && S.el.contains(e.target) && !e.target.closest('input, textarea, [role="menu"], .sw, .tkc-dp')) {
@@ -112,6 +123,10 @@ export async function openTask(uid, ctx = {}) {
112
123
  document.addEventListener('keydown', onKey, true);
113
124
  el.addEventListener('click', press);
114
125
  el.addEventListener('focusout', descOut); // the description saves when the PM leaves its box (task-descriptions)
126
+ el.addEventListener('focusout', notesOut); // the one column's Notes block saves the same way (task-detail-one-column)
127
+ el.addEventListener('submit', (e) => { const f = e.target; if (!S || !f.matches) return; if (f.matches('[data-ctp-sadd]')) { e.preventDefault(); subAdd(f); } else if (f.matches('[data-ctp-cform]')) { e.preventDefault(); sendComment(f); } });
128
+ el.addEventListener('input', (e) => { if (S && e.target.matches && e.target.matches('[data-ctp-cbox]')) S.draft = e.target.value; });
129
+ el.addEventListener('keydown', (e) => { const a = e.target; if (S && a.matches && a.matches('[data-ctp-cbox]') && e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); sendComment(a.form); } });
115
130
  // the status pick waits for the day (point 18): the card's own press is held here, the line opens under the card
116
131
  el.addEventListener('click', holdStatus, true);
117
132
  }
@@ -147,11 +162,15 @@ async function show(uid) {
147
162
  const crumbs = path.map((p, k) => (k === last ? `<button type="button" class="ctp-cr" ${lastAttr}>${esc(p)}</button>` : `<span class="ctp-cr">${esc(p)}</span>`)).join('<span class="ctp-sep" aria-hidden="true">›</span>');
148
163
  const head = ctx.head ? ctx.head(t) : '';
149
164
  const back = path.length && !ctx.iniCrumb ? 'Back to ' + path[last] : 'Close';
150
- S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}${t.jira ? '<span class="pm-chip">Jira</span>' : ''}</nav>`
151
- + `<span class="ctp-tools">${step}${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${more}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
152
- + `<div class="ctp-th">${kind}${title}</div><p class="pm-meta ctp-meta">${esc(VD.metaOf(t))}</p>`
153
- + `<div class="ctp-g"><div class="ctp-main">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-descw"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`
154
- + '<aside class="ctp-side"><section class="pm-block" aria-label="Fields and notes"><div class="ctp-b"></div><div class="ctp-when" hidden></div></section></aside></div>';
165
+ // task-detail-one-column (TjC): the Jira key is a chip in the path; Open in Jira beside Ask PMOS; ⋯ holds milestone, move, archive
166
+ const jkey = t.jira ? t.jira.key : raw.tracker && raw.tracker.key ? raw.tracker.key : '';
167
+ const jurl = (raw.tracker && raw.tracker.url) || raw.url || '';
168
+ const jira = jurl ? `<a class="ctp-ib ctp-jira" href="${esc(jurl)}" target="_blank" rel="noopener" aria-label="Open in Jira" title="Open in Jira">${SVG(P.out)}</a>` : '';
169
+ const mark = t.milestone ? `<span class="ctp-mk" role="img" aria-label="Milestone" title="Milestone">${SVG(P.dia)}</span>` : '';
170
+ S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}</nav>${jkey ? `<span class="pm-chip ctp-key">${esc(jkey)}</span>` : ''}`
171
+ + `<span class="ctp-tools"><span class="ctp-step">${step}</span>${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${jira}${ib('data-ctp-more aria-haspopup="menu"', 'More for this task', P.more)}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
172
+ + `<div class="ctp-th">${mark}${title}</div><div class="ctp-chips ctp-b"></div><div class="ctp-when" hidden></div>`
173
+ + `<div class="ctp-col">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-descw"></div><div class="ctp-notesw"></div><div class="ctp-subs"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`;
155
174
  } else {
156
175
  S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
157
176
  + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
@@ -165,7 +184,7 @@ async function show(uid) {
165
184
  return base(patch);
166
185
  };
167
186
  // the host's row changes at once (ctx.patch: the list behind shows the new status and dates before the board is read again)
168
- const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); if (ctx.full) drawMain(); };
187
+ const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; raw.priority = t.priority; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); if (ctx.full) drawMain(); };
169
188
  const toast = (msg, undo) => (ctx.toast ? ctx.toast(msg, undo) : undefined);
170
189
  S.hist = historyFor({ ws: ctx.ws, board: raw.board || ctx.board, t, post: (p, b) => ctx.pmPost(p, b) });
171
190
  S.histL = null;
@@ -177,20 +196,123 @@ async function show(uid) {
177
196
  inis: () => (ctx.inis ? ctx.inis() : []),
178
197
  // the full popup says PMOS's changes once, in its Activity block; the small popup keeps the card's History fold
179
198
  history: ctx.full ? null : S.hist,
199
+ // the one column (TjC): the card is the chip row; + adds a note or a subtask here; the stages come from the board's initiatives
200
+ ...(ctx.full ? {
201
+ layout: 'chips',
202
+ sections: () => { const x = (S && S.inis || []).find((y) => y.id === t.ini); return x && x.stages && x.stages.length ? x.stages : null; },
203
+ kind: () => (ctx.kind ? ctx.kind(t) : workKind(t)),
204
+ add: (k) => addField(k),
205
+ canSub: () => !t.jira && !!t.ini && !t.parent,
206
+ } : {}),
180
207
  });
181
- if (ctx.full) { drawMain(); loadActivity(); describe(); }
208
+ if (ctx.full) { S.nopen = false; S.sadd = false; S.atab = S.atab || 'all'; S.draft = ''; S.propNo = false; S.dfull = false; S.links = null; drawMain(); loadActivity(); loadLinks(); describe(); }
182
209
  const f = S.el.querySelector('.ctp-t') || S.el.querySelector('button'); if (f) f.focus();
183
210
  }
184
- /* the full popup's main column (viewer-ds-task, pm/vw-ds.js): Where it stands and Linked from the task, Activity from PMOS's kept changes */
211
+ /* the one column (task-detail-one-column, pm/vw-ds.js): Where it stands, Description, Notes, Subtasks, Linked, Activity — in that order */
212
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
213
+ const typing = (sel) => { const a = document.activeElement; return !!(a && S && S.el.contains(a) && a.matches(sel)); };
214
+ /** The task's relations from the board's items and its links: its subtasks, its parent, what it waits on and what it blocks. */
215
+ function relOf() {
216
+ const t = S.t, I = S.items || [];
217
+ const name = (uid, other) => { const x = I.find((y) => y.uid === uid); return x ? { uid, title: x.title, status: x.status } : { uid, title: (other && other.title) || '' }; };
218
+ const L = (S.links && S.links.links) || [];
219
+ return {
220
+ subs: VD.subtasksOf(I, t.uid),
221
+ parent: t.parent ? name(t.parent) : null,
222
+ waitsOn: L.filter((l) => l.to === t.uid).map((l) => name(l.from, l.other)),
223
+ blocks: L.filter((l) => l.from === t.uid).map((l) => name(l.to, l.other)),
224
+ };
225
+ }
185
226
  function drawMain() {
186
227
  if (!S || !S.ctx.full || !S.t) return;
187
228
  const put = (sel, html) => { const x = S.el.querySelector(sel); if (x) x.innerHTML = html; };
188
- put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '' }));
189
- // the description (initiative task-descriptions): never redrawn under the PM's typing
229
+ const R = relOf();
230
+ put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '', subs: R.subs, waitsOn: R.waitsOn, noProp: !!(S.propNo || S.t.jira) }));
231
+ // the description (initiative task-descriptions): never redrawn under the PM's typing; on a phone it folds to its first line (TjPhone)
190
232
  const dw = S.el.querySelector('.ctp-descw');
191
- if (dw && !(document.activeElement && dw.contains(document.activeElement) && document.activeElement.matches('[data-ctp-desc]'))) dw.innerHTML = VD.descriptionHtml(S.t, { busy: !!S.dbusy, edit: !!S.dedit, undo: !!S.dundo });
192
- put('.ctp-linked', VD.linkedHtml(S.t));
193
- put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen }));
233
+ if (dw && !typing('[data-ctp-desc]')) {
234
+ const fold = phone() && !S.dfull && !S.dedit && !!S.t.description;
235
+ dw.innerHTML = VD.descriptionHtml(S.t, { busy: !!S.dbusy, edit: !!S.dedit, undo: !!S.dundo })
236
+ + (fold ? '<button type="button" class="pm-fold ctp-dmore" data-ctp-dmore aria-expanded="false">More</button>' : '');
237
+ dw.classList.toggle('ctp-fold', fold);
238
+ }
239
+ // Notes: no empty block; + Note opens one, and a note that exists shows under the Description
240
+ if (!typing('[data-ctp-notes]')) put('.ctp-notesw', VD.notesHtml(S.t, { open: !!S.nopen }));
241
+ if (!typing('.ctp-sadd input')) put('.ctp-subs', VD.subtasksHtml(R.subs, { adding: !!S.sadd, canAdd: !S.t.jira && !!S.t.ini && !S.t.parent }));
242
+ put('.ctp-linked', VD.linkedHtml(S.t, R));
243
+ if (!typing('[data-ctp-cbox]')) put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen, tab: S.atab, comments: S.t.comments || [], draft: S.draft || '', first: phone() ? 2 : 3 }));
244
+ }
245
+ /** The kind of work a task reads as when its host does not say (TjKinds): a change or a done test reads Full ADLC, a sprint or an estimate
246
+ * reads Project, else Product. Only the order of the chips follows it. */
247
+ function workKind(t) { return t.change || t.doneTest ? 'adlc' : t.sprint || (t.estimate !== '' && t.estimate != null) ? 'project' : 'product'; }
248
+ /* + Note and + Subtask (TjC): the block opens with its box focused */
249
+ function addField(k) {
250
+ if (!S) return;
251
+ if (k === 'note') S.nopen = true; else if (k === 'sub') S.sadd = true;
252
+ drawMain();
253
+ const f = S.el.querySelector(k === 'note' ? '[data-ctp-notes]' : '.ctp-sadd input'); if (f) f.focus();
254
+ }
255
+ /* the links between tasks (lib/task-links.js): Waits on and Blocks */
256
+ function loadLinks() {
257
+ const s = S; if (!s || !s.t.ini || !(s.raw.board || s.ctx.board)) return;
258
+ const q = new URLSearchParams({ board: s.raw.board || s.ctx.board, initiative: s.t.ini, ...(s.ctx.ws ? { ws: s.ctx.ws } : {}) });
259
+ fetch('/api/task-links?' + q, { credentials: 'same-origin' }).then((x) => x.json()).catch(() => null).then((j) => { if (S !== s || !j || !j.ok) return; s.links = j.links || null; drawMain(); });
260
+ }
261
+ /* Notes save when the PM leaves the box, through the card's own change (Undo in the toast) */
262
+ function notesOut(e) {
263
+ const a = e.target; if (!S || !S.card || !a.matches || !a.matches('[data-ctp-notes]')) return;
264
+ const v = a.value.replace(/\s+$/, '');
265
+ if (v === (S.t.notes || '')) { if (!v) { S.nopen = false; setTimeout(drawMain, 0); } return; }
266
+ if (!v) S.nopen = false;
267
+ S.card.change('notes', { notes: v });
268
+ }
269
+ /* a subtask: tick (tasks/state, Undo in the toast), add (tasks/add with the parent), open (the same popup steps to it) */
270
+ async function subTick(uid, b) {
271
+ const s = S; if (!s) return;
272
+ const x = (s.items || []).find((y) => y.uid === uid); if (!x) return;
273
+ const was = x.status, to = /^done$/i.test(String(was)) ? 'To do' : 'Done', board = x.board || s.raw.board || s.ctx.board;
274
+ const post = (state) => s.ctx.pmPost('/api/boards/tasks/state', { ws: s.ctx.ws, board, task: uid, state });
275
+ b.disabled = true; x.status = to; drawMain();
276
+ const r = await post(to).catch(() => null);
277
+ if (!r || r.ok === false) { x.status = was; if (S === s) drawMain(); if (s.ctx.toast) s.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
278
+ if (s.ctx.onChange) s.ctx.onChange();
279
+ if (s.ctx.toast) s.ctx.toast((to === 'Done' ? 'Done · ' : 'Open again · ') + x.title, async () => { const u = await post(was).catch(() => null); if (u && u.ok !== false) { x.status = was; if (S === s) drawMain(); if (s.ctx.onChange) s.ctx.onChange(); } return u || { ok: false }; });
280
+ }
281
+ async function subAdd(form) {
282
+ const s = S; if (!s) return;
283
+ const inp = form.querySelector('input'), title = (inp.value || '').trim(); if (!title) return;
284
+ inp.disabled = true;
285
+ const board = s.raw.board || s.ctx.board;
286
+ const r = await s.ctx.pmPost('/api/boards/tasks/add', { ws: s.ctx.ws, board, initiative: s.t.ini, title, parent: s.t.uid }).catch(() => null);
287
+ if (S !== s) return;
288
+ inp.disabled = false;
289
+ if (!r || r.ok === false) { if (s.ctx.toast) s.ctx.toast((r && r.error) || 'The subtask was not added.'); return; }
290
+ const it = r.item || { uid: r.task || r.id || '', title, status: 'To do', owner: '', board };
291
+ s.items = (s.items || []).concat([{ ...it, parent: s.t.uid }]);
292
+ inp.value = ''; drawMain();
293
+ const f = s.el.querySelector('.ctp-sadd input'); if (f) f.focus();
294
+ if (s.ctx.onChange) s.ctx.onChange();
295
+ if (s.ctx.toast && it.uid) s.ctx.toast('Subtask added · ' + title, async () => {
296
+ const u = await s.ctx.pmPost('/api/boards/tasks/delete', { ws: s.ctx.ws, board, task: it.uid }).catch(() => null);
297
+ if (u && u.ok !== false) { s.items = (s.items || []).filter((y) => y.uid !== it.uid); if (S === s) drawMain(); if (s.ctx.onChange) s.ctx.onChange(); }
298
+ return u || { ok: false };
299
+ });
300
+ }
301
+ /* a comment (POST /api/boards/tasks/comment): kept in PMOS, never sent to Jira */
302
+ async function sendComment(form) {
303
+ const s = S; if (!s || !form) return;
304
+ const a = form.querySelector('[data-ctp-cbox]'), text = (a.value || '').replace(/\s+$/, '');
305
+ if (!text.trim()) { a.focus(); return; }
306
+ a.disabled = true;
307
+ const r = await s.ctx.pmPost('/api/boards/tasks/comment', { ws: s.ctx.ws, board: s.raw.board || s.ctx.board, task: s.t.jira ? s.t.jira.key : s.t.uid, text }).catch(() => null);
308
+ if (S !== s) return;
309
+ a.disabled = false;
310
+ if (!r || r.ok === false) { if (s.ctx.toast) s.ctx.toast((r && r.error) || 'The comment was not saved.'); return; }
311
+ s.t.comments = r.comments || (s.t.comments || []).concat([r.comment]); s.raw.comments = s.t.comments;
312
+ s.draft = ''; a.value = ''; a.blur(); if (s.atab === 'log') s.atab = 'comments';
313
+ drawMain();
314
+ if (s.ctx.onChange) s.ctx.onChange();
315
+ if (s.ctx.toast) s.ctx.toast('Comment added');
194
316
  }
195
317
  /* PMOS writes a task's description by itself when it has none (POST /api/boards/tasks/describe-draft): once per task, from the initiative's
196
318
  * own files, with its sources and Undo. The server never writes it twice, so opening the task again costs nothing. */
@@ -245,10 +367,12 @@ function holdStatus(e) {
245
367
  e.stopPropagation(); e.preventDefault();
246
368
  S.held = st;
247
369
  // the line sits right under the facts card (the status row), the card does not redraw while it waits
248
- const w = S.el.querySelector('.ctp-when'), facts = S.el.querySelector('.ctp-b .tkc-f');
370
+ const w = S.el.querySelector('.ctp-when'), facts = S.el.querySelector('.ctp-b .tkc-f') || S.el.querySelector('.ctp-chips');
371
+ if (S.ctx.full && S.card && S.card.open) S.card.open(null); // the chip row's Status menu closes; the day is asked under the row
249
372
  if (facts && w.previousElementSibling !== facts) facts.after(w);
250
373
  w.hidden = false; w.innerHTML = '';
251
374
  S.el.querySelectorAll('[data-tkc-state]').forEach((x) => x.classList.toggle('ctp-held', x.dataset.tkcState === st));
375
+ const chip = S.el.querySelector('.ctp-chips [data-tkc="status"]'); if (chip) chip.classList.add('ctp-held');
252
376
  const pick = (day) => { const s = S; if (!s) return; s.held = null; s.nextDay = day && day !== SWN.localDay() ? day : null; hideWhen(); s.card.setStatus(st); };
253
377
  const head = document.createElement('p'); head.className = 'ctp-wh'; head.textContent = st; w.appendChild(head);
254
378
  const box = document.createElement('div'); w.appendChild(box);
@@ -272,6 +396,13 @@ async function press(e) {
272
396
  return;
273
397
  }
274
398
  if ('ctpAfold' in d) { S.aopen = true; drawMain(); return; }
399
+ // the one column (task-detail-one-column): Activity's tabs, a linked task or a subtask opens here, its tick, the ✦ proposal, the phone's fold
400
+ if (d.ctpAtab) { S.atab = d.ctpAtab; S.aopen = false; drawMain(); const x = S.el.querySelector(`[data-ctp-atab="${d.ctpAtab}"]`); if (x) x.focus(); return; }
401
+ if (d.ctpOpen) { show(d.ctpOpen); return; }
402
+ if (d.ctpStick) { subTick(d.ctpStick, b); return; }
403
+ if (d.ctpProp && t) { S.propNo = true; S.card.setStatus(d.ctpProp); return; }
404
+ if ('ctpPropx' in d) { S.propNo = true; drawMain(); return; }
405
+ if ('ctpDmore' in d) { S.dfull = true; drawMain(); return; }
275
406
  if ('ctpDedit' in d) { S.dedit = true; drawMain(); const a = S.el.querySelector('[data-ctp-desc]'); if (a) { a.focus(); a.setSelectionRange(a.value.length, a.value.length); } return; }
276
407
  if ('ctpDundo' in d) { saveDesc('', { word: 'PMOS\'s description taken back' }); return; }
277
408
  if (b.closest('.ctp-hx')) { if (ctx.headPress) { const s0 = S; await ctx.headPress(b, { refresh: () => { if (S === s0) show(s0.uid); }, close: closeTask }); } return; }
@@ -294,15 +425,23 @@ async function kindOf(on) {
294
425
  if (s.ctx.onChange) s.ctx.onChange();
295
426
  if (S === s) show(s.uid);
296
427
  }
428
+ const jurlOf = (s) => (s.raw && ((s.raw.tracker && s.raw.tracker.url) || s.raw.url)) || '';
429
+ const jkeyOf = (s) => (s.t && s.t.jira ? s.t.jira.key : s.raw && s.raw.tracker && s.raw.tracker.key) || '';
297
430
  function moreMenu(btn) {
298
431
  const s = S; if (!s) return;
299
432
  let m = s.el.querySelector('.ctp-menu');
300
433
  if (m) { m.remove(); btn.setAttribute('aria-expanded', 'false'); return; }
301
434
  m = document.createElement('div'); m.className = 'ctp-menu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'More for this task');
302
- m.innerHTML = `<button type="button" role="menuitem" data-k="kind">${SVG(s.t.milestone ? P.box : P.dia)}${s.t.milestone ? 'Make it a task' : 'Make it a milestone'}</button>`
435
+ // the full popup's ⋯ (TjC): milestone, Move, Copy link, Archive, Delete; on a phone also ↑ ↓ (TjPhone). A Jira ticket: Copy link only
436
+ const L = s.ctx.list ? s.ctx.list() : [], i = L.indexOf(s.uid), full = !!s.ctx.full, j = !!s.t.jira;
437
+ m.innerHTML = (j ? '' : `<button type="button" role="menuitem" data-k="kind">${SVG(s.t.milestone ? P.box : P.dia)}${s.t.milestone ? 'Make it a task' : 'Make it a milestone'}</button>`)
438
+ + (full && !j ? '<button type="button" role="menuitem" data-k="move">Move…</button>' : '')
303
439
  + (linkPath({ kind: 'task', id: s.uid }) ? '<button type="button" role="menuitem" data-k="link">Copy link</button>' : '') // the short link (bet A428)
304
- + (s.t.status !== 'Archived' ? '<button type="button" role="menuitem" data-k="arch">Archive</button>' : '')
305
- + '<button type="button" role="menuitem" data-k="del" class="ctp-del">Delete</button>';
440
+ + (!j && s.t.status !== 'Archived' ? '<button type="button" role="menuitem" data-k="arch">Archive</button>' : '')
441
+ + (full && L.length > 1 && i >= 0 ? `<button type="button" role="menuitem" class="ctp-ph" data-k="prev"${i === 0 ? ' disabled' : ''}>Previous task</button><button type="button" role="menuitem" class="ctp-ph" data-k="next"${i === L.length - 1 ? ' disabled' : ''}>Next task</button>` : '')
442
+ + (full && jurlOf(s) ? `<a role="menuitem" class="ctp-ph" href="${esc(jurlOf(s))}" target="_blank" rel="noopener">Open in Jira${jkeyOf(s) ? ' · ' + esc(jkeyOf(s)) : ''}</a>` : '')
443
+ + (j ? '' : '<button type="button" role="menuitem" data-k="del" class="ctp-del">Delete</button>');
444
+ if (!m.innerHTML) return;
306
445
  btn.setAttribute('aria-expanded', 'true');
307
446
  btn.closest('.ctp-h').appendChild(m);
308
447
  m.querySelector('button').focus();
@@ -312,6 +451,8 @@ function moreMenu(btn) {
312
451
  if (x.dataset.k === 'kind') kindOf(!s.t.milestone);
313
452
  else if (x.dataset.k === 'link') copyLink({ kind: s.t.milestone ? 'milestone' : 'task', id: s.uid, ws: s.ctx.ws || '' });
314
453
  else if (x.dataset.k === 'arch') s.card.setStatus('Archived');
454
+ else if (x.dataset.k === 'move') s.card.open('move');
455
+ else if (x.dataset.k === 'prev' || x.dataset.k === 'next') { const L2 = s.ctx.list ? s.ctx.list() : [], k = L2.indexOf(s.uid) + (x.dataset.k === 'prev' ? -1 : 1); if (k >= 0 && k < L2.length) show(L2[k]); }
315
456
  else if (x.dataset.k === 'del') delTask(s);
316
457
  });
317
458
  m.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); m.remove(); btn.setAttribute('aria-expanded', 'false'); btn.focus(); } });
@@ -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
- return { draw, setStatus: (s) => change('status', { status: s }), task: t };
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
  }