Skip to content

Commit

Permalink
Merge pull request #1077 from opentripplanner/calltaker-fix-bike-relu…
Browse files Browse the repository at this point in the history
…ctance

CallTaker: Remove Bike Tolerance Slider, add Bike Tolerance Dropdown
  • Loading branch information
miles-grant-ibigroup authored Nov 28, 2023
2 parents 50bbe82 + d9867ba commit 2a6d4df
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions lib/components/form/call-taker/advanced-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ class AdvancedOptions extends Component {
})
}

_setBikeTolerance = ({ bikeTolerance }) => {
_setBikeReluctance = ({ bikeReluctance }) => {
this.props.setUrlSearch({
bikeTolerance
bikeReluctance
})
}

Expand Down Expand Up @@ -221,6 +221,10 @@ class AdvancedOptions extends Component {
title: modeObj.label
}
})
const bikeEnabled = hasBike(
currentModes?.map((m) => m.mode).join(',') || ''
)
const bikeString = bikeEnabled ? 'Biking' : 'Walking'
return (
<div>
<div
Expand All @@ -231,34 +235,32 @@ class AdvancedOptions extends Component {
}}
>
<DropdownSelector
label={intl.formatMessage({
id: 'components.AdvancedOptions.walkTolerance'
})}
name="walkReluctance"
onChange={this._setWalkTolerance}
label={
bikeEnabled
? intl.formatMessage({
id: 'components.AdvancedOptions.bikeTolerance'
})
: intl.formatMessage({
id: 'components.AdvancedOptions.walkTolerance'
})
}
name={bikeEnabled ? 'bikeReluctance' : 'walkReluctance'}
onChange={
bikeEnabled ? this._setBikeReluctance : this._setWalkTolerance
}
options={[
{ text: 'Normal Walking', value: 3 },
{ text: 'Avoid Walking', value: 15 },
{ text: 'Prefer walking', value: 1 }
{ text: `Normal ${bikeString}`, value: 3 },
{ text: `Avoid ${bikeString}`, value: 15 },
{ text: `Prefer ${bikeString}`, value: 1 }
]}
style={{ display: 'block', width: '33ch' }}
value={this.props.modeSettingValues.walkReluctance}
value={
bikeEnabled
? this.props.modeSettingValues.bikeReluctance
: this.props.modeSettingValues.walkReluctance
}
/>

{hasBike(currentModes?.map((m) => m.mode).join(',') || '') ? (
<SliderSelector
label={intl.formatMessage({
id: 'components.AdvancedOptions.bikeTolerance'
})}
max={5}
min={0}
name="bikeTolerance"
onChange={this._setBikeTolerance}
step={1}
style={{ display: 'block', marginRight: '10px', width: '150px' }}
value={this.props.modeSettingValues.bikeTolerance}
/>
) : null}
<StyledSubmodeSelector
modes={transitModes}
onChange={this._onSubModeChange}
Expand Down

0 comments on commit 2a6d4df

Please sign in to comment.