create-pmos 0.442.0 → 0.444.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 +25 -25
- 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/briefing-premium-board-test.js +8 -2
- package/workspace/briefing-premium-insights-test.js +40 -38
- package/workspace/briefing-premium-test.js +2 -1
- package/workspace/changelog.json +24 -0
- package/workspace/goals-clear-ui-test.js +263 -0
- package/workspace/guide/home.md +12 -2
- package/workspace/guide/metric-drafts.md +8 -2
- package/workspace/home-railcard-test.js +193 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +16 -14
- package/workspace/lib/board-premium.js +1 -1
- package/workspace/lib/engine/boards.js +9 -2
- package/workspace/lib/engine/records/index.js +9 -2
- package/workspace/lib/initiative-layout.js +3 -1
- package/workspace/lib/insights-premium.js +22 -1
- package/workspace/lib/metric-drafts.js +37 -10
- package/workspace/lib/metric-read-runs.js +20 -13
- package/workspace/lib/metric-reads.js +208 -23
- package/workspace/lib/metrics-cli.js +62 -5
- package/workspace/lib/routes-boards.js +40 -1
- package/workspace/lib/routes-goal-status.js +89 -6
- package/workspace/lib/routes-insights-premium.js +1 -1
- package/workspace/lib/routes-metric-drafts.js +26 -3
- package/workspace/live-pill-round-test.js +178 -0
- package/workspace/metric-drafts-ui-test.js +5 -2
- package/workspace/okr-goals-ui-test.js +27 -23
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +231 -0
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-item-test.js +10 -2
- package/workspace/premium-vw-jira-test.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/cozy-adler.js +21 -0
- package/workspace/public/pm/cozy-divider.css +32 -0
- package/workspace/public/pm/cozy-divider.js +45 -0
- package/workspace/public/pm/cozy-insights.css +96 -0
- package/workspace/public/pm/cozy-live-pill.css +16 -17
- package/workspace/public/pm/cozy-live-pill.js +28 -17
- package/workspace/public/pm/cozy-panels.css +59 -0
- package/workspace/public/pm/cozy-panels.js +524 -0
- package/workspace/public/pm/cozy-today.css +15 -0
- package/workspace/public/pm/cozy-viewer.js +173 -69
- package/workspace/public/pm/cozy-vw-shell.css +4 -0
- package/workspace/public/pm/goals-clear.js +265 -0
- package/workspace/public/pm/home-app.js +73 -14
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/home-today.js +55 -12
- package/workspace/public/pm/ini-edit.js +401 -0
- package/workspace/public/pm/ini-groups.js +14 -8
- package/workspace/public/pm/ini-tasks.js +84 -26
- package/workspace/public/pm/ini-versions.js +18 -4
- package/workspace/public/pm/ini-view-model.js +45 -18
- package/workspace/public/pm/ini-view.css +117 -5
- package/workspace/public/pm/ini-view.js +51 -17
- package/workspace/public/pm/metric-drafts.js +4 -1
- package/workspace/public/pm/mission.js +11 -7
- package/workspace/public/pm/premium-board.js +8 -6
- package/workspace/public/pm/premium-insights.js +375 -59
- package/workspace/public/pm/task-card.css +2 -0
- package/workspace/public/pm/task-card.js +4 -1
- package/workspace/server.js +6 -2
- package/workspace/skills/metric-read.skill +7 -5
- package/workspace/stage-card-tasks-test.js +396 -0
- package/workspace/stage-card-test.js +12 -4
- package/workspace/task-delete-test.js +9 -1
- package/workspace/task-milestones-test.js +3 -3
- package/workspace/task-press-test.js +12 -4
- package/workspace/task-views-test.js +198 -5
- package/workspace/test-lists/batch18-live-pill-round.json +10 -0
- package/workspace/test-lists/batch18-panels.json +9 -0
- package/workspace/test-lists/goals-clear.json +15 -0
- package/workspace/test-lists/home-railcard.json +9 -0
- package/workspace/test-lists/stage-card-tasks.json +6 -0
- package/workspace/tk-tasks-test.js +2 -2
|
@@ -28,7 +28,7 @@ export const P = {
|
|
|
28
28
|
pause: 'M8 5v14M16 5v14', stop: 'M7 7h10v10H7z', list: 'M9 6h11M9 12h11M9 18h11', doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
|
|
29
29
|
gate: 'M12 3l7 3v6c0 4-3 7-7 9-4-2-7-5-7-9V6z', flag: 'M5 21V4h11l-2 4 2 4H5', cal: 'M4 6h16v14H4zM4 10h16', pin: 'M9 4h6l-1 6 3 3H7l3-3zM12 13v7',
|
|
30
30
|
decide: 'M12 3v18M5 8l7-5 7 5', ret: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', back: 'M19 12H5M11 6l-6 6 6 6', warn: 'M12 4l9 16H3zM12 10v4M12 17v.5',
|
|
31
|
-
chat: 'M4 5h16v11H9l-5 4z', prog: 'M4 5h7v5H4zM13 5h7v5h-7zM8.5 14h7v5h-7zM7.5 10v2h9v-2M12 12v2', dots: 'M5 12h.01M12 12h.01M19 12h.01', send: 'M5 12h14M13 6l6 6-6 6', ticket: 'M3 5h18v4H3zM3 11h18v4H3z',
|
|
31
|
+
chat: 'M4 5h16v11H9l-5 4z', fold: 'M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zM9 4v16', prog: 'M4 5h7v5H4zM13 5h7v5h-7zM8.5 14h7v5h-7zM7.5 10v2h9v-2M12 12v2', dots: 'M5 12h.01M12 12h.01M19 12h.01', send: 'M5 12h14M13 6l6 6-6 6', ticket: 'M3 5h18v4H3zM3 11h18v4H3z',
|
|
32
32
|
};
|
|
33
33
|
export const svg = (d, w = 16, cls = '') => `<svg aria-hidden="true"${cls ? ` class="${cls}"` : ''} width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
34
34
|
const ROW_ICON = { decision: P.decide, blocked: P.warn, waited: P.clock, src: P.doc, source: P.doc, ev: P.gate, run: P.ret, update: P.doc, meeting: P.cal };
|
|
@@ -147,10 +147,11 @@ export function sesSheetHtml(M, o) {
|
|
|
147
147
|
* the pill lists what is in it. On a desktop the list opens right under the pill; on a phone it is a sheet (sesSheetHtml). */
|
|
148
148
|
function iniHtml(r, o, po) {
|
|
149
149
|
const on = o.ses === sesKey(r, o) && !o.phone && r.kids.length;
|
|
150
|
-
|
|
150
|
+
// in the folded rail's card (batch 18 item 14, FlA2) the sessions open in place under the row, inside the card
|
|
151
|
+
const pop = !on ? '' : o.card ? `<div class="hv-rcs" role="group" aria-label="In ${esc(r.name)}">${sesListHtml(r, o)}</div>` : `<div class="hv-spp" data-esc-layer role="dialog" aria-label="In ${esc(r.name)}">${sesListHtml(r, o)}</div>`;
|
|
151
152
|
const t = track(r.at, r.stage, r.steps);
|
|
152
153
|
return `<div class="hm-r hv-r ini st-${esc(r.state)}${o.sel === r.id ? ' sel' : ''}${on ? ' sp-on' : ''}" data-id="${esc(r.id)}"${po ? ` data-po-id="${esc(r.ini || r.id)}"` : ''}>${po ? gripHtml(r.name) : ''}<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${o.sel === r.id ? ' aria-current="true"' : ''} title="${esc(r.hint)}">${markHtml(r.yours && r.state !== 'blocked' ? { state: 'needs' } : r)}`
|
|
153
|
-
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span></button>${pillHtml(r, o)}${t ? `<button type="button" class="hv-tk" data-hm-sel="${esc(r.id)}" tabindex="-1" aria-hidden="true">${t}</button>` : ''}${pop}</div
|
|
154
|
+
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span></button>${pillHtml(r, o)}${t ? `<button type="button" class="hv-tk" data-hm-sel="${esc(r.id)}" tabindex="-1" aria-hidden="true">${t}</button>` : ''}${o.card ? '' : pop}</div>${o.card ? pop : ''}`;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/* ── a group (HvAC .pg, .card; PgHomePhone .psub) ── */
|
|
@@ -163,10 +164,15 @@ function productHtml(g, o) {
|
|
|
163
164
|
const say = [g.name, open ? (g.goals && g.goals.n ? g.goals.text : '') : [plural(g.count, 'initiative', 'initiatives'), yoursWords(g)].filter(Boolean).join(', ')].filter(Boolean).join(', ');
|
|
164
165
|
// the name opens the product in the Viewer, with its own chat; the rest of the header folds the group (canvas HbCProduct)
|
|
165
166
|
const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
|
|
166
|
-
+ `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
|
|
167
|
+
+ `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
|
|
167
168
|
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(say)}. ${open ? 'Close' : 'Open'} the group">${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
|
|
168
169
|
const sec = `<section class="hm-pg hv-g" aria-label="${esc(g.name)}" data-po-id="${esc(prodKey(g.name))}">${SO.gripHtml(g.name)}`;
|
|
169
170
|
if (!open) return `${sec}${head}</section>`;
|
|
171
|
+
return `${sec}${head}<div class="hv-card">${productBody(g, o, true)}</div></section>`;
|
|
172
|
+
}
|
|
173
|
+
/** A product's rows: its tasks, its initiatives with the quiet ones folded to "N more", the open one always shown. po: the grip arranges
|
|
174
|
+
* them (the list); the folded rail's card shows the same rows without it. */
|
|
175
|
+
function productBody(g, o, po) {
|
|
170
176
|
const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
|
|
171
177
|
const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
|
|
172
178
|
const QUIET = 3;
|
|
@@ -175,10 +181,11 @@ function productHtml(g, o) {
|
|
|
175
181
|
const rest = restAll ? g.rest : g.rest.filter((r, i) => i < Math.max(0, QUIET - g.inis.length) || r.id === o.sel);
|
|
176
182
|
const more = g.rest.length - rest.length;
|
|
177
183
|
// the product's initiatives are one list the grip arranges, shared with the Board (batch 14 item 8)
|
|
178
|
-
const
|
|
184
|
+
const inis = g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key }, po)).join('');
|
|
185
|
+
const body = flat + (po ? `<div class="po-list" data-po-list="@${esc(prodKey(g.name))}">${inis}</div>` : inis)
|
|
179
186
|
+ (more > 0 ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="false" aria-label="${more} more ${more === 1 ? 'initiative' : 'initiatives'} with nothing today. Show"><span class="hv-mk"></span>${more} more${svg(P.chevD, 16)}</button>`
|
|
180
187
|
: restAll && g.rest.length > QUIET ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="true"><span class="hv-mk"></span>Fewer${svg(P.chevU, 16)}</button>` : '');
|
|
181
|
-
return
|
|
188
|
+
return g.inis.length + rest.length + g.flat.length ? body : `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`;
|
|
182
189
|
}
|
|
183
190
|
/** A program's group (canvas PgHomePhone, PgHomeDesk): above the products. Its header: the program tile, the name, the next milestone's
|
|
184
191
|
* diamond with its date and one small diamond per initiative it waits on (filled when that initiative is past the Deliver milestone), a chevron.
|
|
@@ -188,21 +195,55 @@ function productHtml(g, o) {
|
|
|
188
195
|
function programHtml(g, o) {
|
|
189
196
|
const open = o.pOpen(g);
|
|
190
197
|
const nx = g.st && g.st.next;
|
|
191
|
-
const ms =
|
|
192
|
-
|
|
198
|
+
const ms = msHtml(g);
|
|
199
|
+
const line = nx ? 'Next milestone ' + nx.name + (nx.day ? ', ' + nx.day : '') + (nx.late ? ', late' : '') + (nx.n ? ', ' + nx.ready + ' of ' + nx.n + (nx.n === 1 ? ' initiative' : ' initiatives') + ' ready' : '') : 'No open milestone';
|
|
193
200
|
const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
|
|
194
|
-
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
201
|
+
+ `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}"${o.here === g.key ? ' data-cz-rail-here' : ''}>${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
|
|
195
202
|
+ `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
|
|
196
203
|
const sec = `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}" data-po-id="g:${esc(g.program.id)}">${SO.gripHtml(g.name)}`;
|
|
197
204
|
if (!open) return `${sec}${head}</section>`;
|
|
198
205
|
// the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
|
|
199
206
|
// a product's sub-heading only when the program's rows on Home come from two or more products (batch 12 item 6): one product repeated
|
|
200
207
|
// under every program said nothing
|
|
208
|
+
return `${sec}${head}<div class="hv-card">${programBody(g, o, true)}</div></section>`;
|
|
209
|
+
}
|
|
210
|
+
/** The next milestone in a program's header: its diamond and date, then one small diamond per initiative it waits on. */
|
|
211
|
+
function msHtml(g) {
|
|
212
|
+
const nx = g.st && g.st.next;
|
|
213
|
+
return nx ? `<span class="hv-msd${nx.late ? ' late' : ''}"><span class="hv-dm"></span>${esc(nx.day || nx.name)}${nx.n ? `<span class="hv-rd">${Array.from({ length: nx.n }, (_, i) => `<i${i < nx.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : ''}</span>` : '';
|
|
214
|
+
}
|
|
215
|
+
/** A program's rows: its milestone row first, then its initiatives, under a product sub-heading when they come from two or more products. */
|
|
216
|
+
function programBody(g, o, po) {
|
|
201
217
|
const many = g.subs.length > 1;
|
|
202
|
-
const body = g.subs.map((x) => `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}
|
|
218
|
+
const body = g.subs.map((x) => { const inis = x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, po)).join(''); return `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}${po ? `<div class="po-list" data-po-list="${esc(g.program.id)}">${inis}</div>` : inis}`; }).join('');
|
|
203
219
|
// the program's milestone changes that wait on the PM lead its card (batch 14 item 4: they were only in Your day, which a desktop no longer has)
|
|
204
220
|
const msr = g.msRow ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
|
|
205
|
-
return
|
|
221
|
+
return msr + (body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`);
|
|
222
|
+
}
|
|
223
|
+
/** Which group holds what is open (o.sel: a row id, or 'i:<initiative>'): the folded rail marks that group's tile (batch 18 item 14, FlA4After).
|
|
224
|
+
* Nothing in a group is open: null. */
|
|
225
|
+
export function groupOfOpen(M, sel) {
|
|
226
|
+
if (!M || !sel) return null;
|
|
227
|
+
const hit = (r) => r && (r.id === sel || (r.kids || []).some((k) => k.id === sel));
|
|
228
|
+
for (const g of M.groups || []) {
|
|
229
|
+
if (g.kind === 'loose') continue;
|
|
230
|
+
const rows = g.kind === 'program' ? [g.msRow].concat(...(g.subs || []).map((x) => x.inis)) : (g.flat || []).concat(g.inis || [], g.rest || []);
|
|
231
|
+
if (rows.some(hit)) return g.key;
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
/** The folded rail's card (batch 18 item 14, FlA1–FlA5): a group's tile, name and › (opens the program or product), a program's next
|
|
236
|
+
* milestone, ×; then Home's own rows for that group (the quiet ones folded, the open one shown), the pill's sessions in place. */
|
|
237
|
+
export function railCardHtml(M, key, o) {
|
|
238
|
+
const g = M && (M.groups || []).find((x) => x.key === key && x.kind !== 'loose');
|
|
239
|
+
if (!g) return '';
|
|
240
|
+
const prog = g.kind === 'program';
|
|
241
|
+
const tile = prog ? `<span class="hv-tl tp" aria-hidden="true">${svg(P.layers, 16)}</span>` : `<span class="hv-tl t${g.tone}" aria-hidden="true">${esc(g.initials)}</span>`;
|
|
242
|
+
const go = prog ? `data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"` : `data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"`;
|
|
243
|
+
const oc = { ...o, card: true };
|
|
244
|
+
return `<div class="hv-rch"><button type="button" class="hv-pt" ${go}>${tile}<b>${esc(g.name)}</b>${svg(P.chevR, 16)}</button>${prog ? msHtml(g) : ''}`
|
|
245
|
+
+ `<button type="button" class="ut-ib hv-ib" data-hm-rcx aria-label="Close" title="Close">${svg(P.x, 18)}</button></div>`
|
|
246
|
+
+ `<div class="hv-rcb">${prog ? programBody(g, oc, false) : productBody(g, oc, false)}</div>`;
|
|
206
247
|
}
|
|
207
248
|
/** "Not in an initiative" (HvAC .lh): a line under the groups. Folded it shows a blue dot when a row waits on you, an amber square when one
|
|
208
249
|
* of your own is late, and the count; open, the rows in a card. */
|
|
@@ -279,7 +320,9 @@ export function listHtml(M, T, o) {
|
|
|
279
320
|
+ (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
|
|
280
321
|
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
|
|
281
322
|
+ SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
|
|
282
|
-
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button
|
|
323
|
+
+ `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button>`
|
|
324
|
+
// fold the list to the rail (batch 18 item 15, TbT1Split): the rail's list button brings it back; a phone has no rail
|
|
325
|
+
+ (o.phone ? '' : `<button type="button" class="ut-ib hv-ib" data-hm-fold aria-label="Fold the list to the rail" title="Fold the list to the rail">${svg(P.fold, 18)}</button>`) + '</span></div>'
|
|
283
326
|
+ (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
|
|
284
327
|
// the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
|
|
285
328
|
const card = MOMENT.has(T.mode) ? todayHtml(T, { greet: M.greet, sub: '', phone: o.phone }) : '';
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/* pm/ini-edit.js — a task changed where it sits in the Tasks List (feedback batch 18 item 16, agreed A; main canvas In development, frames
|
|
2
|
+
* StA1Rows to StA10bDragPhone, stickies stRules and stWhy). pm/ini-view.js draws the List and calls this file for the parts below; the
|
|
3
|
+
* Board's panel and Home's initiative page draw the same List, so both get them.
|
|
4
|
+
*
|
|
5
|
+
* openOf(id) / addOf(id) the task whose row is open in place, and the stage whose + field is open (one each per initiative)
|
|
6
|
+
* stagesSet(id, v) the stages a task can move to (the workflow's, then Not in a stage), from the view by stage
|
|
7
|
+
* rowHtml(x, o) the open row (StA2Edit): the name field (a Jira row: its title and "<Status> in Jira · read N min ago"),
|
|
8
|
+
* then ONE quiet line: the status icon chip, the date chips (Start – Due; a milestone: one ◇ chip; none: a
|
|
9
|
+
* dashed Dates chip) and ⋯ right after the dates (StA8Desk)
|
|
10
|
+
* ticketHtml(k, o) an unlinked Jira ticket's open row: the same, with Open the ticket in place of ⋯ (its place is Jira's)
|
|
11
|
+
* plusHtml(sec, id, o) the + on an open stage's header: "New task in <stage>" (StA5Add)
|
|
12
|
+
* addHtml(sec, id) the field at the top of that stage's list, with an optional Dates chip
|
|
13
|
+
* press(b, d, root, H, e) a press this file owns → true: a title (opens the row), ⋯ and its menu, the +, the field's Dates chip
|
|
14
|
+
* wire(body) once per body: the name field (Enter or blur saves, Esc closes), the add field (Enter adds and stays open),
|
|
15
|
+
* a press outside the open row closes it, and the drag (StA10Drag): a grip on hover on a desktop, a long press
|
|
16
|
+
* on the title on a phone; the target stage lights up and a blue line shows where the task lands
|
|
17
|
+
* writes(h) the host's handlers with the writes this file needs, where the host has none: h.rename(uid, title),
|
|
18
|
+
* h.move(uid, { to, from, ids, name }) (a stage, and the order inside it), each with Undo in the toast
|
|
19
|
+
*
|
|
20
|
+
* A move never changes a task's status or dates. Zero is silence: a row with no dates shows none. Icon-only presses carry their words in
|
|
21
|
+
* aria-label and title. */
|
|
22
|
+
import * as TV from './ini-tasks.js';
|
|
23
|
+
import { stateIcon, freshness } from './task-card.js';
|
|
24
|
+
import { pmPost } from './http.js';
|
|
25
|
+
|
|
26
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
27
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
28
|
+
const P = {
|
|
29
|
+
more: 'M5 12h.01M12 12h.01M19 12h.01', plus: 'M12 5v14M5 12h14', check: 'M5 12l5 5 9-10', down: 'M7 10l5 5 5-5', right: 'M10 7l5 5-5 5', left: 'M14 7l-5 5 5 5',
|
|
30
|
+
dia: 'M12 4l8 8-8 8-8-8z', cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01',
|
|
31
|
+
open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', bin: 'M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/* ── what is open, per initiative ── */
|
|
35
|
+
const OPEN = new Map(); // initiative id → the uid of the row open in place
|
|
36
|
+
const ADD = new Map(); // initiative id → the stage key whose + field is open
|
|
37
|
+
const ADD_D = new Map(); // initiative id → { start, due } the add field's Dates chip picked
|
|
38
|
+
const STAGES = new Map(); // initiative id → [{ key, name }] the stages a task can move to
|
|
39
|
+
const VIEW = new Map(); // initiative id → the view the List drew last (the drag reads its stages' tasks)
|
|
40
|
+
export const openOf = (id) => OPEN.get(id) || '';
|
|
41
|
+
export const addOf = (id) => (ADD.has(id) ? ADD.get(id) : null);
|
|
42
|
+
/** For the tests: close every open row and field. */
|
|
43
|
+
export const reset = () => { OPEN.clear(); ADD.clear(); ADD_D.clear(); STAGES.clear(); VIEW.clear(); };
|
|
44
|
+
/** The stages of the view by stage (v0), in workflow order, then Not in a stage. Folded lines (past, Later) hold their stages inside.
|
|
45
|
+
* v: the view as the List draws it (grouped as the PM picked). */
|
|
46
|
+
export function stagesSet(id, v0, v) {
|
|
47
|
+
VIEW.set(id, v || v0);
|
|
48
|
+
v = v0;
|
|
49
|
+
const out = [];
|
|
50
|
+
const walk = (s) => { if (s.stages) { s.stages.forEach(walk); return; } if (s.kind === 'stage') out.push({ key: s.key, name: s.name }); };
|
|
51
|
+
for (const s of (v.tasks && v.tasks.sections) || []) walk(s);
|
|
52
|
+
out.push({ key: '', name: 'Not in a stage' });
|
|
53
|
+
STAGES.set(id, out);
|
|
54
|
+
}
|
|
55
|
+
const stageName = (id, key) => { const s = (STAGES.get(id) || []).find((x) => x.key === key); return s ? s.name : key || 'Not in a stage'; };
|
|
56
|
+
|
|
57
|
+
/* ── the open row (StA2Edit, StA6Jira, StA8Desk) ── */
|
|
58
|
+
const chip = (cls, attrs, inner, label) => `<button type="button" class="iv-edc ${cls}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${inner}</button>`;
|
|
59
|
+
/** The date chips: a milestone's one ◇ day; else Start – Due; with no dates one dashed Dates chip. The press opens the task card's picker. */
|
|
60
|
+
function datesHtml(x, uid) {
|
|
61
|
+
const base = `data-iv-date="${esc(uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" data-t="${esc(x.title)}"`;
|
|
62
|
+
if (x.ms && !x.jiraTk) {
|
|
63
|
+
return x.dueText ? chip('iv-edd ms', `${base} data-one="1"`, `${SVG(P.dia, 13, 2.2)}<b>${esc(x.dueText)}</b>`, 'Milestone date: ' + x.dueText + '. Change')
|
|
64
|
+
: chip('iv-edd ms dash', `${base} data-one="1"`, `${SVG(P.dia, 13, 2.2)}Date`, 'Set the milestone date');
|
|
65
|
+
}
|
|
66
|
+
if (!x.start && !x.end) return chip('iv-edd dash', `${base} data-f="start"`, `${SVG(P.cal, 14, 2)}Dates`, 'Add dates');
|
|
67
|
+
return chip('iv-edd', `${base} data-f="start"`, `<small>Start</small><b>${esc(x.startText || 'None')}</b>`, 'Start: ' + (x.startText || 'none') + '. Change')
|
|
68
|
+
+ '<span class="iv-eds" aria-hidden="true">–</span>'
|
|
69
|
+
+ chip('iv-edd', `${base} data-f="due"`, `<small>Due</small><b>${esc(x.dueText || 'None')}</b>`, 'Due: ' + (x.dueText || 'none') + '. Change');
|
|
70
|
+
}
|
|
71
|
+
/** "In Progress in Jira · read 4 min ago": a Jira row's status and title are Jira's (read-only here). */
|
|
72
|
+
const jiraLine = (st, at) => `<p class="iv-edj">${esc((st || 'To do') + ' in Jira')}${at ? `<span> · ${esc(freshness(at))}</span>` : ''}</p>`;
|
|
73
|
+
export function rowHtml(x, o, box, name) {
|
|
74
|
+
const jira = !!(x.jkey && !x.dr);
|
|
75
|
+
const field = jira ? `<b class="iv-tt">${name}</b>${jiraLine(x.jst || x.status, o.jiraRead)}`
|
|
76
|
+
: `<form class="iv-edf" data-iv-renf="${esc(x.uid)}"><input type="text" class="iv-edn" data-iv-ren="${esc(x.uid)}" value="${esc(x.title)}" maxlength="200" autocomplete="off" aria-label="Task name" data-was="${esc(x.title)}"></form>`;
|
|
77
|
+
const st = jira ? '' : chip('iv-edst', `data-iv-stat="${esc(x.uid)}" data-st="${esc(x.status)}" data-plain="1" aria-haspopup="dialog"`, `${stateIcon(x.status)}${SVG(P.down, 11, 2.4)}`, 'Status: ' + x.status + '. Change');
|
|
78
|
+
const more = `<button type="button" class="iv-ib iv-edm" data-iv-more="${esc(x.uid)}" aria-haspopup="menu" aria-expanded="false" aria-label="More for this task" title="More">${SVG(P.more, 18, 3)}</button>`;
|
|
79
|
+
return `<div class="iv-tr iv-ed${jira ? ' jr' : ''}" data-esc-layer data-iv-r="${esc(x.uid)}" data-iv-open="${esc(x.uid)}">${box}<span class="w">${field}<span class="iv-edl">${st}${datesHtml(x, x.uid)}${more}</span></span></div>`;
|
|
80
|
+
}
|
|
81
|
+
/** An unlinked Jira ticket's open row (StA6Jira): the start and due kept in PMOS change here; Open the ticket sits after them. */
|
|
82
|
+
export function ticketHtml(k, o) {
|
|
83
|
+
const r = TV.jiraRow(k), x = { ...r, jiraTk: true, startText: k.startText || '', dueText: k.dueText || '' };
|
|
84
|
+
const open = `<button type="button" class="iv-ib iv-edm" data-iv-ticket="${esc(k.key)}" aria-label="Open the ticket" title="Open the ticket">${SVG(P.open, 16, 2)}</button>`;
|
|
85
|
+
return `<div class="iv-tr iv-tkr iv-ed jr" data-esc-layer data-iv-open="${esc(k.key)}"><span class="iv-jq" aria-hidden="true"></span><span class="w"><b class="iv-tt"><em>${esc(k.key)}</em> ${esc(k.title)}</b>${jiraLine(k.status, o.jiraRead)}<span class="iv-edl">${datesHtml(x, k.key)}${open}</span></span></div>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* ── + on a stage, and its field (StA5Add) ── */
|
|
89
|
+
export function plusHtml(sec, id, o) {
|
|
90
|
+
if (!o.addIn) return '';
|
|
91
|
+
const nm = sec.name || 'Not in a stage', on = addOf(id) === (sec.key || '');
|
|
92
|
+
return `<button type="button" class="iv-ib iv-plus${on ? ' on' : ''}" data-iv-plus="${esc(sec.key || '')}" data-nm="${esc(nm)}" aria-pressed="${on}" aria-label="${esc('New task in ' + nm)}" title="${esc('New task in ' + nm)}">${SVG(P.plus, 16, 2.2)}</button>`;
|
|
93
|
+
}
|
|
94
|
+
const mdIso = (iso) => { const n = TV.dn(iso); return n == null ? '' : TV.md(n); };
|
|
95
|
+
export function addHtml(sec, id) {
|
|
96
|
+
if (addOf(id) !== (sec.key || '')) return '';
|
|
97
|
+
const nm = sec.name || 'Not in a stage', D = ADD_D.get(id) || {};
|
|
98
|
+
const dt = D.start || D.due ? [mdIso(D.start), mdIso(D.due)].filter(Boolean).join(' – ') : '';
|
|
99
|
+
return `<form class="iv-addf iv-addin" data-esc-layer data-iv-addin="${esc(sec.key || '')}" data-nm="${esc(nm)}"><span class="iv-cb" aria-hidden="true"></span>`
|
|
100
|
+
+ `<input type="text" data-iv-addinp maxlength="200" autocomplete="off" placeholder="${esc('New task in ' + nm)}" aria-label="${esc('New task in ' + nm)}">`
|
|
101
|
+
+ `<button type="submit" class="iv-go" aria-label="Add the task" title="Add (Enter). Esc closes.">${SVG(P.check, 16, 2.2)}</button></form>`
|
|
102
|
+
+ `<div class="iv-addd"><button type="button" class="iv-edc iv-edd${dt ? '' : ' dash'}" data-iv-adddt data-s="${esc(D.start || '')}" data-e="${esc(D.due || '')}" data-f="start" aria-label="${esc(dt ? 'Dates: ' + dt + '. Change' : 'Dates, optional')}" title="Dates, optional">${SVG(P.cal, 14, 2)}${esc(dt || 'Dates')}</button></div>`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ── the writes (Undo in the host's toast) ── */
|
|
106
|
+
async function post(H, route, body) {
|
|
107
|
+
const at = H.where ? H.where() : {};
|
|
108
|
+
return pmPost('/api/boards/tasks/' + route, { ws: at.ws, board: at.board, ...body }).catch(() => null);
|
|
109
|
+
}
|
|
110
|
+
const say = (H, m, undo) => { if (H.toast) H.toast(m, undo); };
|
|
111
|
+
const failed = (H, res, m) => { say(H, (res && res.error) || m || 'Nothing was changed.'); return false; };
|
|
112
|
+
const after = async (H) => { if (H.reload) await H.reload(); else if (H.redraw) H.redraw(); };
|
|
113
|
+
/** Add the writes the host does not have. The draft's own writes wrap these (pm/ini-versions.js). */
|
|
114
|
+
export function writes(h) {
|
|
115
|
+
const W = { ...h };
|
|
116
|
+
if (!W.rename) W.rename = async (uid, title) => {
|
|
117
|
+
const res = await post(W, 'rename', { task: uid, title });
|
|
118
|
+
if (!res || res.ok === false) return failed(W, res, 'The name was not changed.');
|
|
119
|
+
await after(W);
|
|
120
|
+
const was = res.from;
|
|
121
|
+
say(W, 'Renamed.', was ? async () => { const u = await post(W, 'rename', { task: uid, title: was }); if (!u || u.ok === false) failed(W, u, 'The undo did not land.'); await after(W); } : undefined);
|
|
122
|
+
return true;
|
|
123
|
+
};
|
|
124
|
+
if (!W.move) W.move = async (uid, m) => {
|
|
125
|
+
const id = W.__id ? W.__id() : '', moved = m.to !== m.from;
|
|
126
|
+
let sec = null, ord = null;
|
|
127
|
+
if (moved) { sec = await post(W, 'edit', { task: uid, section: m.to }); if (!sec || sec.ok === false) return failed(W, sec, 'The task was not moved.'); }
|
|
128
|
+
if (m.ids) { ord = await post(W, 'order', { initiative: id, section: m.to, tasks: m.ids }); if (!ord || ord.ok === false) { if (!moved) return failed(W, ord, 'The order was not saved.'); say(W, 'Moved, but not its place in the stage: ' + ((ord && ord.error) || 'the server did not say why') + '.'); ord = null; } }
|
|
129
|
+
await after(W);
|
|
130
|
+
say(W, moved ? 'Moved to ' + (m.name || stageName(id, m.to)) + '.' : 'Order saved.', async () => {
|
|
131
|
+
if (ord) { const u = await post(W, 'order', { initiative: id, section: m.to, tasks: ord.from || [] }); if (!u || u.ok === false) { failed(W, u, 'The undo did not land.'); await after(W); return; } }
|
|
132
|
+
if (moved) { const u = await post(W, 'edit', { task: uid, section: sec.from && typeof sec.from.section === 'string' ? sec.from.section : m.from }); if (!u || u.ok === false) failed(W, u, 'The undo did not land.'); }
|
|
133
|
+
await after(W);
|
|
134
|
+
});
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
return W;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ── the presses ── */
|
|
141
|
+
let SUPPRESS = 0; // a long press lifted the row: the click that follows is not a press on the title
|
|
142
|
+
let TOUCHED = 0; // this click opened or kept a row open: the document's own click does not close it
|
|
143
|
+
const rowOf = (v, uid) => {
|
|
144
|
+
for (const s of (v && v.tasks && v.tasks.sections) || []) for (const c of s.stages || [s]) {
|
|
145
|
+
for (const x of [...(c.top || []), ...(c.groups || []).flatMap((g) => g.rows), ...(c.done || []), ...(c.archived || [])]) if (x.uid === uid) return { x, sec: c };
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
};
|
|
149
|
+
/** The open (not closed) tasks of a stage, top to bottom, as the List draws them. */
|
|
150
|
+
const openIds = (v, key) => {
|
|
151
|
+
for (const s of (v && v.tasks && v.tasks.sections) || []) for (const c of s.stages || [s]) if (c.kind !== 'group' && (c.key || '') === key) return [...(c.top || []), ...(c.groups || []).flatMap((g) => g.rows)].filter((x) => !x.dr).map((x) => x.uid);
|
|
152
|
+
return [];
|
|
153
|
+
};
|
|
154
|
+
export function press(b, d, root, H, e) {
|
|
155
|
+
const id = root.dataset.iv, v = VIEW.get(id);
|
|
156
|
+
if (d.ivEdit) {
|
|
157
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
158
|
+
if (Date.now() - SUPPRESS < 350) return true;
|
|
159
|
+
OPEN.set(id, d.ivEdit); ADD.delete(id); if (H.redraw) H.redraw();
|
|
160
|
+
focusLater(root, `[data-iv-open="${cssq(d.ivEdit)}"] .iv-edn`, true);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (d.ivPlus != null) {
|
|
164
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
165
|
+
if (addOf(id) === d.ivPlus) { ADD.delete(id); ADD_D.delete(id); } else { ADD.set(id, d.ivPlus); ADD_D.delete(id); OPEN.delete(id); }
|
|
166
|
+
if (H.redraw) H.redraw();
|
|
167
|
+
focusLater(root, '[data-iv-addinp]');
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
if ('ivAdddt' in d) {
|
|
171
|
+
e.preventDefault(); TOUCHED = Date.now();
|
|
172
|
+
TV.datePop(b, '', { dates: (u, p) => { ADD_D.set(id, { ...(ADD_D.get(id) || {}), ...p }); const f = b.closest('.iv-wl'); redrawAdd(f, id); } });
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (d.ivMore) { e.preventDefault(); TOUCHED = Date.now(); moreMenu(b, d.ivMore, id, v, H); return true; }
|
|
176
|
+
if (b.closest('.iv-ed')) TOUCHED = Date.now();
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const cssq = (s) => String(s).replace(/["\\]/g, '\\$&');
|
|
180
|
+
function focusLater(root, sel, select) {
|
|
181
|
+
const body = root.parentElement;
|
|
182
|
+
// a host may draw after a read: try for a short while, until the field is there and holds the focus
|
|
183
|
+
let n = 0;
|
|
184
|
+
const go = () => {
|
|
185
|
+
const f = (body && body.isConnected ? body : document).querySelector(sel);
|
|
186
|
+
if (f && document.activeElement !== f) { f.focus({ preventScroll: true }); if (select && f.setSelectionRange) f.setSelectionRange(f.value.length, f.value.length); }
|
|
187
|
+
if ((!f || document.activeElement !== f) && ++n < 40) setTimeout(go, 50); // up to 2 s: a slow host draws late
|
|
188
|
+
};
|
|
189
|
+
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(go); else go();
|
|
190
|
+
}
|
|
191
|
+
/** The add field's Dates chip again, after a pick, without a redraw (the typed words stay). */
|
|
192
|
+
function redrawAdd(list, id) {
|
|
193
|
+
const f = list && list.querySelector('.iv-addd'); if (!f) return;
|
|
194
|
+
const D = ADD_D.get(id) || {}, dt = [mdIso(D.start), mdIso(D.due)].filter(Boolean).join(' – '), c = f.querySelector('[data-iv-adddt]');
|
|
195
|
+
if (!c) return;
|
|
196
|
+
c.dataset.s = D.start || ''; c.dataset.e = D.due || ''; c.classList.toggle('dash', !dt);
|
|
197
|
+
c.setAttribute('aria-label', dt ? 'Dates: ' + dt + '. Change' : 'Dates, optional');
|
|
198
|
+
c.innerHTML = SVG(P.cal, 14, 2) + esc(dt || 'Dates');
|
|
199
|
+
}
|
|
200
|
+
/** ⋯ of the open row (StA2bMore): Milestone (or Make it a plain task), Move to a stage, Open the task card (Open the ticket on a Jira row),
|
|
201
|
+
* Delete (only where the task can be deleted; never a Jira row). Move to a stage turns the menu into the workflow's stages, ← goes back. */
|
|
202
|
+
function moreMenu(b, uid, id, v, H) {
|
|
203
|
+
const f = rowOf(v, uid); if (!f) return;
|
|
204
|
+
const x = f.x, jira = !!(x.jkey && !x.dr), cur = f.sec.kind === 'stage' || f.sec.kind === 'none' ? f.sec.key || '' : null;
|
|
205
|
+
const del = !jira && !!H.remove && TV.deletable(uid);
|
|
206
|
+
const item = (attr, ico, label, extra = '') => `<button type="button" role="menuitem" class="o" ${attr}><span class="ck" aria-hidden="true">${SVG(ico, 15, 2)}</span><span>${esc(label)}</span>${extra}</button>`;
|
|
207
|
+
const main = () => `<div class="tkc-pop ivq-m ive-m" role="menu" aria-label="More for this task">`
|
|
208
|
+
+ item('data-ive-ms', P.dia, x.ms ? 'Make it a plain task' : 'Milestone')
|
|
209
|
+
+ item('data-ive-mv aria-haspopup="menu"', P.grip, 'Move to a stage', `<span class="k" aria-hidden="true">${SVG(P.right, 14, 2)}</span>`)
|
|
210
|
+
+ item('data-ive-card', P.open, jira ? 'Open the ticket' : 'Open the task card')
|
|
211
|
+
+ (del ? '<hr>' + item('data-ive-del class="o dl"', P.bin, 'Delete task') : '') + '</div>';
|
|
212
|
+
const stages = () => `<div class="tkc-pop ivq-m ive-m" role="menu" aria-label="Move to a stage"><button type="button" class="o ive-bk" data-ive-bk><span class="ck" aria-hidden="true">${SVG(P.left, 15, 2)}</span><span>Move to a stage</span></button><hr>`
|
|
213
|
+
+ (STAGES.get(id) || []).map((s) => `<button type="button" role="menuitemradio" class="o${s.key === cur ? ' hl' : ''}" aria-checked="${s.key === cur}" data-ive-to="${esc(s.key)}"><span class="ck" aria-hidden="true">${s.key === cur ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(s.name)}</span></button>`).join('') + '</div>';
|
|
214
|
+
const el = TV.openPop(b, main(), (o) => {
|
|
215
|
+
const d = o.dataset;
|
|
216
|
+
if ('iveMv' in d) { el.innerHTML = stages(); const c = el.querySelector('[aria-checked="true"], button'); if (c) c.focus({ preventScroll: true }); return; }
|
|
217
|
+
if ('iveBk' in d) { el.innerHTML = main(); return; }
|
|
218
|
+
TV.closePop();
|
|
219
|
+
if ('iveMs' in d) { milestone(H, x, !x.ms); return; }
|
|
220
|
+
if (d.iveTo != null) { if (d.iveTo !== cur && H.move) { OPEN.delete(id); H.move(uid, { to: d.iveTo, from: cur == null ? '' : cur, name: stageName(id, d.iveTo) }); } return; }
|
|
221
|
+
if ('iveCard' in d) { OPEN.delete(id); if (jira) { if (H.openTicket) H.openTicket(x.jkey, b); } else if (H.openTask) H.openTask(uid, b); return; }
|
|
222
|
+
if ('iveDel' in d && del) { OPEN.delete(id); H.remove(uid); }
|
|
223
|
+
}, { right: true });
|
|
224
|
+
}
|
|
225
|
+
/** A milestone has one date (StA4Milestone): turning ◇ on keeps the due day (or the start, when it has no due day) and clears the start; the
|
|
226
|
+
* host's Undo puts both back. */
|
|
227
|
+
function milestone(H, x, on) {
|
|
228
|
+
if (!H.dates) return;
|
|
229
|
+
const p = { milestone: on };
|
|
230
|
+
if (on && x.start) { p.start = ''; if (!x.end) p.due = x.start; }
|
|
231
|
+
H.dates(x.uid, p);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ── the fields, the outside press, the drag ── */
|
|
235
|
+
export function wire(body) {
|
|
236
|
+
if (!body || body.__iveWired) return;
|
|
237
|
+
body.__iveWired = true;
|
|
238
|
+
const H = () => body.__iv || {};
|
|
239
|
+
const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : ''; };
|
|
240
|
+
const close = (id) => { if (!id) return; const had = OPEN.has(id) || ADD.has(id); OPEN.delete(id); ADD.delete(id); ADD_D.delete(id); if (had && H().redraw) H().redraw(); };
|
|
241
|
+
// the name: Enter saves and closes the row; a blur saves (the row stays); Esc closes it as it was
|
|
242
|
+
const save = (inp) => {
|
|
243
|
+
const t = inp.value.trim(), was = inp.dataset.was || '';
|
|
244
|
+
if (!t || t === was) { inp.value = was; return false; }
|
|
245
|
+
inp.dataset.was = t;
|
|
246
|
+
if (H().rename) H().rename(inp.dataset.ivRen, t);
|
|
247
|
+
return true;
|
|
248
|
+
};
|
|
249
|
+
body.addEventListener('submit', (e) => {
|
|
250
|
+
const f = e.target.closest('[data-iv-renf], [data-iv-addin]'); if (!f) return;
|
|
251
|
+
e.preventDefault(); e.stopPropagation();
|
|
252
|
+
if (f.dataset.ivRenf != null) { const inp = f.querySelector('[data-iv-ren]'), id = idOf(); OPEN.delete(id); if (!save(inp) && H().redraw) H().redraw(); return; }
|
|
253
|
+
const inp = f.querySelector('[data-iv-addinp]'), t = inp ? inp.value.trim() : '', id = idOf();
|
|
254
|
+
if (!t || !H().addTask) return;
|
|
255
|
+
const D = ADD_D.get(id) || {};
|
|
256
|
+
inp.disabled = true;
|
|
257
|
+
Promise.resolve(H().addTask(t, inp, { section: f.dataset.ivAddin, name: f.dataset.nm, ...(D.start ? { start: D.start } : {}), ...(D.due ? { due: D.due } : {}) })).then(() => {
|
|
258
|
+
// Enter keeps the field open for the next one (StA5Add)
|
|
259
|
+
ADD_D.delete(id);
|
|
260
|
+
const n = body.querySelector('[data-iv-addinp]'); if (n) { if (n === inp) n.value = ''; n.disabled = false; n.focus({ preventScroll: true }); }
|
|
261
|
+
});
|
|
262
|
+
}, true);
|
|
263
|
+
body.addEventListener('focusout', (e) => { const inp = e.target.closest && e.target.closest('[data-iv-ren]'); if (inp && inp.isConnected) save(inp); });
|
|
264
|
+
body.addEventListener('keydown', (e) => {
|
|
265
|
+
if (e.key !== 'Escape') return;
|
|
266
|
+
const inp = e.target.closest && e.target.closest('[data-iv-ren], [data-iv-addinp]');
|
|
267
|
+
if (DRAG) { e.preventDefault(); e.stopPropagation(); dragStop(true); return; }
|
|
268
|
+
if (!inp && !(e.target.closest && e.target.closest('.iv-ed'))) return;
|
|
269
|
+
e.preventDefault(); e.stopPropagation();
|
|
270
|
+
if (inp && inp.dataset.was != null) inp.value = inp.dataset.was;
|
|
271
|
+
close(idOf());
|
|
272
|
+
});
|
|
273
|
+
// Esc with the focus outside the row (after a drill-in and Back, the row is drawn open again and the focus is on the page): the open row
|
|
274
|
+
// or + field is the top layer, so it closes here; the Viewer's own Esc steps aside while any layer is open (cozy-viewer.js)
|
|
275
|
+
window.addEventListener('keydown', (e) => {
|
|
276
|
+
if (e.key !== 'Escape' || e.defaultPrevented || !body.isConnected || DRAG) return;
|
|
277
|
+
const a = document.activeElement;
|
|
278
|
+
if (a && a !== document.body && a.closest && a.closest('[data-esc-layer]')) return; // a picker, a menu or the row itself has it
|
|
279
|
+
if ([...document.querySelectorAll('[data-esc-layer]')].some((l) => !body.contains(l))) return; // another layer is on top
|
|
280
|
+
if (!body.querySelector('.iv-ed, .iv-addin')) return;
|
|
281
|
+
e.preventDefault(); close(idOf());
|
|
282
|
+
});
|
|
283
|
+
// a press outside the open row (and outside its pickers) closes it
|
|
284
|
+
document.addEventListener('click', (e) => {
|
|
285
|
+
const id = idOf(); if (!id || !body.isConnected || (!OPEN.has(id) && !ADD.has(id)) || Date.now() - TOUCHED < 50) return;
|
|
286
|
+
const t = e.target; if (!t || !t.closest || t.closest('.iv-ed, .iv-addin, .iv-addd, .tkc.ivq, .vs-scrim, .cz-toast, [role="status"]')) return;
|
|
287
|
+
if (!t.isConnected) return;
|
|
288
|
+
close(id);
|
|
289
|
+
});
|
|
290
|
+
/* the drag (StA10Drag, StA10bDragPhone) */
|
|
291
|
+
body.addEventListener('pointerdown', (e) => {
|
|
292
|
+
const g = e.target.closest && e.target.closest('[data-iv-grip]');
|
|
293
|
+
if (g && e.button === 0) { e.preventDefault(); dragStart(body, g.closest('.iv-tr'), e); return; }
|
|
294
|
+
const t = e.target.closest && e.target.closest('[data-iv-edit][data-drag]');
|
|
295
|
+
if (t && (e.pointerType === 'touch' || coarse())) {
|
|
296
|
+
LP_off();
|
|
297
|
+
// a touch keeps sending its events to the element it began on: when a read draws the list again mid-press, that element leaves the
|
|
298
|
+
// page and its events no longer reach the document, so it hands them on itself while it is out of the page
|
|
299
|
+
const out = (fn) => (ev) => { if (!t.isConnected) fn(ev); };
|
|
300
|
+
const mv = out(docMove), up = out(docUp), cn = out(docCancel), tm = (ev) => { if (DRAG) ev.preventDefault(); }; // and the page does not scroll
|
|
301
|
+
const off = () => { t.removeEventListener('pointermove', mv); t.removeEventListener('pointerup', up); t.removeEventListener('pointercancel', cn); t.removeEventListener('touchmove', tm); };
|
|
302
|
+
t.addEventListener('pointermove', mv); t.addEventListener('touchmove', tm, { passive: false }); t.addEventListener('pointerup', (ev) => { up(ev); off(); }, { once: true }); t.addEventListener('pointercancel', (ev) => { cn(ev); off(); }, { once: true });
|
|
303
|
+
LP = { x: e.clientX, y: e.clientY, t: setTimeout(() => { LP = null; SUPPRESS = Date.now(); dragStart(body, t.closest('.iv-tr'), { clientX: LPX.x, clientY: LPX.y, pointerId: e.pointerId }); }, 450) };
|
|
304
|
+
LPX = { x: e.clientX, y: e.clientY };
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
body.addEventListener('contextmenu', (e) => { if (e.target.closest && e.target.closest('[data-iv-edit][data-drag]') && coarse()) e.preventDefault(); });
|
|
308
|
+
if (!wire.doc) {
|
|
309
|
+
wire.doc = true;
|
|
310
|
+
document.addEventListener('pointermove', docMove);
|
|
311
|
+
document.addEventListener('pointerup', docUp);
|
|
312
|
+
document.addEventListener('pointercancel', docCancel);
|
|
313
|
+
document.addEventListener('touchmove', (e) => { if (DRAG) e.preventDefault(); }, { passive: false });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function docMove(e) { if (LP) { LPX = { x: e.clientX, y: e.clientY }; if (Math.abs(e.clientX - LP.x) + Math.abs(e.clientY - LP.y) > 10) LP_off(); } if (DRAG) dragMove(e); }
|
|
317
|
+
function docUp() { LP_off(); if (DRAG) dragStop(false); }
|
|
318
|
+
function docCancel() { LP_off(); if (DRAG) dragStop(true); }
|
|
319
|
+
const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
320
|
+
let LP = null, LPX = { x: 0, y: 0 };
|
|
321
|
+
const LP_off = () => { if (LP) { clearTimeout(LP.t); LP = null; } };
|
|
322
|
+
|
|
323
|
+
let DRAG = null;
|
|
324
|
+
function dragStart(body, row, e) {
|
|
325
|
+
if (!row || DRAG) return;
|
|
326
|
+
if (!row.isConnected) { const u = row.dataset.ivR; row = u ? body.querySelector(`.iv-tr[data-iv-r="${cssq(u)}"]`) : null; if (!row) return; }
|
|
327
|
+
const wbs = row.closest('.iv-wbs'), list = row.closest('.iv-wl[data-iv-sec]'); if (!wbs || !list) return;
|
|
328
|
+
const r = row.getBoundingClientRect();
|
|
329
|
+
const fly = row.cloneNode(true);
|
|
330
|
+
fly.classList.add('iv-fly'); fly.removeAttribute('data-iv-r'); fly.setAttribute('aria-hidden', 'true'); fly.setAttribute('data-esc-layer', '');
|
|
331
|
+
fly.querySelectorAll('[id]').forEach((n) => n.removeAttribute('id'));
|
|
332
|
+
fly.style.setProperty('--fly-w', r.width + 'px');
|
|
333
|
+
document.body.appendChild(fly);
|
|
334
|
+
const line = document.createElement('div'); line.className = 'iv-dl'; line.hidden = true; wbs.appendChild(line);
|
|
335
|
+
const tip = document.createElement('div'); tip.className = 'iv-dtip'; tip.hidden = true; document.body.appendChild(tip);
|
|
336
|
+
row.classList.add('iv-ghost');
|
|
337
|
+
document.body.classList.add('iv-dragging');
|
|
338
|
+
DRAG = { body, row, wbs, fly, line, tip, uid: row.dataset.ivR, from: list.dataset.ivSec, dx: e.clientX - r.left, dy: e.clientY - r.top, to: null, before: null };
|
|
339
|
+
dragMove(e);
|
|
340
|
+
}
|
|
341
|
+
// a read that lands mid-drag draws the list again: the ghost and the line follow the new rows
|
|
342
|
+
function live(g) {
|
|
343
|
+
if (!g.wbs.isConnected) { const w = g.body.querySelector('.iv-wbs'); if (w) { g.wbs = w; w.appendChild(g.line); } }
|
|
344
|
+
if (!g.row.isConnected) { const r = g.body.querySelector(`.iv-tr[data-iv-r="${cssq(g.uid)}"]`); if (r) { g.row = r; r.classList.add('iv-ghost'); } }
|
|
345
|
+
}
|
|
346
|
+
function dragMove(e) {
|
|
347
|
+
const g = DRAG; if (!g) return;
|
|
348
|
+
live(g);
|
|
349
|
+
g.fly.style.setProperty('--fly-x', (e.clientX - g.dx) + 'px'); g.fly.style.setProperty('--fly-y', (e.clientY - g.dy) + 'px');
|
|
350
|
+
const el = document.elementFromPoint(e.clientX, e.clientY);
|
|
351
|
+
g.wbs.querySelectorAll('.iv-tgt').forEach((n) => n.classList.remove('iv-tgt'));
|
|
352
|
+
g.to = null; g.before = null; g.line.hidden = true; g.tip.hidden = true;
|
|
353
|
+
if (!el || !g.wbs.contains(el)) return;
|
|
354
|
+
const head = el.closest('.iv-ws[data-iv-sec]');
|
|
355
|
+
const row = el.closest('.iv-tr[data-iv-r]');
|
|
356
|
+
const list = (row && row.closest('.iv-wl[data-iv-sec]')) || el.closest('.iv-wl[data-iv-sec]');
|
|
357
|
+
const W = g.wbs.getBoundingClientRect();
|
|
358
|
+
const at = (y, x0) => { g.line.hidden = false; g.line.style.setProperty('--dl-y', (y - W.top + g.wbs.scrollTop) + 'px'); g.line.style.setProperty('--dl-x', (x0 - W.left) + 'px'); };
|
|
359
|
+
if (head && !row) {
|
|
360
|
+
// a stage's header: the task lands last in that stage
|
|
361
|
+
g.to = head.dataset.ivSec; g.before = null;
|
|
362
|
+
head.classList.add('iv-tgt');
|
|
363
|
+
const L = g.wbs.querySelector(`.iv-wl[data-iv-sec="${cssq(g.to)}"]`), rows = L ? [...L.querySelectorAll(':scope > .iv-tr[data-iv-r]')].filter((n) => n !== g.row) : [];
|
|
364
|
+
const last = rows[rows.length - 1], hr = head.getBoundingClientRect();
|
|
365
|
+
at(last ? last.getBoundingClientRect().bottom : hr.bottom, (last || head).getBoundingClientRect().left);
|
|
366
|
+
} else if (list) {
|
|
367
|
+
g.to = list.dataset.ivSec;
|
|
368
|
+
const h = g.wbs.querySelector(`.iv-ws[data-iv-sec="${cssq(g.to)}"]`); if (h) h.classList.add('iv-tgt');
|
|
369
|
+
const rows = [...list.querySelectorAll(':scope > .iv-tr[data-iv-r]')];
|
|
370
|
+
let y = null, x0 = list.getBoundingClientRect().left;
|
|
371
|
+
for (const n of rows) { const b = n.getBoundingClientRect(); if (e.clientY < b.top + b.height / 2) { g.before = n.dataset.ivR; y = b.top; x0 = b.left; break; } }
|
|
372
|
+
if (y == null) { const n = rows[rows.length - 1]; y = n ? n.getBoundingClientRect().bottom : list.getBoundingClientRect().top; if (n) x0 = n.getBoundingClientRect().left; }
|
|
373
|
+
if (g.before === g.uid) g.before = (() => { const i = rows.findIndex((n) => n.dataset.ivR === g.uid); const nx = rows[i + 1]; return nx ? nx.dataset.ivR : null; })();
|
|
374
|
+
at(y, x0);
|
|
375
|
+
}
|
|
376
|
+
if (g.to != null) {
|
|
377
|
+
const id = g.body.querySelector('[data-iv]').dataset.iv;
|
|
378
|
+
const nm = stageName(id, g.to), where = g.before ? 'in ' + nm : 'last in ' + nm;
|
|
379
|
+
g.tip.textContent = 'Drop: ' + where + '. Its dates stay; Undo puts it back';
|
|
380
|
+
g.tip.style.setProperty('--fly-x', (e.clientX + 18) + 'px'); g.tip.style.setProperty('--fly-y', (e.clientY + 14) + 'px');
|
|
381
|
+
g.tip.hidden = false;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function dragStop(cancel) {
|
|
385
|
+
const g = DRAG; DRAG = null; if (!g) return;
|
|
386
|
+
live(g);
|
|
387
|
+
g.fly.remove(); g.line.remove(); g.tip.remove(); g.row.classList.remove('iv-ghost');
|
|
388
|
+
document.body.classList.remove('iv-dragging');
|
|
389
|
+
g.wbs.querySelectorAll('.iv-tgt').forEach((n) => n.classList.remove('iv-tgt'));
|
|
390
|
+
SUPPRESS = Date.now();
|
|
391
|
+
if (cancel || g.to == null) return;
|
|
392
|
+
const H = g.body.__iv || {}, id = g.body.querySelector('[data-iv]').dataset.iv, v = VIEW.get(id);
|
|
393
|
+
const f = rowOf(v, g.uid), dr = f && f.x.dr;
|
|
394
|
+
const ids = openIds(v, g.to).filter((u) => u !== g.uid);
|
|
395
|
+
const i = g.before ? ids.indexOf(g.before) : -1;
|
|
396
|
+
ids.splice(i < 0 ? ids.length : i, 0, g.uid);
|
|
397
|
+
const was = openIds(v, g.from);
|
|
398
|
+
if (g.to === g.from && was.join('\n') === ids.join('\n')) return;
|
|
399
|
+
OPEN.delete(id);
|
|
400
|
+
if (H.move) H.move(g.uid, { to: g.to, from: g.from, ids: dr ? null : ids, name: stageName(id, g.to) });
|
|
401
|
+
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* place, set), POST /api/jira/draft; reads: GET /api/initiative-layout, GET /api/jira/tickets. Every write is the PM's press, file mode. */
|
|
19
19
|
import { pmGet, pmPost } from './http.js';
|
|
20
20
|
import * as VW from './cozy-viewer.js';
|
|
21
|
-
import { groupBy, groupSections, GROUP_BY } from './ini-view-model.js';
|
|
21
|
+
import { groupBy, groupSections, GROUP_BY, linkRows, bodyOf } from './ini-view-model.js';
|
|
22
22
|
import { readLine } from './tk-model.js';
|
|
23
23
|
|
|
24
24
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -75,9 +75,15 @@ export function attach(body, H) {
|
|
|
75
75
|
const byOf = (id) => groupBy(LAY.get(id), TK.get(id));
|
|
76
76
|
|
|
77
77
|
/* ── the view ── */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
/** The tickets the drafted ones put in Jira, with their Jira status: a task whose title names one is linked to it (ini-view-model.js linkRows). */
|
|
79
|
+
const inJiraOf = (id) => { const T = TK.get(id); return T && T.ok === true ? (T.tickets || []).filter((t) => t && t.inJira && t.key).map((t) => ({ key: t.key, status: (t.jira && t.jira.status) || (t.jira && t.jira.category === 'done' ? 'Done' : t.jira && t.jira.category === 'doing' ? 'In progress' : 'To do') })) : []; };
|
|
80
|
+
// a row linked here takes Jira's status, so the section is split into open and done again
|
|
81
|
+
const relink = (S, tk) => S.map((s) => (s.stages ? { ...s, stages: relink(s.stages, tk) }
|
|
82
|
+
: s.top ? { ...s, ...bodyOf(linkRows([...s.top, ...(s.groups || []).flatMap((g) => g.rows), ...(s.done || [])], tk), linkRows(s.archived || [], tk)) } : s));
|
|
83
|
+
export function view(v0) {
|
|
84
|
+
const id = v0 && v0.id;
|
|
85
|
+
if (!idOk(id) || !v0.tasks || v0.tasks.empty) return v0;
|
|
86
|
+
const tk = inJiraOf(id), v = tk.length ? { ...v0, tasks: { ...v0.tasks, sections: relink(v0.tasks.sections || [], tk) } } : v0;
|
|
81
87
|
const by = byOf(id);
|
|
82
88
|
if (by === 'stage') return { ...v, tasks: { ...v.tasks, by } };
|
|
83
89
|
const f = ONLY.get(id), keep = f ? stagesOf(v.tasks.sections || [], f.key) : null;
|
|
@@ -103,7 +109,7 @@ export function headHtml(v) {
|
|
|
103
109
|
* (→ the write's promise), more(anchor) the full menu (Epic, Your groups, the sets, New group) under the view button. */
|
|
104
110
|
export function api(root, H) {
|
|
105
111
|
const id = root && root.dataset.iv;
|
|
106
|
-
return { ok: idOk(id), by: () => byOf(id), label: () => GROUP_BY[byOf(id)] || 'Stage', set: (k) => (byOf(id) === k ? null : lay(id, H, { kind: 'by',
|
|
112
|
+
return { ok: idOk(id), by: () => byOf(id), label: () => GROUP_BY[byOf(id)] || 'Stage', set: (k) => (byOf(id) === k ? null : lay(id, H, { kind: 'by', grouping: k })), more: (a) => groupMenu(a, id, H) };
|
|
107
113
|
}
|
|
108
114
|
export function sumHtml(v) {
|
|
109
115
|
const s = v && v.tasks && v.tasks.gsum; if (!s) return '';
|
|
@@ -192,11 +198,11 @@ function groupMenu(b, id, H) {
|
|
|
192
198
|
const epics = T && T.ok === true ? new Set((T.tickets || []).map((t) => t.epic || '')).size : 0;
|
|
193
199
|
const same = (n) => n.join('|').toLowerCase() === names.join('|').toLowerCase();
|
|
194
200
|
const sets = L.sets || [];
|
|
195
|
-
const newGroup = { label: 'New group', icon: P.plus, keep: true, go: (a) => ask(a, 'Name the group', '', async (v) => { if (await lay(id, H, { kind: 'groups', names: names.concat(v) })) if (by !== 'mine') lay(id, H, { kind: 'by',
|
|
201
|
+
const newGroup = { label: 'New group', icon: P.plus, keep: true, go: (a) => ask(a, 'Name the group', '', async (v) => { if (await lay(id, H, { kind: 'groups', names: names.concat(v) })) if (by !== 'mine') lay(id, H, { kind: 'by', grouping: 'mine' }); }) };
|
|
196
202
|
menu(b, [{ head: 'Group by' }, ...Object.entries(GROUP_BY).map(([k, l]) => ({ label: l, radio: true, on: by === k,
|
|
197
|
-
sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by',
|
|
203
|
+
sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by', grouping: k }) })),
|
|
198
204
|
{ hr: true }, ...(sets.length ? [{ head: 'Your group sets' }] : []),
|
|
199
|
-
...sets.map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : '', go: async () => { if (await lay(id, H, { kind: 'groups', names: s.names })) if (by !== 'mine') lay(id, H, { kind: 'by',
|
|
205
|
+
...sets.map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : '', go: async () => { if (await lay(id, H, { kind: 'groups', names: s.names })) if (by !== 'mine') lay(id, H, { kind: 'by', grouping: 'mine' }); } })),
|
|
200
206
|
...(names.length && !sets.some((s) => same(s.names)) ? [{ label: 'Save these groups as a set', icon: P.plus, go: () => lay(id, H, { kind: 'set', name: names.join(' · '), names }) }] : []),
|
|
201
207
|
newGroup], 'Group tasks by');
|
|
202
208
|
}
|