-
Notifications
You must be signed in to change notification settings - Fork 57
Select scooter mode when starting trip from scooter in nearby view #1449
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
base: dev
Are you sure you want to change the base?
Changes from all commits
5cb8ab5
85993ff
29d5d3f
4605c6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import { connect } from 'react-redux' | |
import { GeolocateControl, NavigationControl } from 'react-map-gl' | ||
import { getCurrentDate } from '@opentripplanner/core-utils/lib/time' | ||
import { injectIntl } from 'react-intl' | ||
import { MapLocationActionArg } from '@opentripplanner/types' | ||
import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' | ||
import BaseMap from '@opentripplanner/base-map' | ||
import generateOTP2TileLayers from '@opentripplanner/otp2-tile-overlay' | ||
import React, { Component } from 'react' | ||
|
@@ -21,7 +23,9 @@ import { ComponentContext } from '../../util/contexts' | |
import { getActiveItinerary, getActiveSearch } from '../../util/state' | ||
import { getCurrentPosition } from '../../actions/location' | ||
import { MainPanelContent } from '../../actions/ui-constants' | ||
import { onSettingsUpdate } from '../form/util' | ||
import { setLocation, setMapPopupLocationAndGeocode } from '../../actions/map' | ||
import { setQueryParam } from '../../actions/form' | ||
import { setViewedStop } from '../../actions/ui' | ||
import { updateOverlayVisibility } from '../../actions/config' | ||
import TransitOperatorIcons from '../util/connected-transit-operator-icons' | ||
|
@@ -278,13 +282,15 @@ class DefaultMap extends Component { | |
carRentalQuery, | ||
carRentalStations, | ||
config, | ||
currentQuery, | ||
getCurrentPosition, | ||
intl, | ||
itinerary, | ||
mapConfig, | ||
nearbyViewActive, | ||
pending, | ||
setLocation, | ||
setQueryParam, | ||
setViewedStop, | ||
vehicleRentalQuery, | ||
vehicleRentalStations, | ||
|
@@ -319,6 +325,23 @@ class DefaultMap extends Component { | |
const baseLayerUrls = baseLayersWithNames?.map((bl) => bl.url) | ||
const baseLayerNames = baseLayersWithNames?.map((bl) => bl.name) | ||
|
||
const overlayTypes = overlays | ||
?.filter((overlay) => overlay?.type === 'otp2')?.[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we not use |
||
?.layers?.map((layer) => layer?.type) | ||
const handleSetLocation = (location: MapLocationActionArg) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one approach, but could we not fix this by adjusting query params? What if we check for map state in the places where query params are set? Might that be a better separation of concerns than setting modes within the map component? |
||
if (overlayTypes && overlayTypes.includes('rentalVehicles')) { | ||
let selectedModeButtons = currentQuery.modeButtons ?? '' | ||
// if selectedModeButtons is undefined, the mode buttons are in their default state, which includes transit | ||
if (selectedModeButtons.length === 0) | ||
selectedModeButtons = 'transit_bike_rent' | ||
else if (!selectedModeButtons.includes('bike_rent')) | ||
selectedModeButtons += '_bike_rent' | ||
const evt: QueryParamChangeEvent = { modeButtons: selectedModeButtons } | ||
onSettingsUpdate(setQueryParam)(evt) | ||
} | ||
setLocation(location) | ||
} | ||
|
||
const routeBasedTransitVehicleOverlayNameOverride = | ||
overlays?.find((o) => o.type === 'vehicles-one-route') || undefined | ||
|
||
|
@@ -435,7 +458,7 @@ class DefaultMap extends Component { | |
name: getLayerName(l, config, intl) || l.network || l.type | ||
})), | ||
vectorTilesEndpoint, | ||
setLocation, | ||
handleSetLocation, | ||
setViewedStop, | ||
viewedRouteStops, | ||
config.companies, | ||
|
@@ -486,6 +509,7 @@ const mapStateToProps = (state) => { | |
bikeRentalStations: state.otp.overlay.bikeRental.stations, | ||
carRentalStations: state.otp.overlay.carRental.stations, | ||
config: state.otp.config, | ||
currentQuery: state.otp.currentQuery, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a huge fan of importing query info into the map component... |
||
itinerary: getActiveItinerary(state), | ||
mapConfig: state.otp.config.map, | ||
nearbyViewActive: | ||
|
@@ -504,6 +528,7 @@ const mapDispatchToProps = { | |
getCurrentPosition, | ||
setLocation, | ||
setMapPopupLocationAndGeocode, | ||
setQueryParam, | ||
setViewedStop, | ||
updateOverlayVisibility, | ||
vehicleRentalQuery | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One weird quirk...I realized after writing this that we don't actually specify that this logic should only fire when the
from
is clicked on a rental vehicle popup. And yet, when I click thefrom
on other popups (like a stop), it doesn't enable the rental vehicle mode. I'm not really sure why...