Skip to content

Commit

Permalink
refactor(NormalizeStopTimesModal): disable if too few timepoints
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-cline committed Nov 17, 2023
1 parent 954f0a2 commit 64e15cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions i18n/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ components:
normalizeStopTimes: Normalize stop times
normalizeStopTimesQuestion: Normalize stop times?
selectBeginningPatternStop: "Select beginning pattern stop:"
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
usageExplanationOne: This feature is useful when the travel times for one or more
pattern stops change. Take for example a pattern
that has been re-routed along to travel a longer distance, has had a
Expand Down
1 change: 1 addition & 0 deletions i18n/german.yml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ components:
normalizeStopTimes: Normalize stop times
normalizeStopTimesQuestion: Normalize stop times?
selectBeginningPatternStop: "Select beginning pattern stop:"
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
usageExplanationOne: This feature is useful when the travel times for one or more
pattern stops change. Take for example a pattern
that has been re-routed along to travel a longer distance, has had a
Expand Down
1 change: 1 addition & 0 deletions i18n/polish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ components:
normalizeStopTimes: Normalize stop times
normalizeStopTimesQuestion: Normalize stop times?
selectBeginningPatternStop: "Select beginning pattern stop:"
tooFewTimepoints: "You must have more than 1 timepoint to interpolate times"
usageExplanationOne: This feature is useful when the travel times for one or more
pattern stops change. Take for example a pattern
that has been re-routed along to travel a longer distance, has had a
Expand Down
24 changes: 17 additions & 7 deletions lib/editor/components/pattern/NormalizeStopTimesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Icon from '@conveyal/woonerf/components/icon'
import React, { Component } from 'react'
import { Alert, Button, Checkbox, ControlLabel, FormControl, Modal } from 'react-bootstrap'
import { Alert, Button, Checkbox, ControlLabel, FormControl, Modal, OverlayTrigger, Tooltip } from 'react-bootstrap'

import * as tripPatternActions from '../../actions/tripPattern'
import type { GtfsStop, Pattern } from '../../../types'
Expand Down Expand Up @@ -48,6 +48,8 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {
render () {
const { Body, Footer, Header, Title } = Modal
const { activePattern, stops } = this.props
const timepoints = activePattern.patternStops.filter(ps => ps.timepoint === 1)
const interpolationDisabled = timepoints.length < 2
return (
<Modal show={this.props.show || this.state.show} onHide={this._onClose}>
<Header>
Expand Down Expand Up @@ -77,12 +79,20 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {
}
)}
</FormControl>
<Checkbox
onChange={this._onChangeInterpolation}
value={this.state.interpolateStopTimes}
>
{this.messages('interpolateStopTimes')}
</Checkbox>
<div style={{alignContent: 'center', alignItems: 'center', display: 'flex'}}>
<OverlayTrigger
overlay={<Tooltip>{this.messages('tooFewTimepoints')}</Tooltip>}
placement='bottom'
>
<Checkbox
disabled={interpolationDisabled}
onChange={this._onChangeInterpolation}
value={this.state.interpolateStopTimes}
/>
</OverlayTrigger>
{/* Separate label so that tooltip appears over checkbox. Hack: Padding to align center with checkbox */}
<span style={{paddingBottom: '2px'}}>{this.messages('interpolateStopTimes')}</span>
</div>
<br />
<Alert bsStyle='warning'>
{this.state.patternStopIndex === 0
Expand Down

0 comments on commit 64e15cc

Please sign in to comment.