Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: setting power restrictions don't remove pathSteps #10032

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 their change. Once the change is saved, the flag will be removed and the pathStep
* will become permanent.
*/
isFromPowerRestriction?: boolean;
};

export type StdcmPathStep = {
Expand Down
Loading