8e552f556d
Polish pass after the first F8-10 walkthrough:
- table-planets: moved the `foreign` chip to the end of the row and
hid the race dropdown until `foreign` is on (it never made sense
to pick a race while the bucket itself was off).
- persistent per-table filter / sort state — extracted to
`table-{planets,ship-groups,fleets}-state.svelte.ts` singletons so
a row click → map → back to the table restores the prior chip /
dropdown / sort state. Held in memory only; an F5 still resets.
- table-ship-groups: the planet and class dropdowns now narrow to
the slice surviving the owner checkboxes, so toggling `foreign`
off removes planets / classes touched only by foreign rows.
- map.svelte: camera (centre + zoom) is captured on every dispose
path into a new `GameStateStore.lastCamera` and consumed on the
next mount, so leaving the map for any other active view and
coming back restores the prior pan / zoom. A pending focus from
the tables still wins for the centre point.
- table-ship-classes: `:disabled` now reads as disabled (muted
colour, no hover ring, not-allowed cursor) — the click was already
a no-op, only the visual was lying.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
// F8-10 planets table — module-level filter / sort rune.
|
|
//
|
|
// Held outside the component so the user's filter selections survive
|
|
// the component being unmounted (e.g. row click → map → back to the
|
|
// table). Held in memory only; an F5 reloads the report and the
|
|
// defaults take over.
|
|
|
|
export type PlanetSortColumn =
|
|
| "number"
|
|
| "name"
|
|
| "kind"
|
|
| "owner"
|
|
| "size"
|
|
| "resources";
|
|
|
|
export type PlanetSortDirection = "asc" | "desc";
|
|
|
|
export interface PlanetsTableState {
|
|
sortColumn: PlanetSortColumn;
|
|
sortDirection: PlanetSortDirection;
|
|
showLocal: boolean;
|
|
showOther: boolean;
|
|
showUninhabited: boolean;
|
|
showUnknown: boolean;
|
|
ownerFilter: string;
|
|
}
|
|
|
|
const DEFAULT_STATE: PlanetsTableState = {
|
|
sortColumn: "number",
|
|
sortDirection: "asc",
|
|
showLocal: true,
|
|
showOther: true,
|
|
showUninhabited: true,
|
|
showUnknown: true,
|
|
ownerFilter: "",
|
|
};
|
|
|
|
export const planetsTableState: PlanetsTableState = $state({ ...DEFAULT_STATE });
|
|
|
|
/**
|
|
* resetPlanetsTableState restores every field to its default value.
|
|
* Production code never calls it; the Vitest harness uses it from
|
|
* `beforeEach` to keep cases independent (the rune is a module-level
|
|
* singleton that otherwise carries state across test boundaries).
|
|
*/
|
|
export function resetPlanetsTableState(): void {
|
|
Object.assign(planetsTableState, DEFAULT_STATE);
|
|
}
|