From fb610b7322baec702b9d886af5872ebd19c6cef0 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:09:24 -0500 Subject: [PATCH 01/31] feat(advanced-settings-panel): turn off mode if all submode settings are false --- .../form/advanced-settings-panel.tsx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index a76b3f85d..ad29c7b94 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -168,13 +168,34 @@ const AdvancedSettingsPanel = ({ ) const processedModeSettings = processSettings(modeSettingDefinitions) + + const checkAllSubsettingsFalse = (modeButton: ModeButtonDefinition) => { + if (modeButton.modeSettings && modeButton.modeSettings.length > 0) { + const transportModeSettings = modeButton.modeSettings.filter( + (setting: ModeSetting) => + // this checks if the setting is a transport mode + (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && + setting.addTransportMode + ) + if (transportModeSettings.length === 0) return modeButton + + console.log('transportModeSettings::::::', transportModeSettings) + const allFalse = transportModeSettings.every((setting) => !setting.value) + return { ...modeButton, enabled: modeButton.enabled && !allFalse } + } + + return modeButton + } + const processedModeButtons = modeButtonOptions.map( pipe( addModeButtonIcon(ModeIcon), addSettingsToButton(processedModeSettings), - setModeButtonEnabled(enabledModeButtons) + setModeButtonEnabled(enabledModeButtons), + checkAllSubsettingsFalse ) ) + console.log('processedModeButtons::::::', processedModeButtons) return ( From e593dea94f1c370d551f8f426e186488bbb32a04 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:05:47 -0500 Subject: [PATCH 02/31] fix(advanced-settings-panel): stop infinite loops on rerender --- .../form/advanced-settings-panel.tsx | 73 +++++++++++++------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index ad29c7b94..79c4057a5 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -15,7 +15,7 @@ import { ModeSetting, ModeSettingValues } from '@opentripplanner/types' -import React, { RefObject, useContext, useState } from 'react' +import React, { RefObject, useContext, useEffect, useState } from 'react' import styled from 'styled-components' import * as formActions from '../../actions/form' @@ -168,35 +168,59 @@ const AdvancedSettingsPanel = ({ ) const processedModeSettings = processSettings(modeSettingDefinitions) + // console.log('processedModeSettings::::', processedModeSettings) - const checkAllSubsettingsFalse = (modeButton: ModeButtonDefinition) => { - if (modeButton.modeSettings && modeButton.modeSettings.length > 0) { - const transportModeSettings = modeButton.modeSettings.filter( - (setting: ModeSetting) => - // this checks if the setting is a transport mode - (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && - setting.addTransportMode - ) - if (transportModeSettings.length === 0) return modeButton - - console.log('transportModeSettings::::::', transportModeSettings) - const allFalse = transportModeSettings.every((setting) => !setting.value) - return { ...modeButton, enabled: modeButton.enabled && !allFalse } - } - - return modeButton - } + const handleModeButtonToggle = setModeButton( + enabledModeButtons, + onSettingsUpdate(setQueryParam) + ) const processedModeButtons = modeButtonOptions.map( pipe( addModeButtonIcon(ModeIcon), addSettingsToButton(processedModeSettings), - setModeButtonEnabled(enabledModeButtons), - checkAllSubsettingsFalse + setModeButtonEnabled(enabledModeButtons) ) ) console.log('processedModeButtons::::::', processedModeButtons) + useEffect(() => { + console.log('processedModeButtons CHANGED!!! ::::::', processedModeButtons) + const checkTransportModeSubsettings = ( + modeButton: ModeButtonDefinition + ) => { + if ( + modeButton.enabled && + modeButton.modeSettings && + modeButton.modeSettings.length > 0 + ) { + const transportModeSettings = modeButton.modeSettings.filter( + (setting: ModeSetting) => + (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && + setting.addTransportMode + ) + if (transportModeSettings.length === 0) return modeButton + + const allFalse = transportModeSettings.every( + (setting) => !setting.value + ) + if (allFalse) { + console.log( + 'subsettings are all false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + ) + modeButton.enabled = false + handleModeButtonToggle(modeButton.key, false) + return modeButton + } + return { ...modeButton, enabled: modeButton.enabled && !allFalse } + } + + return modeButton + } + + processedModeButtons.map(pipe(checkTransportModeSubsettings)) + }, [processedModeButtons, handleModeButtonToggle]) + return ( @@ -235,10 +259,7 @@ const AdvancedSettingsPanel = ({ label="test" modeButtons={processedModeButtons} onSettingsUpdate={onSettingsUpdate(setQueryParam)} - onToggleModeButton={setModeButton( - enabledModeButtons, - onSettingsUpdate(setQueryParam) - )} + onToggleModeButton={handleModeButtonToggle} /> { + /* console.log( + 'state.otp.modeSettingDefinitions::::', + state.otp.modeSettingDefinitions + ) */ const urlSearchParams = new URLSearchParams(state.router.location.search) const modeSettingValues = generateModeSettingValues( urlSearchParams, From 96d238105fd0db6bbd0ce72f2bc042487797f0d6 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:50:50 -0500 Subject: [PATCH 03/31] fix(advanced-settings-panel): start trying to use url search params to reset to default values --- .../form/advanced-settings-panel.tsx | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 79c4057a5..4985d8767 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -15,6 +15,7 @@ import { ModeSetting, ModeSettingValues } from '@opentripplanner/types' +import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' import React, { RefObject, useContext, useEffect, useState } from 'react' import styled from 'styled-components' @@ -118,7 +119,8 @@ const AdvancedSettingsPanel = ({ modeButtonOptions, modeSettingDefinitions, modeSettingValues, - setQueryParam + setQueryParam, + urlSearchParams }: { closeAdvancedSettings: () => void enabledModeButtons: string[] @@ -127,7 +129,8 @@ const AdvancedSettingsPanel = ({ modeSettingDefinitions: ModeSetting[] modeSettingValues: ModeSettingValues onPlanTripClick: () => void - setQueryParam: (evt: any) => void + setQueryParam: (evt: QueryParamChangeEvent) => void + urlSearchParams: URLSearchParams }): JSX.Element => { const [closingBySave, setClosingBySave] = useState(false) const [closingByX, setClosingByX] = useState(false) @@ -189,11 +192,7 @@ const AdvancedSettingsPanel = ({ const checkTransportModeSubsettings = ( modeButton: ModeButtonDefinition ) => { - if ( - modeButton.enabled && - modeButton.modeSettings && - modeButton.modeSettings.length > 0 - ) { + if (modeButton.modeSettings && modeButton.modeSettings.length > 0) { const transportModeSettings = modeButton.modeSettings.filter( (setting: ModeSetting) => (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && @@ -204,14 +203,31 @@ const AdvancedSettingsPanel = ({ const allFalse = transportModeSettings.every( (setting) => !setting.value ) - if (allFalse) { + // modeButton is enabled, but all of its subsettings are false + if (allFalse && enabledModeButtons.includes(modeButton.key)) { + console.log('button on -> off') + modeButton.enabled = false console.log( - 'subsettings are all false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + 'before delete urlSerchParams::::: ', + urlSearchParams.toString() + ) + urlSearchParams.forEach((value, key) => { + console.log('key:::::::::', key) + if (transportModeSettings.some((setting) => setting.key === key)) { + console.log('deleting key:::::::::', key) + urlSearchParams.delete(key) + } + }) + console.log( + 'after delete urlSerchParams::::: ', + urlSearchParams.toString() ) - modeButton.enabled = false handleModeButtonToggle(modeButton.key, false) + console.log('transportModeSettings:::::::::', transportModeSettings) + return modeButton } + return { ...modeButton, enabled: modeButton.enabled && !allFalse } } @@ -219,7 +235,12 @@ const AdvancedSettingsPanel = ({ } processedModeButtons.map(pipe(checkTransportModeSubsettings)) - }, [processedModeButtons, handleModeButtonToggle]) + }, [ + processedModeButtons, + handleModeButtonToggle, + enabledModeButtons, + urlSearchParams + ]) return ( @@ -284,10 +305,6 @@ const AdvancedSettingsPanel = ({ const queryParamConfig = { modeButtons: DelimitedArrayParam } const mapStateToProps = (state: AppReduxState) => { - /* console.log( - 'state.otp.modeSettingDefinitions::::', - state.otp.modeSettingDefinitions - ) */ const urlSearchParams = new URLSearchParams(state.router.location.search) const modeSettingValues = generateModeSettingValues( urlSearchParams, @@ -305,7 +322,8 @@ const mapStateToProps = (state: AppReduxState) => { [], modeButtonOptions: state.otp.config?.modes?.modeButtons || [], modeSettingDefinitions: state.otp?.modeSettingDefinitions || [], - modeSettingValues + modeSettingValues, + urlSearchParams } } From 2c8b84c0fc0eeb0c45d379662513f320f1d930c0 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:34:07 -0500 Subject: [PATCH 04/31] feat(form): create deleteQueryParams function --- lib/actions/form.js | 16 ++++++++++++ .../form/advanced-settings-panel.tsx | 25 +++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/actions/form.js b/lib/actions/form.js index bfdc65fe7..4eecdb428 100644 --- a/lib/actions/form.js +++ b/lib/actions/form.js @@ -80,6 +80,22 @@ export function setQueryParam(payload, searchId) { } } +/** + * Deletes the specified query parameter from the current query and updates the + * application state accordingly. + */ +export function deleteQueryParams(params) { + return function (dispatch, getState) { + const state = getState() + const { currentQuery } = state.otp + const newQuery = Object.assign({}, currentQuery) + params.forEach((param) => { + delete newQuery[param] + }) + dispatch(settingQueryParam(newQuery)) + } +} + /** * An action that parses the active URL's query params (or whatever is passed in) * and updates the state with the OTP plan query params. A new search will be diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 4985d8767..863aeb3c3 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -114,6 +114,7 @@ const DtSelectorContainer = styled.div` const AdvancedSettingsPanel = ({ closeAdvancedSettings, + deleteQueryParams, enabledModeButtons, innerRef, modeButtonOptions, @@ -123,6 +124,7 @@ const AdvancedSettingsPanel = ({ urlSearchParams }: { closeAdvancedSettings: () => void + deleteQueryParams: (params: string[]) => void enabledModeButtons: string[] innerRef: RefObject modeButtonOptions: ModeButtonDefinition[] @@ -205,25 +207,9 @@ const AdvancedSettingsPanel = ({ ) // modeButton is enabled, but all of its subsettings are false if (allFalse && enabledModeButtons.includes(modeButton.key)) { - console.log('button on -> off') - modeButton.enabled = false - console.log( - 'before delete urlSerchParams::::: ', - urlSearchParams.toString() - ) - urlSearchParams.forEach((value, key) => { - console.log('key:::::::::', key) - if (transportModeSettings.some((setting) => setting.key === key)) { - console.log('deleting key:::::::::', key) - urlSearchParams.delete(key) - } - }) - console.log( - 'after delete urlSerchParams::::: ', - urlSearchParams.toString() - ) + console.log('all keys:::::', Object.keys(transportModeSettings)) + deleteQueryParams(Object.keys(transportModeSettings)) handleModeButtonToggle(modeButton.key, false) - console.log('transportModeSettings:::::::::', transportModeSettings) return modeButton } @@ -239,7 +225,7 @@ const AdvancedSettingsPanel = ({ processedModeButtons, handleModeButtonToggle, enabledModeButtons, - urlSearchParams + deleteQueryParams ]) return ( @@ -328,6 +314,7 @@ const mapStateToProps = (state: AppReduxState) => { } const mapDispatchToProps = { + deleteQueryParams: formActions.deleteQueryParams, setQueryParam: formActions.setQueryParam, updateQueryTimeIfLeavingNow: formActions.updateQueryTimeIfLeavingNow } From 2e43af4267d4fda5a9933c614f88342883963242 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:43:42 -0500 Subject: [PATCH 05/31] fix(advanced-trip-form): get correct param keys --- lib/components/form/advanced-settings-panel.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 863aeb3c3..41382acbb 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -207,8 +207,11 @@ const AdvancedSettingsPanel = ({ ) // modeButton is enabled, but all of its subsettings are false if (allFalse && enabledModeButtons.includes(modeButton.key)) { - console.log('all keys:::::', Object.keys(transportModeSettings)) - deleteQueryParams(Object.keys(transportModeSettings)) + console.log( + 'all keys:::::', + transportModeSettings.map((setting) => setting.key) + ) + deleteQueryParams(transportModeSettings.map((setting) => setting.key)) handleModeButtonToggle(modeButton.key, false) return modeButton From 65f146eabbe09b120610abcf42c6f3b6f88ed329 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:54:30 -0500 Subject: [PATCH 06/31] fix(util): disable mode button if all subsettings are false and reset values of all subsettings --- lib/actions/form.js | 16 ----- .../form/advanced-settings-panel.tsx | 60 +++--------------- lib/components/form/util.tsx | 61 ++++++++++++++++++- 3 files changed, 69 insertions(+), 68 deletions(-) diff --git a/lib/actions/form.js b/lib/actions/form.js index 4eecdb428..bfdc65fe7 100644 --- a/lib/actions/form.js +++ b/lib/actions/form.js @@ -80,22 +80,6 @@ export function setQueryParam(payload, searchId) { } } -/** - * Deletes the specified query parameter from the current query and updates the - * application state accordingly. - */ -export function deleteQueryParams(params) { - return function (dispatch, getState) { - const state = getState() - const { currentQuery } = state.otp - const newQuery = Object.assign({}, currentQuery) - params.forEach((param) => { - delete newQuery[param] - }) - dispatch(settingQueryParam(newQuery)) - } -} - /** * An action that parses the active URL's query params (or whatever is passed in) * and updates the state with the OTP plan query params. A new search will be diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 41382acbb..ab83513be 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -29,6 +29,7 @@ import PageTitle from '../util/page-title' import { addCustomSettingLabels, addModeButtonIcon, + onAdvancedModeSubsettingsUpdate, onSettingsUpdate, pipe, populateSettingWithIcon, @@ -114,7 +115,6 @@ const DtSelectorContainer = styled.div` const AdvancedSettingsPanel = ({ closeAdvancedSettings, - deleteQueryParams, enabledModeButtons, innerRef, modeButtonOptions, @@ -124,7 +124,6 @@ const AdvancedSettingsPanel = ({ urlSearchParams }: { closeAdvancedSettings: () => void - deleteQueryParams: (params: string[]) => void enabledModeButtons: string[] innerRef: RefObject modeButtonOptions: ModeButtonDefinition[] @@ -173,12 +172,6 @@ const AdvancedSettingsPanel = ({ ) const processedModeSettings = processSettings(modeSettingDefinitions) - // console.log('processedModeSettings::::', processedModeSettings) - - const handleModeButtonToggle = setModeButton( - enabledModeButtons, - onSettingsUpdate(setQueryParam) - ) const processedModeButtons = modeButtonOptions.map( pipe( @@ -187,49 +180,11 @@ const AdvancedSettingsPanel = ({ setModeButtonEnabled(enabledModeButtons) ) ) - console.log('processedModeButtons::::::', processedModeButtons) - - useEffect(() => { - console.log('processedModeButtons CHANGED!!! ::::::', processedModeButtons) - const checkTransportModeSubsettings = ( - modeButton: ModeButtonDefinition - ) => { - if (modeButton.modeSettings && modeButton.modeSettings.length > 0) { - const transportModeSettings = modeButton.modeSettings.filter( - (setting: ModeSetting) => - (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && - setting.addTransportMode - ) - if (transportModeSettings.length === 0) return modeButton - - const allFalse = transportModeSettings.every( - (setting) => !setting.value - ) - // modeButton is enabled, but all of its subsettings are false - if (allFalse && enabledModeButtons.includes(modeButton.key)) { - console.log( - 'all keys:::::', - transportModeSettings.map((setting) => setting.key) - ) - deleteQueryParams(transportModeSettings.map((setting) => setting.key)) - handleModeButtonToggle(modeButton.key, false) - - return modeButton - } - return { ...modeButton, enabled: modeButton.enabled && !allFalse } - } - - return modeButton - } - - processedModeButtons.map(pipe(checkTransportModeSubsettings)) - }, [ - processedModeButtons, - handleModeButtonToggle, + const handleModeButtonToggle = setModeButton( enabledModeButtons, - deleteQueryParams - ]) + onSettingsUpdate(setQueryParam) + ) return ( @@ -268,7 +223,11 @@ const AdvancedSettingsPanel = ({ fillModeIcons label="test" modeButtons={processedModeButtons} - onSettingsUpdate={onSettingsUpdate(setQueryParam)} + onSettingsUpdate={onAdvancedModeSubsettingsUpdate( + setQueryParam, + processedModeButtons, + handleModeButtonToggle + )} onToggleModeButton={handleModeButtonToggle} /> { } const mapDispatchToProps = { - deleteQueryParams: formActions.deleteQueryParams, setQueryParam: formActions.setQueryParam, updateQueryTimeIfLeavingNow: formActions.updateQueryTimeIfLeavingNow } diff --git a/lib/components/form/util.tsx b/lib/components/form/util.tsx index 23b5ab8fe..9cb6ad1d7 100644 --- a/lib/components/form/util.tsx +++ b/lib/components/form/util.tsx @@ -56,16 +56,75 @@ export const onSettingsUpdate = setQueryParam({ queryParamData: params, ...params }) } +const getModeButtonFromSubmode = ( + key: string, + modeButtons: ModeButtonDefinition[] +): ModeButtonDefinition | undefined => { + return modeButtons.find((button: ModeButtonDefinition) => { + if (button.modeSettings) { + return button.modeSettings.some((setting: ModeSetting) => { + // check if transport mode + if ( + (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && + setting.addTransportMode + ) { + return setting.key === key + } + return false + }) + } + return false + }) +} + +export const onAdvancedModeSubsettingsUpdate = + ( + setQueryParam: (evt: any) => void, + processedModeButtons: ModeButtonDefinition[], + handleModeButtonToggle: (buttonId: string, newState: boolean) => void + ) => + (params: any) => { + // check if setting is a transport mode and get the mode button that contains it + const modeButton = getModeButtonFromSubmode( + Object.keys(params)[0], + processedModeButtons + ) + if (modeButton && modeButton.modeSettings && !Object.values(params)[0]) { + const transportModeSettings = modeButton.modeSettings.filter( + (setting: ModeSetting) => + (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && + setting.addTransportMode + ) + // if we're disabling a transport mode, we need to check if the mode button needs to be disabled (all of its subsettings are false) + const allFalse = transportModeSettings.every((setting: ModeSetting) => { + if (setting.key === Object.keys(params)[0]) { + return !Object.values(params)[0] + } + return !setting.value + }) + if (allFalse) { + transportModeSettings.forEach((setting) => (params[setting.key] = true)) + handleModeButtonToggle(modeButton.key, false) + } + } + setQueryParam({ queryParamData: params, ...params }) + } + export const setModeButton = (enabledModeButtons: string[], updateHandler: (params: any) => void) => (buttonId: string, newState: boolean) => { + console.log('SET MODE BUTTON IS BEING CALLED. NEW STATE:::: ', newState) let newButtons + if (newState) { + // enable modeButton + // we need to add it to the list of enabled buttons newButtons = [...enabledModeButtons, buttonId] } else { + // disable modeButton + // we need to remove it from the list of enabled buttons newButtons = enabledModeButtons.filter((c) => c !== buttonId) } - // encodeQueryParams serializes the mode buttons for the URL // to get nice looking URL params and consistency updateHandler( From f24376bea7157f9512eda7e3b32bee4c3277e30f Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:21:56 -0500 Subject: [PATCH 07/31] update yarn lock --- yarn.lock | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/yarn.lock b/yarn.lock index 634ff87b2..a9dca0a61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" From f452700e9ebf0bbabab8e4800e8a70e891a9498c Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:51:28 -0500 Subject: [PATCH 08/31] feat(advanced-settings-panel): add support for onAllSubmodesDisabled prop --- .../form/advanced-settings-panel.tsx | 12 ++--- lib/components/form/util.tsx | 54 ------------------- 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index ab83513be..7f1500f23 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -29,7 +29,6 @@ import PageTitle from '../util/page-title' import { addCustomSettingLabels, addModeButtonIcon, - onAdvancedModeSubsettingsUpdate, onSettingsUpdate, pipe, populateSettingWithIcon, @@ -186,6 +185,10 @@ const AdvancedSettingsPanel = ({ onSettingsUpdate(setQueryParam) ) + const handleAllSubmodesDisabled = (modeButton: ModeButtonDefinition) => { + handleModeButtonToggle(modeButton.key, false) + } + return ( @@ -223,11 +226,8 @@ const AdvancedSettingsPanel = ({ fillModeIcons label="test" modeButtons={processedModeButtons} - onSettingsUpdate={onAdvancedModeSubsettingsUpdate( - setQueryParam, - processedModeButtons, - handleModeButtonToggle - )} + onAllSubmodesDisabled={handleAllSubmodesDisabled} + onSettingsUpdate={onSettingsUpdate(setQueryParam)} onToggleModeButton={handleModeButtonToggle} /> { - return modeButtons.find((button: ModeButtonDefinition) => { - if (button.modeSettings) { - return button.modeSettings.some((setting: ModeSetting) => { - // check if transport mode - if ( - (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && - setting.addTransportMode - ) { - return setting.key === key - } - return false - }) - } - return false - }) -} - -export const onAdvancedModeSubsettingsUpdate = - ( - setQueryParam: (evt: any) => void, - processedModeButtons: ModeButtonDefinition[], - handleModeButtonToggle: (buttonId: string, newState: boolean) => void - ) => - (params: any) => { - // check if setting is a transport mode and get the mode button that contains it - const modeButton = getModeButtonFromSubmode( - Object.keys(params)[0], - processedModeButtons - ) - if (modeButton && modeButton.modeSettings && !Object.values(params)[0]) { - const transportModeSettings = modeButton.modeSettings.filter( - (setting: ModeSetting) => - (setting.type === 'CHECKBOX' || setting.type === 'SUBMODE') && - setting.addTransportMode - ) - // if we're disabling a transport mode, we need to check if the mode button needs to be disabled (all of its subsettings are false) - const allFalse = transportModeSettings.every((setting: ModeSetting) => { - if (setting.key === Object.keys(params)[0]) { - return !Object.values(params)[0] - } - return !setting.value - }) - if (allFalse) { - transportModeSettings.forEach((setting) => (params[setting.key] = true)) - handleModeButtonToggle(modeButton.key, false) - } - } - setQueryParam({ queryParamData: params, ...params }) - } - export const setModeButton = (enabledModeButtons: string[], updateHandler: (params: any) => void) => (buttonId: string, newState: boolean) => { From a39f049821640a9641ceb0c8761c420282ab4304 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:04:51 -0500 Subject: [PATCH 09/31] chore(advanced-settings-panel): remove unused prop --- lib/components/form/advanced-settings-panel.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 7f1500f23..c5e99f656 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -119,8 +119,7 @@ const AdvancedSettingsPanel = ({ modeButtonOptions, modeSettingDefinitions, modeSettingValues, - setQueryParam, - urlSearchParams + setQueryParam }: { closeAdvancedSettings: () => void enabledModeButtons: string[] @@ -130,7 +129,6 @@ const AdvancedSettingsPanel = ({ modeSettingValues: ModeSettingValues onPlanTripClick: () => void setQueryParam: (evt: QueryParamChangeEvent) => void - urlSearchParams: URLSearchParams }): JSX.Element => { const [closingBySave, setClosingBySave] = useState(false) const [closingByX, setClosingByX] = useState(false) @@ -270,8 +268,7 @@ const mapStateToProps = (state: AppReduxState) => { [], modeButtonOptions: state.otp.config?.modes?.modeButtons || [], modeSettingDefinitions: state.otp?.modeSettingDefinitions || [], - modeSettingValues, - urlSearchParams + modeSettingValues } } From e0979791623fab83f85123be518416616ec65ba3 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:02:43 -0500 Subject: [PATCH 10/31] chore(form/util): clean up unnecessary logs and comments --- lib/components/form/util.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/components/form/util.tsx b/lib/components/form/util.tsx index a65c1e721..9dfd6366d 100644 --- a/lib/components/form/util.tsx +++ b/lib/components/form/util.tsx @@ -59,16 +59,10 @@ export const onSettingsUpdate = export const setModeButton = (enabledModeButtons: string[], updateHandler: (params: any) => void) => (buttonId: string, newState: boolean) => { - console.log('SET MODE BUTTON IS BEING CALLED. NEW STATE:::: ', newState) let newButtons - if (newState) { - // enable modeButton - // we need to add it to the list of enabled buttons newButtons = [...enabledModeButtons, buttonId] } else { - // disable modeButton - // we need to remove it from the list of enabled buttons newButtons = enabledModeButtons.filter((c) => c !== buttonId) } // encodeQueryParams serializes the mode buttons for the URL From 8a6bef9d872f91de2e783509e895fd3e0b150857 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:48:21 -0500 Subject: [PATCH 11/31] fix: address PR feedback --- .../form/advanced-settings-panel.tsx | 3 +- lib/components/form/util.tsx | 34 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index c5e99f656..730c53e2f 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -15,7 +15,6 @@ import { ModeSetting, ModeSettingValues } from '@opentripplanner/types' -import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' import React, { RefObject, useContext, useEffect, useState } from 'react' import styled from 'styled-components' @@ -128,7 +127,7 @@ const AdvancedSettingsPanel = ({ modeSettingDefinitions: ModeSetting[] modeSettingValues: ModeSettingValues onPlanTripClick: () => void - setQueryParam: (evt: QueryParamChangeEvent) => void + setQueryParam: (evt: any) => void }): JSX.Element => { const [closingBySave, setClosingBySave] = useState(false) const [closingByX, setClosingByX] = useState(false) diff --git a/lib/components/form/util.tsx b/lib/components/form/util.tsx index 9dfd6366d..85dd3107d 100644 --- a/lib/components/form/util.tsx +++ b/lib/components/form/util.tsx @@ -5,6 +5,7 @@ import React from 'react' import { getFormattedMode } from '../../util/i18n' import { hasValidLocation } from '../../util/state' +import { QueryParamChangeHandler } from '../util/types' import { RoutingQueryCallResult } from '../../actions/api-constants' import { updateQueryTimeIfLeavingNow } from '../../actions/form' @@ -18,9 +19,9 @@ export const modesQueryParamConfig = { modeButtons: DelimitedArrayParam } export const populateSettingWithIcon = (ModeIcon: React.ComponentType<{ mode?: string; width?: number }>) => // eslint-disable-next-line react/display-name - (msd: ModeSetting): ModeSetting => ({ - ...msd, - icon: + (modeSetting: ModeSetting): ModeSetting => ({ + ...modeSetting, + icon: }) export const addModeButtonIcon = @@ -34,17 +35,17 @@ export const addModeButtonIcon = export const addCustomSettingLabels = (intl: IntlShape) => - (msd: ModeSetting): ModeSetting => { - let modeLabel + (modeSetting: ModeSetting): ModeSetting => { // If we're using route mode overrides, make sure we're using the custom mode name - if (msd.type === 'SUBMODE') { - modeLabel = msd.overrideMode || msd.addTransportMode.mode + if (modeSetting.type === 'SUBMODE') { + const modeLabel = + modeSetting.overrideMode || modeSetting.addTransportMode.mode return { - ...msd, + ...modeSetting, label: getFormattedMode(modeLabel, intl) } } - return msd + return modeSetting } /** @@ -52,19 +53,18 @@ export const addCustomSettingLabels = * @param params Params to store */ export const onSettingsUpdate = - (setQueryParam: (evt: any) => void) => (params: any) => { + (setQueryParam: QueryParamChangeHandler) => + (params: any): void => { setQueryParam({ queryParamData: params, ...params }) } export const setModeButton = (enabledModeButtons: string[], updateHandler: (params: any) => void) => - (buttonId: string, newState: boolean) => { - let newButtons - if (newState) { - newButtons = [...enabledModeButtons, buttonId] - } else { - newButtons = enabledModeButtons.filter((c) => c !== buttonId) - } + (buttonId: string, newState: boolean): void => { + const newButtons = newState + ? [...enabledModeButtons, buttonId] + : enabledModeButtons.filter((c) => c !== buttonId) + // encodeQueryParams serializes the mode buttons for the URL // to get nice looking URL params and consistency updateHandler( From 3f91771db0c58de957908aae08e05d83ea3c974b Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:12:14 -0500 Subject: [PATCH 12/31] chore: update ui package --- package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7b69da5c0..6c0a5d74e 100644 --- a/package.json +++ b/package.json @@ -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 1a65ef7a9..81fb842c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2408,7 +2408,7 @@ 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== @@ -2698,14 +2698,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" From 6c100ce6684409c08d1d6040708c156bd229ec1d Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Tue, 8 Oct 2024 13:46:21 -0700 Subject: [PATCH 13/31] allow multiple transport modes to be specified in a single transportmode --- example-config.yml | 6 +++++- lib/actions/form.js | 2 +- lib/reducers/create-otp-reducer.js | 10 +++++++++- lib/util/config-types.ts | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) 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/reducers/create-otp-reducer.js b/lib/reducers/create-otp-reducer.js index 0bc899936..b84951935 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 80f9cf10f..e0abbaf11 100644 --- a/lib/util/config-types.ts +++ b/lib/util/config-types.ts @@ -312,7 +312,7 @@ export interface GeocoderConfig extends GeocoderConfigOtpUI { export interface TransitModeConfig { color?: string label?: string - mode: string + mode: string | string[] showWheelchairSetting?: boolean } From f177bc4667ebe76a6ac06ff414f87f50a6dcebd5 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 9 Oct 2024 12:19:25 -0400 Subject: [PATCH 14/31] respect mode text color --- lib/actions/apiV2.js | 11 +++++++++++ lib/util/viewer.js | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 16d6c5e1d..a10a06381 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -26,6 +26,7 @@ import { import { getRouteColorBasedOnSettings, getRouteIdForPattern, + getRouteTextColorBasedOnSettings, routeIsValid } from '../util/viewer' import { isLastStop } from '../util/stop-times' @@ -1144,6 +1145,16 @@ export function routingQuery(searchId = null, updateSearchInReducer) { config.transitOperators ), { color: leg?.route?.color, mode: leg.mode } + ).split('#')?.[1], + textColor: getRouteTextColorBasedOnSettings( + getRouteOperator( + { + agencyId: leg?.agency?.id, + id: leg?.route?.id + }, + config.transitOperators + ), + { color: leg?.route?.color, mode: leg.mode } ).split('#')?.[1] } } diff --git a/lib/util/viewer.js b/lib/util/viewer.js index d407b356c..45912bbd1 100644 --- a/lib/util/viewer.js +++ b/lib/util/viewer.js @@ -353,6 +353,10 @@ export function getRouteColorBasedOnSettings(operator = {}, route = {}) { return backgroundColor } } +export function getRouteTextColorBasedOnSettings(operator = {}, route = {}) { + const { color } = getColorAndNameFromRoute(operator, route) + return color +} /** * Helper method to determine if a stop being viewed is a flex stop. This is not marked by From 21046bb4a06c97b2ffe95ff1d14ecf7166c7f2df Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 11 Oct 2024 11:34:48 -0400 Subject: [PATCH 15/31] make use of new stops+stations layer --- lib/components/map/default-map.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index b2e7b899f..5548f8171 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -158,7 +158,12 @@ class DefaultMap extends Component { // Generate operator logos to pass through OTP tile layer to map-popup getEntityPrefix = (entity) => { - 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, From a81a2dc592f2c198d1bbe4eb3171a39cb214cb67 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Tue, 15 Oct 2024 13:18:09 -0400 Subject: [PATCH 16/31] set correct hover index --- .../map/itinerary-summary-overlay.tsx | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index aec2823fc..0cab9ad6f 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import { Feature, lineString, LineString, Position } from '@turf/helpers' -import { Itinerary, Location } from '@opentripplanner/types' +import { Itinerary, Leg, Location } from '@opentripplanner/types' import { Marker } from 'react-map-gl' import centroid from '@turf/centroid' import distance from '@turf/distance' @@ -103,6 +103,8 @@ function addTrueIndex(array: ItinWithGeometry[]): ItinWithGeometry[] { return array } +const getLegRoute = (leg: Leg) => leg.routeId + type ItinUniquePoint = { itin: ItinWithGeometry uniquePoint: Position @@ -152,14 +154,18 @@ const ItinerarySummaryOverlay = ({ ) if (!itins || !visible) return <> - const mergedItins: ItinWithGeometry[] = addTrueIndex( - doMergeItineraries(itins).mergedItineraries.map(addItinLineString) + const indexedItins: ItinWithGeometry[] = addTrueIndex( + itins.map(addItinLineString) ) + const mergedItins = doMergeItineraries(indexedItins).mergedItineraries - const midPoints = mergedItins.reduce((prev, curItin) => { - prev.push(getUniquePoint(curItin, prev)) - return prev - }, []) + const midPoints = mergedItins.reduce( + (prev: ItinUniquePoint[], curItin: ItinWithGeometry) => { + prev.push(getUniquePoint(curItin, prev)) + return prev + }, + [] + ) // The first point is probably not well placed, so let's run the algorithm again if (midPoints.length > 1) { midPoints[0] = getUniquePoint(mergedItins[0], midPoints) @@ -186,18 +192,8 @@ const ItinerarySummaryOverlay = ({ onClick={() => { setActive({ index: mp.itin.index }) }} - // TODO: useCallback here (getting weird errors?) - onMouseEnter={() => { - setSharedTimeout( - setTimeout(() => { - setVisible({ index: mp.itin.index }) - }, 150) - ) - }} - onMouseLeave={() => { - sharedTimeout && clearTimeout(sharedTimeout) - setVisible({ index: null }) - }} + // TODO: restore setting visible itinerary on hover without + // causing endless re-render? > Date: Tue, 15 Oct 2024 14:31:48 -0400 Subject: [PATCH 17/31] remove dead code --- lib/components/map/itinerary-summary-overlay.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index 0cab9ad6f..8df12478e 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -103,8 +103,6 @@ function addTrueIndex(array: ItinWithGeometry[]): ItinWithGeometry[] { return array } -const getLegRoute = (leg: Leg) => leg.routeId - type ItinUniquePoint = { itin: ItinWithGeometry uniquePoint: Position From dea32116297135eb9355ce3b7c24d546f43eaaf3 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Tue, 15 Oct 2024 14:32:15 -0400 Subject: [PATCH 18/31] clean up --- lib/components/map/itinerary-summary-overlay.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index 8df12478e..d28307b80 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import { Feature, lineString, LineString, Position } from '@turf/helpers' -import { Itinerary, Leg, Location } from '@opentripplanner/types' +import { Itinerary, Location } from '@opentripplanner/types' import { Marker } from 'react-map-gl' import centroid from '@turf/centroid' import distance from '@turf/distance' From 4b0ff358958001e7fb8ea70cc86770a10e06e667 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:26:16 -0500 Subject: [PATCH 19/31] feat(advanced-trip-form): Add autoplan --- lib/components/app/batch-routing-panel.tsx | 24 +++++++++++++++++-- .../form/advanced-settings-panel.tsx | 18 +++++++++++--- lib/components/form/batch-settings.tsx | 6 +---- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/lib/components/app/batch-routing-panel.tsx b/lib/components/app/batch-routing-panel.tsx index 5c6a69c73..6ca1f6da2 100644 --- a/lib/components/app/batch-routing-panel.tsx +++ b/lib/components/app/batch-routing-panel.tsx @@ -3,12 +3,14 @@ import { CSSTransition, TransitionGroup } from 'react-transition-group' import { FormattedMessage, injectIntl, IntlShape } from 'react-intl' import React, { Component, FormEvent } from 'react' +import * as apiActions from '../../actions/api' import { advancedPanelClassName, mainPanelClassName, transitionDuration, TransitionStyles } from '../form/styled' +import { alertUserTripPlan } from '../form/util' import { getActiveSearch, getShowUserSettings } from '../../util/state' import { getPersistenceMode } from '../../util/user' import AdvancedSettingsPanel from '../form/advanced-settings-panel' @@ -22,9 +24,11 @@ import ViewerContainer from '../viewers/viewer-container' interface Props { activeSearch: any + currentQuery: any intl: IntlShape mainPanelContent: number mobile?: boolean + routingQuery: () => void showUserSettings: boolean } @@ -75,7 +79,13 @@ class BatchRoutingPanel extends Component { handleSubmit = (e: FormEvent) => e.preventDefault() handlePlanTripClick = () => { - this.setState({ planTripClicked: true }) + const { currentQuery, intl, routingQuery } = this.props + alertUserTripPlan( + intl, + currentQuery, + () => this.setState({ planTripClicked: true }), + routingQuery + ) } render() { @@ -128,6 +138,7 @@ class BatchRoutingPanel extends Component { > { (state.user.loggedInUser?.hasConsentedToTerms || getPersistenceMode(state.otp.config.persistence).isLocalStorage) const { mainPanelContent } = state.otp.ui + const currentQuery = state.otp.currentQuery return { activeSearch: getActiveSearch(state), + currentQuery, mainPanelContent, showUserSettings } } -export default connect(mapStateToProps)(injectIntl(BatchRoutingPanel)) +const mapDispatchToProps = { + routingQuery: apiActions.routingQuery +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(injectIntl(BatchRoutingPanel)) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index ea085d017..97662470f 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -111,8 +111,10 @@ const DtSelectorContainer = styled.div` ` const AdvancedSettingsPanel = ({ + autoPlan, closeAdvancedSettings, enabledModeButtons, + handlePlanTrip, innerRef, modeButtonOptions, modeSettingDefinitions, @@ -121,8 +123,10 @@ const AdvancedSettingsPanel = ({ setCloseAdvancedSettingsWithDelay, setQueryParam }: { + autoPlan: boolean closeAdvancedSettings: () => void enabledModeButtons: string[] + handlePlanTrip: () => void innerRef: RefObject modeButtonOptions: ModeButtonDefinition[] modeSettingDefinitions: ModeSetting[] @@ -177,11 +181,16 @@ const AdvancedSettingsPanel = ({ ) ) + const closePanel = useCallback(() => { + autoPlan && handlePlanTrip() + closeAdvancedSettings() + }, [autoPlan, closeAdvancedSettings, handlePlanTrip]) + const onSaveAndReturnClick = useCallback(async () => { await setCloseAdvancedSettingsWithDelay() setClosingBySave(true) - closeAdvancedSettings() - }, [closeAdvancedSettings, setCloseAdvancedSettingsWithDelay]) + closePanel() + }, [closePanel, setCloseAdvancedSettingsWithDelay]) return ( @@ -190,7 +199,7 @@ const AdvancedSettingsPanel = ({ aria-label={closeButtonText} id="close-advanced-settings-button" onClick={() => { - closeAdvancedSettings() + closePanel() }} title={closeButtonText} > @@ -256,9 +265,12 @@ const mapStateToProps = (state: AppReduxState) => { state.otp.modeSettingDefinitions || [], modes?.initialState?.modeSettingValues || {} ) + + const { autoPlan } = state.otp.config const saveAndReturnButton = state.otp.config?.advancedSettingsPanel?.saveAndReturnButton return { + autoPlan: autoPlan !== false, currentQuery: state.otp.currentQuery, // TODO: Duplicated in apiv2.js enabledModeButtons: diff --git a/lib/components/form/batch-settings.tsx b/lib/components/form/batch-settings.tsx index 23bd13a6c..12f036491 100644 --- a/lib/components/form/batch-settings.tsx +++ b/lib/components/form/batch-settings.tsx @@ -80,10 +80,6 @@ function BatchSettings({ pipe(addModeButtonIcon(ModeIcon), setModeButtonEnabled(enabledModeButtons)) ) - const _planTrip = useCallback(() => { - alertUserTripPlan(intl, currentQuery, onPlanTripClick, routingQuery) - }, [currentQuery, intl, onPlanTripClick, routingQuery]) - const baseColor = getBaseColor() const accentColor = getDarkenedBaseColor() @@ -109,7 +105,7 @@ function BatchSettings({ /> Date: Wed, 16 Oct 2024 17:49:15 -0500 Subject: [PATCH 20/31] Prevent autoplan if there are validation errors --- .../form/advanced-settings-panel.tsx | 12 ++++++++--- lib/components/form/util.tsx | 20 +++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index 97662470f..0d951f57f 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -30,7 +30,8 @@ import { onSettingsUpdate, pipe, populateSettingWithIcon, - setModeButton + setModeButton, + tripPlannerValidationErrors } from './util' import { setModeButtonEnabled } from './batch-settings' import { styledCheckboxCss } from './styled' @@ -113,6 +114,7 @@ const DtSelectorContainer = styled.div` const AdvancedSettingsPanel = ({ autoPlan, closeAdvancedSettings, + currentQuery, enabledModeButtons, handlePlanTrip, innerRef, @@ -125,6 +127,7 @@ const AdvancedSettingsPanel = ({ }: { autoPlan: boolean closeAdvancedSettings: () => void + currentQuery: any enabledModeButtons: string[] handlePlanTrip: () => void innerRef: RefObject @@ -181,10 +184,13 @@ const AdvancedSettingsPanel = ({ ) ) + const tripFormErrors = tripPlannerValidationErrors(currentQuery, intl) + const closePanel = useCallback(() => { - autoPlan && handlePlanTrip() + // Only autoplan if there are no validation errors + tripFormErrors.length === 0 && autoPlan && handlePlanTrip() closeAdvancedSettings() - }, [autoPlan, closeAdvancedSettings, handlePlanTrip]) + }, [autoPlan, closeAdvancedSettings, handlePlanTrip, tripFormErrors.length]) const onSaveAndReturnClick = useCallback(async () => { await setCloseAdvancedSettingsWithDelay() diff --git a/lib/components/form/util.tsx b/lib/components/form/util.tsx index 85dd3107d..c973af17c 100644 --- a/lib/components/form/util.tsx +++ b/lib/components/form/util.tsx @@ -72,13 +72,10 @@ export const setModeButton = ) } -export const alertUserTripPlan = ( - intl: IntlShape, +export const tripPlannerValidationErrors = ( currentQuery: any, - onPlanTripClick: () => void, - routingQuery: () => any -): void => { - // Check for any validation issues in query. + intl: IntlShape +): string[] => { const issues: string[] = [] if (!hasValidLocation(currentQuery, 'from')) { issues.push(intl.formatMessage({ id: 'components.BatchSettings.origin' })) @@ -88,6 +85,17 @@ export const alertUserTripPlan = ( intl.formatMessage({ id: 'components.BatchSettings.destination' }) ) } + return issues +} + +export const alertUserTripPlan = ( + intl: IntlShape, + currentQuery: any, + onPlanTripClick: () => void, + routingQuery: () => any +): void => { + // Check for any validation issues in query and alert user. + const issues = tripPlannerValidationErrors(currentQuery, intl) onPlanTripClick() if (issues.length > 0) { // TODO: replace with less obtrusive validation. From d2a884f3a502ab723a8054f798631170b2b13017 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:10:05 -0500 Subject: [PATCH 21/31] Pass plan trip through mobile --- lib/components/mobile/batch-search-screen.tsx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/components/mobile/batch-search-screen.tsx b/lib/components/mobile/batch-search-screen.tsx index c24b4dacb..89b14a433 100644 --- a/lib/components/mobile/batch-search-screen.tsx +++ b/lib/components/mobile/batch-search-screen.tsx @@ -4,6 +4,7 @@ import { injectIntl, IntlShape } from 'react-intl' import React, { Component } from 'react' import styled from 'styled-components' +import * as apiActions from '../../actions/api' import * as uiActions from '../../actions/ui' import { advancedPanelClassName, @@ -11,6 +12,7 @@ import { transitionDuration, TransitionStyles } from '../form/styled' +import { alertUserTripPlan } from '../form/util' import { MobileScreens } from '../../actions/ui-constants' import AdvancedSettingsPanel from '../form/advanced-settings-panel' import BatchSettings from '../form/batch-settings' @@ -43,8 +45,10 @@ const MobileSearchSettings = styled.div<{ ` interface Props { + currentQuery: any intl: IntlShape map: React.ReactElement + routingQuery: any setMobileScreen: (screen: number) => void } @@ -63,7 +67,10 @@ class BatchSearchScreen extends Component { _advancedSettingRef = React.createRef() handlePlanTripClick = () => { - this.setState({ planTripClicked: true }) + const { currentQuery, intl, routingQuery } = this.props + alertUserTripPlan(intl, currentQuery, routingQuery, () => + this.setState({ planTripClicked: true }) + ) } openAdvancedSettings = () => { @@ -159,6 +166,7 @@ class BatchSearchScreen extends Component { > { // connect to the redux store +const mapStateToProps = (state: any) => { + const { currentQuery } = state.otp.currentQuery + return { + currentQuery + } +} + const mapDispatchToProps = { + routingQuery: apiActions.routingQuery, setMobileScreen: uiActions.setMobileScreen } -export default connect(null, mapDispatchToProps)(injectIntl(BatchSearchScreen)) +export default connect( + mapStateToProps, + mapDispatchToProps +)(injectIntl(BatchSearchScreen)) From 779615c055d8c6ad1a9f0724d8485bc8f534fdd6 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:18:03 -0500 Subject: [PATCH 22/31] remove unnecessary props --- lib/components/form/batch-settings.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/components/form/batch-settings.tsx b/lib/components/form/batch-settings.tsx index 12f036491..47700fdeb 100644 --- a/lib/components/form/batch-settings.tsx +++ b/lib/components/form/batch-settings.tsx @@ -5,9 +5,8 @@ import { ModeButtonDefinition } from '@opentripplanner/types' import { Search } from '@styled-icons/fa-solid/Search' import { SyncAlt } from '@styled-icons/fa-solid/SyncAlt' import { useIntl } from 'react-intl' -import React, { useCallback, useContext, useState } from 'react' +import React, { useContext, useState } from 'react' -import * as apiActions from '../../actions/api' import * as formActions from '../../actions/form' import { ComponentContext } from '../../util/contexts' import { getActiveSearch, hasValidLocation } from '../../util/state' @@ -16,7 +15,6 @@ import { StyledIconWrapper } from '../util/styledIcon' import { addModeButtonIcon, - alertUserTripPlan, modesQueryParamConfig, onSettingsUpdate, pipe, @@ -39,7 +37,6 @@ type Props = { modeButtonOptions: ModeButtonDefinition[] onPlanTripClick: () => void openAdvancedSettings: () => void - routingQuery: any setQueryParam: (evt: any) => void spacedOutModeSelector?: boolean } @@ -64,7 +61,6 @@ function BatchSettings({ modeButtonOptions, onPlanTripClick, openAdvancedSettings, - routingQuery, setQueryParam, spacedOutModeSelector }: Props) { @@ -147,7 +143,6 @@ const mapStateToProps = (state: any) => { } const mapDispatchToProps = { - routingQuery: apiActions.routingQuery, setQueryParam: formActions.setQueryParam } From 49f2817fa1e703cf291a40b701fedf8f2a40e213 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 18 Oct 2024 08:11:43 -0400 Subject: [PATCH 23/31] update otp-ui --- package.json | 8 +++--- yarn.lock | 81 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 37 deletions(-) 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" From e3a8756f61197692da44aea0ed6d55c1b938acca Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 18 Oct 2024 16:19:10 -0400 Subject: [PATCH 24/31] fallback to departure time when `useArrivalTime` is true --- lib/util/viewer.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/util/viewer.js b/lib/util/viewer.js index d407b356c..e5bcd85a2 100644 --- a/lib/util/viewer.js +++ b/lib/util/viewer.js @@ -21,13 +21,15 @@ export function getSecondsUntilDeparture( ) { let time if (useSchedule) { - time = useArrivalTime - ? stopTime.scheduledArrival - : stopTime.scheduledDeparture + time = + useArrivalTime && !!stopTime.scheduledArrival + ? stopTime.scheduledArrival + : stopTime.scheduledDeparture } else { - time = useArrivalTime - ? stopTime.realtimeArrival - : stopTime.realtimeDeparture + time = + useArrivalTime && !!stopTime.realtimeArrival + ? stopTime.realtimeArrival + : stopTime.realtimeDeparture } return time + stopTime.serviceDay - Date.now() / 1000 From 38de6c2de6e892109d691b164a91b363a2a44ae0 Mon Sep 17 00:00:00 2001 From: josh-willis-arcadis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:40:08 -0500 Subject: [PATCH 25/31] refactor(advanced-settings-panel): remove new line to clean up git blame --- lib/components/form/advanced-settings-panel.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/components/form/advanced-settings-panel.tsx b/lib/components/form/advanced-settings-panel.tsx index d3cd25c3d..d39e03ec9 100644 --- a/lib/components/form/advanced-settings-panel.tsx +++ b/lib/components/form/advanced-settings-panel.tsx @@ -169,7 +169,6 @@ const AdvancedSettingsPanel = ({ ) const processedModeSettings = processSettings(modeSettingDefinitions) - const processedModeButtons = modeButtonOptions.map( pipe( addModeButtonIcon(ModeIcon), From 15252bad991f5215820e7217f87519356ed8d53e Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:41:19 -0500 Subject: [PATCH 26/31] Fix mapstatetoprops incorrect destructure --- lib/components/mobile/batch-search-screen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/mobile/batch-search-screen.tsx b/lib/components/mobile/batch-search-screen.tsx index 89b14a433..5be2cc8c7 100644 --- a/lib/components/mobile/batch-search-screen.tsx +++ b/lib/components/mobile/batch-search-screen.tsx @@ -189,7 +189,7 @@ class BatchSearchScreen extends Component { // connect to the redux store const mapStateToProps = (state: any) => { - const { currentQuery } = state.otp.currentQuery + const currentQuery = state.otp.currentQuery return { currentQuery } From a00d5b5e38fcf24be27c2e6af6a7c6ccd6b73be6 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:42:52 -0500 Subject: [PATCH 27/31] Fix percy tests and add openEditIfNeeded function --- percy/percy.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/percy/percy.test.js b/percy/percy.test.js index 37433032d..957f07e43 100644 --- a/percy/percy.test.js +++ b/percy/percy.test.js @@ -42,6 +42,12 @@ async function loadPath(otpPath) { return page } +const openEditIfNeeded = async (page, isMobile) => { + if (isMobile) { + await page.click('button.edit-search-button') + } +} + beforeAll(async () => { try { // Launch OTP-RR web server @@ -114,9 +120,7 @@ async function executeTest(page, isMobile, isCallTaker) { if (!isCallTaker) { // Edit trip params [mobile-specific] - if (isMobile) { - await page.click('button.edit-search-button') - } + await openEditIfNeeded(page, isMobile) // Change the modes: Activate Transit and remove Bike. await page.click('label[title="Transit"]') @@ -148,6 +152,8 @@ async function executeTest(page, isMobile, isCallTaker) { await page.waitForTimeout(500) // Delete both origin and destination + await openEditIfNeeded(page, isMobile) + await page.click('.from-form-control') await page.waitForTimeout(300) // Click the clear button next to it From ca9ef6c6efe4b47981c6497a2b31e3cf4b93ef1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 02:32:30 +0000 Subject: [PATCH 28/31] chore(deps): bump elliptic from 6.5.7 to 6.6.0 Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.7 to 6.6.0. - [Commits](https://github.com/indutny/elliptic/compare/v6.5.7...v6.6.0) --- updated-dependencies: - dependency-name: elliptic dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 98cb3d267..d475f12a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7476,9 +7476,9 @@ electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.811: integrity sha512-bpLc4QU4B8PYmdO4MSu2ZBTMD8lAaEXRS43C09lB31BvYwuk9UxgBRXbY5OJBw7VuMGcg2MZG5FyTaP9u4PQnw== elliptic@^6.5.3, elliptic@^6.5.4: - version "6.5.7" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.7.tgz#8ec4da2cb2939926a1b9a73619d768207e647c8b" - integrity sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q== + version "6.6.0" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.0.tgz#5919ec723286c1edf28685aa89261d4761afa210" + integrity sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA== dependencies: bn.js "^4.11.9" brorand "^1.1.0" From d471628b1914d4f2e4f4b20a220d76f89b520387 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 1 Nov 2024 10:59:36 -0400 Subject: [PATCH 29/31] address pr feedback --- lib/actions/apiV2.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 5a48370db..a9e1deb57 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -1131,30 +1131,30 @@ export function routingQuery(searchId = null, updateSearchInReducer) { ...itin, legs: itin.legs ?.map((leg) => { + const routeOperator = getRouteOperator( + { + agencyId: leg?.agency?.id, + id: leg?.route?.id + }, + config.transitOperators + ) + const routeProperties = { + color: leg?.route?.color, + mode: leg.mode + } + return { ...leg, origColor: leg?.route?.color, route: { ...leg.route, color: getRouteColorBasedOnSettings( - getRouteOperator( - { - agencyId: leg?.agency?.id, - id: leg?.route?.id - }, - config.transitOperators - ), - { color: leg?.route?.color, mode: leg.mode } + routeOperator, + routeProperties ).split('#')?.[1], textColor: getRouteTextColorBasedOnSettings( - getRouteOperator( - { - agencyId: leg?.agency?.id, - id: leg?.route?.id - }, - config.transitOperators - ), - { color: leg?.route?.color, mode: leg.mode } + routeOperator, + routeProperties ).split('#')?.[1] } } From c5da17ba64a19faa0df890836e609baddc069abc Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 1 Nov 2024 11:07:51 -0400 Subject: [PATCH 30/31] add missing typescript --- lib/components/map/itinerary-summary-overlay.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index d28307b80..d66e50d45 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -173,7 +173,10 @@ const ItinerarySummaryOverlay = ({ return ( <> {midPoints.map( - (mp) => + (mp: { + itin: Itinerary & { index: number } + uniquePoint: [number, number] + }) => // If no itinerary is hovered, show all of them. If one is selected, show only that one // TODO: clean up conditionals, move these to a more appropriate place without breaking indexing (isDefined(visibleItinerary) From 6909653a2f2cc6b4f155bc638209cb68b75c382b Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Mon, 4 Nov 2024 12:57:11 -0800 Subject: [PATCH 31/31] clean up miles's bad code --- lib/components/map/itinerary-summary-overlay.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index d66e50d45..5f47f527d 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -5,7 +5,7 @@ import { Marker } from 'react-map-gl' import centroid from '@turf/centroid' import distance from '@turf/distance' import polyline from '@mapbox/polyline' -import React, { useContext, useState } from 'react' +import React, { useContext } from 'react' import styled from 'styled-components' import * as narriativeActions from '../../actions/narrative' @@ -147,17 +147,14 @@ const ItinerarySummaryOverlay = ({ // @ts-expect-error React context is populated dynamically const { LegIcon } = useContext(ComponentContext) - const [sharedTimeout, setSharedTimeout] = useState( - null - ) - if (!itins || !visible) return <> const indexedItins: ItinWithGeometry[] = addTrueIndex( itins.map(addItinLineString) ) - const mergedItins = doMergeItineraries(indexedItins).mergedItineraries + const mergedItins: ItinWithGeometry[] = + doMergeItineraries(indexedItins).mergedItineraries - const midPoints = mergedItins.reduce( + const midPoints = mergedItins.reduce( (prev: ItinUniquePoint[], curItin: ItinWithGeometry) => { prev.push(getUniquePoint(curItin, prev)) return prev @@ -173,10 +170,7 @@ const ItinerarySummaryOverlay = ({ return ( <> {midPoints.map( - (mp: { - itin: Itinerary & { index: number } - uniquePoint: [number, number] - }) => + (mp) => // If no itinerary is hovered, show all of them. If one is selected, show only that one // TODO: clean up conditionals, move these to a more appropriate place without breaking indexing (isDefined(visibleItinerary)