Skip to content
Open
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 @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions front/src/modules/trainSchedule/helpers/pacedTrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
Loading