Skip to content

Commit

Permalink
Merge branch 'dev' into consolidate-findStopTimesForStop-query
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup committed Oct 22, 2024
2 parents 2a5e6b9 + cab7c04 commit 28ba62f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
6 changes: 5 additions & 1 deletion example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ modes:
iconName: wheelchair
type: CHECKBOX # Possible options: CHECKBOX, SUBMODE, SLIDER, DROPDOWN
transitModes:
- mode: BUS
# Mode can be a string or an array of strings.
- mode: ["TROLLEYBUS", "BUS"]
# When mode is an array an overrideMode must be provided.
# This specifies the displayed mode used for icon and URL param.
overrideMode: BUS
label: Bus
# A mode color can be added, used throughout the application,
# most notably in the enhanced stop viewer bubble
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function resetForm(full = false) {
const options = getTripOptionsFromQuery(defaultQuery)
// Default mode is currently WALK,TRANSIT. We need to update this value
// here to match the list of modes, otherwise the form will break.
options.mode = ['WALK', ...transitModes.map((m) => m.mode)].join(',')
options.mode = ['WALK', ...transitModes.flatMap((m) => m.mode)].join(',')
dispatch(settingQueryParam(options))
}
if (full) {
Expand Down
15 changes: 11 additions & 4 deletions lib/components/form/advanced-settings-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ const AdvancedSettingsPanel = ({
)
)

const handleModeButtonToggle = setModeButton(
enabledModeButtons,
onSettingsUpdate(setQueryParam)
)

const handleAllSubmodesDisabled = (modeButton: ModeButtonDefinition) => {
handleModeButtonToggle(modeButton.key, false)
}

const onSaveAndReturnClick = useCallback(async () => {
await setCloseAdvancedSettingsWithDelay()
setClosingBySave(true)
Expand Down Expand Up @@ -221,11 +230,9 @@ const AdvancedSettingsPanel = ({
id: 'components.BatchSearchScreen.submodeSelectorLabel'
})}
modeButtons={processedModeButtons}
onAllSubmodesDisabled={handleAllSubmodesDisabled}
onSettingsUpdate={onSettingsUpdate(setQueryParam)}
onToggleModeButton={setModeButton(
enabledModeButtons,
onSettingsUpdate(setQueryParam)
)}
onToggleModeButton={handleModeButtonToggle}
/>
{saveAndReturnButton && (
<ReturnToTripPlanButton
Expand Down
10 changes: 9 additions & 1 deletion lib/reducers/create-otp-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,18 @@ export function getInitialState(userDefinedConfig) {

const transitModeSettings = config?.modes?.transitModes.map((transitMode) => {
const { mode, overrideMode } = transitMode
if (Array.isArray(mode) && !overrideMode) {
console.warn(
`Mode ${mode} is an array, but no overrideMode is specified.`
)
}
const displayedMode = overrideMode || mode
const addTransportModes = Array.isArray(mode)
? mode.map((m) => ({ mode: m }))
: { mode }
return {
// This is the mode that gets added to the actual query to OTP
addTransportMode: { mode },
addTransportMode: addTransportModes,
applicableMode: 'TRANSIT',
default: true,
iconName: displayedMode.toLowerCase(),
Expand Down
2 changes: 1 addition & 1 deletion lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export interface GeocoderConfig extends GeocoderConfigOtpUI {
export interface TransitModeConfig {
color?: string
label?: string
mode: string
mode: string | string[]
showWheelchairSetting?: boolean
}

Expand Down

0 comments on commit 28ba62f

Please sign in to comment.