Skip to content

Commit 93b1f53

Browse files
author
Rob Gregg
committed
improvement(OatternStopCard.js lib/gtfs/util/index.js lib/types/index.js): Update to the GTFS Spec U
Added the changes where applicable to the gtfs.yml file. Added the new types for continuous drop off/pick up and added fields as well as basic validation in the patternStopCard file. BREAKING CHANGE: There have been added fields that need to coincide with changes on the backend as the api will be looking for the new fields and those fields need to be present on the Front end #663
1 parent acd651a commit 93b1f53

File tree

3 files changed

+158
-2
lines changed

3 files changed

+158
-2
lines changed

lib/editor/components/pattern/PatternStopCard.js

Lines changed: 154 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Icon from '@conveyal/woonerf/components/icon'
44
import React, {Component} from 'react'
55
import { DragSource, DropTarget } from 'react-dnd'
6-
import { Row, Col, Collapse, FormGroup, ControlLabel, Checkbox } from 'react-bootstrap'
6+
import { Row, Col, Collapse, FormGroup, ControlLabel, Checkbox, FormControl } from 'react-bootstrap'
77

88
import * as activeActions from '../../actions/active'
99
import * as stopStrategiesActions from '../../actions/map/stopStrategies'
@@ -246,12 +246,90 @@ class PatternStopContents extends Component<Props, State> {
246246
updatePatternStops(activePattern, patternStops)
247247
}
248248

249+
_onPickupChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
250+
const newPickup: number = parseInt(evt.target.value)
251+
const {activePattern, index, updatePatternStops} = this.props
252+
const patternStops = [...activePattern.patternStops]
253+
254+
patternStops[index].pickupType = newPickup
255+
this.setState({update: true})
256+
updatePatternStops(activePattern, patternStops)
257+
}
258+
259+
_onDropOffChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
260+
const newDropOff: number = parseInt(evt.target.value)
261+
const {activePattern, index, updatePatternStops} = this.props
262+
const patternStops = [...activePattern.patternStops]
263+
264+
patternStops[index].dropOffType = newDropOff
265+
this.setState({update: true})
266+
updatePatternStops(activePattern, patternStops)
267+
}
268+
269+
_onContinuousPickupChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
270+
const newPickup: number = parseInt(evt.target.value)
271+
const {activePattern, index, updatePatternStops} = this.props
272+
const patternStops = [...activePattern.patternStops]
273+
274+
patternStops[index].continuousPickup = newPickup
275+
this.setState({update: true})
276+
updatePatternStops(activePattern, patternStops)
277+
}
278+
279+
_onContinuousDropOffChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
280+
const newPickup: number = parseInt(evt.target.value)
281+
const {activePattern, index, updatePatternStops} = this.props
282+
const patternStops = [...activePattern.patternStops]
283+
284+
patternStops[index].continuousDropOff = newPickup
285+
this.setState({update: true})
286+
updatePatternStops(activePattern, patternStops)
287+
}
288+
249289
render () {
250-
const {active, patternEdited, patternStop} = this.props
290+
const {active, activePattern, patternEdited, patternStop} = this.props
251291
// This component has a special shouldComponentUpdate to ensure that state
252292
// is not overwritten with new props, so use state.update to check edited
253293
// state.
254294
const isEdited = patternEdited || this.state.update
295+
const hasShapeId = activePattern.shapeId !== null ? false : true
296+
const pickupDropoffOptions = [
297+
{
298+
value: 0,
299+
text: 'Regularly scheduled (0)'
300+
},
301+
{
302+
value: 1,
303+
text: 'Not available (1)'
304+
},
305+
{
306+
value: 2,
307+
text: 'Must phone agency to arrange (2)'
308+
},
309+
{
310+
value: 3,
311+
text: 'Must coordinate with driver to arrange (3)'
312+
}
313+
]
314+
const continuousPickupDropoffOptions = [
315+
{
316+
value: 0,
317+
text: 'Continuous stopping pickup (0)'
318+
},
319+
{
320+
value: 1,
321+
text: 'Not available (1)'
322+
},
323+
{
324+
value: 2,
325+
text: 'Must phone agency to arrange (2)'
326+
},
327+
{
328+
value: 3,
329+
text: 'Must coordinate with driver to arrange (3)'
330+
}
331+
]
332+
255333
let innerDiv
256334
if (active) {
257335
innerDiv = <div>
@@ -301,6 +379,80 @@ class PatternStopContents extends Component<Props, State> {
301379
</FormGroup>
302380
</Col>
303381
</Row>
382+
{/* Pickup and drop off type selectors */}
383+
<Row>
384+
<Col xs={6}>
385+
<FormGroup
386+
controlId='pickupType'
387+
bsSize='small'>
388+
<ControlLabel
389+
className='small'
390+
title='Define the pickup method/availability at this stop.'
391+
>
392+
Pickup type
393+
</ControlLabel>
394+
<FormControl componentClass='select' placeholder='select' value={patternStop.pickupType} onChange={this._onPickupChange}>
395+
{pickupDropoffOptions.map(o => (
396+
<option key={o.value} value={o.value}>{o.text}</option>
397+
))}
398+
</FormControl>
399+
</FormGroup>
400+
</Col>
401+
<Col xs={6}>
402+
<FormGroup
403+
controlId='dropoffType'
404+
bsSize='small'>
405+
<ControlLabel
406+
className='small'
407+
title='Define the dropff method/availability at this stop.'
408+
>
409+
Drop-off type
410+
</ControlLabel>
411+
<FormControl componentClass='select' placeholder='select' value={patternStop.dropOffType} onChange={this._onDropOffChange}>
412+
{pickupDropoffOptions.map(o => (
413+
<option key={o.value} value={o.value}>{o.text}</option>
414+
))}
415+
</FormControl>
416+
</FormGroup>
417+
</Col>
418+
</Row>
419+
{/* Continuous Stopping Pickup and drop off type selectors */}
420+
<Row>
421+
<Col xs={6}>
422+
<FormGroup
423+
controlId='continuous_pick-up'
424+
bsSize='small'>
425+
<ControlLabel
426+
className='small'
427+
title='Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path.'
428+
>
429+
Continuous Pickup
430+
</ControlLabel>
431+
<FormControl componentClass='select' placeholder='select' disabled={hasShapeId} defaultValue={1} value={patternStop.continuousPickup} onChange={this._onContinuousPickupChange}>
432+
{continuousPickupDropoffOptions.map(o => (
433+
<option key={o.value} value={o.value}>{o.text}</option>
434+
))}
435+
</FormControl>
436+
</FormGroup>
437+
</Col>
438+
<Col xs={6}>
439+
<FormGroup
440+
controlId='continuous_drop_off'
441+
bsSize='small'>
442+
<ControlLabel
443+
className='small'
444+
title='Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.'
445+
>
446+
Continuous Drop off
447+
</ControlLabel>
448+
<FormControl componentClass='select' disabled={hasShapeId} placeholder='select' defaultValue={1} value={patternStop.continuousDropOff} onChange={this._onContinuousDropOffChange}>
449+
{continuousPickupDropoffOptions.map(o => (
450+
<option key={o.value} value={o.value}>{o.text}</option>
451+
))}
452+
</FormControl>
453+
</FormGroup>
454+
</Col>
455+
</Row>
304456
<NormalizeStopTimesTip />
305457
</div>
306458
}

lib/gtfs/util/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
7979
pickup_type
8080
drop_off_type
8181
timepoint
82+
continuous_pickup
83+
continuous_drop_off
8284
}`
8385
switch (type.toLowerCase()) {
8486
case 'stoptime':

lib/types/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ export type GeoJsonFeatureCollection = {
492492
}
493493

494494
export type PatternStop = {
495+
continuousDropOff: number,
496+
continuousPickup: number,
495497
defaultDwellTime: number,
496498
defaultTravelTime: number,
497499
dropOffType: number,

0 commit comments

Comments
 (0)