Skip to content

Planner night picker: a panel with a close button, the stay kinds as a filter, a calm map #3290

Closed

Description

@timohueser

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

  1. Caravan sites. planner/search/query/schema.py: delete caravan_site from DATA_KINDS["campsite"], and write planner/search/query/contract.json again with python3 planner/search/query/schema.py; planner/search/query/test_artifacts.py checks that the two agree. The query kinds campsite and sleep then find no caravan site. Add one case to planner/search/test/query.test.mjs: a search for campsites does not return its caravan_site record. builder/web/src/lib/planner/search/presentation.ts: delete caravan_site from stayKinds; sleepCategory returns undefined for the kind caravan_site. A caravan site stays a place on the map with its own label.
  2. builder/web/src/lib/planner/stops.ts:
    • Add suitable(stop: Stop, kinds: Stay[]): StopPlace[]: the places of stop.sleep whose stayKind is in kinds. suits uses it.
    • stopCounts(stop, kinds) counts suitable(stop, kinds) by stay kind, in the order camp, hut, hostel, hotel, shelter: "2 campsites · 1 hut".
  3. builder/web/src/components/planner/StopPicker.svelte: stops is the list of ready stops with suits(stop, kinds). The km text of a row uses the first and last km of suitable(stop, kinds). Delete the .lead paragraph. 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 from NightNode.svelte (nouns) to stops.ts as the export stayNouns. Pass kinds to StopCard.svelte, which lists suitable(stop, kinds) only.
  4. builder/web/src/components/planner/NightNode.svelte: while open, 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 on var(--panel). In the header, an icon button with the close icon, aria-label="Close" and title="Close (Esc)" replaces the text button "Close". Escape inside the panel closes it. A closed night shows "Choose" or "Change" with the down icon. The two step buttons get title texts equal to their aria-label.
  5. StopPicker.svelte footer: 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.
  6. builder/web/src/components/planner/PlannerApp.svelte visiblePlaces: for an open stop and for an open night, take suitable(stop, nights.kinds(night)) in place of stop.sleep.
  7. Calm map. New file builder/web/src/lib/planner/view-change.ts with one pure function:
    nightView(view: Bounds, spot: Coordinate, towns: Coordinate[][]): { action: 'stay' } | { action: 'pan' | 'fit'; box: Bounds }, where Bounds is [west, south, east, north]. spot is the end of the day: the pinned place, else the place of the suggested night, else the even end. towns holds, for each listed stop, the coordinates of suitable(stop, kinds), ordered by the distance of stop.km from the km of spot, nearest first. needed is min(3, towns.length).
    • stay: spot is inside view, and at least needed towns have a place inside view.
    • Otherwise box is the bounds of spot and of all places of the first needed towns. So a far town of the list never widens the box.
    • pan: the width and the height of box are each at most 80 % of the width and height of view.
    • fit: otherwise.
      PlannerMap.svelte exports showNight(spot, towns). It calls nightView with map.getBounds(). For pan it calls map.panTo with the centre of box. For fit it calls fitBounds with box and maxZoom equal to the current zoom, so it never zooms in. showNightArea in PlannerApp.svelte calls showNight in place of fitCoordinates. An effect runs it once for each opening of a night: when pickerNight is set and nights.found(pickerNight)?.state === 'ready', and not again while the same night stays open, so a change of the kinds does not move the map.
  8. Tests: stops.test.ts for suitable and stopCounts; a new view-change.test.ts with one case for each of the three results; update the StopPicker and NightNode cases in the existing component tests.

Done when

  • From builder/web: npx vitest run src/lib/planner/ src/components/planner/ and npm 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions