front: handle unrecognized track in itinerary modal#16634
Conversation
52d3532 to
03a2d9e
Compare
eed9b21 to
e69b46f
Compare
e69b46f to
d38fb4a
Compare
| // blackAlpha10 | ||
| background-color: rgba(0, 0, 0, 0.1); |
There was a problem hiding this comment.
Can't you use black10 ?
| // blackAlpha10 | |
| background-color: rgba(0, 0, 0, 0.1); | |
| background-color: var(--black10); |
There was a problem hiding this comment.
Black10 is different. where we using transparency
There was a problem hiding this comment.
You can totally use var(--black10) 👍
rgba(0, 0, 0, 0.1) means you are using the black color with 10% opacity
d28d7ab to
e30e887
Compare
Signed-off-by: theocrsb <theo_crosbie@yahoo.fr>
e30e887 to
3d3c0cf
Compare
Signed-off-by: theocrsb <theo_crosbie@yahoo.fr>
3d3c0cf to
88e1116
Compare
| "moveLocationOnMap": "Move location on the map", | ||
| "movePointOnMap": "Move this waypoint using the map", | ||
| "next": "Next", | ||
| "noComputation": "there will be no computation for this train", |
There was a problem hiding this comment.
| "noComputation": "there will be no computation for this train", | |
| "noComputation": "There will be no computation for this train.", |
| "moveLocationOnMap": "Déplacer le point remarquable sur la carte", | ||
| "movePointOnMap": "Déplacez ce point en utilisant la carte", | ||
| "next": "Suivant", | ||
| "noComputation": "il n'y aura pas de calcul pour ce train", |
There was a problem hiding this comment.
| "noComputation": "il n'y aura pas de calcul pour ce train", | |
| "noComputation": "Il n'y aura pas de calcul pour ce train.", |
| return; | ||
| } | ||
|
|
||
| const isTrackNameUnknown = local_track_name |
There was a problem hiding this comment.
I find this naming/logic combination a bit odd: isTrackNameUnknown is computed through a negated condition, which makes the code less intuitive to read.
I think it would be clearer to go back to:
const isValidLocalTrackName = local_track_name
? matchedOp?.parts.some((part) => {
const track = trackSectionsById[part.track];
if (!track) return false;
return local_track_name === part.local_track_name;
})
: false;
Also, if local_track_name is undefined, i believe isValidLocalTrackName should be false rather than true.
You can then use it l.139 with a negation :)
| ...currentData, | ||
| path: currentData.path.map((item) => | ||
| item.id === stepId && item.location.type !== 'track_offset' | ||
| ? { ...item, location: { ...item.location, local_track_name: trackName || undefined } } |
There was a problem hiding this comment.
| ? { ...item, location: { ...item.location, local_track_name: trackName || undefined } } | |
| ? { ...item, location: { ...item.location, local_track_name: trackName } } |
| itineraryModalIsOpen: boolean; | ||
| setItineraryModalIsOpen: (isOpen: boolean) => void; | ||
| displayTrainScheduleManagement: string; | ||
| trainScheduleToEditData?: TrainScheduleToEditData; |
There was a problem hiding this comment.
You can only pass the trainScheduleId here
| await dispatch( | ||
| osrdEditoastApi.endpoints.putTrainSchedulesById.initiate({ | ||
| id: trainScheduleId, | ||
| trainSchedule: { | ||
| ...currentData, | ||
| path: currentData.path.map((item) => | ||
| item.id === stepId && item.location.type !== 'track_offset' | ||
| ? { ...item, location: { ...item.location, local_track_name: trackName || undefined } } |
There was a problem hiding this comment.
Same for this, you can sort of re-use a part of the updatePacedTrain helper by spliting it like :
export async function updateTrainSchedule(dispatch: AppDispatch, id: number, trainSchedule: TrainSchedule) {
await dispatch(
osrdEditoastApi.endpoints.putTrainSchedulesById.initiate({
id,
trainSchedule,
})
).unwrap();
}
async function updatePacedTrain(dispatch: AppDispatch, id: number, trainSchedule: TrainSchedule) {
if (trainSchedule.paced?.exceptions && trainSchedule.paced.exceptions.length > 0) {
console.error(
'updatePacedTrain: exceptions should not be included in the paced field. Use exception endpoints instead.'
);
}
await updateTrainSchedule(dispatch, id, trainSchedule);
}
| // blackAlpha10 | ||
| background-color: rgba(0, 0, 0, 0.1); |
There was a problem hiding this comment.
You can totally use var(--black10) 👍
rgba(0, 0, 0, 0.1) means you are using the black color with 10% opacity
| {hasInvalidPathStepDisplay && ( | ||
| <div key={`invalid-op-${bannerWiggle}`}> | ||
| <Banner type="error" message={t('alertInvalidOP')} /> | ||
| <Banner type="info" message={`${t('alertInvalidOP')} ${t('noComputation')}`} /> |
There was a problem hiding this comment.
| <Banner type="info" message={`${t('alertInvalidOP')} ${t('noComputation')}`} /> | |
| <Banner type="info" message={`${t('alertInvalidOP')}. ${t('noComputation')}`} /> |
You can either add the missing period between the two sentences here or, better, directly in the translation file :)
| {!hasInvalidPathStepDisplay && pathfindingError && ( | ||
| <div key={`pathfinding-${bannerWiggle}`}> | ||
| <Banner type="error" message={pathfindingError} /> | ||
| <Banner type="info" message={`${pathfindingError} ${t('noComputation')}`} /> |
There was a problem hiding this comment.
| <Banner type="info" message={`${pathfindingError} ${t('noComputation')}`} /> | |
| <Banner type="info" message={`${pathfindingError}. ${t('noComputation')}`} /> |
Same
closes #16553
import this train to test it
unknowntrack.json
At the moment, the track names that have been added are not yet visible in the drop-down list. This will be resolved with the latest PR (once the back-end PR has been merged).