Skip to content

Commit a1d74bd

Browse files
SharglutDevmultun
authored andcommitted
front: disable electrical profiles options if rs use thermal mode only
1 parent 5455169 commit a1d74bd

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

front/src/applications/operationalStudies/components/SimulationResults/ChartHelpers/ChartHelpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export function makeTrainListWithAllTrainsOffset(trains: Train[], dragOffset = 0
366366
}
367367

368368
/**
369-
* Get the width of an element based of it's text content
369+
* Get the width of an element based on its text content
370370
* @param text the text content of the element
371371
* @param fontSize the font size of the element (pixel)
372372
* @param selector the name of the DOM selector (id, class...)

front/src/applications/operationalStudies/components/SimulationResults/ChartHelpers/drawElectricalProfile.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ const drawElectricalProfile = (
7676
const textZone = chart.drawZone.select(`#${groupID}`);
7777

7878
// get the width of the text element and adding a few pixels for readability
79-
const svgWidth = getElementWidth(dataSimulation.text, 8, `#${groupID}`) + 10;
79+
const labelFontSize = 8; // in px
80+
const svgWidth = getElementWidth(dataSimulation.text, labelFontSize, `#${groupID}`) + 10;
8081

8182
// add rect for text zone
8283
textZone

front/src/applications/operationalStudies/components/SimulationResults/SpeedSpaceSettings/SpeedSpaceSettings.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ type RollingStockMode = {
1616
};
1717
};
1818
interface SpeedSpaceSettingsProps {
19-
// rollingStockMode: RollingStockMode;
2019
electrificationRanges: ElectrificationRange[];
2120
showSettings: boolean;
2221
speedSpaceSettings: { [key in SPEED_SPACE_SETTINGS_KEYS]: boolean };
2322
onSetSettings: (newSettings: { [key in SPEED_SPACE_SETTINGS_KEYS]: boolean }) => void;
2423
}
2524

2625
export default function SpeedSpaceSettings({
27-
// rollingStockMode,
2826
electrificationRanges,
2927
showSettings,
3028
speedSpaceSettings,
@@ -53,6 +51,18 @@ export default function SpeedSpaceSettings({
5351
onSetSettings(newSettings);
5452
};
5553

54+
/**
55+
* Check if the train (in case of bimode rolling stock) runs in thermal mode on the whole path
56+
* @param electricRanges all of the different path's ranges.
57+
* If the range is electrified and the train us the eletrical mode, mode_handled is true
58+
*/
59+
const runsOnlyThermal = (electricRanges: ElectrificationRange[]) =>
60+
!electricRanges.some(
61+
(range) =>
62+
range.electrificationUsage.object_type === 'Electrified' &&
63+
range.electrificationUsage.mode_handled
64+
);
65+
5666
useEffect(() => {
5767
if (selectedTrain) {
5868
getTrainSchedule({ id: selectedTrain.id })
@@ -103,7 +113,7 @@ export default function SpeedSpaceSettings({
103113
getCheckboxRadio(
104114
SPEED_SPACE_SETTINGS_KEYS.ELECTRICAL_PROFILES,
105115
settings.electricalProfiles,
106-
isOnlyThermal(rollingStock.effort_curves.modes)
116+
isOnlyThermal(rollingStock.effort_curves.modes) || runsOnlyThermal(electrificationRanges)
107117
)}
108118
{getCheckboxRadio(SPEED_SPACE_SETTINGS_KEYS.POWER_RESTRICTION, settings.powerRestriction)}
109119
</div>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.custom-control .custom-control-input:disabled ~ .custom-control-label {
2-
color: #b9b9b9 !important;
2+
color: var(--coolgray5) !important;
33
&:before {
4-
border-color: #f2f2f2 !important;
4+
border-color: var(--coolgray1) !important;
55
}
66
}

front/src/common/BootstrapSNCF/CheckboxRadioSNCF.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const CheckboxRadioSNCF = ({
3737
id,
3838
label,
3939
name,
40-
checked = false,
40+
checked,
4141
onChange,
42-
type = 'checkbox',
42+
type,
4343
disabled = false,
4444
}: CheckboxRadioSNCFProps) => (
4545
<div className={cx('custom-control', `custom-${type}`)}>

0 commit comments

Comments
 (0)