Skip to content

Commit 194d8c8

Browse files
committed
front: pathfinding: display CI/CH codes
- create formatUicToCi in utils/strings.ts - add CI/CH codes in ModalSugerredVias, StationCard and DisplayVias - add CH code in AllowancesModalOP and DriverTrainScheduleStop - add elipsis to vias name in modal - replace suggered by suggested
1 parent a611db7 commit 194d8c8

File tree

12 files changed

+86
-43
lines changed

12 files changed

+86
-43
lines changed

front/src/applications/operationalStudies/consts.ts

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export interface PointOnMap {
113113
track?: string;
114114
position?: number;
115115
path_offset?: number;
116+
uic?: number | null;
117+
ch?: string | null;
116118
location?: {
117119
track_section?: string;
118120
offset?: number;

front/src/common/StationCard.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { formatUicToCi } from 'utils/strings';
23

34
export interface ImportStation {
45
trigram?: string;
@@ -33,17 +34,15 @@ export default function StationCard({ station, onClick, fixedHeight = false }: P
3334
>
3435
<div className="station-card-head">
3536
<span className="station-card-code">{trigram}</span>
36-
<span className="station-card-name">{name}</span>
37-
{yardname && !yardNamesToExclude.includes(yardname) && (
38-
<span className="station-card-ch">{yardname}</span>
39-
)}
37+
<span className="station-card-name">{name}&nbsp;</span>
38+
{yardname && !yardNamesToExclude.includes(yardname) && <span>{yardname}</span>}
39+
<span className="station-card-uic ml-3">{uic ? formatUicToCi(uic) : ''}</span>
4040
</div>
4141
<div className="station-card-localization">
4242
<span className="station-card-city">{town}</span>
4343
<span className="station-card-department">{department}</span>
4444
{department && region && <div className="station-card-separator">/</div>}
4545
<span className="station-card-region">{region}</span>
46-
<span className="station-card-uic">{uic}</span>
4746
</div>
4847
{linename && (
4948
<div className="station-card-footer">

front/src/common/api/osrdEditoastApi.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,7 @@ export type GeoJsonPoint = {
16421642
type: 'Point';
16431643
};
16441644
export type PathWaypoint = {
1645+
ch?: string | null;
16451646
duration: number;
16461647
geo: GeoJsonPoint;
16471648
id: string | null;
@@ -1650,6 +1651,7 @@ export type PathWaypoint = {
16501651
path_offset: number;
16511652
sch: GeoJsonPoint;
16521653
suggestion: boolean;
1654+
uic?: number | null;
16531655
};
16541656
export type PathResponse = {
16551657
created: string;
@@ -2200,6 +2202,7 @@ export type ResultSpeed = {
22002202
time: number;
22012203
};
22022204
export type ResultStops = {
2205+
ch?: string | null;
22032206
duration: number;
22042207
position: number;
22052208
time: number;

front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStop.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export default function DriverTrainScheduleStop({ stop, idx, train }: Props) {
5252
<td className="d-flex justify-content-center">
5353
<div>{Number.isInteger(pk) ? `${pk}.0` : pk}</div>
5454
</td>
55-
<td>{stop.name || 'Unknown'}</td>
55+
<td>
56+
{stop.name || 'Unknown'}&nbsp;
57+
{stop.ch === '00' || !stop.ch ? 'BV' : `${stop.ch}`}
58+
</td>
5659
<td className="stoptime-container">
5760
<div className="box">
5861
<div className="box-row">

front/src/modules/trainschedule/components/ImportTrainSchedule/generateTrainSchedulesPayload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PathWaypoint, TrainScheduleBatchItem } from 'common/api/osrdEditoastApi
33
import { time2sec } from 'utils/timeManipulation';
44

55
// Hope for indexes are the same !
6-
// Synchronisation is done with indexes between pathfinding not suggered positions, and required steps from importation
6+
// Synchronisation is done with indexes between pathfinding not suggested positions, and required steps from importation
77
function mixPathPositionsAndTimes(requiredSteps: Step[], pathFindingWaypoints: PathWaypoint[]) {
88
const startTime = new Date(requiredSteps[0].departureTime);
99
const pathFindingStepsFiltered = pathFindingWaypoints.filter((waypoint) => !waypoint.suggestion);

front/src/modules/trainschedule/components/ManageTrainSchedule/Allowances/AllowancesModalOP.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export default function AllowancesModalOP({
2727
key={waypoint.path_offset}
2828
>
2929
<div className="col-6">{waypoint.path_offset}</div>
30-
<div className="col-6">{waypoint.name}</div>
30+
<div className="col-6">
31+
{waypoint.name}&nbsp;
32+
{waypoint.ch === '00' || !waypoint.ch ? 'BV' : `${waypoint.ch}`}
33+
</div>
3134
</button>
3235
))}
3336
</div>

front/src/modules/trainschedule/components/ManageTrainSchedule/Itinerary/DisplayVias.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import cx from 'classnames';
99
import { AnyAction, ThunkAction } from '@reduxjs/toolkit';
1010
import { Position } from 'geojson';
1111
import { RootState } from 'reducers';
12+
import { formatUicToCi } from 'utils/strings';
1213

1314
type InputStopTimeProps = {
1415
index: number;
@@ -99,6 +100,12 @@ export default function DisplayVias({ zoomToFeaturePoint }: DisplayViasProps) {
99100
`KM ${place.position && Math.round(place.position) / 1000}`
100101
}`}
101102
</small>
103+
<small className="">
104+
{place.ch === '00' || !place.ch ? 'BV' : `${place.ch}`}
105+
</small>
106+
<small className="text-muted ml-3">
107+
{place.uic ? formatUicToCi(place.uic) : ''}
108+
</small>
102109
</div>
103110
{index !== indexSelected && (
104111
<div className="default-durations-button mr-1">

front/src/modules/trainschedule/components/ManageTrainSchedule/Itinerary/ModalSuggeredVias.tsx

+30-24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ModalContext } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
1111
import { Spinner } from 'common/Loader';
1212
import type { ArrayElement } from 'utils/types';
1313
import type { PathResponse, PathWaypoint } from 'common/api/osrdEditoastApi';
14+
import { formatUicToCi } from 'utils/strings';
1415

1516
type Props = {
1617
removeAllVias: () => void;
@@ -65,32 +66,37 @@ export default function ModalSugerredVias({ removeAllVias, pathfindingInProgress
6566

6667
const formatVia = (via: ArrayElement<PathResponse['steps']>, idx: number, idxTrueVia: number) => (
6768
<div
68-
key={`suggered-via-modal-${via.id}-${idx}`}
69-
className={`d-flex align-items-center p-1 ${via.suggestion && 'suggerred-via-clickable'}`}
69+
key={`suggested-via-modal-${via.id}-${idx}`}
70+
className={`d-flex align-items-center p-1 ${via.suggestion && 'suggested-via-clickable'}`}
71+
title={via.name!}
7072
>
7173
{!via.suggestion && <small className="pr-2">{idxTrueVia}</small>}
7274
<i className={`${via.suggestion ? 'text-muted' : 'text-info'} icons-itinerary-bullet mr-2`} />
73-
{via.name || ''}
74-
<small className="ml-2">
75-
{via.path_offset && `KM ${Math.round(via.path_offset) / 1000}`}
76-
</small>
77-
{via.suggestion && via.id && !selectedViasTracks.includes(via.id) ? (
78-
<button
79-
className="btn btn-sm btn-only-icon ml-auto"
80-
type="button"
81-
onClick={() => convertPathfindingVias(suggeredVias, idx - 1)}
82-
>
83-
<GoPlus />
84-
</button>
85-
) : (
86-
<button
87-
className="btn btn-sm btn-only-icon ml-auto bg-dark"
88-
type="button"
89-
onClick={() => removeViaFromPath(via)}
90-
>
91-
<GoDash color="white" />
92-
</button>
93-
)}
75+
<span className="suggested-via-name">{via.name || ''}</span>&nbsp;
76+
<span>{via.ch === '00' || !via.ch ? 'BV' : `${via.ch}`}</span>
77+
<small className="text-muted ml-3">{via.uic ? formatUicToCi(via.uic) : ''}</small>
78+
<div className="ml-auto">
79+
<small className="mr-2">
80+
{via.path_offset && `KM ${Math.round(via.path_offset) / 1000}`}
81+
</small>
82+
{via.suggestion && via.id && !selectedViasTracks.includes(via.id) ? (
83+
<button
84+
className="btn btn-sm btn-only-icon"
85+
type="button"
86+
onClick={() => convertPathfindingVias(suggeredVias, idx - 1)}
87+
>
88+
<GoPlus />
89+
</button>
90+
) : (
91+
<button
92+
className="btn btn-sm btn-only-icon bg-dark"
93+
type="button"
94+
onClick={() => removeViaFromPath(via)}
95+
>
96+
<GoDash color="white" />
97+
</button>
98+
)}
99+
</div>
94100
</div>
95101
);
96102

@@ -104,7 +110,7 @@ export default function ModalSugerredVias({ removeAllVias, pathfindingInProgress
104110
</button>
105111
</ModalHeaderSNCF>
106112
<ModalBodySNCF>
107-
<div className="suggered-vias">
113+
<div className="suggested-vias">
108114
{pathfindingInProgress && <LoaderPathfindingInProgress />}
109115
{suggeredVias &&
110116
suggeredVias.map((via, idx) => {

front/src/modules/trainschedule/styles/ManageTrainSchedule/_itinerary.scss

+15-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535

3636
.manage-vias-modal {
37-
.suggered-vias {
37+
.suggested-vias {
3838
max-height: 30vh;
3939
overflow-y: auto;
4040
.loaderPathfindingInProgress {
@@ -48,11 +48,20 @@
4848
border-radius: 0 0 4px 4px;
4949
background-color: rgba(242, 242, 242, 0.75);
5050
}
51-
.suggerred-via-clickable {
52-
cursor: pointer;
53-
border-radius: 4px;
54-
&:hover {
55-
background-color: var(--coolgray1);
51+
.suggested-via {
52+
&-clickable {
53+
cursor: pointer;
54+
border-radius: 4px;
55+
&:hover {
56+
background-color: var(--coolgray1);
57+
}
58+
}
59+
60+
&-name {
61+
max-width: 47%;
62+
white-space: nowrap;
63+
overflow: hidden;
64+
text-overflow: ellipsis;
5665
}
5766
}
5867
}

front/src/reducers/osrdsimulation/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export interface Stop {
8080
track_number: number | null;
8181
line_name: string | null;
8282
track_name: string | null;
83+
ch?: string | null;
8384
}
8485

8586
export interface RouteAspect<Time = number, Color = number> {

front/src/styles/scss/common/components/_stationCard.scss

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
font-weight: 500;
3535
font-size: .8rem;
3636
}
37+
.station-card-uic {
38+
margin-left: auto;
39+
font-size: .6rem;
40+
color: var(--primary);
41+
}
3742
}
3843
.station-card-localization {
3944
display: flex;
@@ -58,11 +63,6 @@
5863
text-transform: uppercase;
5964
font-size: .6rem;
6065
}
61-
.station-card-uic {
62-
margin-left: auto;
63-
font-size: .6rem;
64-
color: var(--primary);
65-
}
6666
}
6767
.station-card-footer {
6868
display: flex;

front/src/utils/strings.ts

+10
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,13 @@ export function onlyDigit(str: string): string {
5555
export function convertInputStringToNumber(str: string) {
5656
return str !== '' && !Number.isNaN(str) ? +str : undefined;
5757
}
58+
59+
/**
60+
* Given an UIC number, check if it begins with 87,
61+
* if true return the UIC without the 87,
62+
* if false return the full UIC
63+
* @param uic full UIC and CI code (8 digits)
64+
*/
65+
export function formatUicToCi(uic: number) {
66+
return uic.toString().startsWith('87') ? uic.toString().slice(2) : uic;
67+
}

0 commit comments

Comments
 (0)