Skip to content

Commit 48f12d2

Browse files
committed
fixup! front: manchette: display waypoints added with map click
1 parent 9b212cc commit 48f12d2

File tree

4 files changed

+50
-31
lines changed

4 files changed

+50
-31
lines changed

front/public/locales/en/simulation.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"used": "used"
3535
},
3636
"projectionInProgress": "Projection in progress: {{ count }}/{{ total }} trains",
37-
"requestedPoint": "requested point {{ count }}",
37+
"requestedPoint": "requested point ({{ count }})",
3838
"reset": "Reset the chart",
3939
"resetTimer": "Reset timer",
4040
"rotate": "Rotate the chart",

front/public/locales/fr/simulation.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"used": "utilisée"
3535
},
3636
"projectionInProgress": "Projection en cours: {{ count }}/{{ total }} trains",
37-
"requestedPoint": "point demandé {{ count }}",
37+
"requestedPoint": "point demandé ({{ count }})",
3838
"reset": "Réinitialiser le graphique",
3939
"resetTimer": "Réinitialiser le compteur",
4040
"rotate": "Pivoter le graphique",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { KebabHorizontal } from '@osrd-project/ui-icons';
2+
import React, { useRef } from 'react';
3+
4+
const SpaceTimeChartHeader = () => {
5+
const dialogRef = useRef<HTMLDialogElement>(null);
6+
7+
return (
8+
<div className="spacetimechart-header">
9+
<button onClick={() => dialogRef.current?.showModal()}>
10+
<KebabHorizontal />
11+
</button>
12+
<dialog ref={dialogRef}>
13+
Manchette Menu <button onClick={() => dialogRef.current?.close()}>close</button>
14+
</dialog>
15+
</div>
16+
);
17+
};
18+
export default SpaceTimeChartHeader;

front/src/modules/simulationResult/components/SpaceTimeChart/useGetProjectedTrainOperationalPoints.ts

+30-29
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const useGetProjectedTrainOperationalPoints = (
2222
const { data: trainScheduleUsedForProjection } =
2323
osrdEditoastApi.endpoints.getTrainScheduleById.useQuery(
2424
{
25-
id: trainIdUsedForProjection as number,
25+
id: trainIdUsedForProjection!,
2626
},
2727
{
2828
skip: !trainIdUsedForProjection,
@@ -31,8 +31,8 @@ const useGetProjectedTrainOperationalPoints = (
3131

3232
const { data: pathfindingResult } = osrdEditoastApi.endpoints.getTrainScheduleByIdPath.useQuery(
3333
{
34-
id: trainIdUsedForProjection as number,
35-
infraId: infraId as number,
34+
id: trainIdUsedForProjection!,
35+
infraId: infraId!,
3636
},
3737
{
3838
skip: !trainIdUsedForProjection || !infraId || trainIdUsedForProjection === STDCM_TRAIN_ID,
@@ -63,34 +63,35 @@ const useGetProjectedTrainOperationalPoints = (
6363
PathProperties['operational_points']
6464
>;
6565
// Check if there are vias added by map click and insert them in the operational points
66-
if (trainScheduleUsedForProjection.path.some((step) => 'track' in step)) {
67-
trainScheduleUsedForProjection.path.forEach((step, i) => {
68-
if ('track' in step) {
69-
const positionOnPath = pathfindingResult.path_item_positions[i];
70-
const indexToInsert = operationalPointsWithAllWaypoints.findIndex(
71-
(op) => op.position >= positionOnPath
72-
);
66+
let waypointCounter = 1;
67+
trainScheduleUsedForProjection.path.forEach((step, i) => {
68+
if (!('track' in step)) return;
7369

74-
const formattedStep: NonNullable<PathProperties['operational_points']>[number] = {
75-
id: step.id,
76-
extensions: {
77-
identifier: {
78-
name: t('requestedPoint', { count: indexToInsert }),
79-
uic: 0,
80-
},
81-
},
82-
part: { track: step.track, position: step.offset },
83-
position: positionOnPath,
84-
};
70+
const positionOnPath = pathfindingResult.path_item_positions[i];
71+
const indexToInsert = operationalPointsWithAllWaypoints.findIndex(
72+
(op) => op.position >= positionOnPath
73+
);
8574

86-
operationalPointsWithAllWaypoints = addElementAtIndex(
87-
operationalPointsWithAllWaypoints,
88-
indexToInsert,
89-
formattedStep
90-
);
91-
}
92-
});
93-
}
75+
const formattedStep: NonNullable<PathProperties['operational_points']>[number] = {
76+
id: step.id,
77+
extensions: {
78+
identifier: {
79+
name: t('requestedPoint', { count: waypointCounter }),
80+
uic: 0,
81+
},
82+
},
83+
part: { track: step.track, position: step.offset },
84+
position: positionOnPath,
85+
};
86+
87+
operationalPointsWithAllWaypoints = addElementAtIndex(
88+
operationalPointsWithAllWaypoints,
89+
indexToInsert,
90+
formattedStep
91+
);
92+
93+
waypointCounter += 1;
94+
});
9495

9596
setOperationalPoints(operationalPointsWithAllWaypoints);
9697
}

0 commit comments

Comments
 (0)