@popcorn245/cornfield 0.40.0 → 0.42.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/core/contrast.js +1 -0
- package/core/map-tokens.js +3 -2
- package/core/strings.js +9 -0
- package/explorer/camera.js +1 -1
- package/explorer/cluster.js +26 -0
- package/explorer/decision-model.js +231 -0
- package/explorer/explorer.css +81 -6
- package/explorer/fly.js +48 -0
- package/explorer/forge-panel.js +28 -5
- package/explorer/index.html +18 -2
- package/explorer/input.js +16 -5
- package/explorer/keyboard.js +12 -22
- package/explorer/labels.js +239 -80
- package/explorer/layout.js +43 -15
- package/explorer/main.js +6 -25
- package/explorer/map-style.js +21 -8
- package/explorer/proposal-model.js +24 -0
- package/explorer/proposal.js +13 -6
- package/explorer/render.js +19 -1
- package/explorer/review-column.js +22 -4
- package/explorer/review.js +413 -44
- package/explorer/runs-model.js +1 -1
- package/explorer/scene.js +28 -36
- package/explorer/search-model.js +156 -0
- package/explorer/search-status.js +24 -13
- package/explorer/search.js +335 -0
- package/explorer/state.js +8 -0
- package/explorer/tokens.css +2 -0
- package/explorer/whatif.js +84 -7
- package/package.json +1 -1
- package/server/decision.js +117 -0
- package/server/proposal-pulls.js +1 -1
- package/server/proposals.js +58 -9
- package/server/server.js +19 -2
- package/server/submit-review.js +52 -7
package/explorer/map-style.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* --corn-map-collision the collision mark of two runs on one node (a DOM mark: explorer.css reads it)
|
|
16
16
|
* --corn-map-font the font list of every label on the map (a list of families, `auto` for the map's own)
|
|
17
17
|
* --corn-map-edge-width the width of an ordinary line, in map px (`auto` keeps each line's own; the focus's and the marks' keep their proportion)
|
|
18
|
+
* --corn-map-label-min the smallest a label is drawn on screen, in px (11 by default; below 9px it is ignored; a hub's title is 2 more)
|
|
18
19
|
* --corn-map-glow the soft glow round nodes, lines and packets: a factor (`0` none, `1` as drawn, `auto` as drawn)
|
|
19
20
|
*
|
|
20
21
|
* `auto` (the default of every one of them but the width and the collision) means "keep what the map draws without a theme": the
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
|
|
35
36
|
import { NODE_THEMES } from '../core/schema.js';
|
|
36
37
|
import { parseColor } from './theme-model.js';
|
|
37
|
-
import { looksFor } from './scene.js';
|
|
38
|
+
import { LABEL_MIN_FLOOR, looksFor } from './scene.js';
|
|
38
39
|
import { iconKeyShape, iconKeysFor, mapGroupToken, mapKindToken } from '../core/layers.js';
|
|
39
40
|
|
|
40
41
|
/** The node kinds (topology types) and the groups (layers a node can belong to) the tokens exist for */
|
|
@@ -53,6 +54,9 @@ export const COLLISION_TOKEN = '--corn-map-collision';
|
|
|
53
54
|
export const FONT_TOKEN = '--corn-map-font';
|
|
54
55
|
export const EDGE_WIDTH_TOKEN = '--corn-map-edge-width';
|
|
55
56
|
export const GLOW_TOKEN = '--corn-map-glow';
|
|
57
|
+
export const LABEL_MIN_TOKEN = '--corn-map-label-min';
|
|
58
|
+
/** The largest label minimum a theme may ask for: bigger text would leave no room for another label */
|
|
59
|
+
export const MAX_LABEL_MIN = 24;
|
|
56
60
|
/** The width an ordinary line has with no theme (scene.js `flowEdge`): the `--corn-map-edge-width` scales every line by its ratio to this */
|
|
57
61
|
export const BASE_EDGE_WIDTH = 1.6;
|
|
58
62
|
/** The most a font list may hold: the families, and the characters */
|
|
@@ -87,7 +91,7 @@ export const MAP_COLOR_TOKENS = Object.freeze([
|
|
|
87
91
|
...MAP_STATES.map(stateToken),
|
|
88
92
|
]);
|
|
89
93
|
/** Every map token */
|
|
90
|
-
export const mapTokenNames = () => [...MAP_COLOR_TOKENS, STROKE_WIDTH_TOKEN, COLLISION_TOKEN, FONT_TOKEN, EDGE_WIDTH_TOKEN, GLOW_TOKEN];
|
|
94
|
+
export const mapTokenNames = () => [...MAP_COLOR_TOKENS, STROKE_WIDTH_TOKEN, COLLISION_TOKEN, FONT_TOKEN, EDGE_WIDTH_TOKEN, GLOW_TOKEN, LABEL_MIN_TOKEN];
|
|
91
95
|
|
|
92
96
|
// ---------------------------------------------------------------------------
|
|
93
97
|
// Reading a token
|
|
@@ -206,6 +210,12 @@ function pxOf(value, max) {
|
|
|
206
210
|
return Number.isFinite(n) && n > 0 && n <= max ? n : null;
|
|
207
211
|
}
|
|
208
212
|
|
|
213
|
+
/** The label minimum: a length in px from LABEL_MIN_FLOOR to MAX_LABEL_MIN, or null for `auto` and anything else (under the floor is ignored, so a theme cannot make labels unreadable) */
|
|
214
|
+
function labelMinOf(value) {
|
|
215
|
+
const n = pxOf(value, MAX_LABEL_MIN);
|
|
216
|
+
return n !== null && n >= LABEL_MIN_FLOOR ? n : null;
|
|
217
|
+
}
|
|
218
|
+
|
|
209
219
|
/** The glow factor: a number (`0` for none, `1` as drawn, up to MAX_GLOW; `0px` reads as 0), or null for `auto` and anything else */
|
|
210
220
|
function factorOf(value) {
|
|
211
221
|
const m = /^\s*(\d*\.?\d+)(px)?\s*$/i.exec(String(value ?? ''));
|
|
@@ -219,8 +229,8 @@ function factorOf(value) {
|
|
|
219
229
|
* The tokens as the page computes them.
|
|
220
230
|
* @param {(name: string) => string} read the value of a custom property
|
|
221
231
|
* @param {string[]} [extra] more colour tokens to read: those of the finer kinds and project layers on the map (`setMapSubjects`)
|
|
222
|
-
* @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null}}
|
|
223
|
-
* `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth` and `
|
|
232
|
+
* @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null, labelMin: number | null}}
|
|
233
|
+
* `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth`, `glow` and `labelMin` are null at `auto` or when the value is not one
|
|
224
234
|
*/
|
|
225
235
|
export function readMapTokens(read, extra = []) {
|
|
226
236
|
const values = {};
|
|
@@ -235,6 +245,7 @@ export function readMapTokens(read, extra = []) {
|
|
|
235
245
|
font: cssFontList(read(FONT_TOKEN)),
|
|
236
246
|
edgeWidth: pxOf(read(EDGE_WIDTH_TOKEN), MAX_EDGE_WIDTH),
|
|
237
247
|
glow: factorOf(read(GLOW_TOKEN)),
|
|
248
|
+
labelMin: labelMinOf(read(LABEL_MIN_TOKEN)),
|
|
238
249
|
};
|
|
239
250
|
}
|
|
240
251
|
|
|
@@ -303,12 +314,13 @@ export function createIconStore(urls, { load = loadImage, onChange = () => {}, w
|
|
|
303
314
|
* @property {string | null} font the label font list (`--corn-map-font`), null at `auto`
|
|
304
315
|
* @property {number | null} edgeWidth an ordinary line's width in px (`--corn-map-edge-width`), null at `auto`
|
|
305
316
|
* @property {number | null} glow the glow factor (`--corn-map-glow`), null at `auto`
|
|
317
|
+
* @property {number | null} labelMin the smallest label size in px (`--corn-map-label-min`), null at `auto` or under 9px
|
|
306
318
|
* @property {ReturnType<typeof createIconStore> | null} icons
|
|
307
319
|
* @property {boolean} pixelated sample icons without smoothing
|
|
308
320
|
* @property {boolean} plain nothing to apply: no colour set, no icon loaded (the scene is drawn as it is)
|
|
309
321
|
*/
|
|
310
322
|
|
|
311
|
-
const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null };
|
|
323
|
+
const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null };
|
|
312
324
|
let tokens = NO_TOKENS;
|
|
313
325
|
let icons = null;
|
|
314
326
|
let pixelated = false;
|
|
@@ -317,8 +329,8 @@ let current = compose();
|
|
|
317
329
|
const listeners = new Set();
|
|
318
330
|
|
|
319
331
|
function compose() {
|
|
320
|
-
const plain = !Object.keys(tokens.values).length && !(icons && icons.anyReady()) && tokens.font === null && tokens.edgeWidth === null && tokens.glow === null;
|
|
321
|
-
return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, icons, pixelated, plain });
|
|
332
|
+
const plain = !Object.keys(tokens.values).length && !(icons && icons.anyReady()) && tokens.font === null && tokens.edgeWidth === null && tokens.glow === null && tokens.labelMin === null;
|
|
333
|
+
return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, labelMin: tokens.labelMin, icons, pixelated, plain });
|
|
322
334
|
}
|
|
323
335
|
|
|
324
336
|
function changed() {
|
|
@@ -359,7 +371,7 @@ export function onMapStyleChange(fn) {
|
|
|
359
371
|
export function refreshMapStyle(read = pageReader()) {
|
|
360
372
|
if (!read) return false;
|
|
361
373
|
const next = readMapTokens(read, subjectTokens);
|
|
362
|
-
const same = next.strokeWidth === tokens.strokeWidth && next.font === tokens.font && next.edgeWidth === tokens.edgeWidth && next.glow === tokens.glow
|
|
374
|
+
const same = next.strokeWidth === tokens.strokeWidth && next.font === tokens.font && next.edgeWidth === tokens.edgeWidth && next.glow === tokens.glow && next.labelMin === tokens.labelMin
|
|
363
375
|
&& Object.keys(next.values).length === Object.keys(tokens.values).length
|
|
364
376
|
&& Object.entries(next.values).every(([k, v]) => tokens.values[k] === v);
|
|
365
377
|
if (same) return false;
|
|
@@ -488,6 +500,7 @@ function compute(scene, style) {
|
|
|
488
500
|
});
|
|
489
501
|
const out = { ...scene, nodes, edges: scene.edges.map((e) => styleEdge(e, style, painted.edges)) };
|
|
490
502
|
if (style.font) out.labelFont = style.font; // every label's font list (labels.js reads `scene.labelFont`)
|
|
503
|
+
if (style.labelMin != null) out.labelMin = style.labelMin; // the smallest label on screen (labels.js reads `scene.labelMin`)
|
|
491
504
|
const halo = values[LABEL_HALO_TOKEN];
|
|
492
505
|
if (halo) { // the outline under the labels, at the widths it has (labels.js reads `scene.labelOutline` before the ground's own)
|
|
493
506
|
const { node, edge } = looksFor(scene.theme).labelOutline;
|
|
@@ -541,3 +541,27 @@ export function pinLanes(flow, baseFlow) {
|
|
|
541
541
|
flow.top = top;
|
|
542
542
|
return true;
|
|
543
543
|
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* The reviewer's own what-if edits, counted apart from the proposal's (spec 0007 D5): "yours: +1 node, 1 step changed". Never added to the proposal's
|
|
547
|
+
* numbers, so the reviewer can still tell what the agent proposed. Empty for no edits.
|
|
548
|
+
* @param {{ op?: string }[]} edits the applied edits (whatif-model.js)
|
|
549
|
+
* @param {boolean} [hidden] My edits is off: the map does not show them
|
|
550
|
+
* @returns {string}
|
|
551
|
+
*/
|
|
552
|
+
export function yoursText(edits, hidden = false) {
|
|
553
|
+
const list = Array.isArray(edits) ? edits : [];
|
|
554
|
+
if (!list.length) return '';
|
|
555
|
+
const n = (ops) => list.filter((e) => e && ops.includes(e.op)).length;
|
|
556
|
+
const unit = (k, word) => `${k} ${word}${k === 1 ? '' : 's'}`;
|
|
557
|
+
const parts = [];
|
|
558
|
+
if (n(['add-node'])) parts.push(`+${unit(n(['add-node']), 'node')}`);
|
|
559
|
+
if (n(['add-edge'])) parts.push(`+${unit(n(['add-edge']), 'edge')}`);
|
|
560
|
+
if (n(['remove-node'])) parts.push(`\u2212${unit(n(['remove-node']), 'node')}`);
|
|
561
|
+
if (n(['remove-edge'])) parts.push(`\u2212${unit(n(['remove-edge']), 'edge')}`);
|
|
562
|
+
const steps = n(['add-step', 'reword-step', 'delete-step', 'move-step']);
|
|
563
|
+
if (steps) parts.push(`${unit(steps, 'step')} changed`);
|
|
564
|
+
const rest = list.length - n(['add-node', 'add-edge', 'remove-node', 'remove-edge', 'add-step', 'reword-step', 'delete-step', 'move-step']);
|
|
565
|
+
if (rest > 0) parts.push(unit(rest, 'other edit'));
|
|
566
|
+
return `yours: ${parts.join(', ')}${hidden ? ' (hidden)' : ''}`;
|
|
567
|
+
}
|
package/explorer/proposal.js
CHANGED
|
@@ -29,6 +29,7 @@ import { looksWith, onMapStyleChange } from './map-style.js';
|
|
|
29
29
|
import {
|
|
30
30
|
PROPOSAL_VIEWS, MARK_WORDS, chipText, barCounts, parseProposalQuery, proposalPanelHtml, touchedIds, viewWords, jumpWords,
|
|
31
31
|
sourceChip, pullNumberOf, notFoundWords, otherCopies, malformedLinkWords,
|
|
32
|
+
yoursText,
|
|
32
33
|
} from './proposal-model.js';
|
|
33
34
|
import { renderReviewColumn, reviewOpenedLine, showSection, setPullHead } from './review-column.js';
|
|
34
35
|
import { applyProposal, edgeKey, proposalProblems, summarize } from '../core/proposal.js';
|
|
@@ -122,7 +123,8 @@ export async function openProposal(slug, source = null) {
|
|
|
122
123
|
const found = res.headers.get('X-Proposal-Source');
|
|
123
124
|
let item;
|
|
124
125
|
try { item = await res.json(); } catch { throw new Error(`${slug} could not be opened: cornfield sent a file this page could not read.`); }
|
|
125
|
-
|
|
126
|
+
const sha256 = res.headers.get('X-Proposal-Sha256'); // the version on screen: a review names it, so a push since is refused, not approved unseen
|
|
127
|
+
showProposal(item, { slug, source: source || (found ? decodeURIComponent(found) : null), pinSource: !!source, view: 'diff', fit: true, sha256 });
|
|
126
128
|
// said once, here: a proposal opens on a person's asking, never on a background refresh
|
|
127
129
|
announce(reviewOpenedLine($('proposal-title').textContent));
|
|
128
130
|
return true;
|
|
@@ -148,14 +150,16 @@ let openToken = 0;
|
|
|
148
150
|
/**
|
|
149
151
|
* Puts a parsed proposal on the map. The map's nodes and edges become `applyProposal(base, proposal)`.
|
|
150
152
|
* @param {object} proposal
|
|
151
|
-
* @param {{slug?: string|null, source?: string|null, pinSource?: boolean, view?: 'before'|'diff'|'after', fit?: boolean}} [opts]
|
|
153
|
+
* @param {{slug?: string|null, source?: string|null, pinSource?: boolean, view?: 'before'|'diff'|'after', fit?: boolean, sha256?: string|null}} [opts]
|
|
154
|
+
* `sha256`: the file's SHA-256 as the server sent it (X-Proposal-Sha256): a review names it (spec 0007)
|
|
152
155
|
* `fit`: fit the camera to what the proposal touches and what it connects to (default true).
|
|
153
156
|
* `pinSource`: put `&source=` in the address (it was asked for by name; otherwise `/?proposal=<slug>` finds the same one)
|
|
154
157
|
*/
|
|
155
|
-
export function showProposal(proposal, { slug = null, source = null, pinSource = false, view, fit = true } = {}) {
|
|
158
|
+
export function showProposal(proposal, { slug = null, source = null, pinSource = false, view, fit = true, sha256 = null } = {}) {
|
|
156
159
|
state.proposal = proposal;
|
|
157
160
|
state.proposalSlug = slug;
|
|
158
161
|
state.proposalSource = source;
|
|
162
|
+
state.proposalSha256 = typeof sha256 === 'string' && /^[0-9a-f]{64}$/.test(sha256) ? sha256 : null;
|
|
159
163
|
pinnedSource = pinSource;
|
|
160
164
|
if (view) state.proposalView = view;
|
|
161
165
|
else if (!PROPOSAL_VIEWS.includes(state.proposalView)) state.proposalView = 'diff';
|
|
@@ -198,6 +202,7 @@ export function closeProposal() {
|
|
|
198
202
|
state.effectiveProposal = null;
|
|
199
203
|
state.proposalSlug = null;
|
|
200
204
|
state.proposalSource = null;
|
|
205
|
+
state.proposalSha256 = null;
|
|
201
206
|
state.proposalErrors = [];
|
|
202
207
|
swapMap(state.baseNodes.map((n) => ({ ...n })), state.baseEdges);
|
|
203
208
|
fitGraphToViewport(fitPadding());
|
|
@@ -371,6 +376,9 @@ export function renderBar() {
|
|
|
371
376
|
if (!c.mark && /scenarios?$/.test(c.text)) return `<button type="button" class="hx-proposal-count" data-action="review-show-scenarios" data-corn-kind="quiet" title="Show the personas and their scenarios">${escHtml(c.text)}</button>`;
|
|
372
377
|
return `<button type="button" class="hx-proposal-count" data-action="review-show-changes" data-corn-kind="quiet" title="Show the list of changes">${dot}${escHtml(c.text)}</button>`;
|
|
373
378
|
}).join('<span class="hx-proposal-sep" aria-hidden="true"> · </span>');
|
|
379
|
+
// The reviewer's own edits are a part of their own, never added to the proposal's numbers (spec 0007 D5)
|
|
380
|
+
const yours = yoursText(state.whatIf && state.whatIf.edits, !!state.whatIfOff);
|
|
381
|
+
if (yours) chip.insertAdjacentHTML('beforeend', `<span class="hx-proposal-sep" aria-hidden="true"> · </span><span class="hx-proposal-count hx-proposal-yours"><span class="hx-mark-dot hx-mark-dot--edit" data-corn="mark-dot" data-corn-state="edit" aria-hidden="true"></span>${escHtml(yours)}</span>`);
|
|
374
382
|
$('proposal-mode').textContent = t(state.proposalView);
|
|
375
383
|
|
|
376
384
|
for (const btn of bar.querySelectorAll('[data-action="proposal-view"]')) {
|
|
@@ -394,14 +402,13 @@ export function renderBar() {
|
|
|
394
402
|
* Picks a row of the changes list: select it, centre it in the part of the map the review column, the node panel and (on a phone) the sheets leave free,
|
|
395
403
|
* at a zoom where its label reads, and make sure the current view shows it
|
|
396
404
|
*/
|
|
397
|
-
function focusChange(kind, key) {
|
|
405
|
+
export function focusChange(kind, key, { select = true } = {}) {
|
|
398
406
|
const item = kind === 'edge' ? state.edges.find((e) => edgeKey(e) === key) : state.nodes.find((n) => n.id === key);
|
|
399
407
|
if (!item) return;
|
|
400
408
|
const ends = (kind === 'edge' ? [state.nodes.find((n) => n.id === item.from), state.nodes.find((n) => n.id === item.to)] : [item]).filter(Boolean);
|
|
401
409
|
if (!ends.length) return;
|
|
402
410
|
if (state.proposalView !== 'diff' && ends.some((n) => !isNodeVisible(n))) setProposalView('diff', { quiet: true }); // Before or After hides what it removes or adds
|
|
403
|
-
if (kind === 'edge') showEdgePanel(item);
|
|
404
|
-
else selectNode(item);
|
|
411
|
+
if (select) { if (kind === 'edge') showEdgePanel(item); else selectNode(item); }
|
|
405
412
|
// The panel is open now, so what it covers is known
|
|
406
413
|
const cam = frameNodes(ends, visibleMapRect(), { padding: fitPadding(), maxZoom: Math.max(READ_ZOOM, state.camera.zoom), minZoom: getMinZoom() });
|
|
407
414
|
if (cam) Object.assign(state.camera, cam);
|
package/explorer/render.js
CHANGED
|
@@ -172,10 +172,28 @@ function paint() {
|
|
|
172
172
|
getRenderer().draw(scene, state.camera, performance.now());
|
|
173
173
|
// The labels repaint only when the camera, the scene or the size changed, never on a packet frame
|
|
174
174
|
const labels = getLabelLayer();
|
|
175
|
-
if (labels) labels.draw(scene, state.camera);
|
|
175
|
+
if (labels) labels.draw(scene, state.camera, { hover: state.hoverNodeId });
|
|
176
176
|
paintHooks.forEach((fn) => fn(scene, state.camera));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
/** The node whose label is drawn under a screen point, or null (labels.js `hit`): a cluster's title frames the cluster */
|
|
180
|
+
export function labelNodeAt(x, y) {
|
|
181
|
+
const labels = getLabelLayer();
|
|
182
|
+
return labels ? labels.hit(x, y) : null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The node the pointer is on (or null): a node with no label is named by a chip over the map while it is. Only the label layer
|
|
187
|
+
* draws again (the map has nothing new to show), so moving across the map costs one small redraw per node entered.
|
|
188
|
+
*/
|
|
189
|
+
export function setHoverNode(id) {
|
|
190
|
+
const next = id || null;
|
|
191
|
+
if (state.hoverNodeId === next) return;
|
|
192
|
+
state.hoverNodeId = next;
|
|
193
|
+
const labels = getLabelLayer();
|
|
194
|
+
if (labels && state.canvas && state.width) labels.draw(getScene(), state.camera, { hover: next });
|
|
195
|
+
}
|
|
196
|
+
|
|
179
197
|
/** Things drawn over the map by the page itself (the runs' marks, explorer/runs-map.js): called after each draw with the scene and the camera */
|
|
180
198
|
const paintHooks = new Set();
|
|
181
199
|
export function onPaint(fn) {
|
|
@@ -111,16 +111,19 @@ function model() {
|
|
|
111
111
|
return buildScenarioList({ scenarios: scenariosNow(), nodes: state.nodes, edges: state.edges, proposal, verdicts, seen: ui.seen, words, hidden });
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** The proposal's own changes: the reviewer's what-if edits are a group of their own (spec 0007 D5), never counted into them */
|
|
115
|
+
const theirRows = (proposal) => changeRows(state.nodes, state.edges, proposal).filter((r) => r.mark !== 'edit');
|
|
116
|
+
|
|
114
117
|
/** What opening a proposal says: "Opened Checkout: 6 changes, 3 scenarios for 2 personas." */
|
|
115
118
|
export function reviewOpenedLine(title) {
|
|
116
119
|
const proposal = state.effectiveProposal || state.proposal;
|
|
117
|
-
return reviewOpenedWords(title,
|
|
120
|
+
return reviewOpenedWords(title, theirRows(proposal).length, model());
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
/** The phone's peek line: "6 changes · 3 scenarios for 2 personas" */
|
|
121
124
|
export function reviewPeekLine() {
|
|
122
125
|
const proposal = state.effectiveProposal || state.proposal;
|
|
123
|
-
return reviewCounts(
|
|
126
|
+
return reviewCounts(theirRows(proposal).length, model());
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
// ---------------------------------------------------------------------------
|
|
@@ -167,7 +170,9 @@ function groupHtml(g) {
|
|
|
167
170
|
/** Everything the two lists say, as markup (the foot is static in index.html) */
|
|
168
171
|
function listsHtml() {
|
|
169
172
|
const proposal = state.effectiveProposal || state.proposal;
|
|
170
|
-
const
|
|
173
|
+
const everyRow = changeRows(state.nodes, state.edges, proposal);
|
|
174
|
+
const rows = everyRow.filter((r) => r.mark !== 'edit');
|
|
175
|
+
const mine = everyRow.filter((r) => r.mark === 'edit'); // "Your edits · 1": the first group, not the last row
|
|
171
176
|
const list = model();
|
|
172
177
|
const phone = isPhone();
|
|
173
178
|
// the phone's tab: the reviewer's last choice, or Scenarios when there are any; a proposal with none opens on its changes
|
|
@@ -181,6 +186,7 @@ function listsHtml() {
|
|
|
181
186
|
|
|
182
187
|
const changes = `<section id="rc-changes" class="hx-rc-section" data-corn="proposal-changes"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-changes"${tab === 'changes' ? '' : ' hidden'}` : ' aria-labelledby="rc-changes-h"'}>`
|
|
183
188
|
+ `<h3 id="rc-changes-h" class="hx-rc-h" tabindex="-1">${countHeading(t('changes'), rows.length)}</h3>`
|
|
189
|
+
+ (mine.length ? `<h4 class="hx-rc-sub">${countHeading(t('yourEdits'), mine.length)}</h4><ul class="hx-change-list">${mine.map(changeRowHtml).join('')}</ul>` : '')
|
|
184
190
|
+ (rows.length ? `<ul class="hx-change-list">${rows.map(changeRowHtml).join('')}</ul>` : '<p class="hx-faint hx-rc-empty">This proposal changes nothing on the map.</p>')
|
|
185
191
|
+ '</section>';
|
|
186
192
|
|
|
@@ -190,7 +196,6 @@ function listsHtml() {
|
|
|
190
196
|
body = list.groups.map(groupHtml).join('');
|
|
191
197
|
if (!personas) body += `<p class="hx-faint hx-rc-note">This map has no personas (topology.personas.json), so every scenario is listed under ${escHtml(t('anyone'))}.</p>`;
|
|
192
198
|
if (list.coverage) body += `<p class="hx-rc-coverage" data-corn="notice">${escHtml(t('notInAnyScenario'))}: ${list.notInAny.map(escHtml).join(', ')}</p>`;
|
|
193
|
-
if (list.playedLine) body += `<p class="hx-faint hx-rc-note" data-corn="notice">${escHtml(list.playedLine)}</p>`;
|
|
194
199
|
}
|
|
195
200
|
const scenarios = `<section id="rc-scenarios" class="hx-rc-section" data-corn="scenario-list"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-scenarios"${tab === 'scenarios' ? '' : ' hidden'}` : ' aria-labelledby="rc-scenarios-h"'}>`
|
|
196
201
|
+ `<h3 id="rc-scenarios-h" class="hx-rc-h" tabindex="-1">${countHeading(t('personasAndScenarios'), list.total)}</h3><div class="hx-rc-sbody">${body}</div></section>`;
|
|
@@ -254,6 +259,18 @@ export function shareRoom() {
|
|
|
254
259
|
col.style.setProperty('--hx-changes-max', `${Math.floor(Math.max(0.4 * h, h - need - gap))}px`);
|
|
255
260
|
}
|
|
256
261
|
|
|
262
|
+
/** "2 of 3 scenarios played", or '': the decision line says it (spec 0007 D1; it used to sit under the scenario list) */
|
|
263
|
+
export function playedLine() {
|
|
264
|
+
return state.proposal ? model().playedLine : '';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const paintWatchers = new Set();
|
|
268
|
+
/** `fn()` after the lists are drawn again: the decision line follows what was played */
|
|
269
|
+
export function onReviewColumnPaint(fn) {
|
|
270
|
+
paintWatchers.add(fn);
|
|
271
|
+
return () => paintWatchers.delete(fn);
|
|
272
|
+
}
|
|
273
|
+
|
|
257
274
|
function repaint() {
|
|
258
275
|
const lists = $('review-lists');
|
|
259
276
|
const col = $('review-column');
|
|
@@ -277,6 +294,7 @@ function repaint() {
|
|
|
277
294
|
if (again) again.focus();
|
|
278
295
|
}
|
|
279
296
|
shareRoom();
|
|
297
|
+
for (const fn of paintWatchers) fn();
|
|
280
298
|
}
|
|
281
299
|
|
|
282
300
|
// ---------------------------------------------------------------------------
|