Skip to content

Commit

Permalink
editoast, front: allow providing etcs_brake_params to RS web api
Browse files Browse the repository at this point in the history
front: persist etcs params when editing a rollingstock handling etcs
 (without this, etcs_brake_params are emptied when updating a RS with the
 front).

Co-authored-by: romainvalls <romain.valls95@gmail.com>

Signed-off-by: Pierre-Etienne Bougué <bougue.pe@proton.me>
  • Loading branch information
bougue-pe committed Jan 17, 2025
1 parent bf85a79 commit 1b0be11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9410,6 +9410,10 @@ components:
type: array
items:
$ref: '#/components/schemas/EnergySource'
etcs_brake_params:
allOf:
- $ref: '#/components/schemas/EtcsBrakeParams'
nullable: true
inertia_coefficient:
type: number
format: double
Expand Down
4 changes: 4 additions & 0 deletions editoast/src/views/rolling_stock/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::HashMap;
use editoast_common::units::{quantities::*, *};
use editoast_schemas::rolling_stock::EffortCurves;
use editoast_schemas::rolling_stock::EnergySource;
use editoast_schemas::rolling_stock::EtcsBrakeParams;
use editoast_schemas::rolling_stock::LoadingGaugeType;
use editoast_schemas::rolling_stock::RollingResistance;
use editoast_schemas::rolling_stock::RollingStockMetadata;
Expand Down Expand Up @@ -55,6 +56,7 @@ pub struct RollingStockForm {
#[schema(example = 5.0)]
#[serde(default, with = "second::option")]
pub electrical_power_startup_time: Option<Time>,
pub etcs_brake_params: Option<EtcsBrakeParams>,
/// The time it takes to raise this train's pantograph in seconds. Is null if the train is not electric.
#[schema(example = 15.0)]
#[serde(default, with = "second::option")]
Expand All @@ -79,6 +81,7 @@ impl From<RollingStockForm> for Changeset<RollingStockModel> {
.startup_acceleration(rolling_stock.startup_acceleration)
.comfort_acceleration(rolling_stock.comfort_acceleration)
.const_gamma(rolling_stock.const_gamma)
.etcs_brake_params(rolling_stock.etcs_brake_params)
.inertia_coefficient(rolling_stock.inertia_coefficient)
.mass(rolling_stock.mass)
.rolling_resistance(rolling_stock.rolling_resistance)
Expand Down Expand Up @@ -115,6 +118,7 @@ impl From<RollingStockModel> for RollingStockForm {
startup_acceleration: value.startup_acceleration,
comfort_acceleration: value.comfort_acceleration,
const_gamma: value.const_gamma,
etcs_brake_params: value.etcs_brake_params,
inertia_coefficient: value.inertia_coefficient,
mass: value.mass,
rolling_resistance: value.rolling_resistance,
Expand Down
1 change: 1 addition & 0 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,7 @@ export type RollingStockForm = {
Duration in s */
electrical_power_startup_time?: number | null;
energy_sources?: EnergySource[];
etcs_brake_params?: EtcsBrakeParams | null;
/** Ratio 1:1 */
inertia_coefficient: number;
/** Length in m */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ const RollingStockEditorForm = ({
}

setErrorMessage('');
const payload = rollingStockEditorQueryArg(validRollingStockForm, effortCurves!);
const payload: RollingStockForm = {
...rollingStockEditorQueryArg(validRollingStockForm, effortCurves!),
etcs_brake_params: rollingStockData?.etcs_brake_params,
};
openModal(
<RollingStockEditorFormModal
setAddOrEditState={setAddOrEditState}
Expand Down

0 comments on commit 1b0be11

Please sign in to comment.