From d98d597581f9ea885138247e7c06e82a25cc6f81 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 9 Aug 2026 23:37:02 +0200 Subject: [PATCH] Make the detail column useful for places no encyclopaedia describes A restaurant got nothing: no wiki article, and a coordinate search around it returns whatever was photographed nearby rather than the place itself. Three changes, all on free sources: OpenStreetMap facts. A tagged restaurant carries its cuisine, its opening hours, a link to its menu, outdoor seating, step-free access and diet tags. Those arrive with the details lookup the dialog already makes, so showing them as chips costs nothing and is the single biggest gain for exactly the places that were empty before. Only positive facts are listed - "no outdoor seating" is noise. Commons categories. Where a place has a wikimedia_commons tag, its category is pictures OF it; geosearch falls back in when the category is empty. Wikivoyage before Wikipedia. Same API, same licence, but it describes a place for someone about to visit rather than opening with area in square kilometres. Two sentences instead of three, because this sits beside a form. The column also follows the section-heading idiom Vacay and the dashboard share (uppercase overline, wide tracking), its header matches the Saved places panel beside it, and a lead picture with a row underneath replaces the two-column grid that left a hole on every odd count. Credits wrap over two lines instead of truncating - a cut-off name credits nobody. Saved places stops after ten with a Show more button; search and filters still run over everything, not just the visible page. Form spacing is one rhythm (12px between groups, 8px inside, 4px label to field) and Notes matches Description in height. The OSM notice fits on one line and no longer claims there are no photos, which stopped being true when the column started fetching them from Wikimedia. The clipboard hint is gone; paste still works. --- .../Collections/CollectionPicker.test.tsx | 44 +++ .../Collections/CollectionPicker.tsx | 25 +- .../Planner/PlaceDetailsColumn.test.tsx | 63 +++- .../components/Planner/PlaceDetailsColumn.tsx | 277 +++++++++++++----- .../Planner/PlaceFormModal.test.tsx | 9 +- .../src/components/Planner/PlaceFormModal.tsx | 9 +- server/src/nest/maps/maps.helpers.ts | 15 + server/src/nest/maps/maps.service.ts | 140 ++++++--- .../place-enrichment.controller.ts | 2 +- .../place-enrichment.service.ts | 87 +++++- server/tests/e2e/place-enrichment.e2e.test.ts | 7 +- server/tests/unit/nest/maps.service.test.ts | 138 ++++++--- .../nest/place-enrichment.controller.test.ts | 6 +- .../nest/place-enrichment.service.test.ts | 130 +++++++- shared/src/i18n/ar/collection.ts | 1 + shared/src/i18n/ar/places.ts | 15 +- shared/src/i18n/br/collection.ts | 1 + shared/src/i18n/br/places.ts | 15 +- shared/src/i18n/ca/collection.ts | 1 + shared/src/i18n/ca/places.ts | 15 +- shared/src/i18n/cs/collection.ts | 1 + shared/src/i18n/cs/places.ts | 14 +- shared/src/i18n/de/collection.ts | 1 + shared/src/i18n/de/places.ts | 15 +- shared/src/i18n/en/collection.ts | 1 + shared/src/i18n/en/places.ts | 15 +- shared/src/i18n/es/collection.ts | 1 + shared/src/i18n/es/places.ts | 15 +- shared/src/i18n/fr/collection.ts | 1 + shared/src/i18n/fr/places.ts | 15 +- shared/src/i18n/gr/collection.ts | 1 + shared/src/i18n/gr/places.ts | 15 +- shared/src/i18n/hu/collection.ts | 1 + shared/src/i18n/hu/places.ts | 15 +- shared/src/i18n/id/collection.ts | 1 + shared/src/i18n/id/places.ts | 15 +- shared/src/i18n/it/collection.ts | 1 + shared/src/i18n/it/places.ts | 15 +- shared/src/i18n/ja/collection.ts | 1 + shared/src/i18n/ja/places.ts | 14 +- shared/src/i18n/ko/collection.ts | 1 + shared/src/i18n/ko/places.ts | 15 +- shared/src/i18n/nl/collection.ts | 1 + shared/src/i18n/nl/places.ts | 15 +- shared/src/i18n/pl/collection.ts | 1 + shared/src/i18n/pl/places.ts | 15 +- shared/src/i18n/ru/collection.ts | 1 + shared/src/i18n/ru/places.ts | 15 +- shared/src/i18n/sv/collection.ts | 1 + shared/src/i18n/sv/places.ts | 15 +- shared/src/i18n/tr/collection.ts | 1 + shared/src/i18n/tr/places.ts | 15 +- shared/src/i18n/uk/collection.ts | 1 + shared/src/i18n/uk/places.ts | 15 +- shared/src/i18n/vi/collection.ts | 1 + shared/src/i18n/vi/places.ts | 15 +- shared/src/i18n/zh-TW/collection.ts | 1 + shared/src/i18n/zh-TW/places.ts | 14 +- shared/src/i18n/zh/collection.ts | 1 + shared/src/i18n/zh/places.ts | 14 +- shared/src/maps/maps.schema.ts | 36 ++- 61 files changed, 1120 insertions(+), 232 deletions(-) diff --git a/client/src/components/Collections/CollectionPicker.test.tsx b/client/src/components/Collections/CollectionPicker.test.tsx index 8a1be5133..75487f1b2 100644 --- a/client/src/components/Collections/CollectionPicker.test.tsx +++ b/client/src/components/Collections/CollectionPicker.test.tsx @@ -53,6 +53,50 @@ describe('CollectionPicker', () => { vi.restoreAllMocks() }) + it('FE-COMP-COLPICKER-017: shows the first ten and offers the rest behind a button', async () => { + // Saved places accumulate across every list, so the panel used to scroll + // without end. + const many = Array.from({ length: 23 }, (_, i) => + place({ id: 100 + i, collection_id: 1, name: `Place ${String(i).padStart(2, '0')}` }), + ) + vi.spyOn(collectionsApi, 'get').mockImplementation(async (id: number) => + id === 1 ? detail(listA, many) : detail(listB, []), + ) + setup() + + expect(await screen.findByText('Place 00')).toBeInTheDocument() + expect(screen.getByText('Place 09')).toBeInTheDocument() + expect(screen.queryByText('Place 10')).not.toBeInTheDocument() + + const more = () => screen.getByRole('button', { name: /show .* more/i }) + fireEvent.click(more()) + expect(screen.getByText('Place 19')).toBeInTheDocument() + expect(screen.queryByText('Place 20')).not.toBeInTheDocument() + + fireEvent.click(more()) + expect(screen.getByText('Place 22')).toBeInTheDocument() + // Nothing left to ask for. + expect(screen.queryByRole('button', { name: /more/i })).not.toBeInTheDocument() + }) + + it('FE-COMP-COLPICKER-018: searching resets the page and looks at every place, not just the visible ten', async () => { + const many = Array.from({ length: 23 }, (_, i) => + place({ id: 100 + i, collection_id: 1, name: `Place ${String(i).padStart(2, '0')}` }), + ) + vi.spyOn(collectionsApi, 'get').mockImplementation(async (id: number) => + id === 1 ? detail(listA, many) : detail(listB, []), + ) + setup() + await screen.findByText('Place 00') + + // "Place 22" is well past the first page; the filter has to reach it. + fireEvent.change(screen.getByPlaceholderText(/search/i), { target: { value: 'Place 22' } }) + + expect(screen.getByText('Place 22')).toBeInTheDocument() + expect(screen.queryByText('Place 00')).not.toBeInTheDocument() + expect(screen.queryByRole('button', { name: /more/i })).not.toBeInTheDocument() + }) + it('FE-COMP-COLPICKER-001: shows a spinner until the lists have loaded', async () => { const { container } = setup() expect(container.querySelector('.animate-spin')).toBeTruthy() diff --git a/client/src/components/Collections/CollectionPicker.tsx b/client/src/components/Collections/CollectionPicker.tsx index 5cc071c82..f82973b0a 100644 --- a/client/src/components/Collections/CollectionPicker.tsx +++ b/client/src/components/Collections/CollectionPicker.tsx @@ -130,6 +130,11 @@ export default function CollectionPicker({ bias, onSelect, t }: CollectionPicker [bias], ) + // The list is every saved place across every collection, which grows without + // bound. Show a first page and let the rest be asked for. + const PAGE = 10 + const [shown, setShown] = useState(PAGE) + const visible = useMemo(() => { const q = search.trim().toLowerCase() const list = places.filter(p => { @@ -143,6 +148,13 @@ export default function CollectionPicker({ bias, onSelect, t }: CollectionPicker return list }, [places, search, center, listFilter, statusFilter]) + // Searching or filtering starts a new list; keeping the old offset would drop + // the user somewhere in the middle of it. + useEffect(() => { setShown(PAGE) }, [search, listFilter, statusFilter]) + + const page = visible.slice(0, shown) + const remaining = visible.length - page.length + const listOpts: Opt[] = [ { key: 'all', label: t('collections.picker.allLists'), icon: , count: places.length }, ...lists.map(l => ({ @@ -192,7 +204,7 @@ export default function CollectionPicker({ bias, onSelect, t }: CollectionPicker

{t('collections.picker.empty')}

) : (
- {visible.map(place => ( + {page.map(place => ( ))} + {remaining > 0 && ( +
+ +
+ )}
)} diff --git a/client/src/components/Planner/PlaceDetailsColumn.test.tsx b/client/src/components/Planner/PlaceDetailsColumn.test.tsx index 078c4c353..ae9610408 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.test.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.test.tsx @@ -41,6 +41,7 @@ const GOOGLE_PHOTO = { const RESULT: MapsPlaceEnrichmentResult = { photos: [COMMONS_PHOTO], + facts: [], description: { text: 'Ein Museum in Köln.', source: 'wikipedia', @@ -120,7 +121,7 @@ describe('PlaceDetailsColumn', () => { }) it('FE-PDC-005: names the source when a picture has no author, instead of inventing one', async () => { - placeEnrichment.mockResolvedValue({ photos: [GOOGLE_PHOTO], description: null }) + placeEnrichment.mockResolvedValue({ photos: [GOOGLE_PHOTO], description: null, facts: [] }) renderColumn() expect(await screen.findByText('Google')).toBeInTheDocument() @@ -169,17 +170,69 @@ describe('PlaceDetailsColumn', () => { }) it('FE-PDC-011: says so when the admin switched enrichment off', async () => { - placeEnrichment.mockResolvedValue({ photos: [], description: null, disabled: true }) + placeEnrichment.mockResolvedValue({ photos: [], description: null, facts: [], disabled: true }) renderColumn() expect(await screen.findByText('places.details.disabled')).toBeInTheDocument() }) - it('FE-PDC-012: says so when a place has no pictures', async () => { - placeEnrichment.mockResolvedValue({ photos: [], description: null }) + it('FE-PDC-012: says so when a place yields nothing at all', async () => { + placeEnrichment.mockResolvedValue({ photos: [], description: null, facts: [] }) renderColumn() - expect(await screen.findByText('places.details.noPhotos')).toBeInTheDocument() + expect(await screen.findByText('places.details.nothing')).toBeInTheDocument() + }) + + it('FE-PDC-016: shows the OpenStreetMap facts, which is all a restaurant gets', async () => { + placeEnrichment.mockResolvedValue({ + photos: [], + description: null, + facts: [ + { kind: 'cuisine', value: 'regional', url: null }, + { kind: 'openingHours', value: 'Mo-Sa 17:30+', url: null }, + { kind: 'menu', value: null, url: 'https://example.org/menu' }, + { kind: 'outdoorSeating', value: null, url: null }, + ], + }) + renderColumn() + + // A value is shown verbatim; a plain yes falls back to the translated label. + expect(await screen.findByText('regional')).toBeInTheDocument() + expect(screen.getByText('Mo-Sa 17:30+')).toBeInTheDocument() + expect(screen.getByText('places.details.fact.outdoorSeating')).toBeInTheDocument() + expect(screen.getByRole('link', { name: /places.details.fact.menu/ })).toHaveAttribute( + 'href', + 'https://example.org/menu', + ) + }) + + it('FE-PDC-017: renders facts even when there is neither a picture nor a description', async () => { + placeEnrichment.mockResolvedValue({ + photos: [], + description: null, + facts: [{ kind: 'cuisine', value: 'pizza', url: null }], + }) + renderColumn() + + expect(await screen.findByText('pizza')).toBeInTheDocument() + expect(screen.queryByText('places.details.nothing')).not.toBeInTheDocument() + }) + + it('FE-PDC-018: names Wikivoyage as the source when the text came from there', async () => { + placeEnrichment.mockResolvedValue({ + photos: [], + facts: [], + description: { + text: 'Berlin ist das politische Zentrum Deutschlands.', + source: 'wikivoyage', + sourceUrl: 'https://de.wikivoyage.org/wiki/Berlin', + license: 'CC BY-SA 4.0', + }, + }) + renderColumn() + + const link = await screen.findByRole('link', { name: /Wikivoyage/ }) + expect(link).toHaveAttribute('href', 'https://de.wikivoyage.org/wiki/Berlin') }) it('FE-PDC-013: shows an error state when the request fails', async () => { diff --git a/client/src/components/Planner/PlaceDetailsColumn.tsx b/client/src/components/Planner/PlaceDetailsColumn.tsx index 3e0bbc3bb..c8b8b3f84 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.tsx @@ -1,6 +1,22 @@ import React, { useEffect, useRef, useState } from 'react' -import { Check, ImageOff, Loader2, ExternalLink } from 'lucide-react' -import type { MapsPlaceEnrichmentResult, PlacePhotoCandidate } from '@trek/shared' +import { + Accessibility, + Bike, + Check, + ChefHat, + Clock, + ExternalLink, + ImageOff, + Landmark, + Leaf, + Loader2, + ScrollText, + ShoppingBag, + Sprout, + Sun, + Wifi, +} from 'lucide-react' +import type { MapsPlaceEnrichmentResult, PlaceFact, PlacePhotoCandidate } from '@trek/shared' import { mapsApi } from '../../api/client' import type { TranslationFn } from '../../types' @@ -60,6 +76,16 @@ function cacheKeyFor(selection: PlaceDetailsSelection, language: string): string type LoadState = 'idle' | 'loading' | 'ready' | 'error' +/** + * Overline label, the section heading Vacay and the dashboard widgets share. + * Uppercase with wide tracking, muted, no rule underneath. + */ +function Overline({ children }: { children: React.ReactNode }): React.ReactElement { + return ( +

{children}

+ ) +} + export default function PlaceDetailsColumn({ selection, selectedImageUrl, @@ -127,10 +153,14 @@ export default function PlaceDetailsColumn({ useEffect(() => () => abortRef.current?.abort(), []) + const isEmpty = + state === 'ready' && !data?.disabled && !data?.photos.length && !data?.description && !data?.facts.length + return (