Skip to content

Commit

Permalink
Merge branch 'dev' into show-stops-in-route-viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup authored Sep 20, 2024
2 parents 8a4f19c + 9a56086 commit a32c7c8
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 91 deletions.
63 changes: 63 additions & 0 deletions __tests__/components/viewers/__snapshots__/nearby-view.js.snap

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions __tests__/test-utils/mock-data/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const mockImg = ''
export default mockImg
2 changes: 2 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ itinerary:
# sessionTimeoutSeconds: 180

# nearbyView:
### Setting to use arrival time instead of departure time in the nearby view.
# useArrivalTime: true
### Setting to hide stops with no depatures in the nearby view.
# hideEmptyStops: true
### What radius should the nearby query get results within? (in meters)
Expand Down
1 change: 1 addition & 0 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export const fetchNearby = (position, radius) => {
stoptimesForPatterns {
pattern {
headsign
desc: name
route {
agency {
name
Expand Down
5 changes: 4 additions & 1 deletion lib/actions/field-trip.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,10 @@ function prepareQueryParams(request, outbound) {
}
const hasExistingLocations = currentQuery.from || currentQuery.to
const locations =
!hasExistingLocations || window.confirm('Overwrite existing locations?')
!hasExistingLocations ||
window.confirm(
'Use custom set locations? Pressing "Cancel" will use the locations you have typed in. Pressing "OK" will use the locations currently saved to the field trip'
)
? await planParamsToQueryAsync(locationsToGeocode, config)
: { from: currentQuery.from, to: currentQuery.to }
return dispatch(setQueryParam({ ...locations, ...queryParams }))
Expand Down
10 changes: 7 additions & 3 deletions lib/components/viewers/stop-time-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Props = {
onlyShowCountdownForRealtime?: boolean
/** A stopTime object as received from a transit index API */
stopTime: Time
/** Whether to use arrival time instead of departure time */
useArrivalTime?: boolean
}

/**
Expand All @@ -46,7 +48,8 @@ type Props = {
const StopTimeCell = ({
homeTimezone = getUserTimezone(),
onlyShowCountdownForRealtime,
stopTime
stopTime,
useArrivalTime
}: Props): JSX.Element => {
const intl = useIntl()

Expand All @@ -72,7 +75,7 @@ const StopTimeCell = ({
// Determine whether to show departure as countdown (e.g. "5 min") or as HH:mm
// time, using realtime updates if available.
const secondsUntilDeparture = Math.round(
getSecondsUntilDeparture(stopTime, false)
getSecondsUntilDeparture(stopTime, false, useArrivalTime)
)
// Determine if vehicle arrives after midnight in order to advance the day of
// the week when showing arrival time/day.
Expand Down Expand Up @@ -151,7 +154,8 @@ const StopTimeCell = ({
const mapStateToProps = (state: AppReduxState) => {
return {
onlyShowCountdownForRealtime:
state.otp.config?.itinerary?.onlyShowCountdownForRealtime || false
state.otp.config?.itinerary?.onlyShowCountdownForRealtime || false,
useArrivalTime: state.otp.config?.nearbyView?.useArrivalTime || false
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export type NearbyViewConfig = {
hideEmptyStops?: boolean
radius?: number
showShadowDotOnMapDrag?: boolean
useArrivalTime?: boolean
useRouteViewSort?: boolean
}

Expand Down
21 changes: 16 additions & 5 deletions lib/util/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ import { isBlank } from './ui'
* Computes the seconds until departure for a given stop time,
* based either on the scheduled or the realtime departure time.
*/
export function getSecondsUntilDeparture(stopTime, useSchedule) {
const departureTime = useSchedule
? stopTime.scheduledDeparture
: stopTime.realtimeDeparture
export function getSecondsUntilDeparture(
stopTime,
useSchedule,
useArrivalTime
) {
let time
if (useSchedule) {
time = useArrivalTime
? stopTime.scheduledArrival
: stopTime.scheduledDeparture
} else {
time = useArrivalTime
? stopTime.realtimeArrival
: stopTime.realtimeDeparture
}

return departureTime + stopTime.serviceDay - Date.now() / 1000
return time + stopTime.serviceDay - Date.now() / 1000
}

export function getRouteIdForPattern(pattern) {
Expand Down
45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@
"@bugsnag/js": "^7.17.0",
"@bugsnag/plugin-react": "^7.17.0",
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "^3.2.0",
"@opentripplanner/building-blocks": "^1.1.0",
"@opentripplanner/core-utils": "^11.4.3",
"@opentripplanner/endpoints-overlay": "^2.1.1",
"@opentripplanner/from-to-location-picker": "^2.1.13",
"@opentripplanner/geocoder": "^3.0.1",
"@opentripplanner/base-map": "^3.2.2",
"@opentripplanner/building-blocks": "^1.2.3",
"@opentripplanner/core-utils": "^11.4.4",
"@opentripplanner/endpoints-overlay": "^2.1.4",
"@opentripplanner/from-to-location-picker": "^2.1.14",
"@opentripplanner/geocoder": "^3.0.2",
"@opentripplanner/humanize-distance": "^1.2.0",
"@opentripplanner/icons": "^2.0.11",
"@opentripplanner/itinerary-body": "^5.3.5",
"@opentripplanner/location-field": "^2.0.22",
"@opentripplanner/icons": "^2.0.13",
"@opentripplanner/itinerary-body": "^5.3.7",
"@opentripplanner/location-field": "^2.0.24",
"@opentripplanner/location-icon": "^1.4.1",
"@opentripplanner/map-popup": "^3.1.1",
"@opentripplanner/otp2-tile-overlay": "^1.0.16",
"@opentripplanner/map-popup": "^4.0.2",
"@opentripplanner/otp2-tile-overlay": "^1.0.17",
"@opentripplanner/park-and-ride-overlay": "^2.0.9",
"@opentripplanner/printable-itinerary": "^2.0.23",
"@opentripplanner/route-viewer-overlay": "^2.0.17",
"@opentripplanner/park-and-ride-overlay": "^2.0.8",
"@opentripplanner/printable-itinerary": "^2.0.21",
"@opentripplanner/stop-viewer-overlay": "^2.0.8",
"@opentripplanner/stops-overlay": "^5.3.0",
"@opentripplanner/transit-vehicle-overlay": "^4.0.11",
"@opentripplanner/transitive-overlay": "3.0.15",
"@opentripplanner/trip-details": "^5.0.13",
"@opentripplanner/trip-form": "^3.6.2",
"@opentripplanner/trip-viewer-overlay": "^2.0.8",
"@opentripplanner/vehicle-rental-overlay": "^2.1.7",
"@opentripplanner/stop-viewer-overlay": "^2.0.10",
"@opentripplanner/stops-overlay": "^5.3.3",
"@opentripplanner/transit-vehicle-overlay": "^4.0.13",
"@opentripplanner/transitive-overlay": "3.0.22",
"@opentripplanner/trip-details": "^5.0.15",
"@opentripplanner/trip-form": "^3.6.4",
"@opentripplanner/trip-viewer-overlay": "^2.0.10",
"@opentripplanner/vehicle-rental-overlay": "^2.1.9",
"@styled-icons/fa-regular": "^10.34.0",
"@styled-icons/fa-solid": "^10.34.0",
"@turf/centroid": "^6.5.0",
Expand Down Expand Up @@ -214,7 +214,8 @@
"jest": {
"moduleNameMapper": {
"i18n/(.*)\\.yml$": "<rootDir>__tests__/test-utils/mock-data/empty-yml.js",
"modeSettings.yml$": "<rootDir>__tests__/test-utils/mock-data/empty-yml.js"
"modeSettings.yml$": "<rootDir>__tests__/test-utils/mock-data/empty-yml.js",
"\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>__tests__/test-utils/mock-data/fileMock.js"
},
"transform": {
"\\.[jt]sx?$": "babel-jest"
Expand Down
Loading

0 comments on commit a32c7c8

Please sign in to comment.