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

front: stdcm linked path enhancement #9567

Merged
merged 1 commit into from
Dec 18, 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
12 changes: 8 additions & 4 deletions front/public/locales/en/stdcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"incompleteForm": "Incomplete form",
"viaNotDefined": "Au moins une localisation n'est pas renseignée"
},
"indicateAnteriorPath": "Indicate anterior path",
"indicatePosteriorPath": "Indicate posterior path",
"leaveAt": "Leave at {{ time }}",
"linkedTrainDefaultCard": {
"anterior": "Indicate anterior train",
"posterior": "Indicate posterior train"
},
"noConfigurationFound": {
"title": "A configuration problem prevents you from performing a search",
"text": "Please contact the maintenance team so they can get you back on track."
Expand Down Expand Up @@ -99,14 +101,16 @@
"stdcmSimulationReport": "Path simulation report",
"trainPath": {
"addVia": "Add intermediate OP",
"anteriorPath": "Anterior path",
"asSoonAsPossible": "as soon as possible",
"ch": "CH",
"ci": "CI",
"date": "Date",
"destination": "Destination",
"linkedTrain": {
"anterior": "Anterior train",
"posterior": "Posterior train"
},
"origin": "Origin",
"posteriorPath": "Posterior path",
"preciseTime": "precise time",
"respectDestinationSchedule": "respect the destination schedule",
"stopFor": "Minimum stop time",
Expand Down
12 changes: 8 additions & 4 deletions front/public/locales/fr/stdcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"incompleteForm": "Formulaire incomplet",
"viaNotDefined": "Au moins une localisation n'est pas renseignée"
},
"indicateAnteriorPath": "Indiquer le sillon antérieur",
"indicatePosteriorPath": "Indiquer le sillon postérieur",
"leaveAt": "Partir à {{ time }}",
"linkedTrainDefaultCard": {
"anterior": "Indiquer le sillon antérieur",
"posterior": "Indiquer le sillon postérieur"
},
"noConfigurationFound": {
"title": "Un problème de configuration vous empêche de faire une recherche",
"text": "Veuillez contacter l'équipe de maintenance pour qu'elle puisse vous remettre sur les rails."
Expand Down Expand Up @@ -99,14 +101,16 @@
"stdcmSimulationReport": "Fiche simulation",
"trainPath": {
"addVia": "Ajouter un PR intermédiaire",
"anteriorPath": "Sillon antérieur",
"asSoonAsPossible": "dès que possible",
"ch": "CH",
"ci": "CI",
"date": "Date",
"destination": "Destination",
"linkedTrain": {
"anterior": "Sillon antérieur",
"posterior": "Sillon postérieur"
},
"origin": "Origine",
"posteriorPath": "Sillon postérieur",
"preciseTime": "horaire précis",
"respectDestinationSchedule": "respecter l'horaire de la destination",
"stopFor": "Temps d'arrêt minimum",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react';

import { Button } from '@osrd-project/ui-core';
import { ArrowDown, ArrowUp } from '@osrd-project/ui-icons';
import cx from 'classnames';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
Expand All @@ -16,7 +15,7 @@ import { useAppDispatch } from 'store';

import StdcmConsist from './StdcmConsist';
import StdcmDestination from './StdcmDestination';
import StdcmLinkedPathSearch from './StdcmLinkedPathSearch';
import StdcmLinkedTrainSearch from './StdcmLinkedTrainSearch';
import StdcmOrigin from './StdcmOrigin';
import useStaticPathfinding from '../../hooks/useStaticPathfinding';
import type { StdcmConfigErrors } from '../../types';
Expand Down Expand Up @@ -148,13 +147,10 @@ const StdcmConfig = ({
)}
<div className="d-flex">
<div className="d-flex flex-column">
<StdcmLinkedPathSearch
<StdcmLinkedTrainSearch
disabled={disabled}
defaultCardText={t('indicateAnteriorPath')}
cardName={t('trainPath.anteriorPath')}
cardIcon={<ArrowUp size="lg" />}
className="anterior-linked-path"
linkedOp={{ extremityType: 'destination', id: origin.id }}
linkedTrainType="anterior"
linkedOpId={origin.id}
/>
<div className="stdcm-simulation-inputs">
<div className="stdcm-consist-container">
Expand All @@ -165,13 +161,10 @@ const StdcmConfig = ({
<StdcmOrigin disabled={disabled} />
<StdcmVias disabled={disabled} />
<StdcmDestination disabled={disabled} />
<StdcmLinkedPathSearch
<StdcmLinkedTrainSearch
disabled={disabled}
defaultCardText={t('indicatePosteriorPath')}
cardName={t('trainPath.posteriorPath')}
cardIcon={<ArrowDown size="lg" />}
className="posterior-linked-path"
linkedOp={{ extremityType: 'origin', id: destination.id }}
linkedTrainType="posterior"
linkedOpId={destination.id}
/>

<div
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ import { useDispatch } from 'react-redux';
import { useOsrdConfActions } from 'common/osrdContext';
import type { StdcmConfSliceActions } from 'reducers/osrdconf/stdcmConf';

import type { StdcmLinkedPathResult, ExtremityPathStepType } from '../../types';
import type { StdcmLinkedTrainResult, ExtremityPathStepType } from '../../types';

type StdcmLinkedPathResultsProps = {
linkedPathResults: StdcmLinkedPathResult[];
type StdcmLinkedTrainResultsProps = {
linkedTrainResults: StdcmLinkedTrainResult[];
linkedOp: { extremityType: ExtremityPathStepType; id: string };
};

const StdcmLinkedPathResults = ({
linkedPathResults,
const StdcmLinkedTrainResults = ({
linkedTrainResults,
linkedOp: { extremityType, id },
}: StdcmLinkedPathResultsProps) => {
}: StdcmLinkedTrainResultsProps) => {
const dispatch = useDispatch();
const { updateLinkedPathStep } = useOsrdConfActions() as StdcmConfSliceActions;
const { updateLinkedTrainExtremity } = useOsrdConfActions() as StdcmConfSliceActions;
return (
<div className="stdcm-linked-path-results">
{linkedPathResults.map(({ trainName, origin, destination }, index) => (
<div className="stdcm-linked-train-results">
{linkedTrainResults.map(({ trainName, origin, destination }, index) => (
<button
key={`linked-path-${index}`}
key={`linked-train-${index}`}
tabIndex={0}
type="button"
className="linked-path-result-infos"
className="linked-train-result-infos"
onClick={() => {
if (linkedPathResults.length === 1)
if (linkedTrainResults.length === 1)
dispatch(
updateLinkedPathStep({
linkedPathStep: extremityType,
updateLinkedTrainExtremity({
linkedTrainExtremity: extremityType,
trainName,
pathStep: linkedPathResults[0][extremityType],
pathStep: linkedTrainResults[0][extremityType],
pathStepId: id,
})
);
}}
>
{linkedPathResults.length > 1 ? (
{linkedTrainResults.length > 1 ? (
<RadioButton
label={trainName}
id={`${extremityType}-${index}`}
value={`${index}`}
name={`linked-path-radio-buttons-${extremityType}`}
name={`linked-train-radio-buttons-${extremityType}`}
onClick={({ target }) => {
const resultIndex = Number((target as HTMLInputElement).value);
dispatch(
updateLinkedPathStep({
linkedPathStep: extremityType,
updateLinkedTrainExtremity({
linkedTrainExtremity: extremityType,
trainName,
pathStep: linkedPathResults[resultIndex][extremityType],
pathStep: linkedTrainResults[resultIndex][extremityType],
pathStepId: id,
})
);
Expand All @@ -62,7 +62,7 @@ const StdcmLinkedPathResults = ({
{[origin, destination].map((opPoint) => (
<div
key={`linked-op-${opPoint.obj_id}-${index}`}
className={cx('d-flex', { 'ml-4 pl-1': linkedPathResults.length > 1 })}
className={cx('d-flex', { 'ml-4 pl-1': linkedTrainResults.length > 1 })}
>
<p className="opDetails grey50">{opPoint.date}</p>
<p className="opDetails info60">{opPoint.time}</p>
Expand All @@ -76,4 +76,4 @@ const StdcmLinkedPathResults = ({
);
};

export default StdcmLinkedPathResults;
export default StdcmLinkedTrainResults;
Loading
Loading