From b1c1b48941ca85a9f94c0523ea61efd8cf3a0b5a Mon Sep 17 00:00:00 2001 From: theocrsb Date: Wed, 20 Nov 2024 13:44:18 +0100 Subject: [PATCH] front: select op with map when add train -bold pr on hover (for PRs on same track) -select pr on map and choose track Signed-off-by: theocrsb --- .../common/Map/Layers/OperationalPoints.tsx | 22 ++++++++++++++++--- .../components/ManageTrainSchedule/Map.tsx | 12 ++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/front/src/common/Map/Layers/OperationalPoints.tsx b/front/src/common/Map/Layers/OperationalPoints.tsx index 9c9a1c4c805..b65029b7497 100644 --- a/front/src/common/Map/Layers/OperationalPoints.tsx +++ b/front/src/common/Map/Layers/OperationalPoints.tsx @@ -10,9 +10,15 @@ interface Props { colors: Theme; layerOrder: number; infraID: number | undefined; + operationnalPointId?: string; } -export default function OperationalPoints({ colors, layerOrder, infraID }: Props) { +export default function OperationalPoints({ + colors, + layerOrder, + infraID, + operationnalPointId, +}: Props) { const point: LayerProps = { type: 'circle', 'source-layer': 'operational_points', @@ -42,7 +48,12 @@ export default function OperationalPoints({ colors, layerOrder, infraID }: Props ['concat', ' ', ['get', 'extensions_sncf_ch']], ], ], - 'text-font': ['Roboto Condensed'], + 'text-font': [ + 'case', + ['==', ['get', 'id'], operationnalPointId || ''], + ['literal', ['Roboto Bold']], + ['literal', ['Roboto Condensed']], + ], 'text-size': 12, 'text-anchor': 'left', 'text-justify': 'left', @@ -100,7 +111,12 @@ export default function OperationalPoints({ colors, layerOrder, infraID }: Props ['get', 'extensions_sncf_ch'], ], ], - 'text-font': ['Roboto Condensed'], + 'text-font': [ + 'case', + ['==', ['get', 'id'], operationnalPointId || ''], + ['literal', ['Roboto Bold']], + ['literal', ['Roboto Condensed']], + ], 'text-size': 11, 'text-anchor': 'left', 'text-allow-overlap': false, diff --git a/front/src/modules/trainschedule/components/ManageTrainSchedule/Map.tsx b/front/src/modules/trainschedule/components/ManageTrainSchedule/Map.tsx index 6dbcea9f83a..e6762d5dfb3 100644 --- a/front/src/modules/trainschedule/components/ManageTrainSchedule/Map.tsx +++ b/front/src/modules/trainschedule/components/ManageTrainSchedule/Map.tsx @@ -101,6 +101,7 @@ const Map = ({ const [mapIsLoaded, setMapIsLoaded] = useState(false); + const [operationnalPointId, setOperationnalPointId] = useState(undefined); const [snappedPoint, setSnappedPoint] = useState | undefined>(); const { urlLat = '', urlLon = '', urlZoom = '', urlBearing = '', urlPitch = '' } = useParams(); const dispatch = useAppDispatch(); @@ -169,13 +170,18 @@ const Map = ({ const onMoveGetFeature = (e: MapLayerMouseEvent) => { if (preventPointSelection) return; - const result = getMapMouseEventNearestFeature(e, { layersId: ['chartis/tracks-geo/main'] }); + const result = getMapMouseEventNearestFeature(e); if ( result && result.feature.properties && result.feature.properties.id && - result.feature.geometry.type === 'LineString' + (result.feature.geometry.type === 'LineString' || result.feature.geometry.type === 'Point') ) { + if (result.feature.geometry.type === 'Point') { + console.log(result.feature); + setOperationnalPointId(result.feature.properties.id); + } + setSnappedPoint({ type: 'Feature', geometry: { @@ -187,6 +193,7 @@ const Map = ({ }, }); } else { + setOperationnalPointId(undefined); setSnappedPoint(undefined); } }; @@ -332,6 +339,7 @@ const Map = ({ colors={colors[mapStyle]} layerOrder={LAYER_GROUPS_ORDER[LAYERS.OPERATIONAL_POINTS.GROUP]} infraID={infraID} + operationnalPointId={operationnalPointId} /> )}