Skip to content

Commit

Permalink
front: be able to search a TVM signal
Browse files Browse the repository at this point in the history
Signed-off-by: SarahBellaha <[email protected]>
  • Loading branch information
SarahBellaha committed Nov 6, 2024
1 parent 00a169a commit fc98731
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 8 additions & 4 deletions front/src/common/Map/Search/MapSearchSignal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
import MultiSelectSNCF from 'common/BootstrapSNCF/MultiSelectSNCF';
import SelectImproved from 'common/BootstrapSNCF/SelectImprovedSNCF';
import SignalCard from 'common/Map/Search/SignalCard';
import { createMapSearchQuery, onResultSearchClick } from 'common/Map/utils';
import {
createMapSearchQuery,
createTrackSystemQuery,
onResultSearchClick,
} from 'common/Map/utils';
import { useInfraID } from 'common/osrdContext';
import { setFailure } from 'reducers/main';
import type { Viewport } from 'reducers/map';
Expand Down Expand Up @@ -101,7 +105,7 @@ const MapSearchSignal = ({ updateExtViewport, closeMapSearchPopUp }: MapSearchSi
lineSearch: string,
signalName: string,
infraIDPayload: number,
trackSystems: string[],
trackSystem: string,
settings: string[]
): SearchPayload => {
const payloadQuery = createMapSearchQuery(lineSearch, {
Expand All @@ -114,7 +118,7 @@ const MapSearchSignal = ({ updateExtViewport, closeMapSearchPopUp }: MapSearchSi
'and',
['=', ['infra_id'], infraIDPayload],
!lineSearch || payloadQuery,
!trackSystems.length || ['contains', ['list', ...trackSystems], ['signaling_systems']],
!trackSystem || createTrackSystemQuery(trackSystem),
!settings.length || ['contains', ['settings'], ['list', ...settings]],
['search', ['label'], signalName],
],
Expand All @@ -127,7 +131,7 @@ const MapSearchSignal = ({ updateExtViewport, closeMapSearchPopUp }: MapSearchSi
searchLineState,
searchState,
infraIDPayload,
signalSystem === SIGNALING_SYSTEMS.ALL ? [] : [signalSystem],
signalSystem === SIGNALING_SYSTEMS.ALL ? '' : signalSystem,
settings
);
await postSearch({
Expand Down
11 changes: 11 additions & 0 deletions front/src/common/Map/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ export function createMapSearchQuery(
: ['search', [nameColumn], searchState];
}

export function createTrackSystemQuery(trackSystem: string) {
if (trackSystem === 'TVM') {
return [
'or',
['contains', ['list', 'TVM300'], ['signaling_systems']],
['contains', ['list', 'TVM430'], ['signaling_systems']],
];
}
return ['contains', ['list', trackSystem], ['signaling_systems']];
}

export function removeSearchItemMarkersOnMap(dispatch: AppDispatch) {
dispatch(updateMapSearchMarker(undefined));
dispatch(updateLineSearchCode(undefined));
Expand Down

0 comments on commit fc98731

Please sign in to comment.