Skip to content

Commit 4dea645

Browse files
Merge pull request #1473 from opentripplanner/trip-in-past-error
add optional trip-in-past error
2 parents 25e183a + 929c14e commit 4dea645

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

example/example-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ itinerary:
438438
displayA11yError: false
439439
# Whether to add OTP_RR_MICROBILITY_SUBJECT_TO_CHANGE error to all searches that include micromobiity rental.
440440
displayMicromobilityRentalError: false
441+
# Whether to add a OTP_RR_TRIP_IN_PAST error to all itineraries which have an itinerary that ends in the past
442+
displayTripInPastError: true
441443
# Whether to display itinerary info in the side of the preview or next to the departure times
442444
showInlineItinerarySummary: false
443445
# Whether to sync the sort type with the depart/arrive time in the date/time modal

i18n/en-US.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ components:
437437
A transit connection was found, but it was outside the search window,
438438
try adjusting your search window, using the vehicle types you selected.
439439
header: No transit connection in search window
440+
OTP_RR_TRIP_IN_PAST:
441+
body: One or more of these itineraries ends in the past.
442+
header: Trip has already occurred
440443
OUTSIDE_BOUNDS:
441444
body: >-
442445
{inputFields} {inputFieldsCount, plural, =0 {} one {location is} other

i18n/fr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ components:
450450
Une desserte en transports a été trouvée mais ne correspond pas à vos
451451
critères. Veuillez ajuster votre recherche.
452452
header: Aucune desserte selon vos critères
453+
OTP_RR_TRIP_IN_PAST:
454+
body: L'heure d'arrivée d'un ou de plusieurs itinéraires est déjà passée.
455+
header: Trajet déjà terminé
453456
OUTSIDE_BOUNDS:
454457
body: >-
455458
{inputFieldsCount, plural, =0 {} one {Votre {inputFields} n'est} other

i18n/i18n-exceptions.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"storeTripHistory"
1111
],
1212
"components.OTP2ErrorRenderer.*.body": [
13+
"OTP_RR_TRIP_IN_PAST",
1314
"LOCATION_NOT_FOUND",
1415
"NO_STOPS_IN_RANGE",
1516
"NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW",
@@ -21,6 +22,7 @@
2122
"WALKING_BETTER_THAN_TRANSIT"
2223
],
2324
"components.OTP2ErrorRenderer.*.header": [
25+
"OTP_RR_TRIP_IN_PAST",
2426
"LOCATION_NOT_FOUND",
2527
"NO_STOPS_IN_RANGE",
2628
"NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW",
@@ -54,5 +56,7 @@
5456
"legally-blind"
5557
]
5658
},
57-
"ignoredIds": ["otpUi.TripDetails.title"]
59+
"ignoredIds": [
60+
"otpUi.TripDetails.title"
61+
]
5862
}

lib/actions/apiV2.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,8 +1270,11 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
12701270
}
12711271
// Add configurable errors, if they're turned on.
12721272
const state = getState()
1273-
const { displayA11yError, displayMicromobilityRentalError } =
1274-
state.otp.config?.itinerary
1273+
const {
1274+
displayA11yError,
1275+
displayMicromobilityRentalError,
1276+
displayTripInPastError
1277+
} = state.otp.config?.itinerary
12751278
if (displayA11yError) {
12761279
if (
12771280
withCollapsedShortNames.find(
@@ -1294,6 +1297,17 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
12941297
})
12951298
}
12961299
}
1300+
if (displayTripInPastError !== false) {
1301+
if (
1302+
response.data.plan.itineraries.some(
1303+
(itin) => itin.endTime < Date.now()
1304+
)
1305+
) {
1306+
response.data.plan.routingErrors.push({
1307+
code: 'OTP_RR_TRIP_IN_PAST'
1308+
})
1309+
}
1310+
}
12971311
}
12981312

12991313
return {

0 commit comments

Comments
 (0)