From 813fecaaf6c19c3f20765f9f2c92843c11526263 Mon Sep 17 00:00:00 2001 From: romainvalls Date: Tue, 7 May 2024 11:28:06 +0200 Subject: [PATCH] front: display dead sections in infra editor --- front/public/locales/en/translation.json | 3 +- front/public/locales/fr/translation.json | 3 +- front/src/applications/editor/Map.tsx | 9 +++++ .../editor/components/LayersModal.tsx | 6 ++- front/src/applications/editor/consts.ts | 3 ++ front/src/applications/referenceMap/Map.tsx | 12 +++--- .../extensions/SNCF/NeutralSections.tsx | 38 ++++++++----------- front/src/config/layerOrder.ts | 1 + .../components/SimulationResultsMap.tsx | 15 +++++--- .../components/ManageTrainSchedule/Map.tsx | 12 +++--- 10 files changed, 61 insertions(+), 41 deletions(-) diff --git a/front/public/locales/en/translation.json b/front/public/locales/en/translation.json index 632fbe36c3e..2e917b6a6e3 100644 --- a/front/public/locales/en/translation.json +++ b/front/public/locales/en/translation.json @@ -199,7 +199,8 @@ "switches": "Switches", "track_sections": "Track sections", "speed_sections": "Speed limits", - "platforms": "Platforms" + "platforms": "Platforms", + "neutral_sections": "Dead sections" }, "layers-modal": { "frozen-layer": "needed for the active tool", diff --git a/front/public/locales/fr/translation.json b/front/public/locales/fr/translation.json index 486c3488388..2919111751c 100644 --- a/front/public/locales/fr/translation.json +++ b/front/public/locales/fr/translation.json @@ -192,7 +192,8 @@ "switches": "Aiguillages", "track_sections": "Sections de lignes", "speed_sections": "Vitesses limites", - "platforms": "Quais" + "platforms": "Quais", + "neutral_sections": "BP/CC" }, "layers-modal": { "frozen-layer": "nécessaire pour l'outil actif", diff --git a/front/src/applications/editor/Map.tsx b/front/src/applications/editor/Map.tsx index 44bbb1d0778..019f0140851 100644 --- a/front/src/applications/editor/Map.tsx +++ b/front/src/applications/editor/Map.tsx @@ -18,6 +18,7 @@ import { CUSTOM_ATTRIBUTION } from 'common/Map/const'; import colors from 'common/Map/Consts/colors'; import Background from 'common/Map/Layers/Background'; import { useMapBlankStyle } from 'common/Map/Layers/blankStyle'; +import NeutralSections from 'common/Map/Layers/extensions/SNCF/NeutralSections'; import Hillshade from 'common/Map/Layers/Hillshade'; import IGN_BD_ORTHO from 'common/Map/Layers/IGN_BD_ORTHO'; import IGN_CADASTRE from 'common/Map/Layers/IGN_CADASTRE'; @@ -325,6 +326,14 @@ const MapUnplugged = ({ layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]} /> + {editorState.editorLayers.has('neutral_sections') && ( + + )} + {/* Tool specific layers */} {!isNil(infraID) && activeTool.layersComponent && mapRef.current && ( diff --git a/front/src/applications/editor/components/LayersModal.tsx b/front/src/applications/editor/components/LayersModal.tsx index b89d91eb929..9423db4f4ed 100644 --- a/front/src/applications/editor/components/LayersModal.tsx +++ b/front/src/applications/editor/components/LayersModal.tsx @@ -2,7 +2,7 @@ import React, { type FC, useEffect, useMemo, useState } from 'react'; import { groupBy, mapKeys, mapValues, sum, isString, isArray, uniq, isNil } from 'lodash'; import { useTranslation } from 'react-i18next'; -import { GiElectric } from 'react-icons/gi'; +import { GiElectric, GiUnplugged } from 'react-icons/gi'; import { MdSpeed } from 'react-icons/md'; import { TbRectangleVerticalFilled } from 'react-icons/tb'; import { useSelector } from 'react-redux'; @@ -40,6 +40,10 @@ export const LAYERS: Array<{ layers: Layer[]; icon: string | JSX.Element }> = [ layers: ['platforms'], icon: , }, + { + layers: ['neutral_sections'], + icon: , + }, ]; interface LayersModalProps { diff --git a/front/src/applications/editor/consts.ts b/front/src/applications/editor/consts.ts index bbd1a9bc357..91c3e8433cb 100644 --- a/front/src/applications/editor/consts.ts +++ b/front/src/applications/editor/consts.ts @@ -15,6 +15,7 @@ const INFRA_EDITOR_LAYERS = [ 'switches', 'track_sections', 'platforms', + 'neutral_sections', ] as const; export const LAYERS_SET: Set = new Set(INFRA_EDITOR_LAYERS); export type Layer = (typeof INFRA_EDITOR_LAYERS)[number]; @@ -28,6 +29,7 @@ export const EDITOAST_TYPES = [ 'SpeedSection', 'Switch', 'TrackSection', + 'NeutralSection', ] as const; export type EditoastType = (typeof EDITOAST_TYPES)[number]; @@ -40,6 +42,7 @@ export const EDITOAST_TO_LAYER_DICT: Record = { SpeedSection: ['speed_sections', 'psl', 'psl_signs'], Switch: ['switches'], TrackSection: ['track_sections'], + NeutralSection: ['neutral_sections'], }; export const LAYER_TO_EDITOAST_DICT = flatMap(EDITOAST_TO_LAYER_DICT, (values, key) => values.map((value) => [value, key]) diff --git a/front/src/applications/referenceMap/Map.tsx b/front/src/applications/referenceMap/Map.tsx index eeaa05d4198..a4b1b5f5371 100644 --- a/front/src/applications/referenceMap/Map.tsx +++ b/front/src/applications/referenceMap/Map.tsx @@ -199,11 +199,13 @@ function Map() { layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]} infraID={infraID} /> - + {layersSettings.neutral_sections && ( + + )} { - const { layersSettings } = useSelector((state: RootState) => state.map); const neutralSectionsParams: LayerProps = { type: 'line', 'source-layer': 'neutral_sections', @@ -39,23 +36,20 @@ export default ({ colors, layerOrder, infraID }: NeutralSectionsProps) => { }, }; - if (layersSettings.neutral_sections) { - return ( - <> - - - - - - ); - } - return
; + return ( + <> + + + + + + ); }; diff --git a/front/src/config/layerOrder.ts b/front/src/config/layerOrder.ts index 610920b18b9..0e11f6488a7 100644 --- a/front/src/config/layerOrder.ts +++ b/front/src/config/layerOrder.ts @@ -71,4 +71,5 @@ export const LAYER_ENTITIES_ORDERS: Record = Object.freeze({ neutral_signs: LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP], errors: LAYER_GROUPS_ORDER[LAYERS.ERRORS.GROUP], platforms: LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP], + neutral_sections: LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP], }); diff --git a/front/src/modules/simulationResult/components/SimulationResultsMap.tsx b/front/src/modules/simulationResult/components/SimulationResultsMap.tsx index 8af5e2470a1..175dad5c39a 100644 --- a/front/src/modules/simulationResult/components/SimulationResultsMap.tsx +++ b/front/src/modules/simulationResult/components/SimulationResultsMap.tsx @@ -63,7 +63,7 @@ import VirtualLayers from 'modules/simulationResult/components/SimulationResults import type { RootState } from 'reducers'; import { updateViewport } from 'reducers/map'; import type { Viewport } from 'reducers/map'; -import { getTerrain3DExaggeration } from 'reducers/map/selectors'; +import { getLayersSettings, getTerrain3DExaggeration } from 'reducers/map/selectors'; import { getPresentSimulation, getSelectedTrain } from 'reducers/osrdsimulation/selectors'; import type { Train } from 'reducers/osrdsimulation/types'; import { useAppDispatch } from 'store'; @@ -86,6 +86,7 @@ const Map: FC = () => { const trains = useMemo(() => keyBy(simulation.trains, 'id'), [simulation.trains]); const selectedTrain = useSelector(getSelectedTrain); const terrain3DExaggeration = useSelector(getTerrain3DExaggeration); + const layersSettings = useSelector(getLayersSettings); const [geojsonPath, setGeojsonPath] = useState>(); const [selectedTrainHoverPosition, setTrainHoverPosition] = useState(); @@ -316,11 +317,13 @@ const Map: FC = () => { layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]} infraID={infraID} /> - + {layersSettings.neutral_sections && ( + + )} { layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]} infraID={infraID} /> - + {layersSettings.neutral_sections && ( + + )}