@popcorn245/cornfield 0.28.0 → 0.29.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/strings.js +2 -1
- package/explorer/explorer.css +64 -17
- package/explorer/index.html +21 -5
- package/explorer/proposal-model.js +13 -0
- package/explorer/proposal.js +66 -6
- package/explorer/review.js +65 -19
- package/explorer/scenario-ui.js +26 -7
- package/explorer/sheets.js +1 -1
- package/explorer/whatif.js +20 -3
- package/package.json +1 -1
package/core/strings.js
CHANGED
|
@@ -28,8 +28,9 @@ export const STRINGS = Object.freeze({
|
|
|
28
28
|
closeProposal: 'Close',
|
|
29
29
|
approve: 'Approve',
|
|
30
30
|
sendBack: 'Send back',
|
|
31
|
+
sendBackWithNote: 'Send back with this note',
|
|
31
32
|
reviewNoteLabel: 'Note for the drafting agent',
|
|
32
|
-
reviewNotePlaceholder: 'What should change?
|
|
33
|
+
reviewNotePlaceholder: 'What should change?',
|
|
33
34
|
// The issues and pull requests panel
|
|
34
35
|
tabPulls: 'Pull requests',
|
|
35
36
|
tabIssues: 'Issues',
|
package/explorer/explorer.css
CHANGED
|
@@ -335,20 +335,16 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
335
335
|
.hx-proposal-meta { display: flex; flex-wrap: wrap; gap: calc(var(--corn-space-1) / 2) var(--corn-space-3); color: var(--corn-text-3); font-size: var(--corn-text-2xs); }
|
|
336
336
|
.hx-proposal-where { color: var(--corn-added-text); }
|
|
337
337
|
|
|
338
|
-
.hx-proposal-bar { position: absolute; top: 48px; left: 12px; width: min(
|
|
338
|
+
.hx-proposal-bar { position: absolute; top: 48px; left: 12px; width: min(960px, calc(100% - 24px)); padding: var(--corn-space-3) var(--corn-space-3); border-radius: var(--corn-radius-lg); font-size: var(--corn-text-sm); z-index: 15; user-select: text; }
|
|
339
339
|
.hx-proposal-bar.is-error { border-color: color-mix(in srgb, var(--corn-removed) 50%, transparent); }
|
|
340
340
|
.hx-proposal-message { color: var(--corn-text-2); }
|
|
341
341
|
.hx-proposal-bar.is-error .hx-proposal-message { color: var(--corn-bad); }
|
|
342
|
-
.hx-proposal-
|
|
343
|
-
.hx-proposal-name { flex: 1 1 140px; min-width: 0; font-size: var(--corn-text-md); color: var(--corn-text); overflow-wrap: anywhere; }
|
|
344
|
-
.hx-proposal-chip { padding: var(--corn-space-1) var(--corn-space-3); border-radius: var(--corn-radius-lg); border: var(--corn-border) solid var(--corn-line); background: color-mix(in srgb, var(--corn-ground) 55%, transparent); color: var(--corn-text-2); font-size: var(--corn-text-xs); font-variant-numeric: tabular-nums; }
|
|
345
|
-
.hx-proposal-chip:hover { background: var(--corn-surface-3); color: var(--corn-text); }
|
|
346
|
-
.hx-proposal-chip:focus-visible, .hx-seg-btn:focus-visible, .hx-change-row:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: 2px; }
|
|
342
|
+
.hx-proposal-chip:focus-visible, .hx-proposal-mode:focus-visible, .hx-seg-btn:focus-visible, .hx-change-row:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: 2px; }
|
|
347
343
|
.hx-proposal-summary { margin-top: var(--corn-space-2); color: var(--corn-text-2); line-height: 1.45; }
|
|
348
344
|
|
|
349
345
|
/* Before / Diff / After */
|
|
350
346
|
.hx-seg { display: inline-flex; padding: calc(var(--corn-space-1) / 2); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: color-mix(in srgb, var(--corn-ground) 55%, transparent); }
|
|
351
|
-
.hx-seg-btn { padding:
|
|
347
|
+
.hx-seg-btn { height: 26px; padding: 0 var(--corn-space-4); border: 0; border-radius: var(--corn-radius-sm); background: none; color: var(--corn-text-3); font-size: var(--corn-text-sm); font-weight: 500; }
|
|
352
348
|
.hx-seg-btn:hover { color: var(--corn-text); }
|
|
353
349
|
.hx-seg-btn.is-on, .hx-seg-btn[aria-pressed="true"] { background: var(--corn-accent); color: var(--corn-text-on-accent); box-shadow: var(--corn-shadow-sm); }
|
|
354
350
|
|
|
@@ -385,11 +381,10 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
385
381
|
.hx-change em { color: var(--corn-text-3); text-decoration: none; }
|
|
386
382
|
|
|
387
383
|
/* The node panel is a 480px slide-over from 768px: the bar makes room for it */
|
|
388
|
-
@media (min-width: 768px) { .hx-stage:has(.drawer-open) .hx-proposal-bar { width: min(
|
|
384
|
+
@media (min-width: 768px) { .hx-stage:has(.drawer-open) .hx-proposal-bar { width: min(960px, calc(100% - 504px)); } }
|
|
389
385
|
|
|
390
386
|
@media (max-width: 639px) {
|
|
391
387
|
.hx-menu--proposals { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; max-width: none; }
|
|
392
|
-
.hx-seg-btn { padding: var(--corn-space-1) var(--corn-space-4); }
|
|
393
388
|
}
|
|
394
389
|
|
|
395
390
|
/* ---- scenario player (scenario-ui.js): the bar while a scenario plays, and the scenario list --------- */
|
|
@@ -410,7 +405,6 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
410
405
|
.hx-player-fill { display: block; height: 100%; width: 0; background: var(--corn-accent-text); }
|
|
411
406
|
|
|
412
407
|
.hx-scenarios { position: absolute; top: 12px; left: 12px; max-width: min(320px, calc(100% - 24px)); padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius); font-size: var(--corn-text-sm); color: var(--corn-text-2); z-index: 12; }
|
|
413
|
-
.hx-scenarios summary { cursor: pointer; font-weight: 600; }
|
|
414
408
|
.hx-scenarios-item { display: block; width: 100%; margin-top: var(--corn-space-2); padding: var(--corn-space-2) var(--corn-space-3); border: var(--corn-border) solid var(--corn-line-soft); border-radius: var(--corn-radius-sm); background: transparent; color: var(--corn-text); font-size: var(--corn-text-sm); text-align: left; cursor: pointer; }
|
|
415
409
|
.hx-scenarios-item:hover { background: color-mix(in srgb, var(--corn-accent-hover) 25%, transparent); }
|
|
416
410
|
/* With a proposal open the list is a row of its bar (scenario-ui.js mounts it there), so it opens in the bar's flow and the bar grows to hold it */
|
|
@@ -455,21 +449,75 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
455
449
|
.hx-rubber svg { display: block; overflow: visible; }
|
|
456
450
|
.hx-rubber-line { stroke: var(--corn-edit); stroke-width: 3; stroke-dasharray: 8 6; stroke-linecap: round; }
|
|
457
451
|
.hx-rubber-from, .hx-rubber-to { fill: color-mix(in srgb, var(--corn-edit) 15%, transparent); stroke: var(--corn-edit); stroke-width: 2; }
|
|
458
|
-
/*
|
|
459
|
-
|
|
460
|
-
.hx-review
|
|
452
|
+
/* The review (review.js, TOPO-12): the status line and the note that opens on Send back. It is in the toolbar, just before Send back and
|
|
453
|
+
Approve (the note's Tab goes on to them); from 768px it takes a row of its own under the toolbar, on a phone it sits under the counts */
|
|
454
|
+
.hx-review { flex: 1 0 100%; order: 1; display: flex; flex-direction: column; gap: var(--corn-space-2); }
|
|
455
|
+
.hx-review[hidden], .hx-review:not(:has(> :not([hidden]))) { display: none; }
|
|
456
|
+
.hx-review-form { display: flex; flex-direction: column; gap: var(--corn-space-2); }
|
|
457
|
+
.hx-review-form[hidden] { display: none; }
|
|
461
458
|
.hx-review-label { color: var(--corn-text-3); font-size: var(--corn-text-xs); }
|
|
462
459
|
.hx-review-note { width: 100%; min-height: 44px; resize: vertical; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); color: var(--corn-text); font: inherit; font-size: var(--corn-text-sm); line-height: 1.4; user-select: text; }
|
|
463
460
|
.hx-review-note:focus { outline: var(--corn-focus-width) solid var(--corn-added-text); outline-offset: 1px; }
|
|
464
461
|
.hx-review-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-2) var(--corn-space-3); }
|
|
465
|
-
.hx-review .hx-btn:disabled { opacity: 0.4; cursor: default; }
|
|
466
462
|
.hx-btn--approve { border-color: color-mix(in srgb, var(--corn-added) 50%, transparent); color: var(--corn-added-text); }
|
|
467
463
|
.hx-btn--approve:hover { background: color-mix(in srgb, var(--corn-added) 20%, transparent); color: var(--corn-added-text); }
|
|
468
|
-
.hx-review-status { color: var(--corn-added-text); font-variant-numeric: tabular-nums; }
|
|
464
|
+
.hx-review-status { margin: 0; color: var(--corn-added-text); font-variant-numeric: tabular-nums; }
|
|
469
465
|
.hx-review-status[hidden], .hx-review-msg[hidden], .hx-review-line[hidden] { display: none; }
|
|
470
466
|
.hx-review-msg { margin: 0; padding: var(--corn-space-1) var(--corn-space-3); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-removed) 12%, transparent); border: var(--corn-border) solid color-mix(in srgb, var(--corn-removed) 35%, transparent); color: var(--corn-bad); line-height: 1.4; }
|
|
471
467
|
.hx-review-line { margin: 0; color: var(--corn-text-2); line-height: 1.4; }
|
|
472
468
|
.hx-proposal-reviewed { color: var(--corn-added-text); }
|
|
469
|
+
/* ---- The proposal toolbar (CF-43): proposal.js, review.js, whatif.js, scenario-ui.js ----------------
|
|
470
|
+
One row from 768px: title, counts (they open the change list), Before / Diff / After, Play, Edit, then Send back,
|
|
471
|
+
Approve (the primary) and a ⋯ menu with Close. The what-if controls sit behind Edit, the scenario list behind Play,
|
|
472
|
+
and the review note opens under the row on Send back. On a phone the row is a sheet: the title, the counts with
|
|
473
|
+
the current mode (a button that opens the switcher), the note when it is open, and Send back and Approve full
|
|
474
|
+
width, each 44px tall. */
|
|
475
|
+
.hx-proposal-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-3) var(--corn-space-4); }
|
|
476
|
+
.hx-proposal-name { flex: 0 1 auto; min-width: 0; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--corn-text-base); font-weight: 650; color: var(--corn-text); }
|
|
477
|
+
.hx-proposal-counts { display: contents; }
|
|
478
|
+
.hx-proposal-chip { display: inline-flex; align-items: center; padding: var(--corn-space-1) var(--corn-space-2); border: 0; border-radius: var(--corn-radius-sm); background: none; color: var(--corn-text-2); font-size: var(--corn-text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
479
|
+
.hx-proposal-chip:hover { color: var(--corn-text); text-decoration: underline; }
|
|
480
|
+
.hx-proposal-chip .hx-mark-dot { margin: 0 var(--corn-space-2) 0 0; }
|
|
481
|
+
.hx-proposal-sep { margin: 0 var(--corn-space-2); color: var(--corn-text-3); }
|
|
482
|
+
.hx-proposal-mode { display: none; }
|
|
483
|
+
.hx-proposal-tools, .hx-proposal-actions { display: flex; align-items: center; gap: var(--corn-space-3); }
|
|
484
|
+
.hx-proposal-tools .hx-btn { height: 30px; font-size: var(--corn-text-sm); font-weight: 500; }
|
|
485
|
+
#proposal-play[aria-expanded="true"] { background: var(--corn-surface-3); color: var(--corn-text); }
|
|
486
|
+
#proposal-edit.hx-btn--active { background: var(--corn-edit-text); border-color: var(--corn-edit); color: var(--corn-ground); }
|
|
487
|
+
.hx-proposal-actions { margin-left: auto; }
|
|
488
|
+
.hx-proposal-actions .hx-btn { height: 32px; justify-content: center; padding: 0 var(--corn-space-5); font-size: var(--corn-text-sm); font-weight: 500; }
|
|
489
|
+
.hx-proposal-actions .hx-btn--approve, .hx-proposal-actions .hx-btn--approve:hover { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); font-weight: 600; }
|
|
490
|
+
.hx-proposal-actions .hx-btn:disabled { opacity: 0.4; cursor: default; }
|
|
491
|
+
.hx-proposal-more { position: relative; }
|
|
492
|
+
.hx-proposal-more .hx-btn--icon { width: 32px; height: 32px; border-color: transparent; background: none; color: var(--corn-text-3); }
|
|
493
|
+
.hx-proposal-more .hx-btn--icon:hover, .hx-proposal-more .hx-btn--icon[aria-expanded="true"] { background: var(--corn-surface-3); color: var(--corn-text); }
|
|
494
|
+
.hx-proposal-more-menu { position: absolute; top: 100%; right: 0; z-index: 20; display: flex; flex-direction: column; min-width: 160px; margin-top: var(--corn-space-2); padding: var(--corn-space-2); border-radius: var(--corn-radius); border: var(--corn-border) solid var(--corn-line); box-shadow: var(--corn-shadow); }
|
|
495
|
+
.hx-proposal-more-menu[hidden] { display: none; }
|
|
496
|
+
.hx-proposal-more-menu .hx-btn { width: 100%; height: 32px; border-color: transparent; background: none; color: var(--corn-text-2); font-size: var(--corn-text-sm); }
|
|
497
|
+
.hx-proposal-more-menu .hx-btn:hover { background: var(--corn-surface-3); color: var(--corn-text); }
|
|
498
|
+
|
|
499
|
+
@media (max-width: 767px) {
|
|
500
|
+
.hx-proposal-head { display: grid; grid-template-columns: 1fr auto; gap: var(--corn-space-2) var(--corn-space-3); }
|
|
501
|
+
.hx-proposal-name { grid-column: 1 / -1; order: 1; max-width: none; }
|
|
502
|
+
.hx-proposal-counts { display: flex; grid-column: 1 / -1; order: 2; align-items: center; flex-wrap: wrap; column-gap: var(--corn-space-2); }
|
|
503
|
+
.hx-proposal-chip, .hx-proposal-mode { min-height: 44px; }
|
|
504
|
+
.hx-proposal-mode { display: inline-flex; align-items: center; gap: var(--corn-space-2); padding: 0 var(--corn-space-3); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); color: var(--corn-text); font-size: var(--corn-text-sm); font-weight: 600; }
|
|
505
|
+
.hx-proposal-mode::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 var(--corn-border-strong) var(--corn-border-strong) 0; transform: translateY(-2px) rotate(45deg); }
|
|
506
|
+
.hx-proposal-mode[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
|
|
507
|
+
.hx-seg, .hx-review { grid-column: 1 / -1; order: 3; }
|
|
508
|
+
.hx-proposal-bar:not([data-mode-open="true"]) .hx-seg { display: none; }
|
|
509
|
+
.hx-seg-btn { flex: 1; height: 44px; font-size: var(--corn-text-md); }
|
|
510
|
+
.hx-proposal-actions { grid-column: 1 / -1; order: 4; display: grid; grid-template-columns: 1fr 1fr; margin-left: 0; gap: var(--corn-space-3); }
|
|
511
|
+
.hx-proposal-actions .hx-btn { height: auto; min-height: 44px; padding: var(--corn-space-2) var(--corn-space-3); white-space: normal; text-align: center; font-size: var(--corn-text-md); }
|
|
512
|
+
.hx-proposal-tools { order: 5; }
|
|
513
|
+
.hx-proposal-tools .hx-btn { height: auto; min-height: 44px; padding: 0 var(--corn-space-5); font-size: var(--corn-text-md); }
|
|
514
|
+
.hx-proposal-more { display: contents; }
|
|
515
|
+
.hx-proposal-more .hx-btn--icon { order: 6; width: 44px; height: 44px; }
|
|
516
|
+
.hx-proposal-more-menu { position: static; grid-column: 1 / -1; order: 7; box-shadow: none; }
|
|
517
|
+
.hx-proposal-more-menu .hx-btn { height: auto; min-height: 44px; font-size: var(--corn-text-md); }
|
|
518
|
+
.hx-scenarios-item, .hx-review .hx-btn, .hx-whatif .hx-btn { min-height: 44px; }
|
|
519
|
+
}
|
|
520
|
+
|
|
473
521
|
/* A proposal's mockups (mockups.js): the buttons in a node's panel and the window one opens in. A mockup is untrusted content, shown in an <img> or a sandboxed <iframe>. */
|
|
474
522
|
.hx-mockup-list { list-style: none; margin: var(--corn-space-1) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--corn-space-2); }
|
|
475
523
|
.hx-mockup-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-1) var(--corn-space-3); }
|
|
@@ -516,8 +564,7 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
516
564
|
.hx-proposal-bar { max-height: 50dvh; overflow-y: auto; padding: 0 var(--corn-space-4) var(--corn-space-3); }
|
|
517
565
|
.hx-proposal-bar[data-sheet-state="peek"] > :not(.hx-sheet-handle):not(#proposal-message):not(#proposal-body),
|
|
518
566
|
.hx-proposal-bar[data-sheet-state="peek"] #proposal-body > :not(.hx-proposal-head),
|
|
519
|
-
.hx-proposal-bar[data-sheet-state="peek"] .hx-proposal-head > :
|
|
520
|
-
.hx-proposal-bar[data-sheet-state="peek"] .hx-proposal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
567
|
+
.hx-proposal-bar[data-sheet-state="peek"] .hx-proposal-head > :is(.hx-proposal-tools, .hx-proposal-more, .hx-proposal-more-menu, .hx-review) { display: none; }
|
|
521
568
|
.hx-proposal-bar[data-sheet-state="expanded"] .hx-scenarios, .hx-proposal-bar[data-sheet-state="expanded"] .hx-proposal-changes, .hx-proposal-bar[data-sheet-state="expanded"] .hx-whatif-panel { max-height: none; overflow: visible; }
|
|
522
569
|
|
|
523
570
|
/* The scenario player: the title, then the step counter and its text on two lines */
|
package/explorer/index.html
CHANGED
|
@@ -193,19 +193,35 @@
|
|
|
193
193
|
|
|
194
194
|
<!-- Below 768px the proposal bar, the scenario player and the node panel stack here as bottom sheets (sheets.js); from 768px the dock is display: contents -->
|
|
195
195
|
<div id="sheet-dock" class="hx-dock" data-corn="dock">
|
|
196
|
-
<!-- The open proposal: counts, Before / Diff / After,
|
|
196
|
+
<!-- The open proposal, a toolbar: title, counts, Before / Diff / After, Play, Edit, Send back, Approve, ⋯ (proposal.js, review.js, whatif.js, scenario-ui.js) -->
|
|
197
197
|
<section id="proposal-bar" class="hx-proposal-bar glass" aria-label="Open proposal" hidden data-corn="proposal-bar">
|
|
198
198
|
<p id="proposal-message" class="hx-proposal-message" role="status" hidden></p>
|
|
199
199
|
<div id="proposal-body">
|
|
200
|
-
<div class="hx-proposal-head">
|
|
200
|
+
<div class="hx-proposal-head" role="group" aria-label="Proposal actions">
|
|
201
201
|
<strong id="proposal-title" class="hx-proposal-name"></strong>
|
|
202
|
-
<
|
|
203
|
-
|
|
202
|
+
<div class="hx-proposal-counts">
|
|
203
|
+
<button type="button" id="proposal-chip" class="hx-proposal-chip" data-action="toggle-proposal-changes" aria-expanded="false"></button>
|
|
204
|
+
<button type="button" id="proposal-mode" class="hx-proposal-mode" data-action="toggle-proposal-mode" data-peek-ok aria-expanded="false" aria-controls="proposal-seg" title="Before, Diff or After"></button>
|
|
205
|
+
</div>
|
|
206
|
+
<div id="proposal-seg" class="hx-seg" role="group" aria-label="Compare">
|
|
204
207
|
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="before" aria-pressed="false" data-corn-string="before">Before</button>
|
|
205
208
|
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="diff" aria-pressed="true" data-corn-string="diff">Diff</button>
|
|
206
209
|
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false" data-corn-string="after">After</button>
|
|
207
210
|
</div>
|
|
208
|
-
<
|
|
211
|
+
<div class="hx-proposal-tools">
|
|
212
|
+
<button type="button" id="proposal-play" class="hx-btn" aria-expanded="false" aria-controls="proposal-scenarios" title="Play one of this proposal's scenarios on the map" hidden>Play</button>
|
|
213
|
+
<button type="button" id="proposal-edit" class="hx-btn" aria-expanded="false" aria-controls="whatif" title="Try a change: add a node or an edge, reword a scenario">Edit</button>
|
|
214
|
+
</div>
|
|
215
|
+
<div class="hx-proposal-actions">
|
|
216
|
+
<button type="button" class="hx-btn" data-review="notes" data-peek-ok title="Send it back to the drafting agent with a note and your edits" data-corn-string="sendBack">Send back</button>
|
|
217
|
+
<button type="button" class="hx-btn hx-btn--approve" data-review="approved" data-peek-ok title="Sign this proposal off" data-corn-kind="approve" data-corn-string="approve">Approve</button>
|
|
218
|
+
</div>
|
|
219
|
+
<div class="hx-proposal-more">
|
|
220
|
+
<button type="button" id="proposal-more" class="hx-btn hx-btn--icon" data-action="toggle-proposal-more" aria-haspopup="menu" aria-expanded="false" aria-controls="proposal-more-menu" aria-label="More" data-corn-kind="icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="3" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="13" cy="8" r="1.5"/></svg></button>
|
|
221
|
+
<div id="proposal-more-menu" class="hx-proposal-more-menu glass" role="menu" aria-label="More" hidden>
|
|
222
|
+
<button type="button" role="menuitem" class="hx-btn hx-btn--quiet" data-action="close-proposal" title="Close the proposal and go back to the map" data-corn-kind="quiet" data-corn-string="closeProposal">Close</button>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
209
225
|
</div>
|
|
210
226
|
<p id="proposal-summary" class="hx-proposal-summary" hidden></p>
|
|
211
227
|
<details id="proposal-errors" class="hx-proposal-errors" hidden>
|
|
@@ -109,6 +109,19 @@ export function chipText(counts) {
|
|
|
109
109
|
return parts.length ? parts.join(' · ') : 'No changes';
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The counts on the toolbar as parts, so each mark can carry its dot: "+4 added", "1 changed", "1 removed", then
|
|
114
|
+
* "3 scenarios". Zero counts are left out; nothing at all reads "No changes".
|
|
115
|
+
* @param {{added?:number, changed?:number, removed?:number, scenarios?:number}} counts `summarize(proposal)`
|
|
116
|
+
* @returns {{mark: string|null, text: string}[]}
|
|
117
|
+
*/
|
|
118
|
+
export function barCounts(counts) {
|
|
119
|
+
const n = (k) => counts?.[k] || 0;
|
|
120
|
+
const parts = MARKS.filter((m) => n(m) > 0).map((m) => ({ mark: m, text: `${m === 'added' ? '+' : ''}${n(m)} ${m}` }));
|
|
121
|
+
if (n('scenarios') > 0) parts.push({ mark: null, text: `${n('scenarios')} ${n('scenarios') === 1 ? 'scenario' : 'scenarios'}` });
|
|
122
|
+
return parts.length ? parts : [{ mark: null, text: 'No changes' }];
|
|
123
|
+
}
|
|
124
|
+
|
|
112
125
|
const SLUG = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
113
126
|
|
|
114
127
|
/**
|
package/explorer/proposal.js
CHANGED
|
@@ -26,7 +26,7 @@ import { edgePoint, looksFor } from './scene.js';
|
|
|
26
26
|
import { onThemeChange } from './theme.js';
|
|
27
27
|
import { looksWith, onMapStyleChange } from './map-style.js';
|
|
28
28
|
import {
|
|
29
|
-
PROPOSAL_VIEWS, MARKS, MARK_WORDS, chipText, parseProposalQuery, proposalPanelHtml, touchedIds,
|
|
29
|
+
PROPOSAL_VIEWS, MARKS, MARK_WORDS, chipText, barCounts, parseProposalQuery, proposalPanelHtml, touchedIds,
|
|
30
30
|
} from './proposal-model.js';
|
|
31
31
|
import { applyProposal, edgeKey, proposalProblems, summarize } from '../core/proposal.js';
|
|
32
32
|
import { reviewWords } from './review-model.js';
|
|
@@ -242,7 +242,7 @@ export function renderBar() {
|
|
|
242
242
|
bar.hidden = !open;
|
|
243
243
|
const legend = $('proposal-legend');
|
|
244
244
|
if (legend) legend.hidden = !open;
|
|
245
|
-
if (!open) { collapseSheet('proposal'); if (hooks.bar) hooks.bar(false); return; }
|
|
245
|
+
if (!open) { closeMore(); toggleMode(false); collapseSheet('proposal'); if (hooks.bar) hooks.bar(false); return; }
|
|
246
246
|
|
|
247
247
|
bar.classList.remove('is-error');
|
|
248
248
|
$('proposal-message').hidden = true;
|
|
@@ -251,12 +251,15 @@ export function renderBar() {
|
|
|
251
251
|
$('proposal-title').textContent = (p && typeof p.title === 'string' && p.title) || state.proposalSlug || 'Proposal';
|
|
252
252
|
const summary = $('proposal-summary');
|
|
253
253
|
summary.textContent = (p && typeof p.summary === 'string' && p.summary) || '';
|
|
254
|
-
|
|
254
|
+
const title = $('proposal-title');
|
|
255
|
+
title.title = summary.textContent; // the toolbar stays one row: the summary is the title's tooltip, and shows above the list of changes
|
|
256
|
+
summary.hidden = !summary.textContent || $('proposal-changes').hidden;
|
|
255
257
|
|
|
256
258
|
const counts = summarize(p);
|
|
257
259
|
const chip = $('proposal-chip');
|
|
258
|
-
chip.
|
|
259
|
-
chip.title =
|
|
260
|
+
chip.innerHTML = barCounts(counts).map((c) => `${c.mark ? `<span class="hx-mark-dot hx-mark-dot--${c.mark}" aria-hidden="true"></span>` : ''}${escHtml(c.text)}`).join('<span class="hx-proposal-sep" aria-hidden="true"> · </span>');
|
|
261
|
+
chip.title = 'Click for the list of changes.';
|
|
262
|
+
$('proposal-mode').textContent = t(state.proposalView);
|
|
260
263
|
|
|
261
264
|
for (const btn of bar.querySelectorAll('[data-action="proposal-view"]')) {
|
|
262
265
|
const on = btn.dataset.view === state.proposalView;
|
|
@@ -297,6 +300,7 @@ function toggleChanges() {
|
|
|
297
300
|
const list = $('proposal-changes');
|
|
298
301
|
if (!list) return;
|
|
299
302
|
list.hidden = !list.hidden;
|
|
303
|
+
$('proposal-summary').hidden = list.hidden || !$('proposal-summary').textContent;
|
|
300
304
|
$('proposal-chip').setAttribute('aria-expanded', String(!list.hidden));
|
|
301
305
|
}
|
|
302
306
|
|
|
@@ -314,6 +318,57 @@ function focusChange(kind, key) {
|
|
|
314
318
|
else selectNode(item);
|
|
315
319
|
}
|
|
316
320
|
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
// The ⋯ menu (a menu button) and the phone's Before / Diff / After switcher
|
|
323
|
+
// ---------------------------------------------------------------------------
|
|
324
|
+
|
|
325
|
+
const moreItems = () => [...document.querySelectorAll('#proposal-more-menu [role="menuitem"]')];
|
|
326
|
+
|
|
327
|
+
function moreOpen() {
|
|
328
|
+
const menu = $('proposal-more-menu');
|
|
329
|
+
return !!menu && !menu.hidden;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** Closes the ⋯ menu; `refocus` puts focus back on its button (Escape, or a choice made) */
|
|
333
|
+
function closeMore(refocus = false) {
|
|
334
|
+
const menu = $('proposal-more-menu');
|
|
335
|
+
const btn = $('proposal-more');
|
|
336
|
+
if (menu) menu.hidden = true;
|
|
337
|
+
if (btn) { btn.setAttribute('aria-expanded', 'false'); if (refocus) btn.focus(); }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function openMore(which = 'first') {
|
|
341
|
+
const menu = $('proposal-more-menu');
|
|
342
|
+
if (!menu) return;
|
|
343
|
+
menu.hidden = false;
|
|
344
|
+
$('proposal-more').setAttribute('aria-expanded', 'true');
|
|
345
|
+
const items = moreItems();
|
|
346
|
+
(which === 'last' ? items[items.length - 1] : items[0])?.focus();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** On a phone the mode button shows the compare switcher under the counts; from 768px the switcher is always there */
|
|
350
|
+
function toggleMode(force) {
|
|
351
|
+
const bar = $('proposal-bar');
|
|
352
|
+
const on = typeof force === 'boolean' ? force : bar.dataset.modeOpen !== 'true';
|
|
353
|
+
bar.dataset.modeOpen = String(on);
|
|
354
|
+
$('proposal-mode').setAttribute('aria-expanded', String(on));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function onMoreKey(e) {
|
|
358
|
+
const btn = $('proposal-more');
|
|
359
|
+
if (e.target === btn && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault(); openMore(e.key === 'ArrowUp' ? 'last' : 'first'); return; }
|
|
360
|
+
if (!moreOpen()) return;
|
|
361
|
+
if (e.key === 'Escape') { e.preventDefault(); closeMore(true); return; }
|
|
362
|
+
if (e.key === 'Tab') { closeMore(); return; }
|
|
363
|
+
const items = moreItems();
|
|
364
|
+
const at = items.indexOf(document.activeElement);
|
|
365
|
+
if (at < 0) return;
|
|
366
|
+
const next = { ArrowDown: (at + 1) % items.length, ArrowUp: (at - 1 + items.length) % items.length, Home: 0, End: items.length - 1 }[e.key];
|
|
367
|
+
if (next === undefined) return;
|
|
368
|
+
e.preventDefault();
|
|
369
|
+
items[next].focus();
|
|
370
|
+
}
|
|
371
|
+
|
|
317
372
|
// ---------------------------------------------------------------------------
|
|
318
373
|
// The picker
|
|
319
374
|
// ---------------------------------------------------------------------------
|
|
@@ -452,7 +507,9 @@ const ACTIONS = {
|
|
|
452
507
|
'toggle-proposals-menu': () => toggleMenu(),
|
|
453
508
|
'open-proposal': (el) => openProposal(el.dataset.slug, el.dataset.source || null),
|
|
454
509
|
'close-proposal': () => closeProposal(),
|
|
455
|
-
'proposal-view': (el) => setProposalView(el.dataset.view),
|
|
510
|
+
'proposal-view': (el) => { setProposalView(el.dataset.view); toggleMode(false); },
|
|
511
|
+
'toggle-proposal-mode': () => toggleMode(),
|
|
512
|
+
'toggle-proposal-more': () => (moreOpen() ? closeMore() : openMore()),
|
|
456
513
|
'toggle-proposal-changes': () => toggleChanges(),
|
|
457
514
|
'proposal-focus': (el) => focusChange(el.dataset.kind, el.dataset.key),
|
|
458
515
|
};
|
|
@@ -461,6 +518,8 @@ function onClick(e) {
|
|
|
461
518
|
const target = e.target.closest ? e.target.closest('[data-action]') : null;
|
|
462
519
|
const action = target && ACTIONS[target.dataset.action];
|
|
463
520
|
if (action) action(target);
|
|
521
|
+
// A choice in the ⋯ menu closes it back onto its button (Close may stop at the what-if confirm); a click anywhere else just closes it
|
|
522
|
+
if (moreOpen() && !(target && target.dataset.action === 'toggle-proposal-more')) closeMore(!!(target && target.closest('#proposal-more-menu')));
|
|
464
523
|
// Any click outside the picker closes it
|
|
465
524
|
const wrap = $('proposal-wrap');
|
|
466
525
|
if (menuOpen() && wrap && !wrap.contains(e.target)) closeMenu();
|
|
@@ -468,6 +527,7 @@ function onClick(e) {
|
|
|
468
527
|
|
|
469
528
|
function onKey(e) {
|
|
470
529
|
if (e.key === 'Escape' && menuOpen()) closeMenu();
|
|
530
|
+
onMoreKey(e);
|
|
471
531
|
}
|
|
472
532
|
|
|
473
533
|
/** The marks' colours for the legend and the panel (the --hx-mark-* variables), the same the map draws on this ground */
|
package/explorer/review.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/review
|
|
3
3
|
*
|
|
4
|
-
* Approving a proposal and sending it back: the two buttons
|
|
5
|
-
* click does. "Approve"
|
|
4
|
+
* Approving a proposal and sending it back: the two buttons on the proposal toolbar (index.html), the note that opens
|
|
5
|
+
* under it, and what a click does. "Approve" takes no note. "Send back" opens the note field (focus moves to it; Cancel
|
|
6
|
+
* closes it and gives focus back to Send back); the button then reads "Send back with this note" and a note is needed.
|
|
7
|
+
* Both put the maintainer's what-if
|
|
6
8
|
* edits (`getEdits()`, whatif.js) in the review, which the server posts as a comment on the spec PR, as the
|
|
7
9
|
* signed-in maintainer (`PUT /proposals/<slug>/review`, server/proposals.js, server/reviews.js). The agent drafting
|
|
8
10
|
* the spec reads it (`cornfield review <slug>`) and folds the edits into the proposal. Only a proposal of a spec PR
|
|
@@ -22,6 +24,7 @@
|
|
|
22
24
|
*/
|
|
23
25
|
|
|
24
26
|
import { state } from './state.js';
|
|
27
|
+
import { expandSheet, isPhone } from './sheets.js';
|
|
25
28
|
import { hooks } from './proposal.js';
|
|
26
29
|
import { refreshMockups } from './mockups.js';
|
|
27
30
|
import { getEdits, clearEdits } from './whatif.js';
|
|
@@ -38,6 +41,7 @@ const ui = {
|
|
|
38
41
|
reviewable: false, // whether it is on a spec PR
|
|
39
42
|
review: null, // { verdict, at } | null: the last review of it
|
|
40
43
|
busy: false,
|
|
44
|
+
noting: false, // the note field is open (Send back was pressed)
|
|
41
45
|
message: '', // an inline refusal or failure
|
|
42
46
|
hint: '', // what happens to the edits
|
|
43
47
|
};
|
|
@@ -52,8 +56,10 @@ const slugOf = () => state.proposalSlug || null;
|
|
|
52
56
|
const keyOf = () => (state.proposal && slugOf() ? `${state.proposalSource || ''}/${slugOf()}` : null);
|
|
53
57
|
const reviewUrl = () => `/proposals/${encodeURIComponent(slugOf())}/review${state.proposalSource ? `?source=${encodeURIComponent(state.proposalSource)}` : ''}`;
|
|
54
58
|
const q = (sel) => (root ? root.querySelector(sel) : null);
|
|
59
|
+
/** The toolbar's own buttons: Send back and Approve (index.html) */
|
|
60
|
+
const button = (verdict) => document.querySelector(`#proposal-bar [data-review="${verdict}"]`);
|
|
55
61
|
|
|
56
|
-
/** The
|
|
62
|
+
/** The status line, the note field and the lines under them; added to the toolbar once, just before Send back and Approve, so Tab goes from the note to Cancel and then to "Send back with this note" (on a phone it sits under the counts, above the two buttons; from 768px CSS gives it a row under the toolbar) */
|
|
57
63
|
function mount() {
|
|
58
64
|
const body = $('proposal-body');
|
|
59
65
|
if (!body) return null;
|
|
@@ -62,14 +68,14 @@ function mount() {
|
|
|
62
68
|
root.id = 'review';
|
|
63
69
|
root.className = 'hx-review';
|
|
64
70
|
root.dataset.corn = 'review-bar';
|
|
65
|
-
root.setAttribute('aria-label', `${t('approve')} or ${t('sendBack')}`);
|
|
66
71
|
root.innerHTML = `
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
72
|
+
<p class="hx-review-status" data-review-status role="status" hidden></p>
|
|
73
|
+
<div class="hx-review-form" id="review-form" data-review-form hidden>
|
|
74
|
+
<label class="hx-review-label" for="review-note"></label>
|
|
75
|
+
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000"></textarea>
|
|
76
|
+
<div class="hx-review-row">
|
|
77
|
+
<button type="button" class="hx-btn hx-btn--quiet" data-review-cancel data-corn-kind="quiet">Cancel</button>
|
|
78
|
+
</div>
|
|
73
79
|
</div>
|
|
74
80
|
<p class="hx-review-msg" data-review-msg role="alert" hidden></p>
|
|
75
81
|
<p class="hx-review-line" data-review-hint role="status" hidden></p>
|
|
@@ -77,11 +83,12 @@ function mount() {
|
|
|
77
83
|
// The words are set as text and attributes, never parsed as HTML (a brand's `strings`, explorer/strings.js)
|
|
78
84
|
q('.hx-review-label').textContent = t('reviewNoteLabel');
|
|
79
85
|
q('#review-note').setAttribute('placeholder', t('reviewNotePlaceholder'));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
root.addEventListener('click', onClick);
|
|
86
|
+
const actions = body.querySelector('.hx-proposal-actions');
|
|
87
|
+
if (actions) actions.before(root); else body.prepend(root);
|
|
88
|
+
const bar = $('proposal-bar');
|
|
89
|
+
(bar || root).addEventListener('click', onClick);
|
|
84
90
|
root.addEventListener('input', () => { if (ui.message) { ui.message = ''; paint(); } });
|
|
91
|
+
root.addEventListener('keydown', (e) => { if (e.key === 'Escape' && ui.noting) { e.stopPropagation(); closeNote(); } });
|
|
85
92
|
}
|
|
86
93
|
return root;
|
|
87
94
|
}
|
|
@@ -92,7 +99,17 @@ function paint() {
|
|
|
92
99
|
const status = q('[data-review-status]');
|
|
93
100
|
status.textContent = reviewWords(ui.review, now());
|
|
94
101
|
status.hidden = !status.textContent;
|
|
95
|
-
for (const btn of
|
|
102
|
+
for (const btn of document.querySelectorAll('#proposal-bar [data-review]')) btn.disabled = ui.busy || !ui.reviewable;
|
|
103
|
+
const approve = button('approved');
|
|
104
|
+
if (approve) approve.textContent = t('approve');
|
|
105
|
+
const sendBack = button('notes');
|
|
106
|
+
if (sendBack) {
|
|
107
|
+
sendBack.textContent = ui.noting ? t('sendBackWithNote') : t('sendBack');
|
|
108
|
+
sendBack.setAttribute('aria-expanded', String(ui.noting));
|
|
109
|
+
sendBack.setAttribute('aria-controls', 'review-form');
|
|
110
|
+
}
|
|
111
|
+
q('[data-review-form]').hidden = !ui.noting;
|
|
112
|
+
q('[data-review-cancel]').disabled = ui.busy;
|
|
96
113
|
q('#review-note').disabled = !ui.reviewable;
|
|
97
114
|
for (const [sel, text] of [['[data-review-msg]', ui.message], ['[data-review-hint]', ui.reviewable ? ui.hint : ui.key ? NOT_ON_A_PR : '']]) {
|
|
98
115
|
const el = q(sel);
|
|
@@ -101,6 +118,25 @@ function paint() {
|
|
|
101
118
|
}
|
|
102
119
|
}
|
|
103
120
|
|
|
121
|
+
/** Send back was pressed: the note field opens and takes focus (on a phone the sheet opens to hold it) */
|
|
122
|
+
function openNote() {
|
|
123
|
+
ui.noting = true;
|
|
124
|
+
ui.message = '';
|
|
125
|
+
paint();
|
|
126
|
+
if (isPhone()) expandSheet('proposal');
|
|
127
|
+
q('#review-note').focus();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Cancel: the field closes, what was typed goes, and focus goes back to Send back */
|
|
131
|
+
function closeNote() {
|
|
132
|
+
ui.noting = false;
|
|
133
|
+
ui.message = '';
|
|
134
|
+
q('#review-note').value = '';
|
|
135
|
+
paint();
|
|
136
|
+
const sendBack = button('notes');
|
|
137
|
+
if (sendBack) sendBack.focus();
|
|
138
|
+
}
|
|
139
|
+
|
|
104
140
|
/** hooks.bar: the bar was drawn. Mount, and when it is another proposal than the one shown, start again for it. */
|
|
105
141
|
function onBar(open) {
|
|
106
142
|
if (!mount()) return;
|
|
@@ -111,6 +147,7 @@ function onBar(open) {
|
|
|
111
147
|
ui.reviewable = !!key && isReviewable(state.proposalSource);
|
|
112
148
|
ui.review = null;
|
|
113
149
|
ui.busy = false;
|
|
150
|
+
ui.noting = false;
|
|
114
151
|
ui.message = ui.hint = '';
|
|
115
152
|
const note = q('#review-note');
|
|
116
153
|
if (note) note.value = '';
|
|
@@ -131,8 +168,12 @@ async function loadReview(key) {
|
|
|
131
168
|
}
|
|
132
169
|
|
|
133
170
|
function onClick(e) {
|
|
134
|
-
|
|
135
|
-
if (
|
|
171
|
+
if (ui.busy || !e.target.closest) return;
|
|
172
|
+
if (e.target.closest('[data-review-cancel]')) { closeNote(); return; }
|
|
173
|
+
const btn = e.target.closest('[data-review]');
|
|
174
|
+
if (!btn || btn.disabled) return;
|
|
175
|
+
if (btn.dataset.review === 'notes' && !ui.noting) openNote(); // the first press opens the field, the second sends
|
|
176
|
+
else sendReview(btn.dataset.review);
|
|
136
177
|
}
|
|
137
178
|
|
|
138
179
|
/**
|
|
@@ -143,13 +184,15 @@ function onClick(e) {
|
|
|
143
184
|
export async function sendReview(verdict) {
|
|
144
185
|
if (!state.proposal || !slugOf() || !mount() || !ui.reviewable) return false;
|
|
145
186
|
const noteEl = q('#review-note');
|
|
146
|
-
const note = noteEl.value;
|
|
187
|
+
const note = verdict === 'notes' ? noteEl.value : ''; // an approval takes no note
|
|
147
188
|
ui.hint = '';
|
|
148
189
|
if (verdict === 'notes') {
|
|
149
190
|
const problem = sendBackProblem(note);
|
|
150
191
|
if (problem) {
|
|
151
192
|
ui.message = problem;
|
|
193
|
+
ui.noting = true; // the refusal is about the note: show it
|
|
152
194
|
paint();
|
|
195
|
+
if (isPhone()) expandSheet('proposal');
|
|
153
196
|
noteEl.focus();
|
|
154
197
|
return false;
|
|
155
198
|
}
|
|
@@ -177,7 +220,10 @@ export async function sendReview(verdict) {
|
|
|
177
220
|
ui.review = { verdict: saved.verdict, at: saved.at };
|
|
178
221
|
ui.hint = editsHint(verdict, body.edits.length);
|
|
179
222
|
noteEl.value = '';
|
|
223
|
+
const wasNoting = ui.noting;
|
|
224
|
+
ui.noting = false;
|
|
180
225
|
paint();
|
|
226
|
+
if (wasNoting && verdict === 'notes') { const sendBack = button('notes'); if (sendBack) sendBack.focus(); }
|
|
181
227
|
refreshMockups(); // an approval covers the screens as they are now; a send back leaves them not reviewed
|
|
182
228
|
if (verdict === 'notes') clearEdits(); // the edits went with the note; an approval keeps them, they are in the review
|
|
183
229
|
return true;
|
|
@@ -208,5 +254,5 @@ export function resetReviewForTests(clock = () => Date.now()) {
|
|
|
208
254
|
wired = false;
|
|
209
255
|
root = null;
|
|
210
256
|
now = clock;
|
|
211
|
-
Object.assign(ui, { key: null, reviewable: false, review: null, busy: false, message: '', hint: '' });
|
|
257
|
+
Object.assign(ui, { key: null, reviewable: false, review: null, busy: false, noting: false, message: '', hint: '' });
|
|
212
258
|
}
|
package/explorer/scenario-ui.js
CHANGED
|
@@ -308,21 +308,39 @@ function mountList() {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
|
|
311
|
+
const wiredPlay = new WeakSet();
|
|
312
|
+
|
|
313
|
+
/** The toolbar's Play button: shown while the open proposal has scenarios and none plays; with one it plays it, with several it opens the list */
|
|
314
|
+
function paintPlay(show) {
|
|
315
|
+
const btn = document.getElementById('proposal-play');
|
|
316
|
+
if (!btn) return;
|
|
317
|
+
btn.hidden = !show;
|
|
318
|
+
// with one scenario Play plays it, so it expands nothing
|
|
319
|
+
if (proposalScenarios().length > 1) btn.setAttribute('aria-expanded', String(!!list && !list.hidden)); else btn.removeAttribute('aria-expanded');
|
|
320
|
+
if (wiredPlay.has(btn)) return;
|
|
321
|
+
wiredPlay.add(btn);
|
|
322
|
+
btn.addEventListener('click', () => {
|
|
323
|
+
const scenarios = proposalScenarios();
|
|
324
|
+
if (scenarios.length === 1) playScenario(scenarios[0]);
|
|
325
|
+
else if (list) { list.hidden = !list.hidden; btn.setAttribute('aria-expanded', String(!list.hidden)); }
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Shows or hides the Play button and its list to match the open proposal's scenarios (and hides them while one plays: the player is the control then) */
|
|
312
330
|
export function refreshList() {
|
|
313
331
|
const stage = $stage();
|
|
314
332
|
const scenarios = proposalScenarios();
|
|
315
333
|
const show = !!stage && scenarios.length > 0 && !player;
|
|
316
|
-
if (!show) { if (list) { list.remove(); list = null; } return; }
|
|
334
|
+
if (!show) { if (list) { list.remove(); list = null; } paintPlay(false); return; }
|
|
317
335
|
const key = scenarios.map((s) => `${s.id}\u0000${s.title}\u0000${(s.steps || []).length}`).join('\u0001');
|
|
318
|
-
if (list && list.dataset.key === key) { mountList(); return; }
|
|
336
|
+
if (list && list.dataset.key === key) { mountList(); paintPlay(true); return; }
|
|
337
|
+
const wasOpen = !!list && !list.hidden;
|
|
319
338
|
if (list) list.remove();
|
|
320
|
-
list = document.createElement('
|
|
339
|
+
list = document.createElement('div');
|
|
340
|
+
list.id = 'proposal-scenarios';
|
|
321
341
|
list.className = 'hx-scenarios glass';
|
|
322
342
|
list.dataset.key = key;
|
|
323
|
-
|
|
324
|
-
summary.textContent = `Scenarios · ${scenarios.length}`;
|
|
325
|
-
list.appendChild(summary);
|
|
343
|
+
list.hidden = !!document.getElementById('proposal-play') && (!wasOpen || scenarios.length < 2); // behind Play when the toolbar has one
|
|
326
344
|
scenarios.forEach((s) => {
|
|
327
345
|
const button = document.createElement('button');
|
|
328
346
|
button.type = 'button';
|
|
@@ -340,6 +358,7 @@ export function refreshList() {
|
|
|
340
358
|
if (scenario) playScenario(scenario);
|
|
341
359
|
});
|
|
342
360
|
mountList();
|
|
361
|
+
paintPlay(true);
|
|
343
362
|
}
|
|
344
363
|
|
|
345
364
|
// ---------------------------------------------------------------------------
|
package/explorer/sheets.js
CHANGED
|
@@ -165,7 +165,7 @@ function peekClick(id, e) {
|
|
|
165
165
|
if (!isPhone() || model.isExpanded(id)) return;
|
|
166
166
|
const target = e.target;
|
|
167
167
|
if (target.closest && target.closest('.hx-sheet-handle')) return; // the handle's own listener
|
|
168
|
-
if (target.closest && target.closest('select, input, textarea')) return; // the speed menu
|
|
168
|
+
if (target.closest && target.closest('select, input, textarea, [data-peek-ok]')) return; // the speed menu, and the proposal's Send back, Approve and mode switcher, work from the peek
|
|
169
169
|
const action = target.closest && target.closest('[data-action]');
|
|
170
170
|
if (action && /close/.test(action.dataset.action)) return;
|
|
171
171
|
e.preventDefault();
|
package/explorer/whatif.js
CHANGED
|
@@ -32,6 +32,7 @@ const $ = (id) => document.getElementById(id);
|
|
|
32
32
|
|
|
33
33
|
/** What the controls are showing; none of it is saved */
|
|
34
34
|
const ui = {
|
|
35
|
+
editing: false, // the Edit button is on: the controls are showing
|
|
35
36
|
panel: null, // 'edits' | 'steps' | null: the list that is open under the toolbar
|
|
36
37
|
form: null, // { kind: 'node' } | { kind: 'edge', from, to } | null: the small form that is open
|
|
37
38
|
drawing: false, // "Draw an edge" is on
|
|
@@ -127,7 +128,7 @@ hooks.bar = () => renderUi();
|
|
|
127
128
|
function resetUi() {
|
|
128
129
|
endGesture();
|
|
129
130
|
setDrawing(false);
|
|
130
|
-
Object.assign(ui, { panel: null, form: null, confirm: false, closing: false, scenarioId: null, stepDraft: '', titleDraft: '', notice: '', messages: {}, lastSelected: null });
|
|
131
|
+
Object.assign(ui, { editing: false, panel: null, form: null, confirm: false, closing: false, scenarioId: null, stepDraft: '', titleDraft: '', notice: '', messages: {}, lastSelected: null });
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
// ---------------------------------------------------------------------------
|
|
@@ -245,7 +246,10 @@ function mount() {
|
|
|
245
246
|
<div class="hx-whatif-panel" data-panel="form" hidden></div>
|
|
246
247
|
<div class="hx-whatif-panel" data-panel="edits" hidden></div>
|
|
247
248
|
<div class="hx-whatif-panel" data-panel="steps" hidden></div>`;
|
|
249
|
+
root.hidden = true;
|
|
248
250
|
body.appendChild(root);
|
|
251
|
+
const edit = $('proposal-edit');
|
|
252
|
+
if (edit) edit.addEventListener('click', () => setEditing(!ui.editing));
|
|
249
253
|
root.addEventListener('click', onClick);
|
|
250
254
|
root.addEventListener('submit', onSubmit);
|
|
251
255
|
root.addEventListener('change', onChange);
|
|
@@ -260,7 +264,13 @@ const q = (sel) => (root ? root.querySelector(sel) : null);
|
|
|
260
264
|
function renderUi() {
|
|
261
265
|
const open = !!state.proposal;
|
|
262
266
|
if (!mount()) return;
|
|
263
|
-
root.hidden = !open;
|
|
267
|
+
root.hidden = !open || !(ui.editing || ui.confirm || ui.notice); // the confirm on Close and the notice about dropped edits are seen whatever Edit says
|
|
268
|
+
const edit = $('proposal-edit');
|
|
269
|
+
if (edit) {
|
|
270
|
+
edit.setAttribute('aria-expanded', String(ui.editing));
|
|
271
|
+
edit.classList.toggle('hx-btn--active', ui.editing);
|
|
272
|
+
edit.textContent = state.whatIf.edits.length ? `Edit · ${state.whatIf.edits.length}` : 'Edit';
|
|
273
|
+
}
|
|
264
274
|
if (!open) { paintDrawer(); return; }
|
|
265
275
|
|
|
266
276
|
const wi = state.whatIf;
|
|
@@ -291,6 +301,13 @@ function renderUi() {
|
|
|
291
301
|
paintDrawer();
|
|
292
302
|
}
|
|
293
303
|
|
|
304
|
+
/** Edit: shows or hides the controls; hiding them ends a drawing and closes the form, the edits stay */
|
|
305
|
+
function setEditing(on) {
|
|
306
|
+
ui.editing = on;
|
|
307
|
+
if (!on) { setDrawing(false); ui.form = null; ui.panel = null; }
|
|
308
|
+
renderUi();
|
|
309
|
+
}
|
|
310
|
+
|
|
294
311
|
/** Puts each inline refusal next to its control (and hides the ones with nothing to say) */
|
|
295
312
|
function paintMessages() {
|
|
296
313
|
if (!root) return;
|
|
@@ -903,6 +920,6 @@ export function resetWhatIfForTests() {
|
|
|
903
920
|
loadedKey = null;
|
|
904
921
|
saveWarned = false;
|
|
905
922
|
listeners.clear();
|
|
906
|
-
Object.assign(ui, { panel: null, form: null, drawing: false, confirm: false, closing: false, scenarioId: null, stepDraft: '', titleDraft: '', notice: '', messages: {}, recentParents: [], lastSelected: null });
|
|
923
|
+
Object.assign(ui, { editing: false, panel: null, form: null, drawing: false, confirm: false, closing: false, scenarioId: null, stepDraft: '', titleDraft: '', notice: '', messages: {}, recentParents: [], lastSelected: null });
|
|
907
924
|
state.whatIf = M.emptyWhatIf();
|
|
908
925
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcorn245/cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|