Skip to content

Read the stored parking type instead of guessing it from the vehicle types - #1773

Merged
a-limyr merged 6 commits into
entur:masterfrom
tmfg:fix/parking-read-stored-type
Oct 23, 2026
Merged

a-limyr merged 6 commits into
entur:masterfrom
tmfg:fix/parking-read-stored-type

Conversation

@teppope

@teppope teppope commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The editor shows every field of a pedalCycle parking that Tiamat stores as parkAndRide. Abzu guessed the type and showed a name and a total capacity only.

  • Reads the stored parkingType, and splits the old guess into four answers:
Question Before Now
Which fields does the parking hold? The guess hasFullFieldSet
What is the parking called? The guess The stored type, with the guess as fallback
What vehicle is the parking for? The guess isForPedalCycle, from the vehicle types
Which fields does a save write? parkingType === bikeParking hasFullFieldSet, the same rule as the editor
  • Points the modern icon and marker title at the vehicle types.
  • Adds a read-only vehicle-types field to both panels, with a motorcycle label.
  • Gives a new, unsaved parking the same two flags.
  • Reads a missing capacity entry as no value, not 0. A save adds no zero entry the parking did not hold.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue

Data with no stored type behaves as before. Two visible changes follow:

  1. A parking with a stored parkAndRide type and pedalCycle vehicles now has the park-and-ride title. The icon still shows the bicycle.
  2. A parking with both car and pedalCycle and no stored type now shows the bicycle icon and title. This combination is likely to be rare.

Unit tests

  • With Parking.js from master, 13 of the 20 tests in src/test/parkingType.spec.js fail.
  • The motorcycle test fails without the new key with expected 'motorcycle' to be 'Moottoripyörä'.
  • The 2 new-parking tests fail without the mapToClient.js change with expected undefined to be true and expected undefined to be false.
  • The 3 new save tests in parkingSaveCapacity.spec.js fail without the review fixes. Two save an extra zero entry. One drops a capacity edit.

Verification

Check Result
vitest run ✅ 247 tests pass, on the 1.659.0 release
npx tsc --noEmit ✅ Clean
npm run check (Prettier) ✅ Clean
New message keys ✅ Present in all five locale files
Both VerboseParking copies ✅ Identical after the change, checked with diff
Bicycle parking, stored as parkAndRide, modern editor, master and this branch ✅ The full field set and the vehicle types show. The bicycle icon stays bicycle parking, modern editor, before and after
The same parking, legacy editor ✅ The full field set shows bicycle parking, legacy editor, before and after
Car and motorcycle parking, modern editor ✅ Only the new vehicle-types field changes car and motorcycle parking, modern editor, before and after
Edit and save a value in a browser ⛔ Not run. The capture is read-only

@teppope
teppope force-pushed the fix/parking-read-stored-type branch 2 times, most recently from ed743e7 to 7a3a3b2 Compare October 2, 2026 10:39
@teppope
teppope force-pushed the fix/parking-read-stored-type branch from 02a5747 to 8e60c35 Compare October 9, 2026 13:54
@teppope
teppope marked this pull request as ready for review October 12, 2026 08:26
@teppope
teppope requested a review from a-limyr October 12, 2026 08:26
@teppope
teppope force-pushed the fix/parking-read-stored-type branch from 8a3e05e to 7891d5d Compare October 13, 2026 09:20

@a-limyr a-limyr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Splitting parkingType into hasFullFieldSet and isForPedalCycle makes the model much clearer, and the tests cover the cases well. A few things before merge:

  1. New registeredDisabled: 0 entry on save. Bicycle parkings with a stored type now get the full field set. toClient() gives numberOfSpacesForRegisteredDisabledUserType: 0 when the entry doesn't exist, and mergeParkingSpaces keeps 0. So every save of such a parking adds a registeredDisabled entry that wasn't there before. Could a missing entry map to undefined instead?
  2. Save path uses a different rule than the editor. mapToQueryVariables.js:414 still checks parkingType === BIKE_PARKING. Could it use !source.hasFullFieldSet, so the same predicate decides both what's shown and what's saved?
  3. isParkAndRide is now just another name for hasFullFieldSet. Can we remove it and use hasFullFieldSet in toClient()?
  4. StopPlaceView.tsx:121: please use the PARKING_TYPE constants instead of the "bikeParking"/"parkAndRide" strings.

I think 1 and 2 should be looked at. 3 and 4 are nice to haves.

@teppope

teppope commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Nice work. Splitting parkingType into hasFullFieldSet and isForPedalCycle makes the model much clearer, and the tests cover the cases well. A few things before merge:

  1. New registeredDisabled: 0 entry on save. Bicycle parkings with a stored type now get the full field set. toClient() gives numberOfSpacesForRegisteredDisabledUserType: 0 when the entry doesn't exist, and mergeParkingSpaces keeps 0. So every save of such a parking adds a registeredDisabled entry that wasn't there before. Could a missing entry map to undefined instead?
  2. Save path uses a different rule than the editor. mapToQueryVariables.js:414 still checks parkingType === BIKE_PARKING. Could it use !source.hasFullFieldSet, so the same predicate decides both what's shown and what's saved?
  3. isParkAndRide is now just another name for hasFullFieldSet. Can we remove it and use hasFullFieldSet in toClient()?
  4. StopPlaceView.tsx:121: please use the PARKING_TYPE constants instead of the "bikeParking"/"parkAndRide" strings.

I think 1 and 2 should be looked at. 3 and 4 are nice to haves.

Thanks, I've pushed a fix to all four.

@teppope
teppope requested a review from a-limyr October 22, 2026 05:13
@a-limyr

a-limyr commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thanks, all four points from the previous review are fixed.

One thing before merge:

  • Merge conflict: ParkingMarkers.tsx conflicts with master, which added pendingPosition. Could you rebase? It should resolve to const [lat, lng] = pendingPosition ?? parking.location; together with const isBike = parking.isForPedalCycle ?? false;.

@a-limyr a-limyr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending rebase with master.

teppope and others added 6 commits October 23, 2026 10:04
…types

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ields by the editor's rule

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@teppope
teppope force-pushed the fix/parking-read-stored-type branch from fea614d to 1a6f82b Compare October 23, 2026 07:05
@a-limyr
a-limyr merged commit 4e63f42 into entur:master Oct 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants