-
Notifications
You must be signed in to change notification settings - Fork 88
Updates to gtfs spec changes - front end UI fields only #668
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
Changes from 36 commits
b299745
976b5c7
b1341cf
8a9c383
baaba8b
acd651a
93b1f53
5397f4a
ad6bfe6
6a9e2ed
b30a941
c4cf115
36a759d
79073f7
094efc7
7717c28
f1cb21e
ff05ac7
5d17fbb
c728b3d
212cf37
3b97719
826088d
4039af7
0255029
ae5eaae
cb588be
a95a02c
5696ff1
2eda50c
e692199
f567077
589b6c6
ef69da3
00ea4d4
e180c43
1c5fd78
59d429a
548fb24
c48bb18
cda4f65
be6b088
a5f9c88
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 |
|---|---|---|
|
|
@@ -3,7 +3,15 @@ | |
| import Icon from '@conveyal/woonerf/components/icon' | ||
| import React, {Component} from 'react' | ||
| import { DragSource, DropTarget } from 'react-dnd' | ||
| import { Row, Col, Collapse, FormGroup, ControlLabel, Checkbox } from 'react-bootstrap' | ||
| import { | ||
| Checkbox, | ||
| Col, | ||
| Collapse, | ||
| ControlLabel, | ||
| FormControl, | ||
| FormGroup, | ||
| Row | ||
| } from 'react-bootstrap' | ||
|
|
||
| import * as activeActions from '../../actions/active' | ||
| import * as stopStrategiesActions from '../../actions/map/stopStrategies' | ||
|
|
@@ -42,6 +50,79 @@ type Props = { | |
| updatePatternStops: typeof tripPatternActions.updatePatternStops | ||
| } | ||
|
|
||
| type PickupDropoffSelectProps = { | ||
| activePattern: Pattern, | ||
| controlLabel: string, | ||
| onChange: (evt: SyntheticInputEvent<HTMLInputElement>) => void, | ||
| selectType: string, | ||
| shouldHaveDisabledOption: boolean, | ||
| title: string, | ||
| value: string | number | ||
| } | ||
|
|
||
| type State = { | ||
| initialDwellTime: number, | ||
| initialTravelTime: number, | ||
| update: boolean | ||
| } | ||
|
|
||
| const pickupDropoffOptions = [ | ||
| { | ||
| value: 0, | ||
| text: 'Available (0)' | ||
| }, | ||
| { | ||
| value: 1, | ||
| text: 'Not available (1)' | ||
| }, | ||
| { | ||
| value: 2, | ||
| text: 'Must phone agency to arrange (2)' | ||
| }, | ||
| { | ||
| value: 3, | ||
| text: 'Must coordinate with driver to arrange (3)' | ||
| } | ||
| ] | ||
|
|
||
| /** renders the form control drop downs for dropOff/Pick up and also continuous */ | ||
| const PickupDropoffSelect = (props: PickupDropoffSelectProps) => { | ||
| const { | ||
| activePattern, | ||
| controlLabel, | ||
| onChange, | ||
| selectType, | ||
| shouldHaveDisabledOption, | ||
| title, | ||
| value | ||
| } = props | ||
| const hasShapeId = activePattern.shapeId === null | ||
| return ( | ||
| <FormGroup | ||
| bsSize='small' | ||
| controlId={selectType} | ||
| > | ||
| <ControlLabel | ||
| className='small' | ||
| title={title} | ||
| > | ||
| {controlLabel} | ||
| </ControlLabel> | ||
| <FormControl | ||
| componentClass='select' | ||
| disabled={shouldHaveDisabledOption && hasShapeId} | ||
| onChange={onChange} | ||
| placeholder='select' | ||
| value={value} | ||
| > | ||
| {pickupDropoffOptions.map(o => ( | ||
| <option key={o.value} value={o.value}>{o.text}</option> | ||
| ))} | ||
| </FormControl> | ||
| </FormGroup> | ||
| ) | ||
| } | ||
|
|
||
| const cardSource = { | ||
| beginDrag (props: Props) { | ||
| return { | ||
|
|
@@ -174,12 +255,6 @@ class PatternStopCard extends Component<Props> { | |
| } | ||
| } | ||
|
|
||
| type State = { | ||
| initialDwellTime: number, | ||
| initialTravelTime: number, | ||
| update: boolean | ||
| } | ||
|
|
||
| class PatternStopContents extends Component<Props, State> { | ||
| componentWillMount () { | ||
| this.setState({ | ||
|
|
@@ -246,12 +321,23 @@ class PatternStopContents extends Component<Props, State> { | |
| updatePatternStops(activePattern, patternStops) | ||
| } | ||
|
|
||
| _onPickupOrDropOffChange = (evt: SyntheticInputEvent<HTMLInputElement>) => { | ||
| const selectedOptionValue: number = parseInt(evt.target.value, 10) | ||
| const {activePattern, index, updatePatternStops} = this.props | ||
| const patternStops = [...activePattern.patternStops] | ||
|
|
||
| patternStops[index][evt.target.id] = selectedOptionValue | ||
|
||
| this.setState({update: true}) | ||
| updatePatternStops(activePattern, patternStops) | ||
| } | ||
|
|
||
| render () { | ||
| const {active, patternEdited, patternStop} = this.props | ||
| const {active, activePattern, patternEdited, patternStop} = this.props | ||
| // This component has a special shouldComponentUpdate to ensure that state | ||
| // is not overwritten with new props, so use state.update to check edited | ||
| // state. | ||
| const isEdited = patternEdited || this.state.update | ||
|
|
||
| let innerDiv | ||
| if (active) { | ||
| innerDiv = <div> | ||
|
|
@@ -301,6 +387,55 @@ class PatternStopContents extends Component<Props, State> { | |
| </FormGroup> | ||
| </Col> | ||
| </Row> | ||
| {/* Pickup and drop off type selectors */} | ||
| <Row> | ||
| <Col xs={6}> | ||
| <PickupDropoffSelect | ||
| activePattern={activePattern} | ||
| controlLabel='Pickup' | ||
| onChange={this._onPickupOrDropOffChange} | ||
| selectType='pickupType' | ||
| shouldHaveDisabledOption={false} | ||
| title='Define the pickup method/availability at this stop.' | ||
| value={patternStop.pickupType || ''} | ||
| /> | ||
| </Col> | ||
| <Col xs={6}> | ||
| <PickupDropoffSelect | ||
| activePattern={activePattern} | ||
| controlLabel='Drop-off' | ||
| onChange={this._onPickupOrDropOffChange} | ||
| selectType='dropOffType' | ||
| shouldHaveDisabledOption={false} | ||
| title='Define the dropff method/availability at this stop.' | ||
| value={patternStop.dropOffType || ''} | ||
| /> | ||
| </Col> | ||
| </Row> | ||
| <Row> | ||
| <Col xs={6}> | ||
| <PickupDropoffSelect | ||
| activePattern={activePattern} | ||
| controlLabel='Continuous pickup' | ||
| onChange={this._onPickupOrDropOffChange} | ||
| selectType='continuousPickup' | ||
| shouldHaveDisabledOption | ||
| title='Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path.' | ||
| value={patternStop.continuousPickup || ''} | ||
| /> | ||
| </Col> | ||
| <Col xs={6}> | ||
| <PickupDropoffSelect | ||
| activePattern={activePattern} | ||
| controlLabel='Continuous drop-off' | ||
| onChange={this._onPickupOrDropOffChange} | ||
| selectType='continuousDropOff' | ||
| shouldHaveDisabledOption | ||
| title='Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.' | ||
| value={patternStop.continuousDropOff || ''} | ||
| /> | ||
| </Col> | ||
| </Row> | ||
| <NormalizeStopTimesTip /> | ||
| </div> | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.