diff --git a/example-config.yml b/example-config.yml index 79a242954..d62b241ae 100644 --- a/example-config.yml +++ b/example-config.yml @@ -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 diff --git a/lib/actions/form.js b/lib/actions/form.js index bfdc65fe7..61ef9b87f 100644 --- a/lib/actions/form.js +++ b/lib/actions/form.js @@ -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) { diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 0d951f57f..a55484b66 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -184,6 +184,7 @@ const AdvancedSettingsPanel = ({ ) ) + const tripFormErrors = tripPlannerValidationErrors(currentQuery, intl) const closePanel = useCallback(() => { @@ -192,6 +193,15 @@ const AdvancedSettingsPanel = ({ closeAdvancedSettings() }, [autoPlan, closeAdvancedSettings, handlePlanTrip, tripFormErrors.length]) + const handleModeButtonToggle = setModeButton( + enabledModeButtons, + onSettingsUpdate(setQueryParam) + ) + + const handleAllSubmodesDisabled = (modeButton: ModeButtonDefinition) => { + handleModeButtonToggle(modeButton.key, false) + } + const onSaveAndReturnClick = useCallback(async () => { await setCloseAdvancedSettingsWithDelay() setClosingBySave(true) @@ -236,11 +246,9 @@ const AdvancedSettingsPanel = ({ id: 'components.BatchSearchScreen.submodeSelectorLabel' })} modeButtons={processedModeButtons} + onAllSubmodesDisabled={handleAllSubmodesDisabled} onSettingsUpdate={onSettingsUpdate(setQueryParam)} - onToggleModeButton={setModeButton( - enabledModeButtons, - onSettingsUpdate(setQueryParam) - )} + onToggleModeButton={handleModeButtonToggle} /> {saveAndReturnButton && ( { - const stopId = entity.gtfsId + // In the case that we are dealing with a station, use the first stop of the station + const firstStopOfStationId = entity.stops + ? JSON.parse(entity.stops)[0] + : false + + const stopId = firstStopOfStationId || entity.gtfsId this.props.findStopTimesForStop({ date: getCurrentDate(), onlyRequestForOperators: true, diff --git a/lib/reducers/create-otp-reducer.js b/lib/reducers/create-otp-reducer.js index fa0f082ef..c4b3a7811 100644 --- a/lib/reducers/create-otp-reducer.js +++ b/lib/reducers/create-otp-reducer.js @@ -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(), diff --git a/lib/util/config-types.ts b/lib/util/config-types.ts index cd29d83f7..481a62582 100644 --- a/lib/util/config-types.ts +++ b/lib/util/config-types.ts @@ -323,7 +323,7 @@ export interface GeocoderConfig extends GeocoderConfigOtpUI { export interface TransitModeConfig { color?: string label?: string - mode: string + mode: string | string[] showWheelchairSetting?: boolean } diff --git a/package.json b/package.json index a9a43acf2..62073cc3d 100644 --- a/package.json +++ b/package.json @@ -44,17 +44,17 @@ "@floating-ui/react": "^0.19.2", "@opentripplanner/base-map": "4.0.0", "@opentripplanner/building-blocks": "2.0.0", - "@opentripplanner/core-utils": "12.0.0", + "@opentripplanner/core-utils": "12.0.1", "@opentripplanner/endpoints-overlay": "3.0.1", "@opentripplanner/from-to-location-picker": "3.0.0", "@opentripplanner/geocoder": "^3.0.2", "@opentripplanner/humanize-distance": "^1.2.0", - "@opentripplanner/icons": "3.0.0", + "@opentripplanner/icons": "3.0.1", "@opentripplanner/itinerary-body": "6.0.1", "@opentripplanner/location-field": "3.0.0", "@opentripplanner/location-icon": "^1.4.1", "@opentripplanner/map-popup": "5.1.0", - "@opentripplanner/otp2-tile-overlay": "2.1.0", + "@opentripplanner/otp2-tile-overlay": "2.1.1", "@opentripplanner/park-and-ride-overlay": "3.0.0", "@opentripplanner/printable-itinerary": "3.0.0", "@opentripplanner/route-viewer-overlay": "3.0.0", @@ -63,7 +63,7 @@ "@opentripplanner/transit-vehicle-overlay": "5.0.0", "@opentripplanner/transitive-overlay": "4.0.0", "@opentripplanner/trip-details": "6.0.0", - "@opentripplanner/trip-form": "4.0.0", + "@opentripplanner/trip-form": "4.1.0", "@opentripplanner/trip-viewer-overlay": "3.0.0", "@opentripplanner/vehicle-rental-overlay": "3.0.0", "@styled-icons/fa-regular": "^10.34.0", diff --git a/yarn.lock b/yarn.lock index a4f77b0ae..98cb3d267 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2408,15 +2408,15 @@ resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-2.0.0.tgz#8282c01dff7db5c7e809f6ea91cb52df559a2f9d" integrity sha512-N07rDaZL8fp552eI9/0j1udKjc0uOpvO0Wv1P19Ge0a4roques463MJgWJ026fbopRCi3uwbc/gYTlh4/ske9A== -"@opentripplanner/building-blocks@^1.0.3", "@opentripplanner/building-blocks@^1.2.2": +"@opentripplanner/building-blocks@^1.2.2": version "1.2.3" resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.2.3.tgz#404e8f9038867d66d55f51adf8855b1326c51ed5" integrity sha512-I0AxiZrTZu+e7+av4u0tHW2ijqpxH0AkLHrhf75BHf1Ep2FOGxaul/v+8UT18mNYiM5eHNstOX3XiXaDjtCUaw== -"@opentripplanner/core-utils@12.0.0", "@opentripplanner/core-utils@^12.0.0": - version "12.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.0.tgz#cc40af92620b207f4dce817d08f99def0cdaea7a" - integrity sha512-udLF8XU+k7gxZ+yyyw7ASz6/4D540zYIv8a9GbUL61TF8HmgGhcMk3XOgBnm5jdOukuaNNpOFE4J3oJc5QsSBQ== +"@opentripplanner/core-utils@12.0.1": + version "12.0.1" + resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.1.tgz#2bafb78133393213b4943c76fec5d46436c0fb6d" + integrity sha512-QUTxEcpiOnbqaoiu6RQngTLlQHjSHO4PCMJqR9IRiaei08FnlTx2jgpvIaRla6u7tRNr12YCzptc37+a10ryww== dependencies: "@conveyal/lonlat" "^1.4.1" "@mapbox/polyline" "^1.1.0" @@ -2449,6 +2449,24 @@ lodash.isequal "^4.5.0" qs "^6.9.1" +"@opentripplanner/core-utils@^12.0.0": + version "12.0.0" + resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.0.tgz#cc40af92620b207f4dce817d08f99def0cdaea7a" + integrity sha512-udLF8XU+k7gxZ+yyyw7ASz6/4D540zYIv8a9GbUL61TF8HmgGhcMk3XOgBnm5jdOukuaNNpOFE4J3oJc5QsSBQ== + 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/endpoints-overlay@3.0.1": version "3.0.1" resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-3.0.1.tgz#b6b8e2f08ae41fbaad475fc0f0fe3e72d7d36463" @@ -2493,12 +2511,12 @@ resolved "https://registry.yarnpkg.com/@opentripplanner/humanize-distance/-/humanize-distance-1.2.0.tgz#71cf5d5d1b756adef15300edbba0995ccd4b35ee" integrity sha512-x0QRXMDhypFeazZ6r6vzrdU8vhiV56nZ/WX6zUbxpgp6T9Oclw0gwR2Zdw6DZiiFpSYVNeVNxVzZwsu6NRGjcA== -"@opentripplanner/icons@3.0.0", "@opentripplanner/icons@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/icons/-/icons-3.0.0.tgz#f7293fd4dd2625eace3a4c82ecd573d6000d85d3" - integrity sha512-naSCdCsPwSyEiP7Vf6oN6dpgwpFIkeQFXfTJG7lp1Dg9emLTAYzRx/f+45e9Bh0zP0aA4DsN4VgHBQllyu82qQ== +"@opentripplanner/icons@3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@opentripplanner/icons/-/icons-3.0.1.tgz#62cf5ffd9ad42c5ba2ac64cf91e9f10c8300ff1e" + integrity sha512-pu96GWVR2ef6aMPPJRjdzHkIVlENGa3LRlqNaW3PEZQLjycsCsT1ZpJ6+zKwVfZsgoMl1L8mx2qjLO4RUZzGAA== dependencies: - "@opentripplanner/core-utils" "^11.4.4" + "@opentripplanner/core-utils" "^12.0.0" prop-types "^15.7.2" "@opentripplanner/icons@^2.0.12": @@ -2509,6 +2527,14 @@ "@opentripplanner/core-utils" "^11.4.4" prop-types "^15.7.2" +"@opentripplanner/icons@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@opentripplanner/icons/-/icons-3.0.0.tgz#f7293fd4dd2625eace3a4c82ecd573d6000d85d3" + integrity sha512-naSCdCsPwSyEiP7Vf6oN6dpgwpFIkeQFXfTJG7lp1Dg9emLTAYzRx/f+45e9Bh0zP0aA4DsN4VgHBQllyu82qQ== + dependencies: + "@opentripplanner/core-utils" "^11.4.4" + prop-types "^15.7.2" + "@opentripplanner/itinerary-body@6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/@opentripplanner/itinerary-body/-/itinerary-body-6.0.1.tgz#74139536b34083af5b324fb94e69be267ea6bbeb" @@ -2566,7 +2592,7 @@ "@styled-icons/fa-regular" "^10.34.0" "@styled-icons/fa-solid" "^10.34.0" -"@opentripplanner/map-popup@5.1.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== @@ -2588,23 +2614,12 @@ "@opentripplanner/from-to-location-picker" "^2.1.14" flat "^5.0.2" -"@opentripplanner/map-popup@^v3.2.0-alpha.1": - version "3.2.0-alpha.1" - resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-3.2.0-alpha.1.tgz#dcad38c103500f7c5ad3c632398204849ed5885e" - integrity sha512-Z0RsyC7wkYU/aOLYQFsJI5tBhzooEE/sQZROX2WODkDWAv4Qfj95ppS8pvNkpoZ0N4fioFcj5aM2VGXVMSy0EA== - dependencies: - "@opentripplanner/base-map" "^3.2.2" - "@opentripplanner/building-blocks" "^1.2.2" - "@opentripplanner/core-utils" "^11.4.4" - "@opentripplanner/from-to-location-picker" "^2.1.14" - flat "^5.0.2" - -"@opentripplanner/otp2-tile-overlay@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-2.1.0.tgz#745cb6c80dbde767a0b5ac7b0b866193a18ec984" - integrity sha512-gkKS5OT/Ayc/987vcdSkFcGSH/YyvEBN9bZFWBHKRN5nbRykBRZu2GNFVfN5ITLoshrFw+YasIk9omfTKVJtRg== +"@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" + integrity sha512-dAU8wd82ySTCHzc1uMbvN5k4WLAtK7AXY56rm6KZdnV3G2UQIFVcaatLj4bpTqS9j90trWnCIvRNm6FKo41f/w== dependencies: - "@opentripplanner/map-popup" "^v3.2.0-alpha.1" + "@opentripplanner/map-popup" "^v5.1.0" "@opentripplanner/park-and-ride-overlay@3.0.0": version "3.0.0" @@ -2698,14 +2713,14 @@ flat "^5.0.2" react-animate-height "^3.0.4" -"@opentripplanner/trip-form@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/trip-form/-/trip-form-4.0.0.tgz#27b36a0504e46cfda1cdf50c971b5cea03de8ae2" - integrity sha512-Cg8SlAVN8M+qoWpz8jAkwuqllIPgrL2PVewTPuDPsIQ8i5B7xo5KKE3TPo7cQUM+jE6WEshpvv0FIdMF+NAlNg== +"@opentripplanner/trip-form@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@opentripplanner/trip-form/-/trip-form-4.1.0.tgz#83bd7135d1c814f1ea0be4f6896dd2494c9ddba9" + integrity sha512-VOWoyAfnnmwNnsolYLk7vfXRQvF3rj2XW5pXJ+OKwplGTgOhxJGNMKjZxau4legRedauyf0MHBNRpD3M3vsqRg== dependencies: "@floating-ui/react" "^0.19.2" - "@opentripplanner/building-blocks" "^1.0.3" - "@opentripplanner/core-utils" "^11.4.4" + "@opentripplanner/building-blocks" "^2.0.0" + "@opentripplanner/core-utils" "^12.0.0" "@styled-icons/bootstrap" "^10.34.0" "@styled-icons/boxicons-regular" "^10.38.0" "@styled-icons/fa-regular" "^10.37.0"