mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
fix(places): a track is a duplicate only of a track, never of a sight of that name
A GPX or KML import skipped every row whose name was already a place of the trip. A watch names a hike after where it went, so "Hokitika Gorge" was refused as already in the trip because the gorge itself was a planned place, with no track to show for it (#2810). A track now matches only the tracks of that name; a pin still matches every place of its name. The Places filter also hid its "Tracks" choice whenever Tours was on, on the grounds that tracks are tours then. A track imported before Tours is a plain place and stays in the list, so the choice now counts the tracks that are no tour.
This commit is contained in:
@@ -48,13 +48,17 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('places pool helpers', () => {
|
||||
it('FE-PLANNER-POOL-001: the Tracks choice needs a track and stays away while tours are on', () => {
|
||||
it('FE-PLANNER-POOL-001: the Tracks choice needs a track that is no tour while tours are on (#2810)', () => {
|
||||
const track = buildPlace({ route_geometry: '[[1,2],[3,4]]' });
|
||||
const tour = buildPlace({ route_geometry: '[[1,2],[3,4]]' });
|
||||
tour.tour_place_id = tour.id;
|
||||
const pin = buildPlace();
|
||||
expect(poolHasTracks([pin], false)).toBe(false);
|
||||
expect(poolHasTracks([pin, track], false)).toBe(true);
|
||||
expect(poolHasTracks([pin, track], undefined)).toBe(true);
|
||||
expect(poolHasTracks([pin, track], true)).toBe(false);
|
||||
expect(poolHasTracks([pin, tour], true)).toBe(false);
|
||||
expect(poolHasTracks([pin, tour], false)).toBe(true);
|
||||
expect(poolHasTracks([pin, tour, track], true)).toBe(true);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-POOL-002: the show choices list all, unplanned and planned, then tracks when there are some', () => {
|
||||
|
||||
@@ -12,9 +12,13 @@ export type PlacesFilter = 'all' | 'unplanned' | 'planned' | 'tracks';
|
||||
|
||||
type Translate = ReturnType<typeof useTranslation>['t'];
|
||||
|
||||
/** Whether the "Tracks" choice belongs in the pool: never while tours are on, since tracks are tours then. */
|
||||
/**
|
||||
* Whether the "Tracks" choice belongs in the pool: a place with a line that is
|
||||
* no tour. While tours are on a tour lists under Tours, but a track imported
|
||||
* before them (4.x) is a plain place and stays here (#2810).
|
||||
*/
|
||||
export function poolHasTracks(places: Place[], toursEnabled: boolean | undefined): boolean {
|
||||
return !toursEnabled && places.some((p) => p.route_geometry);
|
||||
return places.some((p) => p.route_geometry && !(toursEnabled && p.tour_place_id === p.id));
|
||||
}
|
||||
|
||||
/** The "show" choices; tracks only once a place has one. */
|
||||
|
||||
Reference in New Issue
Block a user