Skip to content

Commit 240a149

Browse files
committed
front: remove frequency labels in nge + ensure uniqueness
Signed-off-by: Louis Greiner <[email protected]>
1 parent a35d7b5 commit 240a149

File tree

1 file changed

+6
-4
lines changed
  • front/src/applications/operationalStudies/components/MacroEditor

1 file changed

+6
-4
lines changed

front/src/applications/operationalStudies/components/MacroEditor/osrdToNge.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const getNgeTrainruns = (state: MacroEditorState, labels: LabelDto[]) =>
308308
let trainrunFrequency: TrainrunFrequency | undefined;
309309
if (trainSchedule.labels) {
310310
trainSchedule.labels.forEach((label) => {
311-
if (label.includes('frequency')) {
311+
if (!label.match(/^frequency::(?!30$|60$|120$)\d+$/)) {
312312
const frequency = parseInt(label.split('::')[1], 10);
313313
const trainrunFrequencyFound = DEFAULT_TRAINRUN_FREQUENCIES.find(
314314
(freq) => freq.frequency === frequency
@@ -329,9 +329,11 @@ const getNgeTrainruns = (state: MacroEditorState, labels: LabelDto[]) =>
329329
categoryId: DEFAULT_TRAINRUN_CATEGORY.id,
330330
frequencyId: trainrunFrequency?.id || DEFAULT_TRAINRUN_FREQUENCY.id,
331331
trainrunTimeCategoryId: DEFAULT_TRAINRUN_TIME_CATEGORY.id,
332-
labelIds: (trainSchedule.labels || []).map((l) =>
333-
labels.findIndex((e) => e.label === l && e.labelGroupId === TRAINRUN_LABEL_GROUP.id)
334-
),
332+
labelIds: (trainSchedule.labels || [])
333+
.filter((l) => l.match(/^frequency::(?!30$|60$|120$)\d+$/))
334+
.map((l) =>
335+
labels.findIndex((e) => e.label === l && e.labelGroupId === TRAINRUN_LABEL_GROUP.id)
336+
),
335337
};
336338
});
337339

0 commit comments

Comments
 (0)