Skip to content

Commit 2e929d2

Browse files
SharglutDevyounesschrifi
authored andcommitted
front: rename driver train schedule margin option
1 parent 19d75e8 commit 2e929d2

File tree

7 files changed

+73
-70
lines changed

7 files changed

+73
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
2-
"actualspeed": "Actual",
3-
"actualspeed-short": "Act.",
4-
"averagespeed": "Mean",
5-
"averagespeed-short": "Mean",
6-
"composition": "Composition",
7-
"dcmdetails": "Train path n°",
8-
"destination": "Destination",
9-
"energyconsumed-basic": "shortest running time",
10-
"energyconsumed-eco": "energy saving running time",
11-
"energydetails": "Energy consumption at the rim",
12-
"mass": "Mass",
13-
"numberoflines": "Number of lines",
14-
"origin": "Origin",
15-
"pk": "PK",
16-
"place": "Facility",
17-
"placeholderline": "No.",
18-
"rollingstock": "Rolling stock",
19-
"speed": "Speed",
20-
"speedlimit": "Limit",
21-
"speedlimit-short": "Lim.",
22-
"speedLimitByTag": "Composition code",
23-
"time": "Time",
24-
"timetable": "Timetable",
25-
"trackname": "Track",
26-
"unknownStop": "Unknown"
2+
"actualspeed": "Actual",
3+
"actualspeed-short": "Act.",
4+
"averagespeed": "Mean",
5+
"averagespeed-short": "Mean",
6+
"composition": "Composition",
7+
"dcmdetails": "Train path n°",
8+
"destination": "Destination",
9+
"energyconsumed-basic": "shortest running time",
10+
"energyconsumed-eco": "energy saving running time",
11+
"energydetails": "Energy consumption at the rim",
12+
"margin": "Margin",
13+
"mass": "Mass",
14+
"numberoflines": "Number of lines",
15+
"origin": "Origin",
16+
"pk": "PK",
17+
"place": "Facility",
18+
"placeholderline": "No.",
19+
"rollingstock": "Rolling stock",
20+
"speed": "Speed",
21+
"speedlimit": "Limit",
22+
"speedlimit-short": "Lim.",
23+
"speedLimitByTag": "Composition code",
24+
"time": "Time",
25+
"timetable": "Timetable",
26+
"trackname": "Track",
27+
"unknownStop": "Unknown"
2728
}
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
2-
"actualspeed": "Actuelle",
3-
"actualspeed-short": "Act.",
4-
"averagespeed": "Moyenne",
5-
"averagespeed-short": "Moy.",
6-
"composition": "Composition",
7-
"dcmdetails": "Sillon n°",
8-
"destination": "Destination",
9-
"energyconsumed-basic": "base",
10-
"energyconsumed-eco": "eco",
11-
"energydetails": "Énergie consommée à la jante",
12-
"mass": "Masse",
13-
"numberoflines": "Nombre de lignes",
14-
"origin": "Origine",
15-
"pk": "PK",
16-
"place": "Établissement",
17-
"placeholderline": "",
18-
"rollingstock": "Matériel roulant",
19-
"speed": "Vitesse",
20-
"speedlimit": "Limite",
21-
"speedlimit-short": "Lim.",
22-
"speedLimitByTag": "Code de composition",
23-
"time": "Horaire",
24-
"timetable": "Table horaire",
25-
"trackname": "Voie",
26-
"unknownStop": "Inconnu"
2+
"actualspeed": "Actuelle",
3+
"actualspeed-short": "Act.",
4+
"averagespeed": "Moyenne",
5+
"averagespeed-short": "Moy.",
6+
"composition": "Composition",
7+
"dcmdetails": "Sillon n°",
8+
"destination": "Destination",
9+
"energyconsumed-basic": "base",
10+
"energyconsumed-eco": "eco",
11+
"energydetails": "Énergie consommée à la jante",
12+
"margin": "Marge",
13+
"mass": "Masse",
14+
"numberoflines": "Nombre de lignes",
15+
"origin": "Origine",
16+
"pk": "PK",
17+
"place": "Établissement",
18+
"placeholderline": "",
19+
"rollingstock": "Matériel roulant",
20+
"speed": "Vitesse",
21+
"speedlimit": "Limite",
22+
"speedlimit-short": "Lim.",
23+
"speedLimitByTag": "Code de composition",
24+
"time": "Horaire",
25+
"timetable": "Table horaire",
26+
"trackname": "Voie",
27+
"unknownStop": "Inconnu"
2728
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ export default function DriverTrainSchedule({
1515
rollingStock: LightRollingStock;
1616
}) {
1717
const [baseOrEco, setBaseOrEco] = useState<BaseOrEcoType>(
18-
train.eco ? BaseOrEco.eco : BaseOrEco.base
18+
train.eco ? BaseOrEco.margin : BaseOrEco.base
1919
);
2020

2121
useEffect(() => {
22-
if (baseOrEco === BaseOrEco.eco && !train[baseOrEco]) {
22+
if (baseOrEco === BaseOrEco.margin && !train.eco) {
2323
setBaseOrEco(BaseOrEco.base);
2424
} else {
25-
setBaseOrEco(BaseOrEco.eco);
25+
setBaseOrEco(BaseOrEco.margin);
2626
}
2727
}, [train]);
2828

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ type Props = {
2020
setBaseOrEco: (baseOrEco: BaseOrEcoType) => void;
2121
};
2222

23-
const baseOrEcoOptions = [
24-
{
25-
label: BaseOrEco.base,
26-
value: BaseOrEco.base,
27-
},
28-
{
29-
label: BaseOrEco.eco,
30-
value: BaseOrEco.eco,
31-
},
32-
];
33-
3423
export default function DriverTrainScheduleHeader({
3524
train,
3625
rollingStock,
3726
baseOrEco,
3827
setBaseOrEco,
3928
}: Props) {
4029
const { t } = useTranslation(['operationalStudies/drivertrainschedule']);
41-
const trainRegime = train[baseOrEco];
30+
const trainRegime = baseOrEco === BaseOrEco.margin ? train.eco : train.base;
31+
32+
const baseOrEcoOptions = [
33+
{
34+
label: t(BaseOrEco.base),
35+
value: BaseOrEco.base,
36+
},
37+
{
38+
label: t(BaseOrEco.margin),
39+
value: BaseOrEco.margin,
40+
},
41+
];
4242

4343
if (!trainRegime) return null;
4444

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
55
import type { Train } from 'reducers/osrdsimulation/types';
66

77
import DriverTrainScheduleStop from './DriverTrainScheduleStop';
8-
import type { BaseOrEcoType } from './DriverTrainScheduleTypes';
8+
import { BaseOrEco, type BaseOrEcoType } from './DriverTrainScheduleTypes';
99

1010
type Props = {
1111
train: Train;
@@ -14,7 +14,7 @@ type Props = {
1414

1515
export default function DriverTrainScheduleStopList({ train, baseOrEco }: Props) {
1616
const { t } = useTranslation(['operationalStudies/drivertrainschedule']);
17-
const trainRegime = train[baseOrEco];
17+
const trainRegime = baseOrEco === BaseOrEco.margin ? train.eco : train.base;
1818

1919
if (!trainRegime) return null;
2020
return (
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export enum BaseOrEco {
22
base = 'base',
3-
eco = 'eco',
3+
margin = 'margin',
44
}
55

66
export type BaseOrEcoType = keyof typeof BaseOrEco;

front/src/modules/trainschedule/components/DriverTrainSchedule/driverTrainScheduleExportCSV.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
Train,
88
} from 'reducers/osrdsimulation/types';
99

10-
import type { BaseOrEcoType } from './DriverTrainScheduleTypes';
10+
import { BaseOrEco, type BaseOrEcoType } from './DriverTrainScheduleTypes';
1111

1212
/**
1313
* CSV Export of trainschedule
@@ -133,7 +133,8 @@ function createFakeLinkWithData(train: Train, baseOrEco: BaseOrEcoType, csvData:
133133
}
134134

135135
export default function driverTrainScheduleExportCSV(train: Train, baseOrEco: BaseOrEcoType) {
136-
const trainRegime = train[baseOrEco];
136+
const trainRegime = baseOrEco === BaseOrEco.margin ? train.eco : train.base;
137+
137138
if (trainRegime) {
138139
const speedsWithOPsAndSpeedLimits = overloadWithOPsAndSpeedLimits(trainRegime, train.vmax);
139140
const steps = speedsWithOPsAndSpeedLimits.map((speed) => ({

0 commit comments

Comments
 (0)