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: add shortslip distance checkbox in timestops #9275

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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
1 change: 1 addition & 0 deletions front/public/locales/en/timesStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noPathLoaded": "No path loaded",
"realMargin": "Real margin",
"receptionOnClosedSignal": "Reception on Closed Signal",
"shortSlipDistance": "Short Slip Distance",
"stopTime": "Stopping Time (s)",
"theoreticalMargin": "Theoretical Margin",
"theoreticalMarginPlaceholder": "% or min/100km",
Expand Down
1 change: 1 addition & 0 deletions front/public/locales/fr/timesStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noPathLoaded": "Aucun chemin chargé",
"realMargin": "Marge réelle",
"receptionOnClosedSignal": "Réception sur signal fermé",
"shortSlipDistance": "Faible glissement",
"stopTime": "Temps d'arrêt (s)",
"theoreticalMargin": "Marge théorique",
"theoreticalMarginPlaceholder": "% ou min/100km",
Expand Down
4 changes: 2 additions & 2 deletions front/src/modules/timesStops/TimesStopsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ const TimesStopsInput = ({ allWaypoints, startTime, pathSteps }: TimesStopsInput
} else {
const newVias = updatedRows
.filter((row, index) => !isEqual(row, rows[index]))
.map(({ onStopSignal, arrival, departure, ...row }) => ({
.map(({ shortSlipDistance, onStopSignal, arrival, departure, ...row }) => ({
...row,
arrival: durationSinceStartTime(startTime, arrival),
departure: durationSinceStartTime(startTime, departure),
receptionSignal: onStopSignalToReceptionSignal(onStopSignal),
receptionSignal: onStopSignalToReceptionSignal(onStopSignal, shortSlipDistance),
}));
dispatch(upsertSeveralViasFromSuggestedOP(newVias));
}
Expand Down
24 changes: 14 additions & 10 deletions front/src/modules/timesStops/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ export const formatSuggestedViasToRowVias = (
? { time: departureTime }
: undefined;
const { receptionSignal: _opReceptionSignal, ...filteredOp } = op;
const { shortSlipDistance, onStopSignal } = receptionSignalToSignalBooleans(receptionSignal);
return {
...filteredOp,
isMarginValid,
arrival: formattedArrival,
departure: formattedDeparture,
onStopSignal: receptionSignalToOnStopSignal(receptionSignal),
onStopSignal,
name: name || t('waypoint', { id: filteredOp.opId }),
shortSlipDistance,
stopFor,
theoreticalMargin,
isWaypoint: op.isWaypoint || pathStep !== undefined,
Expand Down Expand Up @@ -303,26 +305,28 @@ export function calculateStepTimeAndDays(

/** Convert onStopSignal boolean to receptionSignal enum */
export function onStopSignalToReceptionSignal(
onStopSignal: boolean | undefined
onStopSignal?: boolean,
shortSlipDistance?: boolean
): ReceptionSignal | undefined {
if (isNil(onStopSignal)) {
return undefined;
}
if (onStopSignal === true) {
return 'STOP';
return shortSlipDistance ? 'SHORT_SLIP_STOP' : 'STOP';
}
return 'OPEN';
}

/** Convert receptionSignal enum to onStopSignal boolean */
export function receptionSignalToOnStopSignal(
receptionSignal: ReceptionSignal | undefined
): boolean | undefined {
export function receptionSignalToSignalBooleans(receptionSignal?: ReceptionSignal) {
if (isNil(receptionSignal)) {
return undefined;
return { shortSlipDistance: undefined, onStopSignal: undefined };
}
if (receptionSignal === 'STOP') {
return { shortSlipDistance: false, onStopSignal: true };
}
if (receptionSignal === 'STOP' || receptionSignal === 'SHORT_SLIP_STOP') {
return true;
if (receptionSignal === 'SHORT_SLIP_STOP') {
return { shortSlipDistance: true, onStopSignal: true };
}
return false;
return { shortSlipDistance: false, onStopSignal: false };
}
7 changes: 7 additions & 0 deletions front/src/modules/timesStops/hooks/useTimeStopsColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ export const useTimeStopsColumns = <T extends TimeStopsRow>(
disabled: ({ rowData, rowIndex }) =>
isOutputTable || (rowIndex !== allWaypoints.length - 1 && !rowData.stopFor),
},
{
...keyColumn('shortSlipDistance', checkboxColumn as Partial<Column<boolean | undefined>>),
title: t('shortSlipDistance'),
...fixedWidth(94),
disabled: ({ rowData, rowIndex }) =>
isOutputTable || (rowIndex !== allWaypoints.length - 1 && !rowData.onStopSignal),
},
{
...keyColumn(
'theoreticalMargin',
Expand Down
1 change: 1 addition & 0 deletions front/src/modules/timesStops/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type TimeStopsRow = {
departure?: TimeExtraDays; // value asked by user
stopFor?: string | null; // value asked by user
onStopSignal?: boolean;
shortSlipDistance?: boolean;
theoreticalMargin?: string; // value asked by user

theoreticalMarginSeconds?: string;
Expand Down
Loading