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

Deselect all submodes #1265

Merged
merged 15 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/components/form/advanced-settings-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
ModeSetting,
ModeSettingValues
} from '@opentripplanner/types'
import React, { RefObject, useContext, useState } from 'react'
import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types'
import React, { RefObject, useContext, useEffect, useState } from 'react'
import styled from 'styled-components'

import * as formActions from '../../actions/form'
Expand Down Expand Up @@ -127,7 +128,7 @@ const AdvancedSettingsPanel = ({
modeSettingDefinitions: ModeSetting[]
modeSettingValues: ModeSettingValues
onPlanTripClick: () => void
setQueryParam: (evt: any) => void
setQueryParam: (evt: QueryParamChangeEvent) => void
josh-willis-arcadis marked this conversation as resolved.
Show resolved Hide resolved
}): JSX.Element => {
const [closingBySave, setClosingBySave] = useState(false)
const [closingByX, setClosingByX] = useState(false)
Expand Down Expand Up @@ -168,6 +169,7 @@ const AdvancedSettingsPanel = ({
)

const processedModeSettings = processSettings(modeSettingDefinitions)

josh-willis-arcadis marked this conversation as resolved.
Show resolved Hide resolved
const processedModeButtons = modeButtonOptions.map(
pipe(
addModeButtonIcon(ModeIcon),
Expand All @@ -176,6 +178,15 @@ const AdvancedSettingsPanel = ({
)
)

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

const handleAllSubmodesDisabled = (modeButton: ModeButtonDefinition) => {
josh-willis-arcadis marked this conversation as resolved.
Show resolved Hide resolved
handleModeButtonToggle(modeButton.key, false)
}

return (
<PanelOverlay className="advanced-settings" ref={innerRef}>
<HeaderContainer>
Expand Down Expand Up @@ -213,11 +224,9 @@ const AdvancedSettingsPanel = ({
fillModeIcons
label="test"
modeButtons={processedModeButtons}
onAllSubmodesDisabled={handleAllSubmodesDisabled}
onSettingsUpdate={onSettingsUpdate(setQueryParam)}
onToggleModeButton={setModeButton(
enabledModeButtons,
onSettingsUpdate(setQueryParam)
)}
onToggleModeButton={handleModeButtonToggle}
/>
<ReturnToTripPlanButton
className="save-settings-button"
Expand Down
1 change: 0 additions & 1 deletion lib/components/form/util.tsx
josh-willis-arcadis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const setModeButton =
} else {
newButtons = enabledModeButtons.filter((c) => c !== buttonId)
}

// encodeQueryParams serializes the mode buttons for the URL
// to get nice looking URL params and consistency
updateHandler(
Expand Down
29 changes: 29 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,24 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/core-utils@^11.4.1":
version "11.4.4"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.4.tgz#11c1be91a5e90afda4fc265831c761d3e044d933"
integrity sha512-WKhOuG7Q+Yxdm+P5MPmJyXndx+JUtGn44GTeilOnUqDdO8lTLTvqqt0hYeEWjA77jWP0u8tG7fAAsft8IZn2cg==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
"@opentripplanner/geocoder" "^3.0.2"
"@styled-icons/foundation" "^10.34.0"
"@turf/along" "^6.0.1"
chroma-js "^2.4.2"
date-fns "^2.28.0"
date-fns-tz "^1.2.2"
graphql "^16.6.0"
lodash.clonedeep "^4.5.0"
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/core-utils@^11.4.3":
version "11.4.3"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.3.tgz#4655f9a3bef1977e53abd81a4a0eae966f977c60"
Expand Down Expand Up @@ -2465,6 +2483,17 @@
isomorphic-mapzen-search "^1.6.1"
lodash.memoize "^4.1.2"

"@opentripplanner/geocoder@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@opentripplanner/geocoder/-/geocoder-3.0.2.tgz#2c7618947d1d9b082bd39d037327c9cf23282782"
integrity sha512-pl7tCiodex0hXWKLH3WE+I+HzoSgOOWp9kR3xMcuRiE5g6k2JXNneoD/ZfSS1n6Oorxcjv3U2DbMSXT2j/39dQ==
dependencies:
"@conveyal/geocoder-arcgis-geojson" "^0.0.3"
"@conveyal/lonlat" "^1.4.1"
"@leeoniya/ufuzzy" "^1.0.14"
isomorphic-mapzen-search "^1.6.1"
lodash.memoize "^4.1.2"

"@opentripplanner/humanize-distance@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/humanize-distance/-/humanize-distance-1.2.0.tgz#71cf5d5d1b756adef15300edbba0995ccd4b35ee"
Expand Down