diff --git a/front/src/applications/operationalStudies/components/MacroEditor/import.ts b/front/src/applications/operationalStudies/components/MacroEditor/import.ts index 18749e5d0de..a68634c6f96 100644 --- a/front/src/applications/operationalStudies/components/MacroEditor/import.ts +++ b/front/src/applications/operationalStudies/components/MacroEditor/import.ts @@ -8,6 +8,7 @@ import type { AppDispatch } from 'store'; import type { Node, + Port, Trainrun, TrainrunSection, TrainrunCategory, @@ -241,6 +242,18 @@ const importTimetable = async ( return port; }; + let transitionId = 0; + const createTransition = (port1Id: number, port2Id: number) => { + const transition = { + id: transitionId, + port1Id, + port2Id, + isNonStopTransit: false, + }; + transitionId += 1; + return transition; + }; + let trainrunSectionId = 0; const trainrunSections: TrainrunSection[] = trainSchedules .map((trainSchedule) => { @@ -249,6 +262,7 @@ const importTimetable = async ( if (!foundAllOps) { return []; } + let prevPort: Port | null = null; return ops.slice(0, -1).map((sourceOp, i) => { const sourceNodeId = sourceOp!.obj_id; const targetNodeId = ops[i + 1]!.obj_id; @@ -269,7 +283,11 @@ const importTimetable = async ( sourceNode.ports.push(sourcePort); targetNode.ports.push(targetPort); - // TODO: create transitions between ports + if (prevPort) { + const transition = createTransition(prevPort.id, sourcePort.id); + sourceNode.transitions.push(transition); + } + prevPort = targetPort; const trainrunSection = { id: trainrunSectionId, diff --git a/front/src/applications/operationalStudies/components/MacroEditor/types.ts b/front/src/applications/operationalStudies/components/MacroEditor/types.ts index 31c494e1d66..a3b93e705f0 100644 --- a/front/src/applications/operationalStudies/components/MacroEditor/types.ts +++ b/front/src/applications/operationalStudies/components/MacroEditor/types.ts @@ -14,7 +14,7 @@ export type Node = { positionX: number; positionY: number; ports: Port[]; - transitions: unknown[]; + transitions: Transition[]; connections: unknown[]; resourceId: number; /** Number of tracks where train can stop */ @@ -34,6 +34,13 @@ export type Port = { trainrunSectionId: number; }; +export type Transition = { + id: number; + port1Id: number; + port2Id: number; + isNonStopTransit: boolean; +}; + export enum PortAlignment { Top, Bottom,