-
Notifications
You must be signed in to change notification settings - Fork 53
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
Create Global Trip settings and variables #1240
Changes from 4 commits
5a359ff
96555b8
8a65b46
4f3ccf0
8d75fb9
077876d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
import * as apiActions from '../../actions/api' | ||
import * as formActions from '../../actions/form' | ||
import { | ||
addSettingsToButton, | ||
AdvancedModeSubsettingsContainer, | ||
ModeSettingRenderer, | ||
populateSettingWithValue | ||
} from '@opentripplanner/trip-form' | ||
import { AppReduxState } from '../../util/state-types' | ||
import { blue, getBaseColor } from '../util/colors' | ||
|
||
import { blue, getBaseColor } from '../util/colors' | ||
import { Close } from '@styled-icons/fa-solid' | ||
|
||
import { ComponentContext } from '../../util/contexts' | ||
|
||
import { connect } from 'react-redux' | ||
import { decodeQueryParams, DelimitedArrayParam } from 'serialize-query-params' | ||
import { FormattedMessage, useIntl } from 'react-intl' | ||
|
@@ -24,9 +20,14 @@ import { | |
ModeSettingValues | ||
} from '@opentripplanner/types' | ||
|
||
import * as apiActions from '../../actions/api' | ||
import * as formActions from '../../actions/form' | ||
import { AppReduxState } from '../../util/state-types' | ||
import { ComponentContext } from '../../util/contexts' | ||
import PageTitle from '../util/page-title' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sort imports |
||
|
||
import React, { RefObject, useContext } from 'react' | ||
import styled from 'styled-components' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sort imports |
||
import { | ||
addCustomSettingLabels, | ||
|
@@ -37,8 +38,7 @@ import { | |
setModeButton | ||
} from './util' | ||
import { setModeButtonEnabled } from './batch-settings' | ||
|
||
import styled from 'styled-components' | ||
import { styledCheckboxCss } from './styled' | ||
|
||
const PanelOverlay = styled.div` | ||
background-color: #fff; | ||
|
@@ -52,6 +52,14 @@ const PanelOverlay = styled.div` | |
overflow-y: scroll; | ||
` | ||
|
||
const GlobalSettingsContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
|
||
${styledCheckboxCss} | ||
` | ||
|
||
const CloseButton = styled.button` | ||
background: transparent; | ||
border: none; | ||
|
@@ -100,14 +108,29 @@ const AdvancedSettingsPanel = ({ | |
// @ts-expect-error Context not typed | ||
const { ModeIcon } = useContext(ComponentContext) | ||
|
||
const processedModeSettings = modeSettingDefinitions.map( | ||
pipe( | ||
populateSettingWithIcon(ModeIcon), | ||
populateSettingWithValue(modeSettingValues), | ||
addCustomSettingLabels(intl) | ||
const processSettings = (settings: any) => | ||
settings.map( | ||
amy-corson-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pipe( | ||
populateSettingWithIcon(ModeIcon), | ||
populateSettingWithValue(modeSettingValues), | ||
addCustomSettingLabels(intl) | ||
) | ||
) | ||
|
||
const globalSettings = modeSettingDefinitions.filter((x) => !x.applicableMode) | ||
const processedGlobalSettings = processSettings(globalSettings) | ||
|
||
const globalSettingsComponents = processedGlobalSettings.map( | ||
(setting: any) => ( | ||
<ModeSettingRenderer | ||
amy-corson-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key={setting.key} | ||
onChange={onSettingsUpdate(setQueryParam)} | ||
setting={setting} | ||
/> | ||
) | ||
) | ||
|
||
const processedModeSettings = processSettings(modeSettingDefinitions) | ||
const processedModeButtons = modeButtonOptions.map( | ||
pipe( | ||
addModeButtonIcon(ModeIcon), | ||
|
@@ -135,15 +158,13 @@ const AdvancedSettingsPanel = ({ | |
<Subheader> | ||
<FormattedMessage id="components.BatchSearchScreen.tripOptions" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's hide this header if there are no global settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left them invisible for screenreaders since I think they're helpful context, and so some configurations could have access to them! I took them out, let me know what you think? I kinda miss them but I see what you mean. |
||
</Subheader> | ||
{/** | ||
* Trip options (walk speed, walk reluctance, accessible routing) go here | ||
*/} | ||
|
||
<GlobalSettingsContainer> | ||
{globalSettingsComponents} | ||
</GlobalSettingsContainer> | ||
<Subheader> | ||
<FormattedMessage id="components.BatchSearchScreen.modeOptions" /> | ||
</Subheader> | ||
{/** | ||
* AdvancedModeSubsettingsContainer (import from Otp-ui) goes here | ||
*/} | ||
<AdvancedModeSubsettingsContainer | ||
accentColor={accentColor} | ||
fillModeIcons | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to sort these and literally couldn't get eslint to be happy, so good luck