Skip to content

Commit

Permalink
front: setting power restrictions do not remove PathSteps
Browse files Browse the repository at this point in the history
When manipulating power restrictions, the pathSteps without any constraints (stop, arrival time or margin) were cleaned.
This was the expected behaviour before, because we could not have pathSteps without constraints.

As the expected behaviour has changed (we now authorize pathSteps without constraints), the pathSteps created from the power restrictions selector
have a new flag and may be cleaned if they are not linked anymore to a power restrictions and have no constraints.
The other pathSteps will not be cleaned.

Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Dec 24, 2024
1 parent 7cda595 commit 32d4a79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions front/src/modules/powerRestriction/helpers/createPathStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};

Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions front/src/reducers/osrdconf/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 32d4a79

Please sign in to comment.