feat(ui): render the Contacts panel from the awareness layer's published view

The awareness layer presents its panel as a plain view and publishes it through subscribePanel() instead of writing markup into #military-awareness-panel. AwarenessPanel renders it from the gev-context store, calls the layer's navigation, and keeps focus on the same control by identity across live repaints, continuing at the note when that control leaves or is disabled.
This commit is contained in:
Sameh Khamis committed 2026-10-31 01:03:28 -07:00
1 parent 749bfd5cd4
commit 1e4df63efe
16 files changed
+582 -380

No files matched your search

+2 -6
View File
@@ -2,6 +2,7 @@
import { storeToRefs } from 'pinia';
import { vClassToggle } from '../rail/classToggle.js';
import { useContextStore } from '../stores/context.js';
import AwarenessPanel from './panels/AwarenessPanel.vue';
import RadioPanel from './panels/RadioPanel.vue';
// ContextControls presents the mode switch and the nearby sites search and
@@ -68,12 +69,7 @@ const { view: ctx } = storeToRefs(useContextStore());
<button id="installations-search-btn" class="panel-layer-toggle" type="button" :aria-disabled="ctx && String(ctx.installationsBusy)" :aria-busy="ctx && String(ctx.installationsBusy)" data-i18n>SEARCH NEARBY SITES</button>
<button id="tr3b-toggle" class="tr3b-toggle" type="button" aria-pressed="false" hidden aria-label="Reclassify tracked contact as TR-3B" title="Reclassify as TR-3B" data-i18n-aria-label data-i18n-title>🛸</button>
</div>
<aside id="military-awareness-panel">
<div class="military-awareness-standby">
<strong data-i18n>CONTACTS CONTEXT OFF</strong>
<span data-i18n>SELECT CONTACTS TO LOAD OBSERVED / MAPPED PROXIMITY</span>
</div>
</aside>
<AwarenessPanel />
</section>
<section id="context-missions-view" class="context-mode-view" role="tabpanel" aria-labelledby="global-context-missions-btn" :hidden="!ctx?.missionsActive">
<div id="space-mission-panel-host">
+8
View File
@@ -0,0 +1,8 @@
<script setup>
// The named areas of a Contacts subject or contact, one per line.
defineProps({ names: { type: Object, required: true } });
</script>
<template>
<details class="military-awareness-names"><summary>{{ names.summary }}</summary><div><template v-for="(name, index) in names.names" :key="index"><br v-if="index">{{ name }}</template></div></details>
</template>
+74
View File
@@ -0,0 +1,74 @@
<script setup>
import { storeToRefs } from 'pinia';
import { onBeforeUpdate, onUpdated, ref } from 'vue';
import { useContextStore } from '../../stores/context.js';
import AwarenessNames from './AwarenessNames.vue';
// The Contacts panel inside Context. The Contacts layer publishes its view
// (standby, results or empty); until it does, the panel shows its initial
// markup. Buttons call the layer's navigation as the person's own.
const { awareness: view, awarenessLayer: layer } = storeToRefs(useContextStore());
const user = { origin: 'user' };
const root = ref(null);
// A live repaint keeps focus on the same control by identity: browsers drop
// focus from a node Vue moves, removes or disables, so the control is found
// again by its key. When it is gone or disabled, focus continues at the note
// beyond the list rather than jumping to another contact.
const CONTINUATION = '[data-awareness-focus-continuation]';
const controlKey = (el) => {
if (el?.matches?.(CONTINUATION)) return 'continuation';
const { awarenessAction: action, awarenessLayer: layer, awarenessId: id } = el?.dataset ?? {};
if (action) return `action:${action}`;
return layer && id ? `target:${layer}:${id}` : null;
};
let focusedKey = null;
onBeforeUpdate(() => {
const active = document.activeElement;
focusedKey = root.value?.contains(active) ? controlKey(active) ?? 'continuation' : null;
});
onUpdated(() => {
const key = focusedKey;
focusedKey = null;
const panel = root.value;
// A disabled control may keep focus until the browser's next frame.
const active = document.activeElement;
if (!key || !panel || (panel.contains(active) && !active.disabled)) return;
const retained = key === 'continuation' ? null : [...panel.querySelectorAll('button[data-awareness-action], button[data-awareness-id]')].find((control) => !control.disabled && controlKey(control) === key);
(retained || panel.querySelector(CONTINUATION))?.focus({ preventScroll: true });
});
</script>
<template>
<aside id="military-awareness-panel" ref="root">
<div v-if="!view" class="military-awareness-standby">
<strong data-i18n>CONTACTS CONTEXT OFF</strong>
<span data-i18n>SELECT CONTACTS TO LOAD OBSERVED / MAPPED PROXIMITY</span>
</div>
<div v-else-if="view.kind === 'standby'" class="military-awareness-standby">
<strong>{{ view.title }}</strong>
<span>{{ view.text }}</span>
</div>
<template v-else-if="view.kind === 'results'">
<div class="military-awareness-subject">{{ view.subject }}</div>
<AwarenessNames v-if="view.subjectNames" :names="view.subjectNames" />
<div class="military-awareness-controls" role="group" :aria-label="view.navigation.label">
<button type="button" data-awareness-action="previous" :title="view.navigation.previous.title" :disabled="view.navigation.previous.disabled" @click="layer?.navigatePrevious(user)">{{ view.navigation.previous.text }}</button>
<button type="button" data-awareness-action="focus" @click="layer?.focusCurrent(user)">{{ view.navigation.focus.text }}</button>
<button type="button" data-awareness-action="next" :title="view.navigation.next.title" :disabled="view.navigation.next.disabled" @click="layer?.navigateNext(user)">{{ view.navigation.next.text }}</button>
</div>
<section v-for="row in view.rows" :key="row.id" :class="['military-awareness-row', row.relationship]">
<div><strong>{{ row.label }}</strong><b aria-live="polite">{{ row.count }}</b></div>
<small>{{ row.detail }}</small>
<ul v-if="row.nearest.length">
<li v-for="item in row.nearest" :key="item.key">
<button v-if="item.targetId" type="button" class="military-awareness-target" :data-awareness-layer="item.layer" :data-awareness-id="item.targetId" :aria-label="item.ariaLabel" @click="layer?.focusTarget(item.layer, item.targetId, user)">{{ item.label }} <span>{{ item.distance }}</span></button>
<span v-else class="military-awareness-target unavailable" :aria-label="item.ariaLabel">{{ item.label }} <span>{{ item.distance }}</span></span>
<AwarenessNames v-if="item.names" :names="item.names" />
</li>
</ul>
</section>
<p class="military-awareness-note" tabindex="-1" data-awareness-focus-continuation>{{ view.note }}</p>
</template>
</aside>
</template>