mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
Merge pull request #715 from mauriceboe/feat/per-trip-map-fit
feat(map): auto-fit planner map to trip places on load (#510)
This commit is contained in:
@@ -17,7 +17,6 @@ client/public/icons/*.png
|
||||
|
||||
# User data
|
||||
server/data/*
|
||||
!server/data/airports.json
|
||||
server/uploads/
|
||||
|
||||
# Environment
|
||||
|
||||
@@ -233,9 +233,19 @@ export default function TripPlannerPage(): React.ReactElement | null {
|
||||
const [showReservationModal, setShowReservationModal] = useState<boolean>(false)
|
||||
const [editingReservation, setEditingReservation] = useState<Reservation | null>(null)
|
||||
const [fitKey, setFitKey] = useState<number>(0)
|
||||
const initialFitTripId = useRef<number | null>(null)
|
||||
const [mobileSidebarOpen, setMobileSidebarOpen] = useState<'left' | 'right' | null>(null)
|
||||
const [deletePlaceId, setDeletePlaceId] = useState<number | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!trip) return
|
||||
if (initialFitTripId.current === trip.id) return
|
||||
const hasGeoPlaces = places.some(p => p.lat != null && p.lng != null)
|
||||
if (!hasGeoPlaces) return
|
||||
initialFitTripId.current = trip.id
|
||||
setFitKey(k => k + 1)
|
||||
}, [trip, places])
|
||||
|
||||
const connectionsStorageKey = tripId ? `trek:visible-connections:${tripId}` : null
|
||||
const [visibleConnections, setVisibleConnections] = useState<number[]>(() => {
|
||||
if (typeof window === 'undefined' || !connectionsStorageKey) return []
|
||||
|
||||
@@ -212,6 +212,7 @@ export interface Settings {
|
||||
show_place_description: boolean
|
||||
route_calculation?: boolean
|
||||
blur_booking_codes?: boolean
|
||||
map_booking_labels?: boolean
|
||||
}
|
||||
|
||||
export interface AssignmentsMap {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// Build server/data/airports.json from OurAirports (davidmegginson.github.io/ourairports-data).
|
||||
// Build server/assets/airports.json from OurAirports (davidmegginson.github.io/ourairports-data).
|
||||
// License: Public Domain. Keeps large/medium airports with an IATA code; timezone derived from coords via tz-lookup.
|
||||
|
||||
import fs from 'node:fs'
|
||||
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url'
|
||||
import tzLookup from 'tz-lookup'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const OUT = path.join(__dirname, '..', 'data', 'airports.json')
|
||||
const OUT = path.join(__dirname, '..', 'assets', 'airports.json')
|
||||
const SRC = 'https://davidmegginson.github.io/ourairports-data/airports.csv'
|
||||
|
||||
function fetchText(url) {
|
||||
|
||||
@@ -18,7 +18,7 @@ let byIata: Map<string, Airport> | null = null;
|
||||
|
||||
function load(): Airport[] {
|
||||
if (cache) return cache;
|
||||
const file = path.join(__dirname, '..', '..', 'data', 'airports.json');
|
||||
const file = path.join(__dirname, '..', '..', 'assets', 'airports.json');
|
||||
if (!fs.existsSync(file)) {
|
||||
console.warn('[airports] airports.json missing — run `node scripts/build-airports.mjs`');
|
||||
cache = [];
|
||||
|
||||
Reference in New Issue
Block a user