Skip to content

Commit e163334

Browse files
committed
front: display invalid op message in itinerary modal
Signed-off-by: SharglutDev <[email protected]>
1 parent c8cb9cd commit e163334

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

front/public/locales/en/operational-studies.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,19 @@
346346
"addLocationOnMap": "Add a location on the map",
347347
"focusLocationOnMap": "Focus the map on this operational point",
348348
"frameAll": "Center on all path steps on map",
349+
"invalidOP": "Non recognized point : ",
349350
"moveLocationOnMap": "Move location on the map",
350351
"next": "Next",
352+
"opId": "Operational point identifier",
351353
"opName": "Operational point name",
352354
"openItineraryModal": "New interface for itinerary edition",
353355
"secondaryCode": "Code",
356+
"requestedPoint": "Point on map",
354357
"track": "Track",
355-
"trainName": "Train name"
358+
"trackId": "Track identifier",
359+
"trainName": "Train name",
360+
"trigram": "Trigram",
361+
"UIC": "UIC"
356362
},
357363
"launchPathFinding": "Launch pathfinding",
358364
"manageVias": "Steps management",

front/public/locales/fr/operational-studies.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,19 @@
346346
"addLocationOnMap": "Ajouter un point remarquable sur la carte",
347347
"focusLocationOnMap": "Centrer la carte sur ce point remarquable",
348348
"frameAll": "Centrer sur tous les points de passage sur la carte",
349+
"invalidOP": "Point non reconnu : ",
349350
"moveLocationOnMap": "Déplacer le point remarquable sur la carte",
350351
"next": "Suivant",
352+
"opId": "Identifiant de point",
351353
"opName": "Nom du point remarquable",
352354
"openItineraryModal": "Nouvelle interface d'édition d'itinéraire",
355+
"requestedPoint": "Point sur la carte",
353356
"secondaryCode": "CH",
354357
"track": "Voie",
355-
"trainName": "Nom du train"
358+
"trackId": "Identifiant de voie",
359+
"trainName": "Nom du train",
360+
"trigram": "Trigramme",
361+
"UIC": "UIC"
356362
},
357363
"launchPathFinding": "Lancer la recherche d'itinéraire",
358364
"manageVias": "Gestion des étapes",

front/src/applications/operationalStudies/views/Scenario/components/ManageTimetableItem/Itinerary/PathStepItem.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,39 @@ const PathStepItem = ({
3939
const mapSettings = useMapSettings();
4040
const { updateViewport } = useMapSettingsActions();
4141

42+
const getInvalidMessage = () => {
43+
let message = t('invalidOP');
44+
if (!pathStepMetadata?.isInvalid || !pathStep?.location) return message;
45+
46+
const { location } = pathStep;
47+
48+
if ('track' in location) {
49+
return (message += `${t('requestedPoint')}`);
50+
}
51+
52+
const trackInfo = location.track_reference
53+
? 'track_name' in location.track_reference
54+
? `, ${t('track')} ${location.track_reference.track_name}`
55+
: `, ${t('trackId')}`
56+
: '';
57+
58+
if ('operational_point' in location) {
59+
return (message += `${t('opId')}${trackInfo}`);
60+
}
61+
62+
const secondaryCodeInfo = `${location.secondary_code ? `/${location.secondary_code}` : ''}`;
63+
64+
if ('trigram' in location) {
65+
message += `${t('trigram')} ${location.trigram}`;
66+
}
67+
68+
if ('uic' in location) {
69+
message += `${t('UIC')} ${location.uic}`;
70+
}
71+
72+
return (message += `${secondaryCodeInfo}${trackInfo}`);
73+
};
74+
4275
const secondaryCodeSuggestions = useMemo(() => {
4376
if (!isOpRefMetadata(pathStepMetadata)) return [];
4477
return [
@@ -238,6 +271,9 @@ const PathStepItem = ({
238271
</button>
239272
</div>
240273
</div>
274+
{pathStepMetadata?.isInvalid && (
275+
<span className="invalid-step-message">{getInvalidMessage()}</span>
276+
)}
241277
</div>
242278
);
243279
};

front/src/styles/scss/applications/operationalStudies/_itineraryModal.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--footer-height: 96px;
44
--footer-box-shadow-height: 1px;
55
--path-step-row-gap: 8px;
6+
--path-step-wrapper-padding-left: 12px;
67
--path-step-wrapper-padding-right: 10px;
78
--path-step-secondary-code-width: 60px;
89
--path-step-track-name-width: 76px;
@@ -148,7 +149,8 @@
148149

149150
// this wrapper is being used to display the "adding location on map" style
150151
.path-step-wrapper {
151-
padding-inline: 12px var(--path-step-wrapper-padding-right);
152+
padding-inline: var(--path-step-wrapper-padding-left)
153+
var(--path-step-wrapper-padding-right);
152154
border-radius: 6px;
153155
padding-bottom: 4px;
154156

@@ -278,6 +280,11 @@
278280
}
279281
}
280282
}
283+
284+
.invalid-step-message {
285+
color: var(--error60);
286+
padding-left: calc(51px - var(--path-step-wrapper-padding-left));
287+
}
281288
}
282289
}
283290
}

0 commit comments

Comments
 (0)