create-pmos 0.766.0 → 0.768.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.
@@ -210,16 +210,37 @@ function sugLine(s, under) {
210
210
  + `<span class="pw-sugb">${acts}</span></div>`;
211
211
  }
212
212
  function headCells(C, W, mode, kind) {
213
- const mk = M.marksOf(W.span, W.today), td = mk.today;
214
- // the Today pill is always on the line when today is in the window (round 3 point 8); a month mark too close to it gives way
215
- const tl = C.tl ? `<div class="pw-tl pw-tlh" aria-hidden="true">`
216
- + mk.months.filter((m) => m.x > 3 && m.x < 90 && !(td != null && Math.abs(m.x - td) < 7)).map((m) => `<span class="pw-mk" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('')
217
- + (td != null ? `<span class="pw-tday" style="left:clamp(24px, ${td.toFixed(2)}%, calc(100% - 24px))">Today</span>` : '') + '</div>' : '';
213
+ const mk = M.marksOf(W.span, W.today, W.view), td = mk.today, z = W.zoom || 1;
214
+ // the Today pill is always on the line when today is in the window (round 3 point 8); a month mark too close to it gives way. On a track
215
+ // (gantt-scroll) the distances are a window's, so they shrink as the track grows
216
+ const tl = C.tl ? `<div class="pw-tl pw-tlh" aria-hidden="true"><div class="pw-tlin">`
217
+ + mk.months.filter((m) => m.x > 3 / z && m.x < 100 - 10 / z && !(td != null && Math.abs(m.x - td) < 7 / z)).map((m) => `<span class="pw-mk" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('')
218
+ + (td != null ? `<span class="pw-tday" style="left:clamp(24px, ${td.toFixed(2)}%, calc(100% - 24px))">Today</span>` : '') + '</div>'
219
+ + (z > 1.001 ? '<i class="pw-tlbar"></i>' : '') + '</div>' : ''; // the thumb: where the window is on the track, so the scroll is seen
218
220
  return `<div class="pw-tr pw-th" role="row"><span role="columnheader">${kind || 'Item'}</span>${W.jc ? '<span class="pw-jc" role="columnheader">Jira</span>' : ''}${C.status ? '<span role="columnheader">Status</span>' : ''}${C.date ? '<span role="columnheader">Date</span>' : ''}${tl}</div>`;
219
221
  }
220
222
  /* the grip between the item columns and the timeline (round 3 point 1): drag it left or right; the item columns keep about 220 px (the name)
221
223
  * and the timeline about 240 px. Double press or Home: back to the default. The width is remembered on this computer. */
222
- const tlStyle = (gc = '') => { const w = +store.get(TLW, 0), s = (w > 0 ? `--pw-tlw:${Math.round(w)}px;` : '') + (gc ? `--pw-gc:${gc};` : ''); return s ? ` style="${s}"` : ''; };
224
+ const tlStyle = (gc = '', W = null) => { const w = +store.get(TLW, 0), s = (w > 0 ? `--pw-tlw:${Math.round(w)}px;` : '') + (gc ? `--pw-gc:${gc};` : '') + trackStyle(W); return s ? ` style="${s}"` : ''; };
225
+ /* the track (gantt-scroll, Wawan 2026-11-24): a period shorter than the work scrolls sideways along the whole track, while Item, Status and
226
+ * Date stay put. --pw-z is the track's width in timeline widths; --pw-sx how far it has scrolled, in timeline widths (0 to z - 1). It opens
227
+ * on the period's window, which holds today; where the PM scrolled to is kept until the period changes. */
228
+ const SX = new Map();
229
+ const sxKey = (W) => (W ? [W.title || '', W.view ? W.view.a : '', W.span ? W.span.a + W.span.b : ''].join('|') : '');
230
+ const trackStyle = (W) => {
231
+ const z = W && W.zoom > 1.001 ? W.zoom : 1; if (z === 1) return '';
232
+ const k = sxKey(W), sx = SX.has(k) ? SX.get(k) : ((W.at || 0) / 100) * z;
233
+ return `--pw-z:${z.toFixed(4)};--pw-sx:${Math.max(0, Math.min(z - 1, sx)).toFixed(4)};`;
234
+ };
235
+ const trackAttr = (W) => (W && W.zoom > 1.001 ? ` data-pw-track="${esc(sxKey(W))}"` : '');
236
+ /** Scroll a card's track by dx timeline widths; it stops at either end. */
237
+ function scrollTrack(card, dx) {
238
+ const z = parseFloat(card.style.getPropertyValue('--pw-z')) || 1; if (z <= 1) return false;
239
+ const now = parseFloat(card.style.getPropertyValue('--pw-sx')) || 0, sx = Math.max(0, Math.min(z - 1, now + dx));
240
+ if (Math.abs(sx - now) < 1e-4) return false;
241
+ card.style.setProperty('--pw-sx', sx.toFixed(4)); SX.set(card.dataset.pwTrack || '', sx);
242
+ return true;
243
+ }
223
244
  /* the Gantt's Jira column (WorkJiraDS, work-subtasks-followups): the grid's columns when it shows, Item · Jira · Status · Date · Timeline */
224
245
  const gridOf = (C) => [C.tl ? 'minmax(220px, 1fr)' : 'minmax(0, 1fr)', 'minmax(0, 132px)', C.status ? (C.tl ? 'minmax(0, 112px)' : '110px') : '', C.date ? (C.tl ? 'minmax(0, 168px)' : '160px') : '', C.tl ? 'var(--pw-tl)' : ''].filter(Boolean).join(' ');
225
246
  const gripHtml = () => `<div class="pw-tlgrip" role="separator" aria-orientation="vertical" tabindex="0" data-pw-grip aria-label="Drag to make the timeline wider or narrower. Double press to reset." title="Drag to make the timeline wider or narrower. Double press to reset."><i></i></div>`;
@@ -235,6 +256,25 @@ function wireGrip(root) {
235
256
  const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('pw-drag'); if (w) store.set(TLW, w); };
236
257
  g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
237
258
  });
259
+ // the track (gantt-scroll): a sideways trackpad swipe, or Shift and the wheel, over the timeline scrolls it; a press on its empty part and a
260
+ // drag pans it (a bar keeps its own drag, which moves the dates)
261
+ root.addEventListener('wheel', (e) => {
262
+ const tl = e.target.closest && e.target.closest('.pw-wbs[data-pw-track] .pw-tl'); if (!tl) return;
263
+ const dx = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.shiftKey ? e.deltaY : 0; if (!dx) return;
264
+ const card = tl.closest('.pw-wbs'), px = e.deltaMode === 1 ? dx * 16 : e.deltaMode === 2 ? dx * tl.clientWidth : dx;
265
+ if (scrollTrack(card, px / Math.max(1, tl.clientWidth)) || Math.abs(e.deltaX) > Math.abs(e.deltaY)) e.preventDefault();
266
+ }, { passive: false });
267
+ root.addEventListener('pointerdown', (e) => {
268
+ if (e.button !== 0) return;
269
+ const tl = e.target.closest && e.target.closest('.pw-wbs[data-pw-track] .pw-tl'); if (!tl) return;
270
+ if (e.target.closest('button, a, input, [data-cb-ms], .iva-tb, .pw-pbar, .iva-md, .iva-b, .cb-md')) return;
271
+ const card = tl.closest('.pw-wbs'), w = Math.max(1, tl.clientWidth);
272
+ let x0 = e.clientX, moved = false;
273
+ try { tl.setPointerCapture(e.pointerId); } catch { /* fine */ }
274
+ const mv = (ev) => { const d = ev.clientX - x0; if (!moved && Math.abs(d) < 4) return; if (!moved) { moved = true; card.classList.add('pw-pan'); } x0 = ev.clientX; scrollTrack(card, -d / w); };
275
+ const up = () => { tl.removeEventListener('pointermove', mv); tl.removeEventListener('pointerup', up); tl.removeEventListener('pointercancel', up); card.classList.remove('pw-pan'); if (moved) root.__pwQuiet = Date.now(); };
276
+ tl.addEventListener('pointermove', mv); tl.addEventListener('pointerup', up); tl.addEventListener('pointercancel', up);
277
+ });
238
278
  root.addEventListener('dblclick', (e) => { const g = e.target.closest('[data-pw-grip]'); if (!g) return; store.set(TLW, 0); const c = g.closest('.pw-wbs'); if (c) c.style.removeProperty('--pw-tlw'); });
239
279
  root.addEventListener('keydown', (e) => {
240
280
  const g = e.target.closest && e.target.closest('[data-pw-grip]'); if (!g) return;
@@ -266,7 +306,7 @@ function rowHtml(x, W, C, sugRows) {
266
306
  // what the row lets the PM change, the same for every Jira row (jira-row-edit): a published copy changes nothing and shows no ✦
267
307
  const E = WT.editOf(x, RO);
268
308
  if (RO) sugRows = new Map();
269
- const tl = C.tl ? `<div class="pw-tl">${(x.kind === 'stage' || x.kind === 'task') ? barHtml(x, W) : ''}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
309
+ const tl = C.tl ? `<div class="pw-tl"><div class="pw-tlin">${(x.kind === 'stage' || x.kind === 'task') ? barHtml(x, W) : ''}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div></div>` : '';
270
310
  // the status: a PMOS task's opens its list; a Jira ticket's moves it in Jira, and says "Moving in Jira" until Jira answers
271
311
  const jst = E.status === 'jira' ? `<button type="button" class="pw-cell" data-pw-jstat="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('Status in Jira: ' + (x.jst || x.status) + '. Move it in Jira')}" title="Status, moved in Jira">${esc(x.status)}${x.jmv ? ' <small class="pw-jmv">Moving in Jira</small>' : ''}</button>` : '';
272
312
  const stc = C.status ? `<span class="pw-st">${jst || (E.status === 'pmos' ? `<button type="button" class="pw-cell" data-pw-status="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('Status: ' + x.status + '. Change it')}">${esc(x.status)}</button>` : esc(x.status || ''))}</span>` : '';
@@ -284,7 +324,7 @@ function rowHtml(x, W, C, sugRows) {
284
324
  // subtasks (WorkSubtasksDS): indent one step per level, a parent's fold and count; a Jira row's key chip and the epic check's dot (WorkJiraDS)
285
325
  const chev = x.kids ? `<button type="button" class="pw-chev" data-pw-sub="${esc(x.uid)}" aria-expanded="${!!x.open}" aria-label="${esc((x.open ? 'Fold ' : 'Open ') + x.title)}">${SVG(x.open ? P.down : P.right, 13)}</button>` : '';
286
326
  const more2 = (x.kids ? `<small class="pw-cnt">${esc(x.count)}</small>` : '') + (W.jc ? '' : chip(x));
287
- return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}${x.kids ? ' par' : ''}${RSEL.has(String(x.uid)) ? ' sel' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"${x.depth ? ` style="--pw-d:${x.depth}"` : ''}><span class="pw-it">${chev}<i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${more2}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${jc}${stc}${dtc}${tl}</div>`
327
+ return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}${x.kids ? ' par' : ''}${RSEL.has(String(x.uid)) ? ' sel' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"${x.depth ? ` style="--pw-d:${x.depth}"` : ''}><span class="pw-it"${!x.jsub && canDrag() ? ' draggable="true"' : ''}>${chev}<i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${more2}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${jc}${stc}${dtc}${tl}</div>`
288
328
  + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
289
329
  }
290
330
  function breakdownHtml(W, C, mode, full, S) {
@@ -306,7 +346,7 @@ function breakdownHtml(W, C, mode, full, S) {
306
346
  // the tasks in no stage are not in the breakdown (Wawan, 2026-11-19): they live in Work › Backlog; one quiet line says so and goes there
307
347
  const loose = W.looseN && !RO ? `<p class="pw-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(W.looseN === 1 ? '1 task with no stage is in the Backlog' : W.looseN + ' tasks with no stage are in the Backlog')}${SVG(P.right, 13)}</button></p>` : '';
308
348
  return `<section class="pw-sec" aria-label="Work breakdown">${full ? `<div class="pw-sech">${tools}</div>` : `<div class="pw-sech"><h3>Work breakdown</h3>${show}${tools}</div>`}`
309
- + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}${W.jc ? ' jc' : ''}" role="table" aria-label="Work breakdown"${tlStyle(W.jc ? gridOf(C) : '')}>${C.tl ? gripHtml() : ''}${headCells(C, W, mode)}${out || '<div class="pw-tr pw-empty" role="row"><span>No task yet.</span></div>'}</div>`
349
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}${W.jc ? ' jc' : ''}" role="table" aria-label="Work breakdown"${tlStyle(W.jc ? gridOf(C) : '', C.tl ? W : null)}${C.tl ? trackAttr(W) : ''}>${C.tl ? gripHtml() : ''}${headCells(C, W, mode)}${out || '<div class="pw-tr pw-empty" role="row"><span>No task yet.</span></div>'}</div>`
310
350
  + (C.tl ? '<p class="pw-key"><span><i class="k-tb pr"></i>In progress</span><span><i class="k-tb"></i>To do</span><span><i class="k-tb dn"></i>Done</span><span><i class="k-md"></i>Milestone</span><span><i class="k-late"></i>Late</span><span><i class="k-gap"></i>No activity</span></p>' : '') + loose + '</section>';
311
351
  }
312
352
  /* the Artefacts (round 3 point 16): one row per Kind, in lifecycle order. Kind | Artefact (the current one) | Version | Updated. Versions and the
@@ -355,7 +395,7 @@ function model(r, v0, o) {
355
395
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
356
396
  const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
357
397
  if (pd && W.overview) for (const L of W.overview.lines || []) if (pd.lines[L.id] != null) { L.text = pd.lines[L.id]; delete L.ask; delete L.miss; }
358
- const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
398
+ const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
359
399
  W.epics = (r.epics || []).filter(Boolean); RSEL = S.sel; // the epic check and the picked rows, for the Gantt rows (initiative work-subtasks)
360
400
  // the Gantt's Jira column (work-subtasks-followups): on unless Choose columns hides it, and only when the work has a Jira row
361
401
  W.jc = !!cols().jira && W.rows.some((x) => x.kind === 'task' && WT.keyOf(x));
@@ -984,17 +1024,30 @@ function parentMenu(btn, ids, c, h, x) {
984
1024
  const kids = new Map(); for (const r of all) if (r.up) { if (!kids.has(r.up)) kids.set(r.up, []); kids.get(r.up).push(r.uid); }
985
1025
  const walk = (u) => { for (const k of kids.get(u) || []) { under.add(k); walk(k); } };
986
1026
  for (const u of ids) walk(u);
987
- const L = all.filter((r) => !pick.has(r.uid) && !under.has(r.uid)).slice(0, 60);
1027
+ // the keyboard way beside the drag (Wawan 2026-11-24: "Bad UI to move as subtask"): the picked task's own stage first, a box to find one
1028
+ const sec0 = String((all.find((r) => r.uid === ids[0]) || {}).sec || '');
1029
+ const C0 = all.filter((r) => !pick.has(r.uid) && !under.has(r.uid));
1030
+ const L = C0.filter((r) => String(r.sec || '') === sec0).concat(C0.filter((r) => String(r.sec || '') !== sec0)).slice(0, 200);
988
1031
  const n = ids.length;
989
1032
  openPop(btn, 'pw-under', `<p class="hi-small">${esc('Move ' + (n === 1 ? 'it' : n + ' tasks') + ' under')}</p>`
1033
+ + (L.length > 8 ? `<input class="pm-input" data-pw-under-q type="search" placeholder="Find a task" aria-label="Find the parent task" autocomplete="off">` : '')
990
1034
  + `<button type="button" class="hi-mi" role="menuitem" data-new>${SVG(P.plus, 14)} A new parent…</button>`
991
- + L.map((r, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}" style="padding-left:${10 + Math.min(r.depth || 0, 3) * 14}px">${esc(r.title)}${r.kids ? ` <span class="hi-small">${esc(String(r.kids))}</span>` : ''}</button>`).join('')
1035
+ + L.map((r, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}" data-q="${esc(String(r.title || '').toLowerCase())}" style="padding-left:${10 + Math.min(r.depth || 0, 3) * 14}px${i >= 12 ? ';display:none' : ''}">${esc(r.title)}${r.kids ? ` <span class="hi-small">${esc(String(r.kids))}</span>` : ''}</button>`).join('')
992
1036
  + `<button type="button" class="hi-mi" role="menuitem" data-top>Top level (no parent)</button>`, async (b) => {
993
1037
  if ('new' in b.dataset) { newParent(btn, ids, all, c, h, x); return; }
994
1038
  closePop();
995
1039
  if ('top' in b.dataset) { await runBulk(ids, 'parent', '', c, h, x, 'the top level'); return; }
996
1040
  const r = L[+b.dataset.i]; if (r) await runBulk(ids, 'parent', r.uid, c, h, x, r.title);
997
1041
  }, { menu: true, label: 'Under a parent' });
1042
+ // typing narrows the list; with nothing typed it shows the first 12 (the picked task's stage first)
1043
+ const q = document.querySelector('[data-pw-under-q]');
1044
+ if (q) {
1045
+ q.addEventListener('input', () => {
1046
+ const t = q.value.trim().toLowerCase(); let shown = 0;
1047
+ for (const b of q.parentElement.querySelectorAll('[data-q]')) { const on = t ? b.dataset.q.includes(t) : shown < 12; b.style.display = on ? '' : 'none'; if (on) shown++; }
1048
+ });
1049
+ setTimeout(() => q.focus(), 0);
1050
+ }
998
1051
  }
999
1052
  /** A new parent: its name, then it is made in the stage of the first picked task and the picked tasks move under it. */
1000
1053
  function newParent(btn, ids, all, c, h, x) {
@@ -1126,25 +1179,27 @@ function wireMoves(body, cur, redraw) {
1126
1179
  const say = (h) => (m, u) => (u ? undoToast(m, u) : h.toast ? h.toast(m) : undoToast(m));
1127
1180
  const allOf = (c) => stagesOf(c.r, c.v, { ...((body.__pwx && body.__pwx.o()) || {}), today: c.W.today, subAll: true });
1128
1181
  const reload = (h) => async () => { if (h.reload) await h.reload(); else if (h.redraw) h.redraw(); };
1129
- // the List: HTML drag and drop (a mouse); onto a row nests, its top or bottom edge is between rows, a stage head is the stage, left is out
1182
+ // the List and the Gantt (Wawan 2026-11-24: "should be able to do it on gantt view"): HTML drag and drop (a mouse); onto a row nests,
1183
+ // its top or bottom edge puts it before or after that row (its parent, its stage and its place in the stage), a stage head is the stage, left is out
1130
1184
  let DR = null;
1131
1185
  const marks = () => body.querySelectorAll('.drop-on, .drop-before, .drop-after, .drop-left, .dragging').forEach((el) => el.classList.remove('drop-on', 'drop-before', 'drop-after', 'drop-left', 'dragging'));
1132
1186
  const zoneOf = (e) => {
1133
1187
  // a stage head (its fold press carries the stage key, its name is the bold text)
1134
- const sh = e.target.closest && e.target.closest('.pwd-gh[data-pw-fold]');
1135
- if (sh) return { el: sh, cls: 'drop-on', to: { zone: 'stage', key: sh.dataset.pwFold, name: (sh.querySelector('b') || {}).textContent || '' } };
1136
- const rw = e.target.closest && e.target.closest('.pwd-li[data-pw-row]'); if (!rw) return null;
1188
+ const sh = e.target.closest && (e.target.closest('.pwd-gh[data-pw-fold]') || e.target.closest('.pw-sr:not(.loose)'));
1189
+ const sk = sh && (sh.dataset.pwFold != null ? sh : sh.querySelector('[data-pw-fold]'));
1190
+ if (sk) return { el: sh, cls: 'drop-on', to: { zone: 'stage', key: sk.dataset.pwFold, name: (sk.querySelector('b') || {}).textContent || '' } };
1191
+ const rw = e.target.closest && e.target.closest('.pwd-li[data-pw-row], .pw-kr[data-pw-row]'); if (!rw) return null;
1137
1192
  const u = rw.dataset.pwRow;
1138
1193
  if (DR.ids.includes(u)) return e.clientX - DR.x0 < -32 ? { el: rw, cls: 'drop-left', to: { zone: 'left' } } : null;
1139
1194
  const r = rw.getBoundingClientRect(), y = (e.clientY - r.top) / Math.max(1, r.height);
1140
- return y < 0.25 ? { el: rw, cls: 'drop-before', to: { zone: 'between', uid: u } } : y > 0.75 ? { el: rw, cls: 'drop-after', to: { zone: 'between', uid: u } } : { el: rw, cls: 'drop-on', to: { zone: 'on', uid: u } };
1195
+ return y < 0.25 ? { el: rw, cls: 'drop-before', to: { zone: 'between', uid: u, edge: 'before' } } : y > 0.75 ? { el: rw, cls: 'drop-after', to: { zone: 'between', uid: u, edge: 'after' } } : { el: rw, cls: 'drop-on', to: { zone: 'on', uid: u } };
1141
1196
  };
1142
1197
  body.addEventListener('dragstart', (e) => {
1143
- const rw = e.target.closest && e.target.closest('.pwd-li[draggable="true"]'); if (!rw) return;
1144
- const c = cur(); if (!c) return;
1198
+ const dg = e.target.closest && e.target.closest('.pwd-li[draggable="true"], .pw-kr .pw-it[draggable="true"]'); if (!dg) return;
1199
+ const rw = dg.closest('[data-pw-row]'), c = cur(); if (!rw || !c) return;
1145
1200
  DR = { ids: SEL.dragIds(c.S.sel, rw.dataset.pwRow), x0: e.clientX };
1146
1201
  try { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', DR.ids.join(',')); } catch { /* an old browser */ }
1147
- for (const u of DR.ids) { const el = body.querySelector(`.pwd-li[data-pw-row="${window.CSS.escape(u)}"]`); if (el) el.classList.add('dragging'); }
1202
+ for (const u of DR.ids) for (const el of body.querySelectorAll(`.pwd-li[data-pw-row="${window.CSS.escape(u)}"], .pw-kr[data-pw-row="${window.CSS.escape(u)}"]`)) el.classList.add('dragging');
1148
1203
  });
1149
1204
  body.addEventListener('dragover', (e) => {
1150
1205
  if (!DR) return; const z = zoneOf(e);
@@ -1161,7 +1216,7 @@ function wireMoves(body, cur, redraw) {
1161
1216
  if (z.to.zone === 'on') { c.S.subOpen.add(z.to.uid); c.S.subShut.delete(z.to.uid); }
1162
1217
  c.S.sel.clear(); c.S.anchor = '';
1163
1218
  moveLog('drag-' + z.to.zone, ids.length);
1164
- await SEL.bulkSteps(pmPost, { ws: at.ws, board: at.board }, plan.steps, { say: say(h), reload: reload(h) }, plan.label);
1219
+ await SEL.bulkSteps(pmPost, { ws: at.ws, board: at.board, ini: at.ini || c.id }, plan.steps, { say: say(h), reload: reload(h) }, plan.label, plan.order);
1165
1220
  });
1166
1221
  // press and hold (a touch screen): the row is picked; after that a tap adds or takes out one row (the click handler's pick)
1167
1222
  let HOLD = null;
@@ -1188,7 +1243,7 @@ function wireMoves(body, cur, redraw) {
1188
1243
  body.addEventListener('pointerdown', (e) => {
1189
1244
  if (e.pointerType !== 'mouse' || e.button !== 0) return;
1190
1245
  const bar = e.target.closest && e.target.closest('.pw-kr .pw-tl .iva-tb, .pw-kr .pw-tl .pw-pbar'); if (!bar) return;
1191
- const rw = bar.closest('[data-pw-row]'), tl = bar.closest('.pw-tl'), c = cur(); if (!rw || !tl || !c) return;
1246
+ const rw = bar.closest('[data-pw-row]'), tl = bar.closest('.pw-tlin') || bar.closest('.pw-tl'), c = cur(); if (!rw || !tl || !c) return;
1192
1247
  const all = allOf(c), ids = SEL.shiftIds(c.S.sel, rw.dataset.pwRow, all);
1193
1248
  const span = (Date.parse(c.W.span.b) - Date.parse(c.W.span.a)) / 864e5, w = tl.getBoundingClientRect().width, x0 = e.clientX;
1194
1249
  const els = [...new Set(ids.concat(String(rw.dataset.pwRow)))].map((u) => body.querySelector(`.pw-kr[data-pw-row="${window.CSS.escape(u)}"] .pw-tl`)).filter(Boolean)
@@ -1413,7 +1468,7 @@ function artItems(body) {
1413
1468
  /* ── one level up: a program or a product (boards 26, 27) ── */
1414
1469
  export function levelHtml(L, o = {}) {
1415
1470
  const W = M.levelOf(L, { today: o.today, mode: store.get(SPAN, 'full') }), C = cols(), mode = store.get(SPAN, 'full');
1416
- const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
1471
+ const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
1417
1472
  const sug = !RO && W.suggests.length ? `<div class="pw-sugs" role="list" aria-label="PMOS suggests"><p class="pw-sugh">PMOS suggests</p>${W.suggests.map((s) => sugLine(s)).join('')}</div>` : '';
1418
1473
  // the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; then the status line and Details ›
1419
1474
  const lk = 'level:' + W.kind + ':' + (W.title || ''), S = stOf(lk), open = !!S.details;
@@ -1424,12 +1479,12 @@ export function levelHtml(L, o = {}) {
1424
1479
  const ov = `<section class="pw-ov" aria-label="Overview"><div class="pw-ovh"><h3>Overview</h3>${mark}${det}</div>${ovLines(W.overview, lk, false)}${W.overview.status ? `<p class="pw-ostat">${esc(W.overview.status)}</p>` : ''}${sug}${facts}</section>`;
1425
1480
  const head = o.rowsTitle || (W.kind === 'product' ? 'Programs and initiatives' : 'Initiatives');
1426
1481
  const rows = W.rows.map((x) => {
1427
- const tl = C.tl ? `<div class="pw-tl">${barHtml({ ...x, kind: 'stage', tone: x.done ? 'dn' : '' }, W)}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
1482
+ const tl = C.tl ? `<div class="pw-tl"><div class="pw-tlin">${barHtml({ ...x, kind: 'stage', tone: x.done ? 'dn' : '' }, W)}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div></div>` : '';
1428
1483
  const lead = x.group ? `<b class="pw-grp">${esc(x.title)}</b>` : `<button type="button" class="pw-stg lv${x.sub ? ' sub' : ''}" data-pw-go="${esc(x.kind + ':' + x.id)}"><b>${esc(x.title)}</b>${SVG(P.right, 14)}${x.count ? `<small>${esc(x.count)}</small>` : ''}</button>`;
1429
1484
  return `<div class="pw-tr pw-sr" role="row"><span class="pw-it">${lead}</span>${C.status ? `<span class="pw-st">${esc(x.stage || '')}</span>` : ''}${C.date ? `<span class="pw-dt${x.late ? ' warn' : ''}">${esc(x.date || '')}</span>` : ''}${tl}</div>`;
1430
1485
  }).join('');
1431
1486
  const wbs = `<section class="pw-sec" aria-label="${esc(head)}"><div class="pw-sech"><h3>${esc(head)}</h3>${!C.tl && !RO ? ib('data-pw-tl', 'Show the timeline', P.show, 'xs') : ''}<span class="pw-tools">${C.tl ? `<button type="button" class="pw-span" data-pw-span aria-haspopup="menu">${esc((M.MODES.find((m) => m[0] === mode) || M.MODES[5])[1])}${SVG(P.down, 12)}</button>` : ''}${RO ? '' : ib('data-pw-tune="wbs" aria-haspopup="menu"', 'Show or hide columns', P.tune)}</span></div>`
1432
- + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table"${tlStyle()}>${C.tl ? gripHtml() : ''}${headCells(C, W, mode, W.kind === 'product' ? 'Program or initiative' : 'Initiative').replace('<span role="columnheader">Status</span>', '<span role="columnheader">Stage</span>')}${rows || '<div class="pw-tr pw-empty" role="row"><span>Nothing one level down yet.</span></div>'}</div></section>`;
1487
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table"${tlStyle('', C.tl ? W : null)}${C.tl ? trackAttr(W) : ''}>${C.tl ? gripHtml() : ''}${headCells(C, W, mode, W.kind === 'product' ? 'Program or initiative' : 'Initiative').replace('<span role="columnheader">Status</span>', '<span role="columnheader">Stage</span>')}${rows || '<div class="pw-tr pw-empty" role="row"><span>Nothing one level down yet.</span></div>'}</div></section>`;
1433
1488
  return `<div class="pw" data-pw-level>${ov}${wbs}${W.artefacts.length || o.add !== false ? artefactsHtml(W.artefacts, C, o.add !== false, { scope: lk }) : ''}</div>`;
1434
1489
  }
1435
1490
  export function wireLevel(body, h0, L0) {
@@ -10,6 +10,7 @@
10
10
  * goal (the goal's name, else the anchor), mode ('full' | 'quarter' | 'half' | 'year' | '2y' | '5y': the timeline's span), open (Set of
11
11
  * stage keys the PM unfolded), shut (Set of stage keys the PM folded), openAll (the List: every stage with tasks opens by itself), farOpen (bool) }
12
12
  * levelOf(L, o) → the same parts one level up: a program or a product (boards 26, 27). L: { kind, title, path, summary, facts, rows, docs, props }
13
+ * trackOf(dates, mode, today) → { span, view, zoom, at } the track the timeline scrolls along; view is the window that shows on open
13
14
  * spanOf(dates, mode, today) → { a, b } ISO the window of the timeline: Full runs from the earliest start to the latest end (no bar is cut)
14
15
  * barOf(x, span, today) → { l, w, pass, late, ms, dot } in % of the window one bar: the plan, the part that has passed, the missed date
15
16
  * dayText(iso, today) → "4 Nov", "13 Jan 2027" dateLate(iso, today) → "4 Nov · 14 days late" | "4 Nov"
@@ -75,6 +76,23 @@ export function spanOf(dates, mode, today) {
75
76
  const months = { quarter: 3, half: 6, year: 12, '2y': 24, '5y': 60 }[mode] || 12;
76
77
  return { a: iso(start), b: iso(new Date(start.getFullYear(), start.getMonth() + months, 0)) };
77
78
  }
79
+ /** The track a period scrolls along (gantt-scroll, Wawan 2026-11-24: "I should be able to scroll gantt here"): the period's window is what
80
+ * shows when the page opens (it holds today), and the track runs on, month by month, to the earliest and the latest date, so no bar is cut
81
+ * and the rest is a sideways scroll away. Full is its own window: nothing to scroll. The track stops 5 years either side of the window.
82
+ * → { span (the whole track), view (the window), zoom (track width / window width, ≥ 1), at (where the window starts, % of the track) } */
83
+ export function trackOf(dates, mode, today) {
84
+ const view = spanOf(dates, mode, today);
85
+ if (!mode || mode === 'full') return { span: view, view, zoom: 1, at: 0 };
86
+ const va = day(view.a), vb = day(view.b);
87
+ const lo = new Date(va.getFullYear() - 5, va.getMonth(), 1), hi = new Date(vb.getFullYear() + 5, vb.getMonth() + 1, 0);
88
+ let a = va, b = vb;
89
+ for (const d of (dates || []).map(day).filter(Boolean)) {
90
+ if (d < a) a = new Date(Math.max(lo, new Date(d.getFullYear(), d.getMonth(), 1)));
91
+ if (d > b) b = new Date(Math.min(hi, new Date(d.getFullYear(), d.getMonth() + 1, 0)));
92
+ }
93
+ const span = { a: iso(a), b: iso(b) };
94
+ return { span, view, zoom: Math.max(1, (b - a) / Math.max(DAY, vb - va)), at: Math.max(0, pct(va, span)) };
95
+ }
78
96
  const pct = (d, S) => { const a = day(S.a), b = day(S.b); return ((d - a) / Math.max(DAY, b - a)) * 100; };
79
97
  const clamp = (n) => Math.max(0, Math.min(100, n));
80
98
  /** One bar in the window. x: { start, end, done, open }. A row with neither date has no bar (null). */
@@ -92,9 +110,11 @@ export function barOf(x, S, today) {
92
110
  late: missed ? { l: clamp(pct(b0, S)), w: Math.max(0.3, tx - clamp(pct(b0, S))) } : null, ms: missed ? clamp(pct(b0, S)) : null };
93
111
  }
94
112
  /** The month marks on the header: the first of each month that fits, thinned to about six. */
95
- export function marksOf(S, today) {
113
+ export function marksOf(S, today, view) {
96
114
  const a = day(S.a), b = day(S.b), t = today instanceof Date ? today : day(today) || new Date(), out = [];
97
- const n = (b.getFullYear() - a.getFullYear()) * 12 + b.getMonth() - a.getMonth();
115
+ // on a track (trackOf) the marks are as close as the window that shows needs, not as the whole track would
116
+ const va = view ? day(view.a) : a, vb = view ? day(view.b) : b;
117
+ const n = (vb.getFullYear() - va.getFullYear()) * 12 + vb.getMonth() - va.getMonth();
98
118
  const step = n <= 6 ? 1 : n <= 14 ? 3 : n <= 30 ? 6 : 12;
99
119
  for (let d = new Date(a.getFullYear(), a.getMonth() + 1, 1); d < b; d = new Date(d.getFullYear(), d.getMonth() + 1, 1)) {
100
120
  if (d.getMonth() % step) continue;
@@ -531,8 +551,8 @@ export function workOf(r, v, o = {}) {
531
551
  const all = sug.top.concat(dv.top), rowS = new Map(sug.rows);
532
552
  for (const [k, s] of dv.rows) if (!rowS.has(k)) rowS.set(k, s);
533
553
  const dates = [r.start, r.end].concat(bd.rows.flatMap((x) => [x.start, x.end])).filter(Boolean);
534
- const span = spanOf(dates, o.mode || 'full', t);
535
- return { title: v.title || r.title || '', summary: sum, overview: overviewOf(r, v, o), suggests: all.slice(0, MAX_SUGGEST), more: sug.more + Math.max(0, all.length - MAX_SUGGEST), rowSuggests: rowS, facts: factsOf(r, v, o),
554
+ const tk = trackOf(dates, o.mode || 'full', t), span = tk.span;
555
+ return { view: tk.view, zoom: tk.zoom, at: tk.at, title: v.title || r.title || '', summary: sum, overview: overviewOf(r, v, o), suggests: all.slice(0, MAX_SUGGEST), more: sug.more + Math.max(0, all.length - MAX_SUGGEST), rowSuggests: rowS, facts: factsOf(r, v, o),
536
556
  rows: bd.rows, many: bd.many, looseN: bd.looseN || 0, span, today: iso(t), artefacts: arts };
537
557
  }
538
558
 
@@ -545,7 +565,7 @@ export function levelOf(L, o = {}) {
545
565
  const dl = x.end ? dateLate(x.end, t, !x.done) : { text: '', late: false };
546
566
  return { ...x, date: dl.text, late: dl.late };
547
567
  });
548
- const span = spanOf(rows.flatMap((x) => [x.start, x.end]).filter(Boolean), o.mode || 'full', t);
568
+ const tk = trackOf(rows.flatMap((x) => [x.start, x.end]).filter(Boolean), o.mode || 'full', t), span = tk.span;
549
569
  const late = rows.filter((x) => x.late).length;
550
570
  // the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; a line with no source offers a draft.
551
571
  // A program reads its charter's why and goal, and Done when from its last milestone and target (initiative chat-saves-to-cards). A draft is
@@ -556,6 +576,6 @@ export function levelOf(L, o = {}) {
556
576
  ask: 'Draft ' + what + ' for the ' + nm + ' ' + who + ', in two short sentences, for me to read. Say what you read. Do not invent anything the records do not say.' + save(f) } : {}) });
557
577
  const sum = L.why ? firstSentences(L.why, 2) : L.summary && !importNote(L.summary) ? firstSentences(L.summary, 2) : '';
558
578
  const overview = { lines: [line('for', 'For', sum, 'what the ' + nm + ' is for', 'why'), line('goal', 'Goal', L.goal || '', 'the goal of the ' + nm, 'goal'), line('done', 'Done when', L.done || '', 'how we will know the ' + nm + ' worked', '')], status: L.status || '' };
559
- return { kind: L.kind, title: L.title, summary: L.summary || '', overview, facts: L.facts || [], rows, span, today: iso(t), late, artefacts: (L.docs || []).map((d) => ({ ...d, when: whenOf(d.when, t) })),
579
+ return { view: tk.view, zoom: tk.zoom, at: tk.at, kind: L.kind, title: L.title, summary: L.summary || '', overview, facts: L.facts || [], rows, span, today: iso(t), late, artefacts: (L.docs || []).map((d) => ({ ...d, when: whenOf(d.when, t) })),
560
580
  suggests: suggestsOf({ props: L.props || null }).top };
561
581
  }
@@ -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
- return steps.length ? { steps, label } : null;
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
+ }