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.
- package/package.json +33 -51
- package/payload/AGENTS.md +3 -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/scripts/kind-sync.js +112 -0
- package/payload/scripts/workflow-state.js +20 -2
- package/payload/scripts/workflows.js +374 -0
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +32 -0
- package/workspace/guide/breakdown.md +5 -3
- package/workspace/guide/cli.md +1 -0
- package/workspace/lib/engine/boards.js +11 -3
- package/workspace/lib/engine/workflow-state.js +20 -2
- package/workspace/lib/engine/workflows.js +27 -3
- package/workspace/lib/initiative-chat.js +1 -1
- package/workspace/lib/initiative-writer.js +12 -1
- package/workspace/lib/routes-boards.js +49 -2
- package/workspace/lib/task-cli.js +25 -2
- package/workspace/lib/task-store.js +1 -1
- package/workspace/lib/vendor/scripts/workflow-state.js +20 -2
- package/workspace/lib/vendor/scripts/workflows.js +374 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-pop-work.css +7 -0
- package/workspace/public/pm/cozy-pop-work.js +27 -12
- 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/public/pm/work-select.js +27 -5
- package/workspace/test-lists/gantt-drag-nest.json +9 -0
- package/workspace/test-lists/task-detail-one-column.json +9 -0
|
@@ -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
|
}
|
|
@@ -123,7 +123,22 @@ export function dropPlan(rows, ids, to) {
|
|
|
123
123
|
for (const [gp, L] of g) add('parent', gp, L);
|
|
124
124
|
label = g.size === 1 && [...g.keys()][0] ? ((by.get([...g.keys()][0]) || {}).title || '') : 'the top level';
|
|
125
125
|
} else return null;
|
|
126
|
-
|
|
126
|
+
const order = to.zone === 'between' ? orderOf(T, I, by.get(String(to.uid)), to.edge) : null;
|
|
127
|
+
if (!steps.length && !order) return null;
|
|
128
|
+
return order ? { steps, label: steps.length ? label : '', order } : { steps, label };
|
|
129
|
+
}
|
|
130
|
+
/** The stage's new order after a drop between rows (Wawan 2026-11-24: reorder by drag, in the Gantt too): every task of the target's stage
|
|
131
|
+
* top to bottom, the dragged ones before or after the target; null when the order does not change or a Jira ticket keeps Jira's stage. */
|
|
132
|
+
function orderOf(T, I, tg, edge) {
|
|
133
|
+
if (!tg || tg.sec == null) return null;
|
|
134
|
+
const sec = String(tg.sec), moving = new Set(I), inSec = (x) => String(x.sec == null ? '' : x.sec) === sec;
|
|
135
|
+
const was = T.filter(inSec).map((x) => String(x.uid));
|
|
136
|
+
const kept = I.filter((u) => { const x = T.find((q) => String(q.uid) === u); return x && (inSec(x) || !x.jira); });
|
|
137
|
+
if (!kept.length) return null;
|
|
138
|
+
const rest = was.filter((u) => !moving.has(u)), at = rest.indexOf(String(tg.uid));
|
|
139
|
+
if (at < 0) return null;
|
|
140
|
+
const tasks = rest.slice(0, edge === 'before' ? at : at + 1).concat(kept, rest.slice(edge === 'before' ? at : at + 1));
|
|
141
|
+
return tasks.join('\u0000') === was.join('\u0000') ? null : { section: sec, tasks };
|
|
127
142
|
}
|
|
128
143
|
export function daysOf(dx, width, days) {
|
|
129
144
|
if (!(width > 0) || !(days > 0)) return 0;
|
|
@@ -141,23 +156,30 @@ export function shiftIds(sel, uid, rows) {
|
|
|
141
156
|
return [u];
|
|
142
157
|
}
|
|
143
158
|
/** A drop that changes parent and stage: each step is a bulk write; one message and one Undo put every step back, the last first. */
|
|
144
|
-
export async function bulkSteps(post, at, steps, h = {}, label = '') {
|
|
159
|
+
export async function bulkSteps(post, at, steps, h = {}, label = '', order = null) {
|
|
145
160
|
const done = [], skipped = [];
|
|
146
161
|
for (const s of steps || []) {
|
|
147
162
|
const r = await bulk(post, at, s.ids, s.op, s.value, {}, label).catch(() => null);
|
|
148
163
|
if (r && r.runs) done.push(...r.runs);
|
|
149
164
|
if (r) skipped.push(...(r.skipped || []));
|
|
150
165
|
}
|
|
166
|
+
// the order inside the stage (POST /api/boards/tasks/order); its Undo sends the order it had back
|
|
167
|
+
let ord = null;
|
|
168
|
+
if (order && at.ini) {
|
|
169
|
+
const r = await post('/api/boards/tasks/order', { ws: at.ws, board: at.board, initiative: at.ini, section: order.section, tasks: order.tasks }).catch(() => null);
|
|
170
|
+
if (r && r.ok !== false) ord = { section: order.section, from: r.from || [] };
|
|
171
|
+
}
|
|
151
172
|
const ids = new Set(done.flatMap((d) => d.undo.map((x) => x.task)));
|
|
152
173
|
const n = ids.size;
|
|
153
174
|
const text = n ? `${n === 1 ? '1 task' : n + ' tasks'} moved${label ? (label === 'the top level' ? ' to the top level' : ' to ' + label) : ''}.${skipped.length ? ' ' + skipped.length + ' not moved: ' + skipped[0].why + '.' : ''}`
|
|
154
|
-
: (skipped[0] && skipped[0].why ? 'Nothing moved: ' + skipped[0].why + '.' : 'Nothing moved.');
|
|
155
|
-
const undo = n ? async () => {
|
|
175
|
+
: ord ? 'Order changed.' : (skipped[0] && skipped[0].why ? 'Nothing moved: ' + skipped[0].why + '.' : 'Nothing moved.');
|
|
176
|
+
const undo = n || ord ? async () => {
|
|
177
|
+
if (ord) await post('/api/boards/tasks/order', { ws: at.ws, board: at.board, initiative: at.ini, section: ord.section, tasks: ord.from }).catch(() => null);
|
|
156
178
|
for (const d of done.slice().reverse()) await post('/api/boards/tasks/bulk-undo', { ws: d.ws, board: d.board, undo: d.undo }).catch(() => null);
|
|
157
179
|
if (h.say) h.say('Put back.');
|
|
158
180
|
if (h.reload) await h.reload();
|
|
159
181
|
} : null;
|
|
160
182
|
if (h.say) h.say(text, undo);
|
|
161
183
|
if (h.reload) await h.reload();
|
|
162
|
-
return { moved: n, skipped };
|
|
184
|
+
return { moved: n, skipped, ordered: !!ord };
|
|
163
185
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Drag to nest, take out and reorder in the Gantt, like the List; the picker's stage-first order and find box (initiative gantt-drag-nest, done test G1-G5). Pure; no browser, server or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"gantt-drag.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"gantt-drag.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -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
|
+
}
|