Files
galaxy-game/ui/frontend/src/lib/active-view/table.svelte
T
Ilia Denisov 209f8508cd
Tests · UI / test (push) Successful in 2m53s
Tests · UI / test (pull_request) Successful in 3m0s
feat(ui): F8-11 — battles table under table submenu (#54)
Adds a sortable battles list as a new entity under the existing
`view → table` submenu (entity slug `battles`), replacing the
standalone top-level `battle log` shortcut which always opened a
"battle not found" placeholder. The single-battle viewer stays put
and is reached only by clicking a row (or a battle marker on the
map), identical to the existing `section-battles.svelte` flow.

Columns are planet (via the shared `planetLabel` helper) and shots
(the per-battle action count carried by `BattleSummary`), sortable
both ways with shots-desc default. No backend / FBS / map changes:
the wire payload is unchanged. Participants / observers / total
mass require the full BattleReport and were intentionally dropped
to avoid N round trips per menu open.

The top-level `battle log` item is removed from `header/view-menu`
and `sidebar/bottom-tabs` (and their stale comment blocks updated);
the now-orphan `game.view.battle` i18n key is dropped from both
locales.
2026-05-27 22:12:51 +02:00

69 lines
1.9 KiB
Svelte

<!--
Active-view router for the per-entity tables. Phase 17 lit up
ship-classes; Phase 21 sciences; Phase 22 races; F8-10 lights up
planets, ship-groups, and fleets. The wrapper preserves
`data-testid="active-view-table"` and `data-entity={entity}` for
every branch (each leaf component mirrors them) so the navigation
e2e specs (`game-shell.spec.ts`, `view-menu`) keep matching.
-->
<script lang="ts">
import { i18n, type TranslationKey } from "$lib/i18n/index.svelte";
import TablePlanets from "./table-planets.svelte";
import TableShipClasses from "./table-ship-classes.svelte";
import TableShipGroups from "./table-ship-groups.svelte";
import TableFleets from "./table-fleets.svelte";
import TableSciences from "./table-sciences.svelte";
import TableRaces from "./table-races.svelte";
import TableBattles from "./table-battles.svelte";
type Props = { entity: string };
let { entity }: Props = $props();
function entityKey(slug: string): TranslationKey {
const normalised = slug.replace(/-/g, "_");
return `game.view.table.${normalised}` as TranslationKey;
}
</script>
{#if entity === "planets"}
<TablePlanets />
{:else if entity === "ship-classes"}
<TableShipClasses />
{:else if entity === "ship-groups"}
<TableShipGroups />
{:else if entity === "fleets"}
<TableFleets />
{:else if entity === "sciences"}
<TableSciences />
{:else if entity === "races"}
<TableRaces />
{:else if entity === "battles"}
<TableBattles />
{:else}
<section
class="active-view"
data-testid="active-view-table"
data-entity={entity}
>
<h2>
{i18n.t("game.view.table")}: {i18n.t(entityKey(entity))}
</h2>
<p>{i18n.t("game.shell.coming_soon")}</p>
</section>
{/if}
<style>
.active-view {
padding: 1.5rem;
font-family: system-ui, sans-serif;
}
.active-view h2 {
margin: 0 0 0.5rem;
font-size: 1.1rem;
}
.active-view p {
margin: 0;
color: var(--color-text-muted);
}
</style>