Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass "geocoderResultsOrder" config item to LocationFields #1268

Merged
merged 10 commits into from
Dec 10, 2024
3 changes: 3 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ map:
# geocoder test account can be obtained from the Pelias maintainers at geocode.earth.
geocoder:
apiKey: PELIAS_API_KEY
# Pass an array of geocoder result types to control the order in which they are displayed.
# The default order is ['STATIONS', 'STOPS', 'OTHER'].
geocoderResultsOrder: ['STATIONS', 'STOPS', 'OTHER']
boundary:
rect:
minLon: -123.2034
Expand Down
13 changes: 12 additions & 1 deletion lib/components/app/batch-routing-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ViewerContainer from '../viewers/viewer-container'
interface Props {
activeSearch: any
currentQuery: any
geocoderResultsOrder?: Array<string>
intl: IntlShape
mainPanelContent: number
mobile?: boolean
Expand Down Expand Up @@ -89,7 +90,13 @@ class BatchRoutingPanel extends Component<Props> {
}

render() {
const { activeSearch, intl, mobile, showUserSettings } = this.props
const {
activeSearch,
geocoderResultsOrder,
intl,
mobile,
showUserSettings
} = this.props
const { planTripClicked } = this.state
const mapAction = mobile
? intl.formatMessage({
Expand Down Expand Up @@ -157,6 +164,7 @@ class BatchRoutingPanel extends Component<Props> {
<div ref={this._mainPanelContentRef}>
<span className="batch-routing-panel-location-fields">
<LocationField
geocoderResultsOrder={geocoderResultsOrder}
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterStartLocation' },
{ mapAction }
Expand All @@ -167,6 +175,7 @@ class BatchRoutingPanel extends Component<Props> {
showClearButton={!mobile}
/>
<LocationField
geocoderResultsOrder={geocoderResultsOrder}
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterDestination' },
{ mapAction }
Expand Down Expand Up @@ -236,9 +245,11 @@ const mapStateToProps = (state: any) => {
const { mainPanelContent } = state.otp.ui
const currentQuery = state.otp.currentQuery

const { geocoderResultsOrder } = state.otp.config.geocoder
return {
activeSearch: getActiveSearch(state),
currentQuery,
geocoderResultsOrder,
mainPanelContent,
showUserSettings
}
Expand Down
1 change: 0 additions & 1 deletion lib/components/form/advanced-settings-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ const AdvancedSettingsPanel = ({
)
)


const tripFormErrors = tripPlannerValidationErrors(currentQuery, intl)

const closePanel = useCallback(() => {
Expand Down
9 changes: 7 additions & 2 deletions lib/components/mobile/batch-search-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const MobileSearchSettings = styled.div<{

interface Props {
currentQuery: any
geocoderResultsOrder: Array<string>
intl: IntlShape
map: React.ReactElement
routingQuery: any
Expand Down Expand Up @@ -91,7 +92,7 @@ class BatchSearchScreen extends Component<Props> {
}

render() {
const { intl } = this.props
const { geocoderResultsOrder, intl } = this.props
const { planTripClicked, showAdvancedModeSettings } = this.state

const transitionDelay = this.state.closeAdvancedSettingsWithDelay ? 300 : 0
Expand Down Expand Up @@ -126,6 +127,7 @@ class BatchSearchScreen extends Component<Props> {
style={{ display: 'content' }}
>
<LocationField
geocoderResultsOrder={geocoderResultsOrder}
inputPlaceholder={intl.formatMessage({
id: 'components.LocationSearch.setOrigin'
})}
Expand All @@ -136,6 +138,7 @@ class BatchSearchScreen extends Component<Props> {
showClearButton={false}
/>
<LocationField
geocoderResultsOrder={geocoderResultsOrder}
inputPlaceholder={intl.formatMessage({
id: 'components.LocationSearch.setDestination'
})}
Expand Down Expand Up @@ -190,8 +193,10 @@ class BatchSearchScreen extends Component<Props> {

const mapStateToProps = (state: any) => {
const currentQuery = state.otp.currentQuery
const { geocoderResultsOrder } = state.otp.config.geocoder
return {
currentQuery
currentQuery,
geocoderResultsOrder
}
}

Expand Down
17 changes: 15 additions & 2 deletions lib/components/mobile/welcome-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import MobileContainer from './container'
import MobileNavigationBar from './navigation-bar'

interface Props {
geocoderResultsOrder: Array<string>
setMobileScreen: (screen: number) => void
}

const MobileWelcomeScreen = ({ setMobileScreen }: Props) => {
const MobileWelcomeScreen = ({
geocoderResultsOrder,
setMobileScreen
}: Props) => {
const intl = useIntl()

const toFieldClicked = useCallback(
Expand All @@ -33,6 +37,7 @@ const MobileWelcomeScreen = ({ setMobileScreen }: Props) => {
<main tabIndex={-1}>
<div className="welcome-location mobile-padding">
<LocationField
geocoderResultsOrder={geocoderResultsOrder}
inputPlaceholder={intl.formatMessage({
id: 'components.WelcomeScreen.prompt'
})}
Expand All @@ -56,4 +61,12 @@ const mapDispatchToProps = {
setMobileScreen: uiActions.setMobileScreen
}

export default connect(null, mapDispatchToProps)(MobileWelcomeScreen)
const mapStateToProps = (state: any) => {
const { geocoderResultsOrder } = state.otp.config.geocoder

return {
geocoderResultsOrder
}
}

export default connect(mapStateToProps, mapDispatchToProps)(MobileWelcomeScreen)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"@opentripplanner/humanize-distance": "^1.2.0",
"@opentripplanner/icons": "3.0.1",
"@opentripplanner/itinerary-body": "6.0.3",
"@opentripplanner/location-field": "3.0.0",
"@opentripplanner/location-field": "3.1.1",
"@opentripplanner/location-icon": "^1.4.1",
"@opentripplanner/map-popup": "5.1.0",
"@opentripplanner/map-popup": "5.1.1",
"@opentripplanner/otp2-tile-overlay": "2.1.1",
"@opentripplanner/park-and-ride-overlay": "3.0.0",
"@opentripplanner/printable-itinerary": "3.0.0",
Expand Down
29 changes: 20 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2578,13 +2578,13 @@
react-resize-detector "^4.2.1"
string-similarity "^4.0.4"

"@opentripplanner/location-field@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/location-field/-/location-field-3.0.0.tgz#a6f8743290cf088bcd589cf8e6b0d07a651b704a"
integrity sha512-wPb9l5pvSeocZ45K1E3Zeb4hDjJtP9tw/S0MQ3HXYEQSf+700n4CWXVXYReYJXJYriOzge5/2whjUPGTlJckWw==
"@opentripplanner/location-field@3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@opentripplanner/location-field/-/location-field-3.1.1.tgz#0658df4cfd47866153c8ae33fd60e991cdf94df0"
integrity sha512-Q9yhi3AVlnj8izrpJvxN+uVBjjtEDyFXUsJ0VhE9zevVpGzCh/gcGNzJY5EnP2IRDd/Szx6dPUogt3XJlHkHTQ==
dependencies:
"@conveyal/geocoder-arcgis-geojson" "^0.0.3"
"@opentripplanner/core-utils" "^11.4.4"
"@opentripplanner/core-utils" "^12.0.0"
"@opentripplanner/geocoder" "^3.0.2"
"@opentripplanner/humanize-distance" "^1.2.0"
"@opentripplanner/location-icon" "^1.4.1"
Expand All @@ -2599,10 +2599,10 @@
"@styled-icons/fa-regular" "^10.34.0"
"@styled-icons/fa-solid" "^10.34.0"

"@opentripplanner/[email protected].0", "@opentripplanner/map-popup@^v5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-5.1.0.tgz#cf6374bf7b69af69c026ec414a84719078c56e9e"
integrity sha512-EShoMyFZa7Zb2ZZrJhEsJfuCAvs2jfQe5QstU+AEk5Jm1zc8LzU6PsXmizQ/RMVi6zIYLhlBoZ3u458tTA3VQA==
"@opentripplanner/[email protected].1":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-5.1.1.tgz#f4699b63a2ba0fae6263f2417c5b85f5ffc204cb"
integrity sha512-HifqZFmrBy3FmARVKZwUnad8U/L8ftBm2PcSck4oGQ768E7TKhqyzXz+GzkO39TyKNU5yiNgmQEbss8elZuJ/g==
dependencies:
"@opentripplanner/base-map" "^4.0.0"
"@opentripplanner/building-blocks" "^2.0.0"
Expand All @@ -2621,6 +2621,17 @@
"@opentripplanner/from-to-location-picker" "^2.1.14"
flat "^5.0.2"

"@opentripplanner/map-popup@^v5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-5.1.0.tgz#cf6374bf7b69af69c026ec414a84719078c56e9e"
integrity sha512-EShoMyFZa7Zb2ZZrJhEsJfuCAvs2jfQe5QstU+AEk5Jm1zc8LzU6PsXmizQ/RMVi6zIYLhlBoZ3u458tTA3VQA==
dependencies:
"@opentripplanner/base-map" "^4.0.0"
"@opentripplanner/building-blocks" "^2.0.0"
"@opentripplanner/core-utils" "^12.0.0"
"@opentripplanner/from-to-location-picker" "^3.0.0"
flat "^5.0.2"

"@opentripplanner/[email protected]":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-2.1.1.tgz#3bd2f26caa01181eb4ca90bbd05ce784f9b05a7a"
Expand Down
Loading