Skip to content

Commit

Permalink
feat(StopTimeNormalization): bring back st normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-cline authored and miles-grant-ibigroup committed Mar 28, 2024
1 parent 685fa6b commit afc3491
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
12 changes: 7 additions & 5 deletions lib/editor/components/pattern/NormalizeStopTimesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Alert, Button, ControlLabel, FormControl, Modal } from 'react-bootstrap

import * as tripPatternActions from '../../actions/tripPattern'
import type { GtfsStop, Pattern } from '../../../types'
import { mergePatternHaltsOfPattern } from '../../../gtfs/util'

type Props = {
activePattern: Pattern,
Expand Down Expand Up @@ -39,7 +40,8 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {

render () {
const { Body, Footer, Header, Title } = Modal
const { activePattern, stops } = this.props
const { activePattern } = this.props
const patternHalts = mergePatternHaltsOfPattern(activePattern)
return (
<Modal show={this.props.show || this.state.show} onHide={this._onClose}>
<Header>
Expand All @@ -56,14 +58,14 @@ export default class NormalizeStopTimesModal extends Component<Props, State> {
value={this.state.patternStopIndex}
componentClass='select'
onChange={this._onChangeStop}>
{activePattern.patternStops.map((patternStop, index) => {
const stop = stops.find(s => s.stop_id === patternStop.stopId)
if (!stop) return null
{patternHalts.map((patternHalt, index) => {
if (!patternHalt) return null
return (
<option
value={index}
key={index}>
{index + 1} - {stop.stop_name}
{/* TODO: We'll need to add area_name here once we support it. */}
{index + 1} - {patternHalt.stop_name || patternHalt.locationId || patternHalt.areaId}
</option>
)
}
Expand Down
21 changes: 9 additions & 12 deletions lib/editor/components/pattern/PatternStopsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import VirtualizedEntitySelect from '../VirtualizedEntitySelect'
import {getEntityBounds, getEntityName} from '../../util/gtfs'
import type {Pattern, GtfsLocation, GtfsStop, Feed, ControlPoint, Coordinates} from '../../../types'
import type {EditorStatus, EditSettingsUndoState, MapState} from '../../../types/reducers'
import { activePatternHasLocations } from '../../util/location'

import PatternStopContainer from './PatternStopContainer'
import NormalizeStopTimesModal from './NormalizeStopTimesModal'
Expand Down Expand Up @@ -128,17 +127,15 @@ export default class PatternStopsPanel extends Component<Props, State> {
{`Stops & Locations (${patternHaltCount})`}
</h4>
<div style={{width: '100%'}}>
{!activePatternHasLocations(activePattern) &&
<Button
onClick={this._clickNormalizeStopTimes}
style={{marginBottom: '5px'}}
className='pull-right'
block
bsSize='small'>
<Icon type='clock-o' />{' '}
Normalize stop times
</Button>
}
<Button
onClick={this._clickNormalizeStopTimes}
style={{marginBottom: '5px'}}
className='pull-right'
block
bsSize='small'>
<Icon type='clock-o' />{' '}
Normalize stop times
</Button>
<Button
onClick={this._toggleAddStopsMode}
className='pull-right'
Expand Down

0 comments on commit afc3491

Please sign in to comment.