mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge origin/main into german/navara
Conflict resolutions:
- src/main.js: upstream's PHOTON_URL place-search setting is read once at
module level and passed as geospatial: { endpoints: { photon } } by
createApplication(), so every engine start of the switch flow gets it; the
old single top-level createStandaloneApplication() call stays removed.
- src/layers/bikeshare/render/cesium/rendering.js: upstream's
publishedCapacity fix applied with this branch's
resolveCapacity(model, capacity, status) signature. The same fix is ported
to src/layers/bikeshare/render/navara.js (record.publishedCapacity, status
polls resolve from it), with a Navara regression test; upstream's
proxyRoute test imports the moved render/cesium/rendering.js.
- src/layers/traffic/flow.js: upstream's nextTask() yield and current()
check kept before the scene is taken from this branch's
_trafficScene?.() ?? _viewer?.scene with its missing-scene return.
- scripts/package-boundaries.json, scripts/format-scope.json: union of both
sides' file lists.
- src/voice/actionSchemas.test.mjs: both history comments kept, payload hash
recomputed for the merged schemas (Sentinel-2 map stack enum plus the
shorter layer alias hint).
- src/hudAltitudeDatum.test.mjs: this branch's engine-based IntelHUD
construction with upstream's placeLabels summary context.
This commit is contained in:
commit
1a1eef0e5c
494 files changed
+28358
-1361
No files matched your search
@@ -11,6 +11,8 @@ import SceneOptions from './SceneOptions.vue';
|
||||
import SceneShotList from './SceneShotList.vue';
|
||||
import CctvPanel from './panels/CctvPanel.vue';
|
||||
import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
import DrawControls from './panels/DrawControls.vue';
|
||||
import GeoImport from './panels/GeoImport.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
|
||||
// Scene sharing (src/scenes/sharing.js) offers its authoring bar and presents
|
||||
@@ -43,6 +45,12 @@ async function importChosen(event) {
|
||||
<div id="data-toggles" class="data-toggle-list ui-scroll"></div>
|
||||
</RailPanel>
|
||||
|
||||
<!-- Utilities: Directions (LayerPanel renders its row here), Draw, Import -->
|
||||
<RailPanel id="utilities-panel" start-collapsed :title="t('UTILITIES')" :hint="t('Directions, drawing and your own files')" scroll>
|
||||
<div id="utilities-toggles" class="data-toggle-list utilities-list"></div>
|
||||
<div class="utilities-tools"><DrawControls /><GeoImport /></div>
|
||||
</RailPanel>
|
||||
|
||||
<!-- CCTV Coverage Panel -->
|
||||
<CctvPanel />
|
||||
|
||||
|
||||
@@ -5,22 +5,20 @@ import { t } from '../../../i18n/index.js';
|
||||
import { vPanelState } from '../../rail/panelState.js';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import PanelCollapseButton from '../../rail/PanelCollapseButton.vue';
|
||||
import { vRangeValue } from '../../rail/rangeValue.js';
|
||||
import UiSegmented from '../../kit/UiSegmented.vue';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import GeoImport from './GeoImport.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
import { StyleParameterRows } from '../../styleParameters.js';
|
||||
|
||||
// The Display panel. VisualSettings presents the HUD, Sonar, Scope,
|
||||
// Celestial, detection, bloom and sharpen, AircraftDisplay the 3D group and
|
||||
// the draw tool its controls, and each publishes them; until they do, the
|
||||
// panel shows its initial markup. GeoImport renders the file import.
|
||||
// Celestial, detection, bloom and sharpen and AircraftDisplay the 3D group,
|
||||
// and each publishes them; until they do, the panel shows its initial markup.
|
||||
// Draw and Import live in UTILITIES (LayerPanelsView).
|
||||
const display = useDisplayStore();
|
||||
const { view, models3d, draw, parameters, cockpitPortal } = storeToRefs(display);
|
||||
// A control's change goes to its owner (DisplayBindings or the draw tool).
|
||||
const { view, models3d, parameters, cockpitPortal } = storeToRefs(display);
|
||||
// A control's change goes to its owner (DisplayBindings).
|
||||
const act = (name, ...args) => display.act(name, ...args);
|
||||
const pct = (value) => `${value}%`;
|
||||
const hud = computed(() => view.value?.hud ?? null);
|
||||
@@ -43,12 +41,6 @@ const modelsOptions = computed(() => [
|
||||
{ value: 'proximity', label: t('Proximity'), attrs: { id: 'models3d-mode-proximity', 'data-mode': 'proximity' } },
|
||||
{ value: 'all', label: t('All'), attrs: { id: 'models3d-mode-all', 'data-mode': 'all' } },
|
||||
]);
|
||||
const drawShape = computed(() => draw.value?.shape ?? 'area');
|
||||
const drawShapeOptions = computed(() => [
|
||||
{ value: 'area', label: t('Area'), attrs: { 'data-shape': 'area' } },
|
||||
{ value: 'line', label: t('Line'), attrs: { 'data-shape': 'line' } },
|
||||
{ value: 'pin', label: t('Pin'), attrs: { 'data-shape': 'pin' } },
|
||||
]);
|
||||
const allocationOptions = computed(() => [
|
||||
{ value: 'ELASTIC', label: t('Elastic'), attrs: { id: 'detection-allocation-elastic', 'data-allocation': 'ELASTIC' } },
|
||||
{ value: 'WEIGHTED', label: t('Weighted'), attrs: { id: 'detection-allocation-weighted', 'data-allocation': 'WEIGHTED' } },
|
||||
@@ -177,29 +169,6 @@ const allocationOptions = computed(() => [
|
||||
<span class="pp-slider-value" id="scope-feather-value">{{ pct(scopeFeather) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="draw?.active ?? false" pressed-class="active" id="draw-toggle" @click="act('toggleDraw')" :title="t('Draw on the world — click vertices, double-click or Enter to finish, Esc to cancel')">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">draw</span>
|
||||
<span class="pp-label">{{ t('Draw') }}</span>
|
||||
</UiButton>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-mode-row">
|
||||
<span class="pp-slider-mini-label">{{ t('Shape') }}</span>
|
||||
<UiSegmented class="pp-mode-seg" item-class="pp-mode-btn" keyboard="none" :label="t('Shape to draw')" :options="drawShapeOptions" :model-value="drawShape" @update:model-value="act('setDrawShape', $event)" />
|
||||
</div>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-label-row">
|
||||
<input type="text" class="pp-text-input" id="draw-label-input" v-range-value="draw?.label ?? ''" @input="act('setDrawLabel', $event.target.value)" maxlength="120" :placeholder="t('Label (optional)')" :aria-label="t('Label for the drawn shape')" autocomplete="off" spellcheck="false">
|
||||
<UiSelect class="pp-select draw-color-select gev-field gev-field--compact" id="draw-color-select" :model-value="draw?.color ?? 'primary'" @update:model-value="act('setDrawColor', $event)" :aria-label="t('Colour of the drawn shape')">
|
||||
<option value="primary">{{ t('Primary') }}</option>
|
||||
<option value="amber">{{ t('Amber') }}</option>
|
||||
<option value="cyan">{{ t('Cyan') }}</option>
|
||||
<option value="green">{{ t('Green') }}</option>
|
||||
<option value="red">{{ t('Red') }}</option>
|
||||
</UiSelect>
|
||||
<button class="pp-mode-btn draw-clear-btn" id="draw-clear" type="button" @click="act('clearDraw')" :title="t('Remove every mark from the board')">{{ t('Clear') }}</button>
|
||||
<span class="draw-hint" id="draw-hint" aria-live="polite">{{ draw?.hint ?? '' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<GeoImport />
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="celestial?.active ?? false" pressed-class="active" id="celestial-toggle" @click="act('toggleCelestial')" :title="celestialTitle" :disabled="celestial ? !celestial.supported : undefined" :aria-disabled="celestial ? String(!celestial.supported) : undefined">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">flare</span>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiSegmented from '../../kit/UiSegmented.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import DrawMarkList from './DrawMarkList.vue';
|
||||
import DrawSwatches from './DrawSwatches.vue';
|
||||
|
||||
// UTILITIES ▸ Draw: the toggle, the shape and the colour for the next shape,
|
||||
// the hint with Clear, and the drawn shapes' rows. The draw tool publishes
|
||||
// what they show and answers them through the display store.
|
||||
const display = useDisplayStore();
|
||||
const { draw } = storeToRefs(display);
|
||||
const act = (name, ...args) => display.act(name, ...args);
|
||||
const drawShape = computed(() => draw.value?.shape ?? 'area');
|
||||
|
||||
// Icons, named for screen readers and tooltips.
|
||||
const shapeOptions = computed(() => [
|
||||
{ value: 'area', label: t('Area'), icon: 'pentagon', attrs: { 'data-shape': 'area' } },
|
||||
{ value: 'line', label: t('Line'), icon: 'timeline', attrs: { 'data-shape': 'line' } },
|
||||
{ value: 'pin', label: t('Pin'), icon: 'location_on', attrs: { 'data-shape': 'pin' } },
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="pp-toggle-group" id="draw-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="draw?.active ?? false" pressed-class="active" id="draw-toggle" @click="act('toggleDraw')" :title="t('Draw on the world — click vertices, double-click or Enter to finish, Esc to cancel')">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">draw</span>
|
||||
<span class="pp-label">{{ t('Draw') }}</span>
|
||||
</UiButton>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-mode-row">
|
||||
<UiSegmented class="pp-mode-seg draw-shape-seg" item-class="pp-mode-btn" keyboard="none" :label="t('Shape to draw')" :options="shapeOptions" :model-value="drawShape" @update:model-value="act('setDrawShape', $event)" />
|
||||
<DrawSwatches id="draw-colors" :label="t('Colour of the next shape')" :model-value="draw?.color ?? 'primary'" @update:model-value="act('setDrawColor', $event)" />
|
||||
</div>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-label-row">
|
||||
<span class="draw-hint" id="draw-hint" aria-live="polite">{{ draw?.hint ?? '' }}</span>
|
||||
<button class="pp-mode-btn draw-clear-btn" id="draw-clear" type="button" @click="act('clearDraw')" :title="t('Remove every mark from the board')">{{ t('Clear') }}</button>
|
||||
</div>
|
||||
<DrawMarkList />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,185 @@
|
||||
// src/ui/views/panels/DrawMarkList.test.mjs — UTILITIES ▸ Draw's shapes:
|
||||
// one row each, rendered from what the draw tool publishes, with the row
|
||||
// controls answered through the display store. Rows are updated in place, so
|
||||
// a board change never takes a half-typed name or the button under a click.
|
||||
import '../../../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { presentDrawMarks } from '../../../annotations/drawMarks.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import DrawMarkList from './DrawMarkList.vue';
|
||||
|
||||
const LINE = { id: 'a1', type: 'route', manual: true, name: null, label: '950 m', color: 'primary', hidden: false };
|
||||
const PIN = { id: 'a2', type: 'pin', manual: true, name: 'Camp', label: 'Camp', color: 'amber', hidden: false };
|
||||
const VOICE = { id: 'a3', type: 'area', manual: false, label: 'Texas', color: 'primary', hidden: false };
|
||||
|
||||
function mount(t) {
|
||||
document.body.replaceChildren();
|
||||
const toggle = document.body.appendChild(document.createElement('button'));
|
||||
toggle.id = 'draw-toggle';
|
||||
const pinia = createPinia();
|
||||
const store = useDisplayStore(pinia);
|
||||
const calls = [];
|
||||
store.connect(
|
||||
new Proxy(
|
||||
{},
|
||||
{ get: (_, name) => (...args) => calls.push([name, ...args]) },
|
||||
),
|
||||
);
|
||||
const app = createApp(DrawMarkList).use(pinia);
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
return { store, calls };
|
||||
}
|
||||
|
||||
async function show(store, marks) {
|
||||
store.publishDraw({ active: true, shape: 'area', color: 'primary', hint: '', marks: presentDrawMarks(marks) });
|
||||
await nextTick();
|
||||
}
|
||||
const row = (id) => document.querySelector(`#draw-mark-list [data-mark-id="${id}"]`);
|
||||
const control = (id, name) => row(id)?.querySelector(`[data-control="${name}"]`);
|
||||
const key = (el, keyName) => {
|
||||
const event = new KeyboardEvent('keydown', { key: keyName, bubbles: true, cancelable: true });
|
||||
el.dispatchEvent(event);
|
||||
return event;
|
||||
};
|
||||
|
||||
test('lists only hand-drawn marks, named or by kind, with Import-style actions', async (t) => {
|
||||
const { store } = mount(t);
|
||||
const list = document.getElementById('draw-mark-list');
|
||||
assert.equal(list.classList.contains('visible'), false);
|
||||
await show(store, [LINE, PIN, VOICE]);
|
||||
assert.equal(list.classList.contains('visible'), true);
|
||||
assert.deepEqual([...list.children].map((node) => node.dataset.markId), ['a1', 'a2']);
|
||||
assert.equal(control('a1', 'name').value, '');
|
||||
assert.equal(control('a1', 'name').placeholder, 'Line · 950 m');
|
||||
assert.equal(control('a2', 'name').value, 'Camp');
|
||||
assert.match(control('a2', 'swatch').style.background, /#ffb547|rgb\(255, 181, 71\)/);
|
||||
assert.equal(control('a2', 'toggle').getAttribute('aria-label'), 'Hide Camp');
|
||||
assert.equal(control('a2', 'toggle').hasAttribute('aria-pressed'), false, 'the label says the state');
|
||||
assert.equal(control('a2', 'fly').getAttribute('aria-label'), 'Fly to Camp');
|
||||
assert.equal(control('a2', 'remove').getAttribute('aria-label'), 'Remove Camp');
|
||||
});
|
||||
|
||||
test('show/hide, fly to and remove act on that one mark', async (t) => {
|
||||
const { store, calls } = mount(t);
|
||||
await show(store, [LINE, PIN]);
|
||||
control('a2', 'toggle').click();
|
||||
control('a1', 'fly').click();
|
||||
control('a1', 'remove').click();
|
||||
assert.deepEqual(calls, [
|
||||
['toggleDrawMark', 'a2'],
|
||||
['flyToDrawMark', 'a1'],
|
||||
['removeDrawMark', 'a1'],
|
||||
]);
|
||||
await show(store, [{ ...PIN, hidden: true }]);
|
||||
assert.equal(control('a2', 'toggle').getAttribute('aria-label'), 'Show Camp');
|
||||
assert.ok(row('a2').classList.contains('hidden-mark'));
|
||||
});
|
||||
|
||||
test('the swatch opens the colours in the row; a colour recolours and closes it', async (t) => {
|
||||
const { store, calls } = mount(t);
|
||||
await show(store, [LINE]);
|
||||
control('a1', 'swatch').click();
|
||||
await nextTick();
|
||||
assert.equal(control('a1', 'swatch').getAttribute('aria-expanded'), 'true');
|
||||
control('a1', 'color-red').click();
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
assert.deepEqual(calls, [['recolorDrawMark', 'a1', 'red']]);
|
||||
assert.equal(control('a1', 'picker'), null, 'choosing closes the picker');
|
||||
assert.equal(document.activeElement, control('a1', 'swatch'), 'and focus goes back to the swatch');
|
||||
});
|
||||
|
||||
test('a name is saved on Enter or leaving the field; an unchanged one costs nothing', async (t) => {
|
||||
const { store, calls } = mount(t);
|
||||
await show(store, [LINE, PIN]);
|
||||
const name = control('a1', 'name');
|
||||
name.focus();
|
||||
name.value = ' Ridge walk ';
|
||||
key(name, 'Enter');
|
||||
assert.deepEqual(calls, [['renameDrawMark', 'a1', 'Ridge walk']]);
|
||||
assert.equal(document.activeElement, name, 'Enter keeps focus in the field');
|
||||
name.blur();
|
||||
assert.equal(calls.length, 1, 'the blur after Enter saves nothing more');
|
||||
const pinName = control('a2', 'name');
|
||||
pinName.focus();
|
||||
pinName.blur();
|
||||
assert.equal(calls.length, 1, 'leaving an unchanged name saves nothing');
|
||||
pinName.focus();
|
||||
pinName.value = 'Base';
|
||||
pinName.blur();
|
||||
assert.deepEqual(calls.at(-1), ['renameDrawMark', 'a2', 'Base']);
|
||||
});
|
||||
|
||||
test('Escape drops the draft and stays in the list, even with the row\'s colours open', async (t) => {
|
||||
const { store, calls } = mount(t);
|
||||
await show(store, [PIN]);
|
||||
control('a2', 'swatch').click();
|
||||
await nextTick();
|
||||
const name = control('a2', 'name');
|
||||
name.focus();
|
||||
name.value = 'Base';
|
||||
const event = key(name, 'Escape');
|
||||
assert.equal(event.defaultPrevented, true);
|
||||
assert.equal(name.value, 'Camp', 'the saved name comes back');
|
||||
assert.equal(document.activeElement, name, 'focus stays in the field');
|
||||
await nextTick();
|
||||
assert.deepEqual(calls, [], 'the draft is not saved');
|
||||
// Escape in the open colours closes them and gives focus to the swatch.
|
||||
control('a2', 'color-green').focus();
|
||||
key(control('a2', 'color-green'), 'Escape');
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
assert.equal(control('a2', 'picker'), null);
|
||||
assert.equal(document.activeElement, control('a2', 'swatch'));
|
||||
});
|
||||
|
||||
test('a board change keeps the row, the name being typed and the focus', async (t) => {
|
||||
const { store } = mount(t);
|
||||
await show(store, [LINE, PIN]);
|
||||
const before = row('a1');
|
||||
const name = control('a1', 'name');
|
||||
name.focus();
|
||||
name.value = 'Half typ';
|
||||
await show(store, [{ ...LINE, color: 'green' }, PIN, VOICE]);
|
||||
assert.equal(row('a1'), before, 'the row is kept');
|
||||
assert.equal(control('a1', 'name').value, 'Half typ', 'the draft survives');
|
||||
assert.equal(document.activeElement, name);
|
||||
});
|
||||
|
||||
test('when the focused row goes, focus moves to the next row, else the Draw button', async (t) => {
|
||||
const { store } = mount(t);
|
||||
await show(store, [LINE, PIN]);
|
||||
control('a1', 'remove').focus();
|
||||
await show(store, [PIN]);
|
||||
assert.equal(document.activeElement, control('a2', 'remove'));
|
||||
await show(store, []);
|
||||
assert.equal(document.activeElement, document.getElementById('draw-toggle'));
|
||||
});
|
||||
|
||||
test('the colours open next to the swatch with the current one focused, and the arrows try others', async (t) => {
|
||||
const { store, calls } = mount(t);
|
||||
await show(store, [PIN]);
|
||||
control('a2', 'swatch').click();
|
||||
await nextTick();
|
||||
const picker = control('a2', 'picker');
|
||||
assert.equal(control('a2', 'swatch').getAttribute('aria-controls'), picker.id);
|
||||
assert.equal(picker.previousElementSibling, control('a2', 'swatch'), 'right after its swatch');
|
||||
assert.equal(document.activeElement, control('a2', 'color-amber'), 'the current colour has focus');
|
||||
assert.deepEqual(
|
||||
[...picker.querySelectorAll('[role="radio"]')].map((node) => node.getAttribute('tabindex')),
|
||||
['-1', '0', '-1', '-1', '-1'],
|
||||
'one tab stop, on the checked colour',
|
||||
);
|
||||
key(control('a2', 'color-amber'), 'ArrowRight');
|
||||
key(control('a2', 'color-amber'), 'End');
|
||||
assert.deepEqual(calls, [
|
||||
['recolorDrawMark', 'a2', 'cyan'],
|
||||
['recolorDrawMark', 'a2', 'red'],
|
||||
]);
|
||||
await nextTick();
|
||||
assert.ok(control('a2', 'picker'), 'the arrows keep the colours open');
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { DRAW_COLOR_CSS } from '../../../annotations/drawMarks.js';
|
||||
import { vFieldValue } from '../../rail/fieldValue.js';
|
||||
import { vFocusSafeChildren } from '../../rail/focusSafeChildren.js';
|
||||
import DrawSwatches from './DrawSwatches.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
|
||||
// UTILITIES ▸ Draw's shapes, one row each like Import's files: the colour
|
||||
// swatch (it opens the five colours in the row), the name typed in place,
|
||||
// and show/hide, fly to and remove. The draw tool publishes the rows and
|
||||
// answers the controls. Rows are keyed, so a board change elsewhere updates a
|
||||
// row in place and never takes the button under a click or the field being
|
||||
// typed in. The list's template is one line: templates keep whitespace.
|
||||
const display = useDisplayStore();
|
||||
const { draw } = storeToRefs(display);
|
||||
const rows = computed(() => draw.value?.marks ?? []);
|
||||
// No `>` in the template: the catalog reads its tags with a regex.
|
||||
const listed = computed(() => rows.value.length > 0);
|
||||
const picking = ref(null);
|
||||
// The name field (v-field-value) shows the saved name except while it is
|
||||
// being typed in: that text is the draft until Enter or leaving saves it.
|
||||
|
||||
const rowOf = (id) => rows.value.find((row) => row.id === id);
|
||||
// The name last sent for each row, so Enter and the blur after it save once
|
||||
// even before the tool publishes the new name.
|
||||
const sent = new Map();
|
||||
|
||||
/** Save a typed name; an unchanged one costs nothing. */
|
||||
function commit(row, input) {
|
||||
const next = input.value.trim();
|
||||
input.value = next;
|
||||
const saved = rowOf(row.id)?.name ?? row.name;
|
||||
if (next === saved || next === sent.get(row.id)) return;
|
||||
sent.set(row.id, next);
|
||||
display.act('renameDrawMark', row.id, next);
|
||||
}
|
||||
|
||||
function onNameKey(row, event) {
|
||||
const input = event.currentTarget;
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
// Saved, and focus stays here: blurring would drop it to the page.
|
||||
commit(row, input);
|
||||
input.select();
|
||||
} else if (event.key === 'Escape') {
|
||||
// Escape drops the draft before anything else, an open colour picker
|
||||
// included, and stays in the list: it must not leave Draw.
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
input.value = rowOf(row.id)?.name ?? row.name;
|
||||
input.select();
|
||||
}
|
||||
}
|
||||
|
||||
async function closePicker(id) {
|
||||
picking.value = null;
|
||||
await nextTick();
|
||||
document
|
||||
.querySelector(`#draw-mark-list [data-mark-id="${id}"] .draw-mark-swatch`)
|
||||
?.focus();
|
||||
}
|
||||
|
||||
function onRowKey(row, event) {
|
||||
// Escape in an open picker closes it and gives focus back to its swatch.
|
||||
if (event.key !== 'Escape' || picking.value !== row.id) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void closePicker(row.id);
|
||||
}
|
||||
|
||||
/** A colour from the row's picker: the arrows try it, a click also closes. */
|
||||
function recolor(row, color) {
|
||||
if (color !== row.color) display.act('recolorDrawMark', row.id, color);
|
||||
}
|
||||
|
||||
// Before the row holding keyboard focus goes, focus moves to the next row's
|
||||
// same control, else the previous row's, else the Draw button.
|
||||
function leave() {
|
||||
const active = document.activeElement;
|
||||
const row = active?.closest('[data-mark-id]');
|
||||
const control = active?.dataset.control;
|
||||
const others = [];
|
||||
for (let next = row?.nextElementSibling; next; next = next.nextElementSibling)
|
||||
others.push(next);
|
||||
for (let prev = row?.previousElementSibling; prev; prev = prev.previousElementSibling)
|
||||
others.push(prev);
|
||||
for (const other of others) {
|
||||
const target =
|
||||
other.querySelector(`[data-control="${control}"]`) ||
|
||||
other.querySelector('button');
|
||||
if (target) return target.focus();
|
||||
}
|
||||
document.getElementById('draw-toggle')?.focus();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="geo-import-list draw-mark-list" :class="{ visible: listed }" id="draw-mark-list" v-focus-safe-children="leave" :aria-label="t('Drawn shapes')"><li v-for="row in rows" :key="row.id" class="geo-import-row draw-mark-row" :class="{ 'hidden-mark': row.hidden }" :data-mark-id="row.id" @keydown="onRowKey(row, $event)"><button type="button" class="geo-import-swatch draw-mark-swatch" data-control="swatch" :style="{ background: DRAW_COLOR_CSS[row.color] }" :title="row.labels.swatch" :aria-label="row.labels.swatch" :aria-expanded="String(picking === row.id)" :aria-controls="`draw-mark-colors-${row.id}`" @click="picking = picking === row.id ? null : row.id"></button><DrawSwatches v-if="picking === row.id" :id="`draw-mark-colors-${row.id}`" class="draw-mark-colors" data-control="picker" autofocus :label="row.labels.colors" :model-value="row.color" @update:model-value="recolor(row, $event)" @choose="closePicker(row.id)" /><input type="text" class="geo-import-name draw-mark-name" data-control="name" maxlength="120" autocomplete="off" spellcheck="false" v-field-value="row.name" :placeholder="row.placeholder" :aria-label="row.labels.name" @keydown="onNameKey(row, $event)" @focusout="commit(row, $event.currentTarget)"><button type="button" class="geo-import-action" data-control="toggle" :title="row.labels.toggle" :aria-label="row.labels.toggle" @click="display.act('toggleDrawMark', row.id)"><span class="material-symbols-outlined" aria-hidden="true">{{ row.hidden ? 'visibility_off' : 'visibility' }}</span></button><button type="button" class="geo-import-action" data-control="fly" :title="row.labels.fly" :aria-label="row.labels.fly" @click="display.act('flyToDrawMark', row.id)"><span class="material-symbols-outlined" aria-hidden="true">my_location</span></button><button type="button" class="geo-import-action" data-control="remove" :title="row.labels.remove" :aria-label="row.labels.remove" @click="display.act('removeDrawMark', row.id)"><span class="material-symbols-outlined" aria-hidden="true">close</span></button></li></ul>
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup>
|
||||
import { onMounted } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import {
|
||||
DRAW_COLORS,
|
||||
DRAW_COLOR_CSS,
|
||||
DRAW_COLOR_NAMES,
|
||||
} from '../../../annotations/drawMarks.js';
|
||||
|
||||
// Draw's five colours as one radio group: the next shape's colour and a
|
||||
// drawn shape's picker. Only the checked colour is a tab stop; the arrows,
|
||||
// Home and End move to and choose another, as a radio group's do. Each swatch
|
||||
// shows its colour from DRAW_COLOR_CSS, the same value the shape is drawn in.
|
||||
// The template is one line: templates keep whitespace.
|
||||
const props = defineProps({
|
||||
modelValue: { type: String, default: 'primary' },
|
||||
/** The group's accessible name, already translated. */
|
||||
label: { type: String, required: true },
|
||||
/** Focus the checked colour once shown (a picker that just opened). */
|
||||
autofocus: { type: Boolean, default: false },
|
||||
});
|
||||
// `choose` is a click: a picker closes on it, and stays open for the arrows.
|
||||
const emit = defineEmits(['update:modelValue', 'choose']);
|
||||
const buttons = [];
|
||||
const STEPS = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 };
|
||||
|
||||
function onKey(event) {
|
||||
const from = Math.max(0, DRAW_COLORS.indexOf(props.modelValue));
|
||||
let to;
|
||||
if (STEPS[event.key])
|
||||
to = (from + STEPS[event.key] + DRAW_COLORS.length) % DRAW_COLORS.length;
|
||||
else if (event.key === 'Home') to = 0;
|
||||
else if (event.key === 'End') to = DRAW_COLORS.length - 1;
|
||||
else return;
|
||||
event.preventDefault();
|
||||
buttons[to]?.focus();
|
||||
if (to !== from) emit('update:modelValue', DRAW_COLORS[to]);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.autofocus)
|
||||
buttons[Math.max(0, DRAW_COLORS.indexOf(props.modelValue))]?.focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="draw-colors" role="radiogroup" :aria-label="props.label" @keydown="onKey"><button v-for="(color, index) in DRAW_COLORS" :key="color" :ref="(el) => (buttons[index] = el)" type="button" class="draw-color" :class="{ active: color === props.modelValue }" role="radio" :data-color="color" :data-control="`color-${color}`" :aria-checked="String(color === props.modelValue)" :tabindex="color === props.modelValue ? 0 : -1" :style="{ background: DRAW_COLOR_CSS[color] }" :title="t(DRAW_COLOR_NAMES[color])" :aria-label="t(DRAW_COLOR_NAMES[color])" @click="emit('update:modelValue', color), emit('choose', color)"></button></div>
|
||||
</template>
|
||||
@@ -67,7 +67,7 @@ const radioWords = computed(() => ({
|
||||
<a id="radio-station-homepage" :href="radio ? radio.station.homepage || undefined : '#'" target="_blank" rel="noopener noreferrer" :hidden="radio ? !radio.station.homepage : true">{{ t('STATION SITE') }}</a>
|
||||
<a href="https://www.radio-browser.info/" target="_blank" rel="noopener noreferrer">{{ t('DIRECTORY: RADIO BROWSER') }}</a>
|
||||
</div>
|
||||
<p class="radio-privacy">{{ t('Audio connects directly to the broadcaster after you press play. Your IP is visible to that broadcaster.') }}</p>
|
||||
<p class="radio-privacy">{{ t('Audio connects directly to the broadcaster when you press play, choose a station on the globe or ask voice to play. Your IP is visible to that broadcaster.') }}</p>
|
||||
<SdrCard />
|
||||
</RailPanel>
|
||||
</template>
|
||||
Reference in new issue
Block a user