mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
feat(collections): own order, KML/KMZ import, copy options, position search, place names on the trip map
- A list keeps its own order: drag a place by its grip (desktop and phone) or move it with the arrow keys. Reordering is off while a search or filter hides places and the list says why. New PUT /collections/:id/places/reorder and the MCP tool reorder_collection_places; new places go to the end. Client and server now order ties the same way (sort_order, oldest first, id). - Copying saved places into a trip no longer takes their notes and tags along unasked. The picker offers both; a tag taken along becomes a trip tag (a trip tag of the same name is reused), never someone's personal tag. - The source trip and place a saved place names are only kept when the user can open that trip and the place belongs to it. - A KML or KMZ map can be read into a list: the dialog lists every placemark to keep or leave out and says which entries were skipped and why (POST /collections/map/read writes nothing; the import does). - A saved place without coordinates says so and can be looked up on the map from its edit form, on the phone too, where a missing position could not be added at all. A typed address without a pick says it will not be on the map. - The trip map can show the place names beside the pins (desktop and phone, both renderers). Names that would cover another pin or a control give way, the selected place and the planned stops first.
This commit is contained in:
@@ -6,6 +6,7 @@ import { mapsApi } from '../../api/client';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { getApiErrorMessage } from '../../utils/apiError';
|
||||
import { normalizeImageFile } from '../../utils/convertHeic';
|
||||
import { hasCoordinates } from '../Planner/placeCoordinates';
|
||||
import { useToast } from '../shared/Toast';
|
||||
import { cleanListLinks } from './useListEditor';
|
||||
|
||||
@@ -92,6 +93,9 @@ export function useCollectionPlaceForm({
|
||||
const [address, setAddress] = useState(shown?.address ?? '');
|
||||
const [lat, setLat] = useState(coordText(shown?.lat));
|
||||
const [lng, setLng] = useState(coordText(shown?.lng));
|
||||
// A position picked from the map search (#2837). The phone form has no coordinate
|
||||
// fields, so its save only sends coordinates once one was picked here.
|
||||
const [positionPicked, setPositionPicked] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
// A higher res photo pulled from the maps provider when the place has none of
|
||||
// its own; the list avatar's little thumbnail is too low res for the cover.
|
||||
@@ -110,8 +114,17 @@ export function useCollectionPlaceForm({
|
||||
setAddress(p.address ?? '');
|
||||
setLat(coordText(p.lat));
|
||||
setLng(coordText(p.lng));
|
||||
setPositionPicked(false);
|
||||
}, []);
|
||||
|
||||
/** Takes a hit of the position search: its coordinates, and its address only where the form has none. */
|
||||
const pickPosition = (spot: { lat: number; lng: number; address?: string }) => {
|
||||
setLat(String(spot.lat));
|
||||
setLng(String(spot.lng));
|
||||
if (!address.trim() && spot.address) setAddress(spot.address);
|
||||
setPositionPicked(true);
|
||||
};
|
||||
|
||||
// Reseed the form and fetch the cover only when a DIFFERENT place opens (keyed on
|
||||
// the id, not on every field).
|
||||
const seededId = useRef<number | null>(null);
|
||||
@@ -201,7 +214,9 @@ export function useCollectionPlaceForm({
|
||||
};
|
||||
setSaving(true);
|
||||
try {
|
||||
await onSave(withCoordinates ? { ...base, lat: parseCoordinate(lat), lng: parseCoordinate(lng) } : base);
|
||||
await onSave(
|
||||
withCoordinates || positionPicked ? { ...base, lat: parseCoordinate(lat), lng: parseCoordinate(lng) } : base
|
||||
);
|
||||
setEditing(false);
|
||||
} catch (err) {
|
||||
toast.error(getApiErrorMessage(err, t('common.error')));
|
||||
@@ -230,6 +245,10 @@ export function useCollectionPlaceForm({
|
||||
address,
|
||||
setAddress,
|
||||
lat,
|
||||
pickPosition,
|
||||
positionPicked,
|
||||
// The search row is for places saved without a position, not for moving one that has it.
|
||||
needsPosition: !!shown && !hasCoordinates(shown),
|
||||
setLat,
|
||||
lng,
|
||||
setLng,
|
||||
|
||||
Reference in New Issue
Block a user