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

Fix update pathfinding when changing rolling stock #9553

Merged
merged 1 commit into from
Nov 8, 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 @@ -93,6 +93,8 @@ const ManageTrainSchedule = ({ trainIdToEdit }: ManageTrainScheduleProps) => {
<RollingStockSelector
rollingStockSelected={rollingStock}
rollingStockComfort={rollingStockComfort}
pathProperties={pathProperties}
setPathProperties={setPathProperties}
/>
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const Itinerary = ({
return (
<div className="osrd-config-item">
<div className="mb-2 d-flex">
<Pathfinding pathProperties={pathProperties} setPathProperties={setPathProperties} />
(
<Pathfinding pathProperties={pathProperties} setPathProperties={setPathProperties} />)
<button
type="button"
className="btn btn-sm btn-only-icon btn-white px-3 ml-2"
Expand Down
4 changes: 3 additions & 1 deletion front/src/modules/pathfinding/hooks/usePathfinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ export const usePathfinding = (
matchPathStepAndOp(step, suggestedOp)
);

const theoreticalMargin = i === 0 ? '0%' : step.theoreticalMargin;
const theoreticalMargin =
i === 0 ? step.theoreticalMargin || '0%' : step.theoreticalMargin;

const stopFor = i === pathSteps.length - 1 && !step.stopFor ? '0' : step.stopFor;
const stopType =
i === pathSteps.length - 1 && !step.stopFor ? undefined : step.stopType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { useRef } from 'react';

import { useTranslation } from 'react-i18next';

import type { ManageTrainSchedulePathProperties } from 'applications/operationalStudies/types';
import icon from 'assets/pictures/components/train.svg';
import type { Comfort, RollingStockWithLiveries } from 'common/api/osrdEditoastApi';
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
import { usePathfinding } from 'modules/pathfinding/hooks/usePathfinding';
import RollingStock2Img from 'modules/rollingStock/components/RollingStock2Img';
import {
comfort2pictogram,
Expand All @@ -17,20 +19,26 @@ type RollingStockProps = {
rollingStockSelected?: RollingStockWithLiveries;
rollingStockComfort: Comfort;
image?: JSX.Element;
pathProperties?: ManageTrainSchedulePathProperties;
setPathProperties: (pathProperties?: ManageTrainSchedulePathProperties) => void;
};

const RollingStockSelector = ({
condensed,
rollingStockSelected,
rollingStockComfort,
image,
pathProperties,
setPathProperties,
}: RollingStockProps) => {
const { openModal } = useModal();

const ref2scroll = useRef<HTMLDivElement>(null);

const { t } = useTranslation('rollingstock');

usePathfinding(setPathProperties, pathProperties);

return (
<div className="osrd-config-item mb-2">
<div
Expand Down
Loading