Skip to content

Commit

Permalink
Merge branch 'dev' into fix-update-leave-now
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup authored Jan 23, 2025
2 parents bf453ec + 7e4f664 commit 573fc11
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
2 changes: 2 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ disableSingleItineraryDays: false
# # Whether to render routes within flex zones of a route's patterns. If set to true,
# # routes will not be rendered within flex zones.
# hideRouteShapesWithinFlexZones: true
# # Setting to sort routes by the number of vehicles on each pattern
# sortRoutePatternsByVehicleCount: true
# # Disable vehicle highlight if necessary (e.g. custom or inverted icons)
# vehicleIconHighlight: true
# # Customize vehicle icon padding (the default iconPadding is 2px in otp-ui)
Expand Down
9 changes: 7 additions & 2 deletions lib/components/map/connected-endpoints-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { connect } from 'react-redux'
import { IntlShape, useIntl } from 'react-intl'
import { UserLocationAndType } from '@opentripplanner/types'
import { Location, UserLocationAndType } from '@opentripplanner/types'
import EndpointsOverlay from '@opentripplanner/endpoints-overlay'
import React, { ComponentProps, useCallback } from 'react'

Expand All @@ -13,16 +13,19 @@ import {
} from '../../actions/user'
import { getActiveSearch, getShowUserSettings } from '../../util/state'
import { setLocation } from '../../actions/map'
import { setViewedStop } from '../../actions/ui'
import { toastOnPlaceSaved } from '../util/toasts'

type Props = ComponentProps<typeof EndpointsOverlay> & {
forgetPlace: (place: string, intl: IntlShape) => void
rememberPlace: (arg: UserLocationAndType, intl: IntlShape) => number
setViewedStop: (arg: Location) => void
}

const ConnectedEndpointsOverlay = ({
forgetPlace,
rememberPlace,
setViewedStop,
...otherProps
}: Props): JSX.Element => {
const intl = useIntl()
Expand All @@ -47,6 +50,7 @@ const ConnectedEndpointsOverlay = ({
{...otherProps}
forgetPlace={_forgetPlace}
rememberPlace={_rememberPlace}
setViewNearby={setViewedStop}
/>
)
}
Expand Down Expand Up @@ -89,7 +93,8 @@ const mapDispatchToProps = {
clearLocation,
forgetPlace,
rememberPlace,
setLocation
setLocation,
setViewedStop
}

export default connect(
Expand Down
31 changes: 29 additions & 2 deletions lib/components/viewers/route-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { Component } from 'react'
import styled from 'styled-components'

import * as uiActions from '../../actions/ui'
import { AppReduxState } from '../../util/state-types'
import { DEFAULT_ROUTE_COLOR } from '../util/colors'
import { extractMainHeadsigns, PatternSummary } from '../../util/pattern-viewer'
import { getOperatorName } from '../../util/state'
Expand Down Expand Up @@ -47,6 +48,11 @@ const PatternSelectDropdown = styled(Dropdown)`
span.caret {
color: #333;
}
ul li button span {
width: 100%;
display: block;
}
`

interface Props {
Expand All @@ -57,6 +63,7 @@ interface Props {
setHoveredStop: (id: string | null) => void
setViewedRoute: SetViewedRouteHandler
setViewedStop: SetViewedStopHandler
sortPatternsByVehicleCount: boolean
}

class RouteDetails extends Component<Props> {
Expand Down Expand Up @@ -87,7 +94,14 @@ class RouteDetails extends Component<Props> {
}

render() {
const { intl, operator, patternId, route, setHoveredStop } = this.props
const {
intl,
operator,
patternId,
route,
setHoveredStop,
sortPatternsByVehicleCount
} = this.props
const { agency, patterns = {}, shortName, url } = route
const pattern = patterns[patternId]

Expand All @@ -100,6 +114,7 @@ class RouteDetails extends Component<Props> {
shortName,
this._editHeadsign
).sort((a, b) => {
if (!sortPatternsByVehicleCount) return 0
// sort by number of vehicles on that pattern
const aVehicleCount =
route.vehicles?.filter((vehicle) => vehicle.patternId === a.id)
Expand Down Expand Up @@ -231,11 +246,23 @@ class RouteDetails extends Component<Props> {
}
}

const mapStateToProps = (state: AppReduxState) => {
const sortRoutePatternsByVehicleCount =
state.otp.config.routeViewer?.sortRoutePatternsByVehicleCount

return {
sortPatternsByVehicleCount: sortRoutePatternsByVehicleCount !== false
}
}

// connect to redux store
const mapDispatchToProps = {
setHoveredStop: uiActions.setHoveredStop,
setViewedRoute: uiActions.setViewedRoute,
setViewedStop: uiActions.setViewedStop
}

export default connect(null, mapDispatchToProps)(injectIntl(RouteDetails))
export default connect(
mapStateToProps,
mapDispatchToProps
)(injectIntl(RouteDetails))
5 changes: 2 additions & 3 deletions lib/components/viewers/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export const PatternContainer = styled.div`
background-color: inherit;
color: inherit;
display: flex;
gap: 16px;
justify-content: flex-start;
justify-content: space-between;
margin: 0;
padding: 8px;
Expand All @@ -48,7 +47,7 @@ export const PatternContainer = styled.div`
// Styling for SortResultsDropdown
& > span {
width: 85%;
width: 80%;
button#headsign-selector-label {
align-items: center;
Expand Down
2 changes: 2 additions & 0 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ export interface RouteViewerConfig {
maxRealtimeVehicleAge?: number
/** Use OTP date limiting to only show current service week in list */
onlyShowCurrentServiceWeek?: boolean
/** Setting to sort routes by the number of vehicles on each pattern */
sortRoutePatternsByVehicleCount?: boolean
/** Disable vehicle highlight if necessary (e.g. custom or inverted icons) */
vehicleIconHighlight?: boolean
/** Customize vehicle icon padding (the default iconPadding is 2px in otp-ui) */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@opentripplanner/base-map": "4.0.0",
"@opentripplanner/building-blocks": "2.1.0",
"@opentripplanner/core-utils": "12.0.1",
"@opentripplanner/endpoints-overlay": "3.0.1",
"@opentripplanner/endpoints-overlay": "3.1.0",
"@opentripplanner/from-to-location-picker": "3.0.0",
"@opentripplanner/geocoder": "^3.0.2",
"@opentripplanner/humanize-distance": "^1.2.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2451,10 +2451,10 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/endpoints-overlay@3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-3.0.1.tgz#b6b8e2f08ae41fbaad475fc0f0fe3e72d7d36463"
integrity sha512-X3T0GM8U+VU/mOOSNUgj6fVcjAKMeciKFYnQNbKiNgNeDHa5JltwvtXsM4x3wCLP2xAF6jH/HTWJmYmsfLPlAw==
"@opentripplanner/endpoints-overlay@3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-3.1.0.tgz#92ad54ed9445385e25c2a968f700945ae4fc9315"
integrity sha512-FxQrd/nDIP9Tq5yfMFVgWx0QIXmy64y521r6yFCNsY/rBLSAtnLCVMLNUW+bCtdo3IUpeSpqshJDLYHHDHpa/g==
dependencies:
"@opentripplanner/base-map" "^4.0.0"
"@opentripplanner/building-blocks" "^2.0.0"
Expand Down

0 comments on commit 573fc11

Please sign in to comment.