Repository navigation
Description
Status: done
Size: M
Part of #3286. Depends on #3287.
Systems: route-planning, search
TL;DR
Goal: The open night picker is one panel with a close button. Its list, its counts and the map markers show only the stay kinds of that night. "Choose" moves the map only as far as needed. Caravan sites are not campsites.
Problem: "Close" replaces "Choose" beside the name of the place, and nothing shows where the open list ends. The picker lists every kind of place to sleep. "Choose" fits the map to the whole searched stretch. Caravan sites count as campsites.
Decision: The open night is one bordered panel with a close icon in its header. The list, the counts and the markers follow the stay kinds of the night. "Choose" leaves the map alone when the night and three listed towns are in view; otherwise it pans, and it zooms out only when a pan is not enough. Caravan sites leave the campsites, in the web planner and in the search service. (Review page, findings 06, 07 step 1 and 08.)
Contracts: planner/search/query/contract.json
Plan
- Caravan sites.
planner/search/query/schema.py: deletecaravan_sitefromDATA_KINDS["campsite"], and writeplanner/search/query/contract.jsonagain withpython3 planner/search/query/schema.py;planner/search/query/test_artifacts.pychecks that the two agree. The query kindscampsiteandsleepthen find no caravan site. Add one case toplanner/search/test/query.test.mjs: a search for campsites does not return itscaravan_siterecord.builder/web/src/lib/planner/search/presentation.ts: deletecaravan_sitefromstayKinds;sleepCategoryreturnsundefinedfor the kindcaravan_site. A caravan site stays a place on the map with its own label. builder/web/src/lib/planner/stops.ts:- Add
suitable(stop: Stop, kinds: Stay[]): StopPlace[]: the places ofstop.sleepwhosestayKindis inkinds.suitsuses it. stopCounts(stop, kinds)countssuitable(stop, kinds)by stay kind, in the order camp, hut, hostel, hotel, shelter: "2 campsites · 1 hut".
- Add
builder/web/src/components/planner/StopPicker.svelte:stopsis the list of ready stops withsuits(stop, kinds). The km text of a row uses the first and last km ofsuitable(stop, kinds). Delete the.leadparagraph. When the list is empty, the text is "No {noun} between km A and B." with the singular noun of the single kind ("No campsite between km 32 and 89."), or "No place to sleep between km A and B." for several kinds. The nouns move fromNightNode.svelte(nouns) tostops.tsas the exportstayNouns. PasskindstoStopCard.svelte, which listssuitable(stop, kinds)only.builder/web/src/components/planner/NightNode.svelte: whileopen, the row and the towns render inside one element.night-panel:border: 1px solid var(--line-strong),border-radius: 10px,background: var(--parchment). Its header is the night row onvar(--panel). In the header, an icon button with thecloseicon,aria-label="Close"andtitle="Close (Esc)"replaces the text button "Close".Escapeinside the panel closes it. A closed night shows "Choose" or "Change" with thedownicon. The two step buttons gettitletexts equal to theiraria-label.StopPicker.sveltefooter: the stay kinds of the night and "Pick on the map" stand in one row at the bottom of the panel. "Cancel" goes; the close button replaces it.builder/web/src/components/planner/PlannerApp.sveltevisiblePlaces: for an open stop and for an open night, takesuitable(stop, nights.kinds(night))in place ofstop.sleep.- Calm map. New file
builder/web/src/lib/planner/view-change.tswith one pure function:
nightView(view: Bounds, spot: Coordinate, towns: Coordinate[][]): { action: 'stay' } | { action: 'pan' | 'fit'; box: Bounds }, whereBoundsis[west, south, east, north].spotis the end of the day: the pinned place, else the place of the suggested night, else the even end.townsholds, for each listed stop, the coordinates ofsuitable(stop, kinds), ordered by the distance ofstop.kmfrom the km ofspot, nearest first.neededismin(3, towns.length).stay:spotis insideview, and at leastneededtowns have a place insideview.- Otherwise
boxis the bounds ofspotand of all places of the firstneededtowns. So a far town of the list never widens the box. pan: the width and the height ofboxare each at most 80 % of the width and height ofview.fit: otherwise.
PlannerMap.svelteexportsshowNight(spot, towns). It callsnightViewwithmap.getBounds(). Forpanit callsmap.panTowith the centre ofbox. Forfitit callsfitBoundswithboxandmaxZoomequal to the current zoom, so it never zooms in.showNightAreainPlannerApp.sveltecallsshowNightin place offitCoordinates. An effect runs it once for each opening of a night: whenpickerNightis set andnights.found(pickerNight)?.state === 'ready', and not again while the same night stays open, so a change of the kinds does not move the map.
- Tests:
stops.test.tsforsuitableandstopCounts; a newview-change.test.tswith one case for each of the three results; update theStopPickerandNightNodecases in the existing component tests.
Done when
- From
builder/web:npx vitest run src/lib/planner/ src/components/planner/andnpm run check - In the running planner with only "Campsites" on: the picker lists only towns with a campsite, the counts name only campsites, the map shows only campsite markers, and "Choose" does not move the map when the night and three listed towns are in view.
Activity
Merge pull request #3317 from timohueser/claude/planner-ux-3290-night…