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: stop putting path step IDs in SuggestedOP.opId #9967

Merged
merged 1 commit into from
Dec 9, 2024
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 @@ -136,7 +136,7 @@ export function getOperationalPointsWithTimes(
const stopEndTime = computeStopDepartureTime(formattedTime, durationToString);

return {
opId: op.opId,
opId: op.opId!,
positionOnPath: op.positionOnPath,
time: formattedTime,
name: op.name,
Expand Down
11 changes: 5 additions & 6 deletions front/src/modules/pathfinding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const upsertPathStepsInOPs = (ops: SuggestedOP[], pathSteps: PathStep[]):
// We check only for pathSteps added by map click
if ('track' in step) {
const formattedStep: SuggestedOP = {
opId: step.id,
pathStepId: step.id,
positionOnPath: step.positionOnPath!,
offsetOnTrack: step.offset,
track: step.track,
Expand Down Expand Up @@ -124,6 +124,7 @@ export const upsertPathStepsInOPs = (ops: SuggestedOP[], pathSteps: PathStep[]):
if (matchPathStepAndOp(step, op) && op.kp === step.kp) {
return {
...op,
pathStepId: step.id,
stopFor,
arrival,
receptionSignal,
Expand All @@ -141,14 +142,12 @@ export const pathStepMatchesOp = (
pathStep: PathStep,
op: Pick<
SuggestedOP,
'opId' | 'uic' | 'ch' | 'trigram' | 'track' | 'offsetOnTrack' | 'name' | 'kp'
'pathStepId' | 'opId' | 'uic' | 'ch' | 'trigram' | 'track' | 'offsetOnTrack' | 'name' | 'kp'
>,
withKP = false
) => {
if (!matchPathStepAndOp(pathStep, op)) {
// TODO: we abuse the PathStep.id field here, the backend also sets it to an
// ID which has nothing to do with OPs
return pathStep.id === op.opId;
return pathStep.id === op.pathStepId;
}
if ('uic' in pathStep) {
return withKP ? pathStep.kp === op.kp : pathStep.name === op.name;
Expand All @@ -168,7 +167,7 @@ export const isVia = (
vias: PathStep[],
op: Pick<
SuggestedOP,
'opId' | 'uic' | 'ch' | 'trigram' | 'track' | 'offsetOnTrack' | 'name' | 'kp'
'pathStepId' | 'opId' | 'uic' | 'ch' | 'trigram' | 'track' | 'offsetOnTrack' | 'name' | 'kp'
>,
{ withKP = false } = {}
) => vias.some((via) => pathStepMatchesOp(via, op, withKP));
Expand Down
6 changes: 2 additions & 4 deletions front/src/modules/timesStops/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import { TableType, type TimeExtraDays, type TimesStopsInputRow } from '../types

const matchPathStepAndOpWithKP = (step: PathStep, op: SuggestedOP) => {
if (!matchPathStepAndOp(step, op)) {
// TODO: we abuse the PathStep.id field here, the backend also sets it to an
// ID which has nothing to do with OPs
return step.id === op.opId;
return step.id === op.pathStepId;
}
// We match the kp in case two OPs have the same uic+ch (can happen when the
// infra is imported)
Expand Down Expand Up @@ -101,7 +99,7 @@ export const formatSuggestedViasToRowVias = (
arrival: formattedArrival,
departure: formattedDeparture,
onStopSignal,
name: name || t('waypoint', { id: filteredOp.opId }),
name: name || t('waypoint', { id: filteredOp.pathStepId }),
shortSlipDistance,
stopFor,
theoreticalMargin,
Expand Down
2 changes: 1 addition & 1 deletion front/src/modules/timesStops/hooks/useOutputTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const useOutputTableData = (
: false;

return {
opId: pathStep.id,
pathStepId: pathStep.id,
name: t('waypoint', { id: pathStep.id }),
ch: undefined,
isWaypoint: true,
Expand Down
3 changes: 2 additions & 1 deletion front/src/modules/timesStops/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type TimeExtraDays = {
};

export type TimesStopsRow = {
opId: string;
pathStepId?: string;
opId?: string;
name?: string;
ch?: string;
trackName?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ReceptionSignal, TrainScheduleBase } from 'common/api/osrdEditoast
import type { IsoDurationString } from 'common/types';

export type SuggestedOP = {
opId: string;
pathStepId?: string;
opId?: string;
name?: string;
uic?: number;
ch?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl
});

const newVia: SuggestedOP = {
opId: 'lemans',
pathStepId: 'lemans',
track: '60ca8dda-6667-11e3-81ff-01f464e0362d',
offsetOnTrack: 426.443,
positionOnPath: 200,
Expand Down
Loading