mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 06:26:26 +00:00
fix(planner): a booked hotel stays in the place list when road trip stops are hidden in Days
Since 4.3.0 every lodging booking types its place as 'hotel', and 'hotel' is one of the road trip stop types. With "Show in Days too" switched off, Days dropped every such place from the trip's place list, so a hotel vanished from the sidebar, from the booking's own place picker and from the Days map the moment it was booked, and a click on it in the day list found nothing. Nothing was deleted: road trip mode kept showing it. Days now leaves out only road trip stops nobody booked. A lodging place stays, and so does any place a stay or a booking points at, on the desktop and on the phone. Trips planned on 4.3.1 show their hotels again without any change to their data. An imported GPX or KML track is no longer offered as the place of a stay, in the booking form, the day's hotel picker and the phone's sheets. A stay that already names a track keeps showing it.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { stayPlaces } from './stayPlaces'
|
||||
|
||||
// FE-UTIL-STAYPLACES-001 to FE-UTIL-STAYPLACES-003
|
||||
|
||||
describe('stayPlaces', () => {
|
||||
const hotel = { id: 1, route_geometry: null }
|
||||
const hut = { id: 2 }
|
||||
const track = { id: 3, route_geometry: '[[50.1,7.6],[50.2,7.7]]' }
|
||||
|
||||
it('FE-UTIL-STAYPLACES-001: offers every place but an imported track', () => {
|
||||
expect(stayPlaces([hotel, hut, track]).map(p => p.id)).toEqual([1, 2])
|
||||
expect(stayPlaces([hotel, hut, track], '').map(p => p.id)).toEqual([1, 2])
|
||||
expect(stayPlaces([hotel, hut, track], null).map(p => p.id)).toEqual([1, 2])
|
||||
})
|
||||
|
||||
it('FE-UTIL-STAYPLACES-002: keeps the track a stay already names, by number or by text', () => {
|
||||
expect(stayPlaces([hotel, track], 3).map(p => p.id)).toEqual([1, 3])
|
||||
expect(stayPlaces([hotel, track], '3').map(p => p.id)).toEqual([1, 3])
|
||||
})
|
||||
|
||||
it('FE-UTIL-STAYPLACES-003: a stay at an ordinary place lets no track in', () => {
|
||||
expect(stayPlaces([hotel, track], 1).map(p => p.id)).toEqual([1])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* The places a stay can be booked at: every place but an imported GPX or KML track,
|
||||
* which is a route to follow, not somewhere to sleep.
|
||||
*
|
||||
* The place a stay already names stays in the list, track or not, so a booking made
|
||||
* before tracks were left out still shows what it points at and saves unchanged.
|
||||
*/
|
||||
export function stayPlaces<P extends { id: number; route_geometry?: string | null }>(
|
||||
places: P[],
|
||||
currentPlaceId?: number | string | null,
|
||||
): P[] {
|
||||
return places.filter(place => !place.route_geometry
|
||||
|| (currentPlaceId != null && currentPlaceId !== '' && String(place.id) === String(currentPlaceId)))
|
||||
}
|
||||
Reference in New Issue
Block a user