Skip to content

Commit

Permalink
Merge branch 'dev' into nearby-view-increase-override-possibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup authored Sep 24, 2024
2 parents 8f21574 + 9a56086 commit 11b188f
Show file tree
Hide file tree
Showing 10 changed files with 432 additions and 325 deletions.
383 changes: 223 additions & 160 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/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class DefaultMap extends Component {
vectorTilesEndpoint,
setLocation,
setViewedStop,
null,
config.companies
)
default:
Expand Down
2 changes: 1 addition & 1 deletion lib/components/map/point-popup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { connect } from 'react-redux'
import { FocusTrapWrapper } from '@opentripplanner/map-popup/lib'
import { FocusTrapWrapper } from '@opentripplanner/building-blocks'
import { Popup } from '@opentripplanner/base-map'
import { Search } from '@styled-icons/fa-solid/Search'
import { useIntl, WrappedComponentProps } from 'react-intl'
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
47 changes: 24 additions & 23 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.12",
"@opentripplanner/park-and-ride-overlay": "^2.0.8",
"@opentripplanner/printable-itinerary": "^2.0.21",
"@opentripplanner/route-viewer-overlay": "^2.0.15",
"@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/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/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 11b188f

Please sign in to comment.