diff --git a/front/src/modules/simulationResult/components/SpaceTimeChartWrapper/helpers/configureHandlePan.ts b/front/src/modules/simulationResult/components/SpaceTimeChartWrapper/helpers/configureHandlePan.ts index 31f1f31edea..2496b522728 100644 --- a/front/src/modules/simulationResult/components/SpaceTimeChartWrapper/helpers/configureHandlePan.ts +++ b/front/src/modules/simulationResult/components/SpaceTimeChartWrapper/helpers/configureHandlePan.ts @@ -5,6 +5,7 @@ import { type SpaceTimeChartProps, } from '@osrd-project/ui-charts'; +import { isExceptionStartTimeException } from 'modules/trainSchedule/helpers/pacedTrain'; import type { TrainId } from 'reducers/osrdconf/types'; import { updateSelectedTrain } from 'reducers/simulationResults'; import type { AppDispatch } from 'store'; @@ -84,7 +85,7 @@ export function configureHandlePan({ // if the dragged train is an occurrence, we need to update the first occurrence because the others are based on it if ( isIndividualOccurrenceProjection(draggedTrain) && - (!draggedTrain.exception || !draggedTrain.exception.start_time) + !isExceptionStartTimeException(draggedTrain.exception) ) { const occurrencesIndex = extractOccurrenceIndexFromOccurrenceId(draggedTrain.id); const pacedTrainId = extractEditoastIdFromPacedTrainId( @@ -134,9 +135,8 @@ export function configureHandlePan({ } // disable start time exception for now - const isStartTimeException = - isIndividualOccurrenceProjection(train) && !!train.exception?.start_time; - if (isStartTimeException) return; + if (isIndividualOccurrenceProjection(train) && isExceptionStartTimeException(train.exception)) + return; setDraggingState({ draggedTrain: train, diff --git a/front/src/modules/trainSchedule/helpers/pacedTrain.ts b/front/src/modules/trainSchedule/helpers/pacedTrain.ts index c033cc9e5d2..054c1777d55 100644 --- a/front/src/modules/trainSchedule/helpers/pacedTrain.ts +++ b/front/src/modules/trainSchedule/helpers/pacedTrain.ts @@ -224,6 +224,20 @@ export const getOccurrenceTrainName = ( return `${pacedTrain.train_name}/+`; }; +export const isExceptionStartTimeException = ( + exception: PacedTrainException | undefined +): boolean => exception?.start_time !== undefined; + +/** + * Returns true if the occurrence identified by occurrenceId is a startTime exception. + * Returns false for occurrences with no exception at all (they are startTime-compliant). + */ +export const isOccurrenceStartTimeException = ( + occurrenceId: OccurrenceId, + exceptions: PacedTrainException[] +): boolean => + isExceptionStartTimeException(findExceptionWithOccurrenceId(exceptions, occurrenceId)); + /** * Return true if the exception has at least one change group defined (excluding disabled). */