From e3219aefca0dd4b6423b018b3245d250abd8b8fe Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:33:29 -0500 Subject: [PATCH 1/5] Pass "renderOtherFirst" config item to LocationFields --- example-config.yml | 3 +++ lib/components/app/batch-routing-panel.tsx | 8 +++++++- lib/components/mobile/batch-search-screen.tsx | 18 ++++++++++++++++-- lib/components/mobile/welcome-screen.tsx | 14 ++++++++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/example-config.yml b/example-config.yml index d132b835e..232839897 100644 --- a/example-config.yml +++ b/example-config.yml @@ -179,6 +179,9 @@ map: # geocoder test account can be obtained from the Pelias maintainers at geocode.earth. geocoder: apiKey: PELIAS_API_KEY + # When set to true, geocoder results will be displayed with the "Other" section first, + # above transit stops and stations + renderOtherFirst: false boundary: rect: minLon: -123.2034 diff --git a/lib/components/app/batch-routing-panel.tsx b/lib/components/app/batch-routing-panel.tsx index c1321091e..5e2a02eef 100644 --- a/lib/components/app/batch-routing-panel.tsx +++ b/lib/components/app/batch-routing-panel.tsx @@ -16,6 +16,7 @@ interface Props { activeSearch: any intl: IntlShape mobile?: boolean + renderOtherFirst?: boolean showUserSettings: boolean } @@ -34,7 +35,8 @@ class BatchRoutingPanel extends Component { } render() { - const { activeSearch, intl, mobile, showUserSettings } = this.props + const { activeSearch, intl, mobile, renderOtherFirst, showUserSettings } = + this.props const { planTripClicked } = this.state const mapAction = mobile ? intl.formatMessage({ @@ -71,6 +73,7 @@ class BatchRoutingPanel extends Component { )} isRequired locationType="from" + renderOtherFirst={renderOtherFirst} selfValidate={planTripClicked} showClearButton={!mobile} /> @@ -81,6 +84,7 @@ class BatchRoutingPanel extends Component { )} isRequired locationType="to" + renderOtherFirst={renderOtherFirst} selfValidate={planTripClicked} showClearButton={!mobile} /> @@ -115,8 +119,10 @@ const mapStateToProps = (state: any) => { getShowUserSettings(state) && (state.user.loggedInUser?.hasConsentedToTerms || getPersistenceMode(state.otp.config.persistence).isLocalStorage) + const { renderOtherFirst } = state.otp.config.geocoder return { activeSearch: getActiveSearch(state), + renderOtherFirst, showUserSettings } } diff --git a/lib/components/mobile/batch-search-screen.tsx b/lib/components/mobile/batch-search-screen.tsx index 930112a88..99b632439 100644 --- a/lib/components/mobile/batch-search-screen.tsx +++ b/lib/components/mobile/batch-search-screen.tsx @@ -17,6 +17,7 @@ const { SET_FROM_LOCATION, SET_TO_LOCATION } = MobileScreens interface Props { intl: IntlShape map: React.ReactElement + renderOtherFirst: boolean setMobileScreen: (screen: number) => void } @@ -34,7 +35,7 @@ class BatchSearchScreen extends Component { } render() { - const { intl } = this.props + const { intl, renderOtherFirst } = this.props const { planTripClicked } = this.state return ( @@ -52,6 +53,7 @@ class BatchSearchScreen extends Component { isRequired locationType="from" onTextInputClick={this._fromFieldClicked} + renderOtherFirst={renderOtherFirst} selfValidate={planTripClicked} showClearButton={false} /> @@ -62,6 +64,7 @@ class BatchSearchScreen extends Component { isRequired locationType="to" onTextInputClick={this._toFieldClicked} + renderOtherFirst={renderOtherFirst} selfValidate={planTripClicked} showClearButton={false} /> @@ -85,4 +88,15 @@ const mapDispatchToProps = { setMobileScreen: uiActions.setMobileScreen } -export default connect(null, mapDispatchToProps)(injectIntl(BatchSearchScreen)) +const mapStateToProps = (state: any) => { + const { renderOtherFirst } = state.otp.config.geocoder + + return { + renderOtherFirst + } +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(injectIntl(BatchSearchScreen)) diff --git a/lib/components/mobile/welcome-screen.tsx b/lib/components/mobile/welcome-screen.tsx index 9a3492407..484eae79b 100644 --- a/lib/components/mobile/welcome-screen.tsx +++ b/lib/components/mobile/welcome-screen.tsx @@ -12,10 +12,11 @@ import MobileContainer from './container' import MobileNavigationBar from './navigation-bar' interface Props { + renderOtherFirst: boolean setMobileScreen: (screen: number) => void } -const MobileWelcomeScreen = ({ setMobileScreen }: Props) => { +const MobileWelcomeScreen = ({ renderOtherFirst, setMobileScreen }: Props) => { const intl = useIntl() const toFieldClicked = useCallback( @@ -38,6 +39,7 @@ const MobileWelcomeScreen = ({ setMobileScreen }: Props) => { })} locationType="to" onTextInputClick={toFieldClicked} + renderOtherFirst={renderOtherFirst} showClearButton={false} /> @@ -56,4 +58,12 @@ const mapDispatchToProps = { setMobileScreen: uiActions.setMobileScreen } -export default connect(null, mapDispatchToProps)(MobileWelcomeScreen) +const mapStateToProps = (state: any) => { + const { renderOtherFirst } = state.otp.config.geocoder + + return { + renderOtherFirst + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(MobileWelcomeScreen) From c512398cce3c104ce2f545feb954738c7929caec Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:14:59 -0600 Subject: [PATCH 2/5] Update config item to geocoderResultsOrder --- example-config.yml | 6 +++--- lib/components/app/batch-routing-panel.tsx | 19 ++++++++++++------- lib/components/mobile/batch-search-screen.tsx | 12 ++++++------ lib/components/mobile/welcome-screen.tsx | 13 ++++++++----- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/example-config.yml b/example-config.yml index 232839897..e5d10ae79 100644 --- a/example-config.yml +++ b/example-config.yml @@ -179,9 +179,9 @@ map: # geocoder test account can be obtained from the Pelias maintainers at geocode.earth. geocoder: apiKey: PELIAS_API_KEY - # When set to true, geocoder results will be displayed with the "Other" section first, - # above transit stops and stations - renderOtherFirst: false + # 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 diff --git a/lib/components/app/batch-routing-panel.tsx b/lib/components/app/batch-routing-panel.tsx index 5e2a02eef..e675e5cc6 100644 --- a/lib/components/app/batch-routing-panel.tsx +++ b/lib/components/app/batch-routing-panel.tsx @@ -14,9 +14,9 @@ import ViewerContainer from '../viewers/viewer-container' interface Props { activeSearch: any + geocoderResultsOrder?: Array intl: IntlShape mobile?: boolean - renderOtherFirst?: boolean showUserSettings: boolean } @@ -35,8 +35,13 @@ class BatchRoutingPanel extends Component { } render() { - const { activeSearch, intl, mobile, renderOtherFirst, showUserSettings } = - this.props + const { + activeSearch, + geocoderResultsOrder, + intl, + mobile, + showUserSettings + } = this.props const { planTripClicked } = this.state const mapAction = mobile ? intl.formatMessage({ @@ -67,24 +72,24 @@ class BatchRoutingPanel extends Component { > @@ -119,10 +124,10 @@ const mapStateToProps = (state: any) => { getShowUserSettings(state) && (state.user.loggedInUser?.hasConsentedToTerms || getPersistenceMode(state.otp.config.persistence).isLocalStorage) - const { renderOtherFirst } = state.otp.config.geocoder + const { geocoderResultsOrder } = state.otp.config.geocoder return { activeSearch: getActiveSearch(state), - renderOtherFirst, + geocoderResultsOrder, showUserSettings } } diff --git a/lib/components/mobile/batch-search-screen.tsx b/lib/components/mobile/batch-search-screen.tsx index 99b632439..f773cf2f7 100644 --- a/lib/components/mobile/batch-search-screen.tsx +++ b/lib/components/mobile/batch-search-screen.tsx @@ -15,9 +15,9 @@ import MobileNavigationBar from './navigation-bar' const { SET_FROM_LOCATION, SET_TO_LOCATION } = MobileScreens interface Props { + geocoderResultsOrder: Array intl: IntlShape map: React.ReactElement - renderOtherFirst: boolean setMobileScreen: (screen: number) => void } @@ -35,7 +35,7 @@ class BatchSearchScreen extends Component { } render() { - const { intl, renderOtherFirst } = this.props + const { geocoderResultsOrder, intl } = this.props const { planTripClicked } = this.state return ( @@ -47,24 +47,24 @@ class BatchSearchScreen extends Component {
@@ -89,10 +89,10 @@ const mapDispatchToProps = { } const mapStateToProps = (state: any) => { - const { renderOtherFirst } = state.otp.config.geocoder + const { geocoderResultsOrder } = state.otp.config.geocoder return { - renderOtherFirst + geocoderResultsOrder } } diff --git a/lib/components/mobile/welcome-screen.tsx b/lib/components/mobile/welcome-screen.tsx index 484eae79b..8fde116df 100644 --- a/lib/components/mobile/welcome-screen.tsx +++ b/lib/components/mobile/welcome-screen.tsx @@ -12,11 +12,14 @@ import MobileContainer from './container' import MobileNavigationBar from './navigation-bar' interface Props { - renderOtherFirst: boolean + geocoderResultsOrder: Array setMobileScreen: (screen: number) => void } -const MobileWelcomeScreen = ({ renderOtherFirst, setMobileScreen }: Props) => { +const MobileWelcomeScreen = ({ + geocoderResultsOrder, + setMobileScreen +}: Props) => { const intl = useIntl() const toFieldClicked = useCallback( @@ -34,12 +37,12 @@ const MobileWelcomeScreen = ({ renderOtherFirst, setMobileScreen }: Props) => {
@@ -59,10 +62,10 @@ const mapDispatchToProps = { } const mapStateToProps = (state: any) => { - const { renderOtherFirst } = state.otp.config.geocoder + const { geocoderResultsOrder } = state.otp.config.geocoder return { - renderOtherFirst + geocoderResultsOrder } } From 8b9c63f01fe14883a2e70381a1b85e0baea84c89 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:21:48 -0600 Subject: [PATCH 3/5] Update otp packages to include location field changes --- package.json | 4 ++-- yarn.lock | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 898bc9182..3ed8c8330 100644 --- a/package.json +++ b/package.json @@ -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.0", "@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", diff --git a/yarn.lock b/yarn.lock index 75e4f6c32..203b32681 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@opentripplanner/location-field/-/location-field-3.1.0.tgz#2339d7214084ccece494969eafd7af8a2a9cc355" + integrity sha512-UDKEwNOlPyWhbcPgycOMTv8Mcto2CuhPVQw6b1r85qjLgzm4urHb00hcvTW0eqNfuCett0h/lM2Y1KFKuBC+iQ== 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" @@ -2599,10 +2599,10 @@ "@styled-icons/fa-regular" "^10.34.0" "@styled-icons/fa-solid" "^10.34.0" -"@opentripplanner/map-popup@5.1.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/map-popup@5.1.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" @@ -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/otp2-tile-overlay@2.1.1": version "2.1.1" resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-2.1.1.tgz#3bd2f26caa01181eb4ca90bbd05ce784f9b05a7a" From 1c6c3ef8313a7b7861bdd3813c286a46db64693d Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:27:02 -0600 Subject: [PATCH 4/5] Update Location Field --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3ed8c8330..1c98635c5 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@opentripplanner/humanize-distance": "^1.2.0", "@opentripplanner/icons": "3.0.1", "@opentripplanner/itinerary-body": "6.0.3", - "@opentripplanner/location-field": "3.1.0", + "@opentripplanner/location-field": "3.1.1", "@opentripplanner/location-icon": "^1.4.1", "@opentripplanner/map-popup": "5.1.1", "@opentripplanner/otp2-tile-overlay": "2.1.1", diff --git a/yarn.lock b/yarn.lock index 203b32681..214d59710 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2578,10 +2578,10 @@ react-resize-detector "^4.2.1" string-similarity "^4.0.4" -"@opentripplanner/location-field@3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/location-field/-/location-field-3.1.0.tgz#2339d7214084ccece494969eafd7af8a2a9cc355" - integrity sha512-UDKEwNOlPyWhbcPgycOMTv8Mcto2CuhPVQw6b1r85qjLgzm4urHb00hcvTW0eqNfuCett0h/lM2Y1KFKuBC+iQ== +"@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" "^12.0.0" From 015dfd44c8f2a2e6074db3d22a0d5dee992ab54c Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:30:04 -0600 Subject: [PATCH 5/5] Handle if geocoderResultsOrder is undefined --- lib/components/app/batch-routing-panel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/app/batch-routing-panel.tsx b/lib/components/app/batch-routing-panel.tsx index 6ffa98b2a..30001e1b3 100644 --- a/lib/components/app/batch-routing-panel.tsx +++ b/lib/components/app/batch-routing-panel.tsx @@ -245,7 +245,7 @@ const mapStateToProps = (state: any) => { const { mainPanelContent } = state.otp.ui const currentQuery = state.otp.currentQuery - const { geocoderResultsOrder } = state.otp.config.geocoder + const geocoderResultsOrder = state.otp.config?.geocoder?.geocoderResultsOrder return { activeSearch: getActiveSearch(state), currentQuery,