diff --git a/front/src/modules/powerRestriction/helpers/createPathStep.ts b/front/src/modules/powerRestriction/helpers/createPathStep.ts index bced6fd396f..3a0f2b7ea0a 100644 --- a/front/src/modules/powerRestriction/helpers/createPathStep.ts +++ b/front/src/modules/powerRestriction/helpers/createPathStep.ts @@ -75,6 +75,7 @@ const createPathStep = ( ...trackOffset, // TODO: we should return the offset in mm once it is stored in mm in the store offset: mmToM(trackOffset.offset), + isFromPowerRestriction: true, }; }; @@ -124,6 +125,7 @@ export const createCutAtPathStep = ( id: nextId(), positionOnPath: cutAtPosition, coordinates: coordinatesAtCut, + isFromPowerRestriction: true, ...trackOffset, // TODO: we should return the offset in mm once it is stored in mm in the store offset: mmToM(trackOffset.offset), diff --git a/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts b/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts index 1566eeb3f1f..c9e025a5902 100644 --- a/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts +++ b/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts @@ -95,7 +95,7 @@ export const cleanPathSteps = ( powerRestrictions: PowerRestriction[] ): PathStep[] => pathSteps.reduce((acc, pathStep, index) => { - if (index === 0 || index === pathSteps.length - 1) { + if (index === 0 || index === pathSteps.length - 1 || !pathStep.isFromPowerRestriction) { acc.push(pathStep); return acc; } diff --git a/front/src/reducers/osrdconf/types.ts b/front/src/reducers/osrdconf/types.ts index b65c347f8a8..7e64bd2ed66 100644 --- a/front/src/reducers/osrdconf/types.ts +++ b/front/src/reducers/osrdconf/types.ts @@ -89,6 +89,14 @@ export type PathStep = PathItemLocation & { trackNumber: number; }; isInvalid?: boolean; + /** Flag specifying whether the pathStep was created from the power restriction selector or not + * + * If true, the pathStep might be cleaned if its power restriction is removed (except if it has time, stop or margin constraints) + * + * This flag will only work if the user has not saved its change. Once the change is saved, the flag will be removed and the pathStep + * will become permanent. + */ + isFromPowerRestriction?: boolean; }; export type StdcmPathStep = {