|
3 | 3 | import Icon from '@conveyal/woonerf/components/icon' |
4 | 4 | import React, {Component} from 'react' |
5 | 5 | 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' |
7 | 7 |
|
8 | 8 | import * as activeActions from '../../actions/active' |
9 | 9 | import * as stopStrategiesActions from '../../actions/map/stopStrategies' |
@@ -246,12 +246,90 @@ class PatternStopContents extends Component<Props, State> { |
246 | 246 | updatePatternStops(activePattern, patternStops) |
247 | 247 | } |
248 | 248 |
|
| 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 | + |
249 | 289 | render () { |
250 | | - const {active, patternEdited, patternStop} = this.props |
| 290 | + const {active, activePattern, patternEdited, patternStop} = this.props |
251 | 291 | // This component has a special shouldComponentUpdate to ensure that state |
252 | 292 | // is not overwritten with new props, so use state.update to check edited |
253 | 293 | // state. |
254 | 294 | 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 | + |
255 | 333 | let innerDiv |
256 | 334 | if (active) { |
257 | 335 | innerDiv = <div> |
@@ -301,6 +379,80 @@ class PatternStopContents extends Component<Props, State> { |
301 | 379 | </FormGroup> |
302 | 380 | </Col> |
303 | 381 | </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> |
304 | 456 | <NormalizeStopTimesTip /> |
305 | 457 | </div> |
306 | 458 | } |
|
0 commit comments