create-pmos 0.833.0 → 0.834.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.
@@ -197,3 +197,64 @@ export function allJira(rows, uids) {
197
197
  const L = [...(uids || [])];
198
198
  return L.length > 0 && L.every((u) => { const x = by.get(String(u)); return !!(x && keyOf(x) && !x.jsub); });
199
199
  }
200
+
201
+ /* Drag a bar on the Gantt to change its dates (initiative timeline-bar-drag, board TbInitTimeline). Pure, like the rest of this file;
202
+ * pm/work-drag.js draws the grips and wires the pointer and the keys.
203
+ * canDrag(row, ro) → true when PMOS may change this bar's dates: a task (not a stage, not a Jira sub-task PMOS only read) with a
204
+ * date, outside a read-only copy
205
+ * dragKind(x, left, width, grip) → 'start' | 'due' | 'move' where a press at x lands on a bar from left to left + width; a grip is the
206
+ * outer `grip` px of each end (8), or a third of a bar too short for both
207
+ * dragPatch(row, kind, days) → { start?, due? } | null the dates after a drag of whole days; an end stops at the other end; a milestone
208
+ * has one date, written as due; 0 days is null (nothing to write)
209
+ * dragTip(row, kind, days) → "9 Nov to 18 Nov" the new dates in words, shown while dragging
210
+ * keyStep(key, mods) → { kind, days } | null ← → move the task a day; Shift moves the due day, Alt the start
211
+ * dragStarts(dx, dy, pointer) → true once a press has moved far enough sideways to be a drag (mouse 3 px, pen and touch 6 px) */
212
+ const DAY_MS = 864e5;
213
+ const isoDay = (v) => (v ? String(v).slice(0, 10) : '');
214
+ const dayNum = (v) => { const t = Date.parse(isoDay(v)); return Number.isFinite(t) ? Math.round(t / DAY_MS) : null; };
215
+ const dayIso = (n) => new Date(n * DAY_MS).toISOString().slice(0, 10);
216
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
217
+ const dayWords = (n) => { const d = new Date(n * DAY_MS); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
218
+
219
+ export function canDrag(row, ro = false) {
220
+ if (ro || !row || row.kind !== 'task' || row.kids || row.jsub) return false;
221
+ if (!editOf(row, ro).dates) return false;
222
+ return dayNum(row.start) != null || dayNum(row.end) != null;
223
+ }
224
+ export function dragKind(x, left, width, grip = 8) {
225
+ const w = Math.max(0, Number(width) || 0), at = (Number(x) || 0) - (Number(left) || 0), g = Math.min(grip, w / 3);
226
+ if (at <= g) return 'start';
227
+ if (at >= w - g) return 'due';
228
+ return 'move';
229
+ }
230
+ function span(row) {
231
+ const a = dayNum(row.start), b = dayNum(row.end);
232
+ return { a: a == null ? b : a, b: b == null ? a : Math.max(a, b), hasA: a != null, hasB: b != null };
233
+ }
234
+ export function dragPatch(row, kind, days) {
235
+ const n = Math.round(Number(days) || 0); if (!row || !n) return null;
236
+ const s = span(row); if (s.a == null) return null;
237
+ if (row.ms) return { due: dayIso(s.b + n) };
238
+ if (kind === 'start') { const a = Math.min(s.a + n, s.b); return a === s.a ? null : { start: dayIso(a) }; }
239
+ if (kind === 'due') { const b = Math.max(s.b + n, s.a); return b === s.b ? null : { due: dayIso(b) }; }
240
+ const out = {};
241
+ if (s.hasA) out.start = dayIso(s.a + n);
242
+ if (s.hasB) out.due = dayIso(s.b + n);
243
+ return out;
244
+ }
245
+ export function dragTip(row, kind, days) {
246
+ if (!row) return '';
247
+ const s = span(row); if (s.a == null) return '';
248
+ const p = dragPatch(row, kind, days) || {};
249
+ const a = p.start ? dayNum(p.start) : s.a, b = p.due ? dayNum(p.due) : s.b;
250
+ if (row.ms) return dayWords(b);
251
+ return a === b ? dayWords(b) : dayWords(a) + ' to ' + dayWords(b);
252
+ }
253
+ export function keyStep(key, mods = {}) {
254
+ const d = key === 'ArrowLeft' ? -1 : key === 'ArrowRight' ? 1 : 0; if (!d) return null;
255
+ return { kind: mods.shiftKey ? 'due' : mods.altKey ? 'start' : 'move', days: d };
256
+ }
257
+ export function dragStarts(dx, dy, pointer = 'mouse') {
258
+ const need = pointer === 'mouse' ? 3 : 6, x = Math.abs(Number(dx) || 0), y = Math.abs(Number(dy) || 0);
259
+ return x >= need && x > y;
260
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "A new bet's story map with the Release 1 line (initiative story-map, done test S1-S7, N1-N4): the pure parse and move, the popup block, the routes and pmos story-map on one scratch server. No browser, model or network.",
3
+ "modules": [
4
+ "story-map.test.js"
5
+ ],
6
+ "seconds": {
7
+ "story-map.test.js": 25
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Drag task bars on the Gantt to change dates (initiative timeline-bar-drag, job #2014; done test D1-D9, N1-N3): the pure helpers of pm/work-tree.js, the bar marking of pm/work-drag.js over a stand-in, and the wiring read from the source. No server, browser, model or network.",
3
+ "modules": [
4
+ "timeline-bar-drag.test.js"
5
+ ],
6
+ "seconds": {
7
+ "timeline-bar-drag.test.js": 1
8
+ }
9
+ }