Skip to content

Commit 2995aac

Browse files
Merge branch 'dev' into pass-operator-logos-to-map-popup
2 parents 6bea334 + 4848925 commit 2995aac

File tree

15 files changed

+114
-377
lines changed

15 files changed

+114
-377
lines changed

i18n/en-US.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ common:
109109
submitting: Submitting…
110110
"yes": "Yes"
111111
itineraryDescriptions:
112-
calories: "{calories, number} Cal"
113112
fareUnknown: No fare information
114113
noItineraryToDisplay: No itinerary to display.
115114
relativeCo2: |
116115
{co2} {isMore, select, true {more} other {less} } CO₂ than driving alone
117116
timeStartEnd: "{start} – {end}"
118-
transfers: "{transfers, plural, =0 {} one {# transfer} other {# transfers}}"
119117
linkOpensNewWindow: (Opens new window)
120118
modes:
121119
bicycle_rent: Bikeshare
@@ -154,7 +152,6 @@ common:
154152
enterStartLocation: Enter start location or {mapAction} on map…
155153
tap: tap
156154
time:
157-
departureArrivalTimes: "{startTime, time, short}—{endTime, time, short}"
158155
duration:
159156
aFewSeconds: a few seconds
160157
nDays: "{days, plural, =1 {one day} other {# days}}"
@@ -269,7 +266,6 @@ components:
269266
ariaLabel: Form navigation
270267
ItinerarySummary:
271268
itineraryDetails: Itinerary details
272-
minMaxFare: "{minTotalFare} - {maxTotalFare}"
273269
LocationSearch:
274270
enterLocation: Enter location
275271
setDestination: Set Destination

i18n/fr.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,11 @@ common:
118118
submitting: Envoi en cours…
119119
"yes": Oui
120120
itineraryDescriptions:
121-
calories: "{calories, number} kcal"
122121
fareUnknown: Tarif inconnu
123122
noItineraryToDisplay: Aucun trajet à afficher.
124123
relativeCo2: |
125124
{co2} de CO₂ en {isMore, select, true {plus} other {moins} } qu'en voiture
126125
timeStartEnd: "{start} – {end}"
127-
transfers: >-
128-
{transfers, plural, =0 {} one {# correspondance} other {#
129-
correspondances}}
130126
linkOpensNewWindow: (Ouvre une nouvelle fenêtre)
131127
modes:
132128
bicycle_rent: En vélo en libre-service
@@ -165,7 +161,6 @@ common:
165161
enterStartLocation: Entrez votre point de départ ou {mapAction} sur la carte…
166162
tap: appuyez
167163
time:
168-
departureArrivalTimes: "{startTime, time, short}—{endTime, time, short}"
169164
duration:
170165
aFewSeconds: quelques secondes
171166
nDays: "{days, plural, =1 {un jour} other {# jours}}"
@@ -286,7 +281,6 @@ components:
286281
ariaLabel: Navigation du formulaire
287282
ItinerarySummary:
288283
itineraryDetails: Détails du trajet
289-
minMaxFare: "{minTotalFare} - {maxTotalFare}"
290284
LocationSearch:
291285
enterLocation: Entrez le lieu
292286
setDestination: Destination

lib/actions/field-trip.js

Lines changed: 70 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getRoutingParams,
77
planParamsToQueryAsync
88
} from '@opentripplanner/core-utils/lib/query'
9-
import { isTransit } from '@opentripplanner/core-utils/lib/itinerary'
9+
import { isTransitLeg } from '@opentripplanner/core-utils/lib/itinerary'
1010
import {
1111
OTP_API_DATE_FORMAT,
1212
OTP_API_TIME_FORMAT
@@ -395,36 +395,34 @@ function makeSaveFieldTripItinerariesData(request, outbound, state) {
395395
}
396396

397397
const gtfsTripsForItinerary = []
398-
itinerary.legs
399-
.filter((leg) => isTransit(leg.mode))
400-
.forEach((leg) => {
401-
let routeName = leg.routeShortName ? `(${leg.routeShortName}) ` : ''
402-
routeName = `${routeName}${leg.routeLongName}`
403-
const gtfsTrip = {
404-
agencyAndId: leg.tripId,
405-
// 'arrive' must be expressed in the agency's timezone
406-
arrive: formatInTz(new Date(leg.endTime), FIELD_TRIP_TIME_FORMAT, {
407-
timeZone: homeTimezone
408-
}),
409-
capacity: getFieldTripGroupCapacityForMode(
410-
fieldTripModuleConfig,
411-
leg.mode
412-
),
413-
// 'depart' must be expressed in the agency's timezone
414-
depart: formatInTz(new Date(leg.startTime), FIELD_TRIP_TIME_FORMAT, {
415-
timeZone: homeTimezone
416-
}),
417-
fromStopIndex: leg.from.stopIndex,
418-
fromStopName: leg.from.name,
419-
headsign: leg.headsign,
420-
routeName,
421-
toStopIndex: leg.to.stopIndex,
422-
toStopName: leg.to.name,
423-
tripHash: tripHashLookup[leg.tripId]
424-
}
425-
if (leg.tripBlockId) gtfsTrip.blockId = leg.tripBlockId
426-
gtfsTripsForItinerary.push(gtfsTrip)
427-
})
398+
itinerary.legs.filter(isTransitLeg).forEach((leg) => {
399+
let routeName = leg.routeShortName ? `(${leg.routeShortName}) ` : ''
400+
routeName = `${routeName}${leg.routeLongName}`
401+
const gtfsTrip = {
402+
agencyAndId: leg.tripId,
403+
// 'arrive' must be expressed in the agency's timezone
404+
arrive: formatInTz(new Date(leg.endTime), FIELD_TRIP_TIME_FORMAT, {
405+
timeZone: homeTimezone
406+
}),
407+
capacity: getFieldTripGroupCapacityForMode(
408+
fieldTripModuleConfig,
409+
leg.mode
410+
),
411+
// 'depart' must be expressed in the agency's timezone
412+
depart: formatInTz(new Date(leg.startTime), FIELD_TRIP_TIME_FORMAT, {
413+
timeZone: homeTimezone
414+
}),
415+
fromStopIndex: leg.from.stopIndex,
416+
fromStopName: leg.from.name,
417+
headsign: leg.headsign,
418+
routeName,
419+
toStopIndex: leg.to.stopIndex,
420+
toStopName: leg.to.name,
421+
tripHash: tripHashLookup[leg.tripId]
422+
}
423+
if (leg.tripBlockId) gtfsTrip.blockId = leg.tripBlockId
424+
gtfsTripsForItinerary.push(gtfsTrip)
425+
})
428426

429427
data.itins.push(itineraryDataToSave)
430428
data.gtfsTrips.push(gtfsTripsForItinerary)
@@ -616,7 +614,6 @@ function getMissingTripHashesForActiveItineraries() {
616614
})
617615
)
618616
}
619-
return true
620617
}
621618

622619
/**
@@ -712,52 +709,50 @@ function checkValidityAndCapacity(state, request) {
712709

713710
// check each individual trip to see if there aren't any trips in this
714711
// itinerary that are already in use by another field trip
715-
itinerary.legs
716-
.filter((leg) => isTransit(leg.mode))
717-
.forEach((leg) => {
718-
const tripId = leg?.trip?.gtfsId
719-
720-
// this variable is used to track how many other field trips are using a
721-
// particular trip
722-
let capacityInUse = 0
723-
724-
// iterate over trips that are already being used by other field trips
725-
// NOTE: In the use case of re-planning trips, there is currently no way
726-
// to discern whether a tripInUse belongs to the current direction of
727-
// the field trip being planned. Therefore, this will result in the
728-
// re-planning of trips avoiding it's own previously planned trips
729-
// that it currently has saved
730-
travelDateTripsInUse.forEach((tripInUse) => {
731-
if (!tripsOverlap(leg, tripHashLookup, tripId, tripInUse)) return
732-
733-
// ranges overlap! Add number of passengers on this other field trip
734-
// to total capacity in use
735-
capacityInUse += tripInUse.passengers
736-
})
712+
itinerary.legs.filter(isTransitLeg).forEach((leg) => {
713+
const tripId = leg?.trip?.gtfsId
714+
715+
// this variable is used to track how many other field trips are using a
716+
// particular trip
717+
let capacityInUse = 0
718+
719+
// iterate over trips that are already being used by other field trips
720+
// NOTE: In the use case of re-planning trips, there is currently no way
721+
// to discern whether a tripInUse belongs to the current direction of
722+
// the field trip being planned. Therefore, this will result in the
723+
// re-planning of trips avoiding it's own previously planned trips
724+
// that it currently has saved
725+
travelDateTripsInUse.forEach((tripInUse) => {
726+
if (!tripsOverlap(leg, tripHashLookup, tripId, tripInUse)) return
727+
728+
// ranges overlap! Add number of passengers on this other field trip
729+
// to total capacity in use
730+
capacityInUse += tripInUse.passengers
731+
})
737732

738-
// check if the remaining capacity on this trip is enough to allow more
739-
// field trip passengers on board
740-
const legModeCapacity = getFieldTripGroupCapacityForMode(
741-
fieldTripModuleConfig,
742-
leg.mode
743-
)
744-
let remainingTripCapacity = legModeCapacity - capacityInUse
745-
if (remainingTripCapacity < minimumAllowableRemainingCapacity) {
746-
// This trip is already too "full" to allow any addition field trips
747-
// on board. Ban this trip in future searches and don't use this
748-
// itinerary in final results (set trip and itinerary capacity to 0).
749-
remainingTripCapacity = 0
750-
}
733+
// check if the remaining capacity on this trip is enough to allow more
734+
// field trip passengers on board
735+
const legModeCapacity = getFieldTripGroupCapacityForMode(
736+
fieldTripModuleConfig,
737+
leg.mode
738+
)
739+
let remainingTripCapacity = legModeCapacity - capacityInUse
740+
if (remainingTripCapacity < minimumAllowableRemainingCapacity) {
741+
// This trip is already too "full" to allow any addition field trips
742+
// on board. Ban this trip in future searches and don't use this
743+
// itinerary in final results (set trip and itinerary capacity to 0).
744+
remainingTripCapacity = 0
745+
}
751746

752-
// always ban trips found in itineraries so that subsequent searches
753-
// don't encounter them.
754-
// TODO: a more advanced way of doing things might be to ban trip
755-
// sequences to not find the same exact sequence, but also
756-
// individual trips that are too full.
757-
tripsToBanInSubsequentSearches.push(tripId)
747+
// always ban trips found in itineraries so that subsequent searches
748+
// don't encounter them.
749+
// TODO: a more advanced way of doing things might be to ban trip
750+
// sequences to not find the same exact sequence, but also
751+
// individual trips that are too full.
752+
tripsToBanInSubsequentSearches.push(tripId)
758753

759-
itineraryCapacity = Math.min(itineraryCapacity, remainingTripCapacity)
760-
})
754+
itineraryCapacity = Math.min(itineraryCapacity, remainingTripCapacity)
755+
})
761756

762757
if (itineraryCapacity > 0) {
763758
// itinerary has capacity, add to list and update remaining group size.

lib/components/narrative/default/default-itinerary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const {
3636
isAdvanceBookingRequired,
3737
isCoordinationRequired,
3838
isFlex,
39-
isTransit
39+
isTransitLeg
4040
} = coreUtils.itinerary
4141

4242
// Styled components
@@ -164,7 +164,7 @@ const ITINERARY_ATTRIBUTES = [
164164
order: 3,
165165
render: (itinerary, options) => {
166166
const leg = clone(itinerary.legs[0])
167-
if (isTransit(leg.mode)) {
167+
if (isTransitLeg(leg)) {
168168
leg.mode = 'WALK'
169169
}
170170

lib/components/narrative/default/itinerary-description.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import FormattedMode from '../../util/formatted-mode'
99

1010
const { isRideshareLeg } = coreUtils.itinerary
1111

12-
const { isBicycle, isMicromobility, isTransit } = coreUtils.itinerary
12+
const { isBicycle, isMicromobility, isTransitLeg } = coreUtils.itinerary
1313

1414
type Props = {
1515
combineTransitModes?: boolean
@@ -32,10 +32,7 @@ export function getMainItineraryModes({
3232
let transitMode
3333
itinerary.legs.forEach((leg, i) => {
3434
const { duration, mode, rentedBike, rentedVehicle } = leg
35-
if (
36-
(leg.transitLeg || isTransit(mode)) &&
37-
duration > primaryTransitDuration
38-
) {
35+
if (isTransitLeg(leg) && duration > primaryTransitDuration) {
3936
primaryTransitDuration = duration
4037
transitMode = getFormattedMode(
4138
combineTransitModes ? 'transit' : mode.toLowerCase(),
@@ -68,7 +65,7 @@ export function ItineraryDescription({ itinerary }: Props): JSX.Element {
6865
let transitMode
6966
itinerary.legs.forEach((leg) => {
7067
const { duration, mode, rentedBike, rentedVehicle } = leg
71-
if (isTransit(mode) && duration > primaryTransitDuration) {
68+
if (isTransitLeg(leg) && duration > primaryTransitDuration) {
7269
primaryTransitDuration = duration
7370

7471
// If custom TransitModes have been defined for the given mode/leg, attempt to use them,

lib/components/narrative/default/itinerary-summary.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-use-before-define */
22

33
import { connect } from 'react-redux'
4-
import { getCompanyFromLeg } from '@opentripplanner/core-utils/lib/itinerary'
4+
import {
5+
getCompanyFromLeg,
6+
isTransitLeg
7+
} from '@opentripplanner/core-utils/lib/itinerary'
58
import PropTypes from 'prop-types'
69
import React, { Component } from 'react'
710
import styled from 'styled-components'
@@ -93,16 +96,16 @@ export default class ItinerarySummary extends Component {
9396
if (
9497
i > 0 &&
9598
i < itinerary.legs.length - 1 &&
96-
!leg.transitLeg &&
97-
itinerary.legs[i - 1].transitLeg &&
98-
itinerary.legs[i + 1].transitLeg
99+
!isTransitLeg(leg) &&
100+
isTransitLeg(itinerary.legs[i - 1]) &&
101+
isTransitLeg(itinerary.legs[i + 1])
99102
) {
100103
return null
101104
}
102105

103106
// Add the mode icon
104107
let title = leg.mode
105-
if (leg.transitLeg) {
108+
if (isTransitLeg(leg)) {
106109
title = leg.routeShortName
107110
? `${leg.routeShortName}${
108111
leg.routeLongName ? ` - ${leg.routeLongName}` : ''

lib/components/narrative/line-itin/LegIconWithA11y.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { getFormattedMode } from '../../../util/i18n'
2-
import coreUtils from '@opentripplanner/core-utils'
3-
import InvisibleA11yLabel from '../../util/invisible-a11y-label'
4-
5-
import React, { useContext } from 'react'
1+
import { isTransitLeg } from '@opentripplanner/core-utils/lib/itinerary'
2+
import { Leg } from '@opentripplanner/types'
3+
import { useIntl } from 'react-intl'
64

75
import { ComponentContext } from '../../../util/contexts'
6+
import { getFormattedMode } from '../../../util/i18n'
7+
import React, { useContext } from 'react'
88

9-
import { useIntl } from 'react-intl'
9+
import InvisibleA11yLabel from '../../util/invisible-a11y-label'
1010

11-
const { isTransit } = coreUtils.itinerary
11+
type Props = {
12+
leg: Leg
13+
}
1214

13-
const LegIconWithA11y = (props: any) => {
15+
const LegIconWithA11y = (props: Props): JSX.Element => {
1416
// @ts-expect-error No type on ComponentContext
1517
const { LegIcon } = useContext(ComponentContext)
1618
const intl = useIntl()
1719
const { leg } = props
1820
const { mode } = leg
19-
const ariaLabel = isTransit(mode) ? getFormattedMode(mode, intl) : null
21+
const ariaLabel = isTransitLeg(leg) ? getFormattedMode(mode, intl) : null
2022
return (
2123
<>
2224
<LegIcon {...props} />

0 commit comments

Comments
 (0)