create-pmos 0.422.0 → 0.424.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 +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/board-programs-test.js +28 -0
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +12 -10
- package/workspace/briefing-premium-initiative-test.js +30 -38
- package/workspace/briefing-premium-products-test.js +16 -3
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/claude-proposes.md +37 -0
- package/workspace/guide/home.md +9 -2
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/programs.md +1 -0
- package/workspace/guide/workflows.md +5 -1
- package/workspace/home-pill-test.js +138 -0
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/board-premium.js +3 -2
- package/workspace/lib/custom-docs.js +65 -3
- package/workspace/lib/engine/boards.js +25 -2
- package/workspace/lib/headless.js +14 -1
- package/workspace/lib/initiative-writer.js +63 -1
- package/workspace/lib/plan-items.js +36 -5
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/programs.js +11 -3
- package/workspace/lib/proposal-runs.js +148 -0
- package/workspace/lib/proposals.js +370 -0
- package/workspace/lib/propose-cli.js +96 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-board-premium.js +33 -0
- package/workspace/lib/routes-boards.js +50 -10
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-proposals.js +325 -0
- package/workspace/lib/routes-task-links.js +336 -0
- package/workspace/lib/split-merge-suggest.js +162 -0
- package/workspace/lib/split-merge.js +379 -0
- package/workspace/lib/task-cli.js +58 -5
- package/workspace/lib/task-items.js +14 -2
- package/workspace/lib/task-links.js +422 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +4 -4
- package/workspace/premium-core-doc-issue-test.js +2 -2
- package/workspace/premium-vw-backlog-test.js +3 -3
- package/workspace/premium-vw-item-test.js +3 -3
- package/workspace/premium-vw-jira-test.js +6 -6
- package/workspace/product-lane-test.js +165 -0
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-asks.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +16 -6
- package/workspace/public/pm/bd-prog.js +6 -1
- package/workspace/public/pm/bd-span.js +69 -15
- package/workspace/public/pm/bd-views.js +3 -2
- package/workspace/public/pm/cozy-board.css +10 -0
- package/workspace/public/pm/cozy-today.css +23 -0
- package/workspace/public/pm/cozy-viewer.js +14 -3
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/home-app.js +45 -14
- package/workspace/public/pm/home-ini-model.js +0 -34
- package/workspace/public/pm/home-ini.js +72 -204
- package/workspace/public/pm/home-task.js +2 -1
- package/workspace/public/pm/home-today.js +66 -16
- package/workspace/public/pm/ini-groups.js +253 -0
- package/workspace/public/pm/ini-links.js +519 -0
- package/workspace/public/pm/ini-props.js +218 -0
- package/workspace/public/pm/ini-tasks.js +58 -22
- package/workspace/public/pm/ini-versions.js +14 -9
- package/workspace/public/pm/ini-view-model.js +93 -4
- package/workspace/public/pm/ini-view.css +306 -18
- package/workspace/public/pm/ini-view.js +161 -36
- package/workspace/public/pm/premium-board.js +54 -6
- package/workspace/public/pm/premium-vw-item.js +2 -1
- package/workspace/public/pm/split-merge.css +77 -0
- package/workspace/public/pm/split-merge.js +265 -0
- package/workspace/public/pm/stage-line.js +414 -0
- package/workspace/public/pm/task-card.css +13 -0
- package/workspace/public/pm/task-card.js +42 -5
- package/workspace/public/pm/wf-page.css +2 -0
- package/workspace/public/pm/wf-page.js +2 -0
- package/workspace/public/pm/wf-stage.js +2 -1
- package/workspace/server.js +52 -3
- package/workspace/skills/initiative-propose.skill +45 -0
- package/workspace/split-merge-ui-test.js +175 -0
- package/workspace/stage-card-test.js +13 -12
- package/workspace/task-card-test.js +3 -2
- package/workspace/task-delete-test.js +126 -0
- package/workspace/task-links-test.js +239 -0
- package/workspace/task-milestones-test.js +1 -1
- package/workspace/task-plans-test.js +6 -0
- package/workspace/task-views-test.js +1 -1
- package/workspace/test-lists/bd-ini-panel.json +8 -2
- package/workspace/test-lists/claude-proposes.json +5 -0
- package/workspace/test-lists/home-sessions-pill.json +6 -0
- package/workspace/test-lists/product-lane.json +6 -0
- package/workspace/test-lists/split-merge.json +15 -0
- package/workspace/test-lists/task-delete.json +5 -0
- package/workspace/test-lists/task-links.json +6 -0
- package/workspace/tk-tasks-test.js +186 -57
- package/workspace/workflows-setup-test.js +4 -3
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* The list column, top to bottom: one header line ("Good morning" with a chevron that opens Your day, the product picker when Home reads
|
|
5
5
|
* more than one product, on a desktop the filter icon for Kept and Done, New), the "N are yours" line, the Today card only while the day has
|
|
6
6
|
* a moment (a recording, a meeting soon or on now, the end of the day, the weekly review open), each program's group, then each product's
|
|
7
|
-
* group (an initials tile, the name, the goal dots, a chevron; one-line rows with the stage track on the right; sessions,
|
|
8
|
-
* meetings
|
|
7
|
+
* group (an initials tile, the name, the goal dots, a chevron; one-line rows with the stage track on the right; an initiative's sessions,
|
|
8
|
+
* next steps and meetings sit in a pill on its row that lists them on a press; its tasks are on its page in the Viewer, not here), and "Not in an initiative" as a folded line. Your day (dayHtml) is a sheet over the list: the date
|
|
9
9
|
* and the day's meetings, Your move with its count, and This week with the Weekly review. Every group folds; home-app.js keeps the folds.
|
|
10
10
|
* The model is home-list.js (pure). This file only turns it into HTML: every control is a <button> (or the capture form) with a data-hm-*
|
|
11
11
|
* press that home-app.js handles. Text from the records goes through esc(). */
|
|
@@ -56,14 +56,14 @@ const MS = '<span class="hv-ms" role="img" aria-label="Milestone" title="Milesto
|
|
|
56
56
|
/** A row of the list: a next step, a task, a note, a mention, a session or a meeting. o: { sel, kid } */
|
|
57
57
|
export function rowHtml(r, o) {
|
|
58
58
|
const sel = o.sel === r.id;
|
|
59
|
-
const cls = ['hm-r', 'hv-r', o.kid ? 'kid' : '', sel ? 'sel' : '', 'st-' + (r.state || 'quiet'), r.kind === 'task' ? 'task' : '', r.kind === 'item' ? 'item' : '', r.done ? 'done' : ''].filter(Boolean).join(' ');
|
|
59
|
+
const cls = ['hm-r', 'hv-r', o.kid ? 'kid' : '', o.sub ? 'two' : '', sel ? 'sel' : '', 'st-' + (r.state || 'quiet'), r.kind === 'task' ? 'task' : '', r.kind === 'item' ? 'item' : '', r.done ? 'done' : ''].filter(Boolean).join(' ');
|
|
60
60
|
const lead = isCheck(r) ? checkHtml(r) : '';
|
|
61
61
|
// ending a session and putting a next step off stay on the row, shown on the row that is open (the frame draws neither)
|
|
62
62
|
const end = !sel ? '' : r.kind === 'session' && r.sid ? `<button type="button" class="ut-ib hm-x" data-hm-end="${esc(r.id)}" aria-label="End ${esc(r.name)}" title="End this session">${svg(P.x, 14)}</button>`
|
|
63
63
|
: r.kind === 'need' && r.row && r.row.kind !== 'source' ? `<button type="button" class="ut-ib hm-x" data-hm-end="${esc(r.id)}" aria-label="Put off ${esc(r.name)} until tomorrow" title="Put off until tomorrow">${svg(P.x, 14)}</button>` : '';
|
|
64
64
|
const link = r.link && r.kind === 'loose-rec' ? '<span class="hv-st">Link it</span>' : '';
|
|
65
65
|
return `<div class="${cls}" data-id="${esc(r.id)}">${lead}<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}${r.hint ? ` title="${esc(r.hint)}"` : ''}>${lead ? '' : markHtml(r)}`
|
|
66
|
-
+ `<span class="hm-rt${r.ms ? ' ms' : ''}"><b>${esc(r.name)}</b>${r.ms ? MS : ''}</span>${clock(r.when || whenOf(r))}${link}</button>${end}</div>`;
|
|
66
|
+
+ `<span class="hm-rt${r.ms ? ' ms' : ''}"><b>${esc(r.name)}</b>${r.ms ? MS : ''}${o.sub ? `<em>${esc(o.sub)}</em>` : ''}</span>${o.sub ? '' : clock(r.when || whenOf(r))}${link}</button>${end}</div>`;
|
|
67
67
|
}
|
|
68
68
|
/** The chat's header line on a desktop (HvACDesk .ch): the open row's mark, its title and the chip of where it sits (the initiative's stage
|
|
69
69
|
* track and name, or the program's tile and name). h: { row, title, scope, at, stage, prog }. A chip that repeats the title is left out, and
|
|
@@ -79,15 +79,62 @@ export function chatHeadHtml(h) {
|
|
|
79
79
|
const name = h.titleHtml ? `<span class="hm-chn">${h.titleHtml}</span>` : `<b class="hm-chb">${esc(h.title)}</b>`;
|
|
80
80
|
return `${mk}${same ? lead : ''}${name}${same && !h.prog ? track(h.at == null ? -1 : h.at, h.stage || '', h.steps) : ''}${chip}`;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
*
|
|
82
|
+
/* ── what sits in an initiative: the pill on its row (batch 12 item 6, canvas HsA1Desk, HsA2Phone, HsA3Sheet) ──
|
|
83
|
+
* Sessions, next steps and today's meetings no longer nest under the initiative (Wawan, 2026-10-26: Home grew too long). The row keeps one
|
|
84
|
+
* line; a pill on it shows the most urgent mark of what sits in it and how many: a blue dot (and a blue number) when one waits on you, amber
|
|
85
|
+
* when one is blocked, a ring when one runs, a clock for a meeting today, else a grey dot. A press lists them right under the pill (a sheet on
|
|
86
|
+
* a phone), each with its mark and one quiet line; a press on one opens it as the nested row did; + starts a new session in the initiative. */
|
|
87
|
+
const RANKED = ['needs', 'blocked', 'working', 'meeting', 'quiet'];
|
|
88
|
+
const kidState = (k) => (k.kind === 'meeting' && k.state !== 'working' ? 'meeting' : k.step ? 'needs' : RANKED.includes(k.state) ? k.state : 'quiet');
|
|
89
|
+
const KID_WORD = { needs: 'Asks you', blocked: 'Blocked, asks you', working: 'Running', quiet: 'Open' };
|
|
90
|
+
/** The quiet line under one row of the list: what it is and where it stands, in words (the mark says it again by shape). */
|
|
91
|
+
export function kidSub(k) {
|
|
92
|
+
if (k.kind === 'meeting') return k.hint || 'Meeting';
|
|
93
|
+
if (k.step) return k.hint || 'Next step';
|
|
94
|
+
return [KID_WORD[kidState(k)] || 'Open', k.kind === 'session' && k.hint ? k.hint : ''].filter(Boolean).join(' · ');
|
|
95
|
+
}
|
|
96
|
+
/** The pill's model: the most urgent state, the count and its accessible words. Nothing in the initiative: null (zero is silence). */
|
|
97
|
+
export function pillOf(r) {
|
|
98
|
+
const kids = (r && r.kids) || [];
|
|
99
|
+
if (!kids.length) return null;
|
|
100
|
+
const st = kids.map(kidState);
|
|
101
|
+
const top = RANKED.find((x) => st.includes(x));
|
|
102
|
+
const n = (x) => st.filter((y) => y === x).length;
|
|
103
|
+
const words = [n('needs') + n('blocked') ? (n('needs') + n('blocked')) + ' waits on you' : '', n('working') ? n('working') + ' running' : '', n('meeting') ? plural(n('meeting'), 'meeting today', 'meetings today') : '', n('quiet') ? n('quiet') + ' open' : ''].filter(Boolean).join(', ');
|
|
104
|
+
return { top, n: kids.length, say: plural(kids.length, 'thing', 'things') + ' in ' + r.name + ': ' + words };
|
|
105
|
+
}
|
|
106
|
+
/** The pill's key: the group and the row, since two products can hold an initiative with the same id. */
|
|
107
|
+
const sesKey = (r, o) => (o.gk || '') + '|' + r.id;
|
|
108
|
+
const pillMark = (top) => (top === 'meeting' ? svg(P.clock, 13) : `<i class="hv-pm ${top}" aria-hidden="true"></i>`);
|
|
109
|
+
function pillHtml(r, o) {
|
|
110
|
+
const m = pillOf(r);
|
|
111
|
+
if (!m) return '';
|
|
112
|
+
const on = o.ses === sesKey(r, o);
|
|
113
|
+
return `<button type="button" class="hv-sp ${m.top}${on ? ' on' : ''}" data-hm-ses="${esc(sesKey(r, o))}" aria-haspopup="dialog" aria-expanded="${on}" aria-label="${esc(m.say)}. ${on ? 'Hide' : 'Show'}" title="${esc(m.say)}">${pillMark(m.top)}<span class="n">${m.n}</span></button>`;
|
|
114
|
+
}
|
|
115
|
+
/** The list behind the pill: the rows that used to nest, waiting first, then + for a new session here. */
|
|
116
|
+
function sesListHtml(r, o) {
|
|
117
|
+
const kids = r.kids.slice().sort((a, b) => RANKED.indexOf(kidState(a)) - RANKED.indexOf(kidState(b)));
|
|
118
|
+
return kids.map((k) => rowHtml(k, { ...o, kid: false, sub: kidSub(k) })).join('')
|
|
119
|
+
+ `<div class="hv-spf"><button type="button" class="ut-ib hv-ib" data-hm-sesnew="${esc(r.ini || '')}" aria-label="New session in ${esc(r.name)}" title="New session here">${svg(P.plus, 18)}</button></div>`;
|
|
120
|
+
}
|
|
121
|
+
/** On a phone the list is a sheet over Home (as Your day was): the initiative's name and stage track on top. M is homeList(). */
|
|
122
|
+
export function sesSheetHtml(M, o) {
|
|
123
|
+
const g = o.ses && M.groups.find((x) => o.ses.startsWith(x.key + '|'));
|
|
124
|
+
const r = g && (g.inis || []).concat(g.rest || []).find((x) => o.ses === g.key + '|' + x.id);
|
|
125
|
+
if (!r || !r.kids.length) return '';
|
|
126
|
+
return `<button type="button" class="hv-scrim" data-hm-sesx tabindex="-1" aria-label="Close"></button><section class="hv-sheet hv-sps" data-esc-layer role="dialog" aria-label="In ${esc(r.name)}" tabindex="-1"><div class="hv-grab" aria-hidden="true"></div>`
|
|
127
|
+
+ `<div class="hv-sbar"><b>${esc(r.name)}</b>${track(r.at, r.stage, r.steps)}<button type="button" class="ut-ib hv-ib" data-hm-sesx aria-label="Close" title="Close">${svg(P.x, 20)}</button></div>`
|
|
128
|
+
+ `<div class="hv-sc">${sesListHtml(r, o)}</div></section>`;
|
|
129
|
+
}
|
|
130
|
+
/** An initiative row: its mark, its title, the pill of what sits in it, and the stage track. The title (and the track) open the initiative;
|
|
131
|
+
* 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). */
|
|
84
132
|
function iniHtml(r, o, po) {
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
+ `<span class="hm-rt"><b>${esc(r.name)}</b></span>${badge}${track(r.at, r.stage, r.steps)}</button>${chev}</div>${nest}`;
|
|
133
|
+
const on = o.ses === sesKey(r, o) && !o.phone && r.kids.length;
|
|
134
|
+
const pop = on ? `<div class="hv-spp" data-esc-layer role="dialog" aria-label="In ${esc(r.name)}">${sesListHtml(r, o)}</div>` : '';
|
|
135
|
+
const t = track(r.at, r.stage, r.steps);
|
|
136
|
+
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)}`
|
|
137
|
+
+ `<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>`;
|
|
91
138
|
}
|
|
92
139
|
|
|
93
140
|
/* ── a group (HvAC .pg, .card; PgHomePhone .psub) ── */
|
|
@@ -109,7 +156,7 @@ function productHtml(g, o) {
|
|
|
109
156
|
const restAll = o.restOpen(g.key);
|
|
110
157
|
const rest = restAll ? g.rest : g.rest.slice(0, Math.max(0, QUIET - g.inis.length));
|
|
111
158
|
const more = g.rest.length - rest.length;
|
|
112
|
-
const body = flat + g.inis.concat(rest).map((r) => iniHtml(r, o)).join('')
|
|
159
|
+
const body = flat + g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key })).join('')
|
|
113
160
|
+ (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>`
|
|
114
161
|
: 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>` : '');
|
|
115
162
|
return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</div></section>`;
|
|
@@ -129,7 +176,10 @@ function programHtml(g, o) {
|
|
|
129
176
|
+ `<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>`;
|
|
130
177
|
if (!open) return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}</section>`;
|
|
131
178
|
// the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
|
|
132
|
-
|
|
179
|
+
// 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
|
|
180
|
+
// under every program said nothing
|
|
181
|
+
const many = g.subs.length > 1;
|
|
182
|
+
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>` : ''}<div class="po-list" data-po-list="${esc(g.program.id)}">${x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, true)).join('')}</div>`).join('');
|
|
133
183
|
return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
|
|
134
184
|
}
|
|
135
185
|
/** "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
|
|
@@ -191,7 +241,7 @@ export function todayHtml(T, o) {
|
|
|
191
241
|
const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
192
242
|
const WEEKDAY = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
193
243
|
const MOMENT = new Set(['rec', 'soon', 'live', 'eod', 'review']);
|
|
194
|
-
/** M is homeList(); T todayCard(); o: { sel,
|
|
244
|
+
/** M is homeList(); T todayCard(); o: { sel, ses (the initiative row whose pill is open), pOpen, restOpen, pin, avHtml, ready, err, product (the picked key), review, phone, day (Your day is open) } */
|
|
195
245
|
export function listHtml(M, T, o) {
|
|
196
246
|
const many = M.products.length > 1;
|
|
197
247
|
const picked = o.product ? M.products.find((p) => p.key === o.product) : null;
|
|
@@ -218,7 +268,7 @@ export function listHtml(M, T, o) {
|
|
|
218
268
|
if (o.cap) body += `<form class="hm-cap" id="hmCapF"><label class="vh" for="hmCap">Add a task to your own list</label><input id="hmCap" autocomplete="off" maxlength="250" placeholder="A task for your own list. Esc to cancel">`
|
|
219
269
|
+ (o.mic ? `<button type="button" class="ut-ib" data-hm-capmic aria-label="Say it instead" title="Say it instead">${svg(P.mic, 16)}</button>` : '') + '</form>';
|
|
220
270
|
}
|
|
221
|
-
return head + card + `<div class="hv-body">${o.top || ''}${body}</div
|
|
271
|
+
return head + card + `<div class="hv-body">${o.top || ''}${body}</div>` + (o.phone && o.ses && !M.list ? sesSheetHtml(M, o) : ''); // o.top: the pinned recording row and Mentions (home-rec-row.js, home-mentions.js)
|
|
222
272
|
}
|
|
223
273
|
/** Your day (HvAOpen): a sheet over the list from "Good morning". The date, the day's meetings and their load (a press opens the calendar,
|
|
224
274
|
* or the day's moment card on a phone), Your move with its count, This week with the Weekly review (and the untouched work it looks at).
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/* pm/ini-groups.js — Group by and Send to Jira in the initiative's Tasks (feedback batch 11 item 20; canvas In development, row "Tasks
|
|
2
|
+
* takes over the old All tasks panel": XtaA1Group, XtaA2Epic, XtaA3Mine, XtaA4NewTask, XtaA5Phone, the rules xtaRules). The old All
|
|
3
|
+
* tasks panel (home-ini.js) is gone; its two jobs live here, in the one Tasks section of Home's page and the Board's panel. The grouping
|
|
4
|
+
* itself is pure (ini-view-model.js groupBy, groupSections); this file reads what it needs, draws the presses and writes the PM's picks.
|
|
5
|
+
*
|
|
6
|
+
* view(v) → v with its Tasks grouped as the PM picked (tasks.by, tasks.sections, tasks.gsum); Stage leaves v as it is
|
|
7
|
+
* headHtml(v) the group icon (layers) in the Tasks header, before the view switch; none while Tasks is empty or has no record id
|
|
8
|
+
* sumHtml(v) By epic's card: "N tickets are drafted, not in Jira" with Send to Jira, or "Sending to Jira" (zero is silence)
|
|
9
|
+
* toolsHtml(sec) what a group's header carries after its fold: ⋯ on the PM's own group, the send icon on an epic with drafted tickets
|
|
10
|
+
* tkRowsHtml(sec) an epic's tickets: a drafted one has no box and opens the draft (tk-draft.js); a sent one shows its key and status
|
|
11
|
+
* tkEmptyHtml(sec) By epic with nothing drafted: Draft the tickets while the PRD has stories, else why there is nothing to draft
|
|
12
|
+
* attach(body, H) once per draw: reads the layout and the tickets for the initiative shown, then H.redraw()
|
|
13
|
+
* press(b, d, root, H) a press this file owns → true: the group icon and its menu, a group's ⋯, the send icons, a ticket, Draft the tickets
|
|
14
|
+
* wireDrag(body) once per body: drag a task between the PM's own groups (List), "Moved to X." with Undo
|
|
15
|
+
*
|
|
16
|
+
* The host gives h.where() → { ws, board }, h.redraw() and h.toast(text, undo?). Writes: POST /api/initiative-layout (by, groups, rename,
|
|
17
|
+
* place, set), POST /api/jira/draft; reads: GET /api/initiative-layout, GET /api/jira/tickets. Every write is the PM's press, file mode. */
|
|
18
|
+
import { pmGet, pmPost } from './http.js';
|
|
19
|
+
import * as VW from './cozy-viewer.js';
|
|
20
|
+
import { groupBy, groupSections, GROUP_BY } from './ini-view-model.js';
|
|
21
|
+
import { readLine } from './tk-model.js';
|
|
22
|
+
|
|
23
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
24
|
+
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>`;
|
|
25
|
+
const P = {
|
|
26
|
+
layers: 'M3 7l9-4 9 4-9 4zM3 12l9 4 9-4M3 17l9 4 9-4', send: 'M4 12l16-8-6 16-3-7zM11 13l9-9', more: 'M5 12h.01M12 12h.01M19 12h.01',
|
|
27
|
+
check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', plus: 'M12 5v14M5 12h14', tk: 'M12 3l9 9-9 9-9-9z', draft: 'M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8',
|
|
28
|
+
};
|
|
29
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
30
|
+
const LAY = new Map(); // initiative id → its layout (GET /api/initiative-layout), as the last read or write answered
|
|
31
|
+
const TK = new Map(); // initiative id → its drafted tickets (GET /api/jira/tickets)
|
|
32
|
+
const READING = new Set(); // 'L|id', 'T|id' while a read is on its way
|
|
33
|
+
const ONLY = new Map(); // initiative id → { key, name }: the stage the stage card showed while Tasks is grouped another way (batch 12 item 0)
|
|
34
|
+
/** For the tests: forget every read. */
|
|
35
|
+
export const resetGroups = () => { LAY.clear(); TK.clear(); READING.clear(); ONLY.clear(); };
|
|
36
|
+
/** The stage card pressed while Tasks is grouped another way: Tasks keeps its grouping and shows that stage's tasks only. true when that
|
|
37
|
+
* applies (the grouping is not Stage); with Stage the caller opens the stage's own section as before. */
|
|
38
|
+
export function onlyStage(id, key) {
|
|
39
|
+
if (!idOk(id) || byOf(id) === 'stage') return false;
|
|
40
|
+
ONLY.set(id, { key: key == null ? '' : String(key), name: '' });
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
/** The stage sections whose key is `key`, from the WBS (a folded line's stages included). */
|
|
44
|
+
const stagesOf = (S, key) => S.flatMap((s) => (s.stages ? s.stages : [s])).filter((s) => (s.key || '') === key);
|
|
45
|
+
/** A section left with nothing to show under the filter. */
|
|
46
|
+
const bare = (s) => !(s.top && s.top.length) && !(s.groups && s.groups.length) && !(s.done && s.done.length) && !(s.archived && s.archived.length) && !s.tk && !s.jira && !s.tkEmpty;
|
|
47
|
+
|
|
48
|
+
const idOk = (id) => /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/.test(String(id || ''));
|
|
49
|
+
const atOf = (H) => (H && H.where ? H.where() || {} : {});
|
|
50
|
+
const q = (at, id) => '?initiative=' + encodeURIComponent(id) + (at.ws ? '&ws=' + encodeURIComponent(at.ws) : '');
|
|
51
|
+
async function readL(id, H) {
|
|
52
|
+
if (READING.has('L|' + id)) return;
|
|
53
|
+
READING.add('L|' + id);
|
|
54
|
+
const r = await pmGet('/api/initiative-layout' + q(atOf(H), id));
|
|
55
|
+
READING.delete('L|' + id);
|
|
56
|
+
LAY.set(id, r && r.ok ? r : { by: 'stage', names: [], of: {}, sets: [] });
|
|
57
|
+
if (H.redraw) H.redraw();
|
|
58
|
+
}
|
|
59
|
+
async function readT(id, H) {
|
|
60
|
+
if (READING.has('T|' + id)) return;
|
|
61
|
+
READING.add('T|' + id);
|
|
62
|
+
const r = await pmGet('/api/jira/tickets' + q(atOf(H), id));
|
|
63
|
+
READING.delete('T|' + id);
|
|
64
|
+
TK.set(id, r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The tickets could not be read.' });
|
|
65
|
+
if (H.redraw) H.redraw();
|
|
66
|
+
}
|
|
67
|
+
/** Reads what the initiative shown needs, once; a redraw follows each answer. */
|
|
68
|
+
export function attach(body, H) {
|
|
69
|
+
const n = body && body.querySelector('[data-iv]'), id = n && n.dataset.iv;
|
|
70
|
+
if (!idOk(id) || !H || !body.querySelector('[data-ig-by]')) return; // no group icon: no record id, or nothing to group
|
|
71
|
+
if (!LAY.has(id)) readL(id, H);
|
|
72
|
+
if (!TK.has(id)) readT(id, H);
|
|
73
|
+
}
|
|
74
|
+
const byOf = (id) => groupBy(LAY.get(id), TK.get(id));
|
|
75
|
+
|
|
76
|
+
/* ── the view ── */
|
|
77
|
+
export function view(v) {
|
|
78
|
+
const id = v && v.id;
|
|
79
|
+
if (!idOk(id) || !v.tasks || v.tasks.empty) return v;
|
|
80
|
+
const by = byOf(id);
|
|
81
|
+
if (by === 'stage') return { ...v, tasks: { ...v.tasks, by } };
|
|
82
|
+
const f = ONLY.get(id), keep = f ? stagesOf(v.tasks.sections || [], f.key) : null;
|
|
83
|
+
if (f && !keep.length) ONLY.delete(id); // the stage is gone from the view: show every task again
|
|
84
|
+
if (!f || !keep.length) {
|
|
85
|
+
const { sections, sum } = groupSections(v.tasks, by, LAY.get(id), TK.get(id));
|
|
86
|
+
return { ...v, tasks: { ...v.tasks, by, sections, gsum: sum } };
|
|
87
|
+
}
|
|
88
|
+
f.name = keep[0].name || keep[0].label || 'Not in a stage';
|
|
89
|
+
// the Jira tickets (By epic's groups) are the work of the stage that carries them; another stage shows its own tasks only
|
|
90
|
+
const withJira = keep.some((s) => s.jira);
|
|
91
|
+
const { sections, sum } = groupSections({ ...v.tasks, sections: keep }, by, LAY.get(id), withJira ? TK.get(id) : null);
|
|
92
|
+
const shown = sections.filter((s) => (s.kind === 'epic' ? withJira : !bare(s)));
|
|
93
|
+
return { ...v, tasks: { ...v.tasks, by, sections: shown, gsum: withJira ? sum : null, only: f.name } };
|
|
94
|
+
}
|
|
95
|
+
export function headHtml(v) {
|
|
96
|
+
if (!v || !idOk(v.id) || !v.tasks || v.tasks.empty) return '';
|
|
97
|
+
const by = v.tasks.by || 'stage';
|
|
98
|
+
// the stage the card showed: its name and a ✕ that shows every stage again (filters earn space: only while one is on)
|
|
99
|
+
const only = v.tasks.only ? `<button type="button" class="ig-only" data-ig-all aria-label="${esc('Showing ' + v.tasks.only + ' only. Show every stage')}" title="Show every stage">${esc(v.tasks.only)}${SVG(P.x, 14, 2)}</button>` : '';
|
|
100
|
+
return only + `<button type="button" class="iv-ib ig-by${by !== 'stage' ? ' on' : ''}" data-ig-by aria-haspopup="menu" aria-label="Group tasks by" title="${esc('Group tasks by · ' + GROUP_BY[by])}">${SVG(P.layers, 18)}</button>`;
|
|
101
|
+
}
|
|
102
|
+
export function sumHtml(v) {
|
|
103
|
+
const s = v && v.tasks && v.tasks.gsum; if (!s) return '';
|
|
104
|
+
const go = s.primary ? `<button type="button" class="ig-sb" data-ig-sendall>${SVG(P.send, 16)}${esc(s.primary.label)}</button>` : '';
|
|
105
|
+
return `<section class="iv-sum ig-sum" aria-label="Jira"><div class="iv-s1 ${s.tone === 'you' ? 'you' : ''}">${s.tone === 'you' ? '<span class="iv-dot" aria-hidden="true"></span>' : ''}<b>${esc(s.line)}</b></div>`
|
|
106
|
+
+ `<p class="iv-why">${esc(s.text)}</p><div class="ig-sf"><span class="iv-meta">${esc(s.meta)}</span>${go}</div></section>`;
|
|
107
|
+
}
|
|
108
|
+
/** A group header's own presses, after the fold. */
|
|
109
|
+
export function toolsHtml(sec) {
|
|
110
|
+
if (sec.mine) return `<button type="button" class="iv-ib ig-gm" data-ig-gmore="${esc(sec.mine)}" aria-haspopup="menu" aria-label="${esc('More for ' + sec.mine)}" title="More">${SVG(P.more, 16, 3)}</button>`;
|
|
111
|
+
if (sec.kind === 'epic' && sec.send) return `<button type="button" class="iv-ib ig-snd" data-ig-send="${esc(sec.gid)}" aria-label="${esc('Send ' + sec.label + ' to Jira')}" title="Send to Jira">${SVG(P.send, 17)}</button>`;
|
|
112
|
+
return '';
|
|
113
|
+
}
|
|
114
|
+
export function tkRowsHtml(sec) {
|
|
115
|
+
return (sec.tk || []).map((r) => {
|
|
116
|
+
const mk = r.inJira ? `<span class="ig-sq ${esc(r.cat || 'todo')}" role="img" aria-label="${esc('In Jira: ' + (r.status || 'To do'))}" title="${esc('Jira · ' + (r.status || 'To do'))}"></span>`
|
|
117
|
+
: `<span class="ig-tkd" role="img" aria-label="Jira ticket drafted, not sent" title="Drafted, not in Jira">${SVG(P.tk, 16)}</span>`;
|
|
118
|
+
const flag = r.mark ? `<span class="ig-mk ${esc(r.mark[0])}" role="img" aria-label="${esc(r.mark[1])}" title="${esc(r.mark[1])}"></span>` : '';
|
|
119
|
+
return `<button type="button" class="iv-tr ig-tk" data-ig-tk="${esc(r.id)}">${mk}<span class="w"><b class="iv-tt">${r.inJira && r.key ? `<em>${esc(r.key)}</em> ` : ''}${esc(r.title)}</b>${!r.inJira && r.sub ? `<span>${esc(r.sub)}</span>` : ''}</span>${flag}`
|
|
120
|
+
+ `${r.av ? `<span class="ivt-av" role="img" aria-label="${esc('Assigned to ' + r.who)}" title="${esc(r.who)}">${esc(r.av)}</span>` : ''}</button>`;
|
|
121
|
+
}).join('') + (sec.tkRead && readLine(sec.tkRead) ? `<p class="iv-q ig-read">${esc(readLine(sec.tkRead))}</p>` : '');
|
|
122
|
+
}
|
|
123
|
+
export function tkEmptyHtml(sec) {
|
|
124
|
+
const e = sec.tkEmpty; if (!e) return '';
|
|
125
|
+
if (e.reading) return '<p class="iv-q" role="status">Reading the tickets.</p>';
|
|
126
|
+
if (e.error) return `<p class="iv-q">${esc(e.error)}</p>`;
|
|
127
|
+
if (e.items) return `<div class="ig-emp"><p class="iv-q">The PRD lists ${esc(plural(e.items, 'story', 'stories'))}. Each one becomes a task with its Jira ticket drafted in your template. Nothing goes to Jira until you send it.</p><button type="button" class="iv-pbtn" data-ig-draft>${SVG(P.draft, 16, 2)}Draft the tickets</button></div>`;
|
|
128
|
+
return '<p class="iv-q">The PRD lists no user stories yet. Give it a "User stories" section, one subheading per story, and each one becomes a task here.</p>';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* ── the popover: right under its press; a bottom sheet on a phone (XtaA5Phone) ── */
|
|
132
|
+
let POP = null;
|
|
133
|
+
const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 640px)').matches;
|
|
134
|
+
function closePop() { if (!POP) return; const { el, scrim, anchor } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
|
|
135
|
+
function openPop(anchor, html, onPress, o = {}) {
|
|
136
|
+
closePop();
|
|
137
|
+
const sheet = phone();
|
|
138
|
+
const el = document.createElement('div');
|
|
139
|
+
el.className = 'tkc ivq vs-pop ig-pop' + (sheet ? ' sheet' : ''); el.dataset.escLayer = ''; el.innerHTML = html;
|
|
140
|
+
let scrim = null;
|
|
141
|
+
if (sheet) { scrim = document.createElement('div'); scrim.className = 'vs-scrim'; document.body.appendChild(scrim); }
|
|
142
|
+
document.body.appendChild(el);
|
|
143
|
+
if (!sheet) {
|
|
144
|
+
const r = anchor.getBoundingClientRect(), w = el.offsetWidth, h = el.offsetHeight;
|
|
145
|
+
const left = Math.max(8, Math.min(r.right - w, innerWidth - w - 8)), below = r.bottom + 6 + h <= innerHeight - 8;
|
|
146
|
+
el.style.setProperty('--tl-x', left + 'px'); el.style.setProperty('--tl-y', (below ? r.bottom + 6 : Math.max(8, r.top - 6 - h)) + 'px');
|
|
147
|
+
}
|
|
148
|
+
anchor.setAttribute('aria-expanded', 'true');
|
|
149
|
+
POP = { el, scrim, anchor, onPress };
|
|
150
|
+
const f = el.querySelector(o.focus || '[aria-checked="true"], button'); if (f) f.focus({ preventScroll: true });
|
|
151
|
+
return el;
|
|
152
|
+
}
|
|
153
|
+
if (typeof document !== 'undefined' && document.head) {
|
|
154
|
+
document.addEventListener('pointerdown', (e) => { if (POP && !POP.el.contains(e.target) && !(POP.anchor && POP.anchor.contains(e.target))) closePop(); }, true);
|
|
155
|
+
document.addEventListener('click', (e) => { if (!POP) return; const b = e.target.closest && e.target.closest('button'); if (b && POP.el.contains(b)) POP.onPress(b, e); });
|
|
156
|
+
document.addEventListener('keydown', (e) => {
|
|
157
|
+
if (!POP) return;
|
|
158
|
+
if (e.key === 'Escape') { e.stopPropagation(); const a = POP.anchor; closePop(); if (a && a.isConnected) a.focus(); return; }
|
|
159
|
+
if (e.key === 'Enter' && e.target && e.target.matches && e.target.matches('.ig-pop input')) { e.preventDefault(); const b = POP.el.querySelector('[data-ig-ok]'); if (b) b.click(); }
|
|
160
|
+
}, true);
|
|
161
|
+
addEventListener('resize', () => { if (POP && !POP.scrim) closePop(); });
|
|
162
|
+
}
|
|
163
|
+
/** A menu of rows: { head } a label, { hr } a divider, { label, sub?, on?, radio?, icon?, disabled?, go } a press. The tk-draft.js `ui.menu` too. */
|
|
164
|
+
function menu(anchor, items, label) {
|
|
165
|
+
const html = `<div class="tkc-pop ivq-m ig-m" role="menu" aria-label="${esc(label)}">${items.map((x, i) => (x.head ? `<p class="ig-h">${esc(x.head)}</p>` : x.hr ? '<div class="ig-hr" role="separator"></div>'
|
|
166
|
+
: `<button type="button" role="${x.radio ? 'menuitemradio' : 'menuitem'}" class="o${x.on ? ' hl' : ''}"${x.radio ? ` aria-checked="${!!x.on}"` : ''} data-ig-i="${i}"${x.disabled ? ' disabled' : ''}>`
|
|
167
|
+
+ `<span class="ck" aria-hidden="true">${x.icon ? SVG(x.icon, 14, 2.2) : x.on ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(x.label)}</span>${x.sub ? `<span class="k">${esc(x.sub)}</span>` : ''}</button>`)).join('')}</div>`;
|
|
168
|
+
openPop(anchor, html, (b) => { const i = b.dataset.igI; if (i == null) return; const it = items[+i]; if (!it || it.disabled) return; if (!it.keep) closePop(); if (it.go) it.go(anchor); });
|
|
169
|
+
}
|
|
170
|
+
/** One line of words in place of the menu: New group, Rename. The tk-draft.js `ui.ask` too. */
|
|
171
|
+
function ask(anchor, label, value, go, o = {}) {
|
|
172
|
+
const html = `<div class="tkc-pop ig-m ig-ask" role="dialog" aria-label="${esc(label)}"><p class="ig-h">${esc(label)}</p><div class="ig-ar"><input type="text" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}" aria-label="${esc(label)}">`
|
|
173
|
+
+ `<button type="button" class="vs-ok" data-ig-ok aria-label="Save" title="Save (Enter)">${SVG(P.check, 16, 2.4)}</button></div></div>`;
|
|
174
|
+
const el = openPop(anchor, html, (b) => { if (!('igOk' in b.dataset)) return; const v = el.querySelector('input').value.trim(); if (!v) return; closePop(); go(v); }, { focus: 'input' });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* ── the writes ── */
|
|
178
|
+
async function lay(id, H, body) {
|
|
179
|
+
const r = await pmPost('/api/initiative-layout', { ws: atOf(H).ws, initiative: id, ...body });
|
|
180
|
+
if (r && r.ok) { LAY.set(id, r); if (H.redraw) H.redraw(); return r; }
|
|
181
|
+
if (H.toast) H.toast((r && r.error) || 'Nothing was changed.');
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function groupMenu(b, id, H) {
|
|
185
|
+
const L = LAY.get(id) || { names: [], sets: [] }, T = TK.get(id), by = byOf(id), names = L.names || [];
|
|
186
|
+
const epics = T && T.ok === true ? new Set((T.tickets || []).map((t) => t.epic || '')).size : 0;
|
|
187
|
+
const same = (n) => n.join('|').toLowerCase() === names.join('|').toLowerCase();
|
|
188
|
+
const sets = L.sets || [];
|
|
189
|
+
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', by: 'mine' }); }) };
|
|
190
|
+
menu(b, [{ head: 'Group by' }, ...Object.entries(GROUP_BY).map(([k, l]) => ({ label: l, radio: true, on: by === k,
|
|
191
|
+
sub: k === 'epic' && epics ? plural(epics, 'epic', 'epics') : k === 'mine' && names.length ? String(names.length) : '', go: () => lay(id, H, { kind: 'by', by: k }) })),
|
|
192
|
+
{ hr: true }, ...(sets.length ? [{ head: 'Your group sets' }] : []),
|
|
193
|
+
...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', by: 'mine' }); } })),
|
|
194
|
+
...(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 }) }] : []),
|
|
195
|
+
newGroup], 'Group tasks by');
|
|
196
|
+
}
|
|
197
|
+
function groupMore(b, id, H, g) {
|
|
198
|
+
const names = (LAY.get(id) || {}).names || [];
|
|
199
|
+
menu(b, [{ label: 'Rename', keep: true, go: (a) => ask(a, 'Rename ' + g, g, (v) => lay(id, H, { kind: 'rename', from: g, to: v })) },
|
|
200
|
+
{ label: 'Delete the group', sub: 'Its tasks stay', go: async () => { if (await lay(id, H, { kind: 'groups', names: names.filter((x) => x !== g) }) && H.toast) H.toast(g + ' deleted. Its tasks stay.'); } }], 'More for ' + g);
|
|
201
|
+
}
|
|
202
|
+
async function send(id, H, o = {}) {
|
|
203
|
+
const at = atOf(H), S = await import('./tk-send.js');
|
|
204
|
+
S.openSend({ ws: at.ws, board: at.board, initiative: id, ...o, toast: H.toast,
|
|
205
|
+
onDone: async () => { TK.delete(id); await readT(id, H); setTimeout(() => { TK.delete(id); readT(id, H); }, 4000); } });
|
|
206
|
+
}
|
|
207
|
+
async function openTk(id, H, tid) {
|
|
208
|
+
const at = atOf(H), T = TK.get(id), t = T && T.ok === true ? (T.tickets || []).find((x) => x.id === tid) : null;
|
|
209
|
+
if (t && t.inJira && !t.selectable) { (await import('./premium-vw-jira.js')).openTicket({ ws: at.ws, board: at.board, initiative: id, ref: t.key }); return; }
|
|
210
|
+
const D = await import('./tk-draft.js');
|
|
211
|
+
D.openDraft({ VW, ws: at.ws, initiative: id, id: tid, view: T && T.ok === true ? T : null, toast: H.toast, ui: { menu, ask },
|
|
212
|
+
onChange: () => { TK.delete(id); readT(id, H); }, onSend: (x) => send(id, H, { ticket: x }) });
|
|
213
|
+
}
|
|
214
|
+
export function press(b, d, root, H) {
|
|
215
|
+
const id = root && root.dataset.iv; if (!idOk(id)) return false;
|
|
216
|
+
if ('igBy' in d) { if (POP && POP.anchor === b) closePop(); else groupMenu(b, id, H); return true; }
|
|
217
|
+
if (d.igGmore) { groupMore(b, id, H, d.igGmore); return true; }
|
|
218
|
+
if ('igAll' in d) { ONLY.delete(id); if (H.redraw) H.redraw(); return true; }
|
|
219
|
+
if (d.igSend != null) { send(id, H, { group: d.igSend }); return true; }
|
|
220
|
+
if ('igSendall' in d) { send(id, H); return true; }
|
|
221
|
+
if (d.igTk) { openTk(id, H, d.igTk); return true; }
|
|
222
|
+
if ('igDraft' in d) {
|
|
223
|
+
b.disabled = true;
|
|
224
|
+
pmPost('/api/jira/draft', { ws: atOf(H).ws, initiative: id }).then(async (r) => {
|
|
225
|
+
if (!r || r.ok === false) { b.disabled = false; if (H.toast) H.toast((r && r.error) || 'The tickets were not drafted.'); return; }
|
|
226
|
+
if (H.toast) H.toast(plural(r.tickets, 'ticket', 'tickets') + ' drafted. Nothing is in Jira yet.');
|
|
227
|
+
TK.delete(id); readT(id, H);
|
|
228
|
+
});
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ── Your groups: drag a task between them (XtaA3Mine), "Moved to X." with Undo ── */
|
|
235
|
+
export function wireDrag(body) {
|
|
236
|
+
if (!body || body.__igDrag) return;
|
|
237
|
+
body.__igDrag = true;
|
|
238
|
+
const zones = () => body.querySelectorAll('.ig-over');
|
|
239
|
+
body.addEventListener('dragstart', (e) => { const r = e.target.closest && e.target.closest('[data-ig-drag]'); if (!r) return; e.dataTransfer.setData('text/plain', r.dataset.igDrag); e.dataTransfer.effectAllowed = 'move'; r.classList.add('drag'); body.__igFrom = r.closest('[data-ig-drop]') ? r.closest('[data-ig-drop]').dataset.igDrop : ''; });
|
|
240
|
+
body.addEventListener('dragend', (e) => { const r = e.target.closest && e.target.closest('[data-ig-drag]'); if (r) r.classList.remove('drag'); zones().forEach((n) => n.classList.remove('ig-over')); body.__igFrom = null; });
|
|
241
|
+
body.addEventListener('dragover', (e) => { const z = e.target.closest && e.target.closest('[data-ig-drop]'); if (!z || body.__igFrom == null) return; e.preventDefault(); zones().forEach((n) => { if (n !== z) n.classList.remove('ig-over'); }); z.classList.add('ig-over'); });
|
|
242
|
+
body.addEventListener('drop', (e) => {
|
|
243
|
+
const z = e.target.closest && e.target.closest('[data-ig-drop]'); if (!z || body.__igFrom == null) return;
|
|
244
|
+
e.preventDefault(); z.classList.remove('ig-over');
|
|
245
|
+
const uid = e.dataTransfer.getData('text/plain'), from = body.__igFrom, to = z.dataset.igDrop, H = body.__iv || {};
|
|
246
|
+
body.__igFrom = null;
|
|
247
|
+
const root = body.querySelector('[data-iv]'), id = root && root.dataset.iv;
|
|
248
|
+
if (!uid || !idOk(id) || from === to) return;
|
|
249
|
+
lay(id, H, { kind: 'place', task: 'task:' + uid, group: to }).then((r) => {
|
|
250
|
+
if (r && H.toast) H.toast('Moved to ' + (to || 'Not in a group') + '.', () => lay(id, H, { kind: 'place', task: 'task:' + uid, group: from }));
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|