Skip to content

Commit 1eedac6

Browse files
committed
Fix map visibility filters when opening stop/stop area from registry
When navigating to the map via "show on map" from stop list, stop details or stop area views, the map filters were not adjusted to match the stop's actual vehicle mode or priority.
1 parent d87fc41 commit 1eedac6

9 files changed

Lines changed: 33 additions & 20 deletions

File tree

ui/src/components/stop-registry/search/components/StopSearchResultStopsTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const StopSearchResultRow: FC<StopSearchResultRowProps> = ({
3434
label: stop.publicCode,
3535
netexId: stop.netexId,
3636
location: getGeometryPoint(stop.location),
37+
priority: stop.priority,
38+
transportMode: stop.transportMode,
3739
};
3840

3941
return (

ui/src/components/stop-registry/stop-areas/stop-area-details/components/StopAreaMemberStopRow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const StopAreaMemberStopRow: FC<StopAreaMemberStopRowProps> = ({
2323
label: member.publicCode,
2424
netexId: member.netexId,
2525
location: getGeometryPoint(member.location),
26+
priority: member.priority,
27+
transportMode: member.transportMode,
2628
};
2729

2830
return (

ui/src/components/stop-registry/stop-areas/stop-area-details/components/StopAreaMinimap.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export const StopAreaMinimap: FC<StopAreaComponentProps> = ({
4848
shape="slim"
4949
className="absolute top-2 right-2"
5050
inverted
51-
onClick={() => showOnMap(area.id ?? undefined, point)}
51+
onClick={() =>
52+
showOnMap(area.id ?? undefined, point, area.transportMode)
53+
}
5254
testId={testIds.openMapButton}
5355
>
5456
{t('stopAreaDetails.minimap.showOnMap')}

ui/src/components/stop-registry/stop-areas/stop-area-details/components/StopAreaTitleRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const StopAreaTitleRow: FC<StopAreaComponentProps> = ({
2929
const point = mapLngLatToPoint(area.geometry?.coordinates ?? []);
3030

3131
const onClickAreaMap = point
32-
? () => showOnMap(area.id ?? undefined, point)
32+
? () => showOnMap(area.id ?? undefined, point, area.transportMode)
3333
: noop;
3434

3535
const transportModeIcon = getTransportModeIcon(area.transportMode);

ui/src/components/stop-registry/stops/stop-details/title-row/OpenOnMapButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export const OpenOnMapButton: FC<OpenOnMapButtonProps> = ({
3333
label: stop.label,
3434
netexId: stop.quay.id,
3535
location,
36+
priority: stop.priority,
37+
transportMode: stop.stop_place?.transportMode ?? null,
3638
});
3739
}
3840
}

ui/src/components/stop-registry/terminals/components/member-stops/StopAreaSection.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ const StopRow: FC<StopRowProps> = ({ stop, observationDate }) => {
135135
label: stop.publicCode,
136136
netexId: stop.netexId,
137137
location: getGeometryPoint(stop.location),
138+
priority: stop.priority,
139+
transportMode: stop.transportMode,
138140
};
139141

140142
return (
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import { StopRegistryTransportModeType } from '../../../generated/graphql';
12
import { Point } from '../../../types';
3+
import { Priority } from '../../../types/enums';
24

35
export type LocatableStop = {
46
readonly label: string;
57
readonly netexId: string | null;
68
readonly location: Point;
9+
readonly priority?: Priority;
10+
readonly transportMode?: StopRegistryTransportModeType | null;
711
};

ui/src/components/stop-registry/utils/useShowStopAreaOnMap.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useAppDispatch, useObservationDateQueryParam } from '../../../hooks';
22
import {
3-
FilterType,
43
MapEntityEditorViewState,
54
resetMapState,
65
setMapStopAreaViewStateAction,
76
setSelectedMapStopAreaIdAction,
8-
setStopFilterAction,
97
} from '../../../redux';
108
import { Point } from '../../../types';
9+
import { useEnsureStopVehicleModeVisible } from '../../map/utils/useEnsureStopVehicleModeVisible';
1110
import { useNavigateToMap } from '../../map/utils/useNavigateToMap';
1211

1312
export function useShowStopAreaOnMap() {
@@ -18,17 +17,17 @@ export function useShowStopAreaOnMap() {
1817
initialize: false,
1918
});
2019
const navigateToMap = useNavigateToMap();
20+
const ensureVehicleModeVisible = useEnsureStopVehicleModeVisible();
2121

22-
return (id: string | undefined, point: Point) => {
22+
return (
23+
id: string | undefined,
24+
point: Point,
25+
transportMode?: string | null,
26+
) => {
2327
dispatch(resetMapState()).then(() => {
2428
dispatch(setSelectedMapStopAreaIdAction(id));
2529
dispatch(setMapStopAreaViewStateAction(MapEntityEditorViewState.POPUP));
26-
dispatch(
27-
setStopFilterAction({
28-
filterType: FilterType.ShowAllBusStops,
29-
isActive: false,
30-
}),
31-
);
30+
ensureVehicleModeVisible(transportMode);
3231

3332
navigateToMap({
3433
viewPort: {

ui/src/components/stop-registry/utils/useShowStopOnMap.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { DateTime } from 'luxon';
22
import { useAppDispatch, useObservationDateQueryParam } from '../../../hooks';
33
import {
4-
FilterType,
54
MapEntityEditorViewState,
65
resetMapState,
76
setMapStopViewStateAction,
87
setSelectedStopIdAction,
9-
setStopFilterAction,
108
} from '../../../redux';
9+
import { useUpdateStopPriorityFilterIfNeeded } from '../../map/stops/hooks/useUpdateStopPriorityFilterIfNeeded';
10+
import { useEnsureStopVehicleModeVisible } from '../../map/utils/useEnsureStopVehicleModeVisible';
1111
import { useNavigateToMap } from '../../map/utils/useNavigateToMap';
1212
import { LocatableStop } from '../types';
1313

@@ -20,9 +20,11 @@ export function useShowStopOnMap() {
2020
initialize: false,
2121
});
2222
const navigateToMap = useNavigateToMap();
23+
const ensureVehicleModeVisible = useEnsureStopVehicleModeVisible();
24+
const updatePriorityFilterIfNeeded = useUpdateStopPriorityFilterIfNeeded();
2325

2426
return (
25-
{ netexId, location }: LocatableStop,
27+
{ netexId, location, priority, transportMode }: LocatableStop,
2628
observeOnDate: DateTime | null = null,
2729
) => {
2830
dispatch(resetMapState()).then(() => {
@@ -31,12 +33,10 @@ export function useShowStopOnMap() {
3133
dispatch(setMapStopViewStateAction(MapEntityEditorViewState.POPUP));
3234
}
3335

34-
dispatch(
35-
setStopFilterAction({
36-
filterType: FilterType.ShowAllBusStops,
37-
isActive: true,
38-
}),
39-
);
36+
if (priority !== undefined) {
37+
updatePriorityFilterIfNeeded(priority);
38+
}
39+
ensureVehicleModeVisible(transportMode);
4040

4141
navigateToMap({
4242
viewPort: {

0 commit comments

Comments
 (0)