Skip to content

Commit 72cfa92

Browse files
Merge pull request #988 from ibi-group/add-stop-headsigns-for-mtc
Add stop headsigns for MTC
2 parents a319dd0 + 099510c commit 72cfa92

File tree

8 files changed

+105
-28
lines changed

8 files changed

+105
-28
lines changed

__tests__/test-utils/mock-data/editor.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const mockTripWithoutStopTimes = {
1212
shape_id: '19',
1313
stopTimes: [],
1414
tripHeadsign: 'Walla Walla',
15+
stopHeadsign: 'North',
1516
tripId: 'test-trip-id-1',
1617
tripShortName: null,
1718
wheelchair_accessible: null

i18n/english.yml

+31
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,37 @@ components:
548548
high: High
549549
low: Low
550550
medium: Medium
551+
title: Usage tier
552+
PageNotFound:
553+
homePage: home page
554+
pageNotFound: Page Not Found.
555+
PatternStopCard:
556+
PatternStopContents:
557+
defaultDwellTime: Default dwell time
558+
defaultTravelTime: Default travel time
559+
firstStopTravelTime: Travel time for first stop must be zero
560+
stopHeadsignPlaceholder: Outbound
561+
stopHeadsignText: Stop headsign
562+
stopHeadsignTitle: Headsign that overrides trip headsign between stops.
563+
timepoint: Timepoint?
564+
travelTimeHelp: Define the default time it takes to travel to this stop from the previous stop.
565+
PickupDropOffSelect:
566+
available: Available (0)
567+
continuousDropOffTitle: Indicates whether a rider can alight from the transit vehicle at any point along the vehicle's travel path.
568+
continuousPickupTitle: Indicates whether a rider can board the transit vehicle anywhere along the vehicle's travel path.
569+
continuousServiceDefault: (Inherit from route)
570+
dropOffTitle: Define the dropff method/availability at this stop.
571+
mustCoordinate: Must coordinate with driver to arrange (3)
572+
mustPhoneAgency: Must phone agency to arrange (2)
573+
notAvailable: Not available (1)
574+
pickupDropOffDefault: (Default - Available)
575+
pickupTitle: Define the pickup method/availability at this stop.
576+
Permissions:
577+
approve-alert: Approve GTFS-RT Alerts
578+
approve-gtfs: Approve GTFS Feeds
579+
edit-alert: Edit GTFS-RT Alerts
580+
edit-gtfs: Edit GTFS Feeds
581+
manage-feed: Manage Feed Configuration
551582
ProjectAccessSettings:
552583
admin: Admin
553584
cannotFetchFeeds: Cannot fetch feeds

lib/editor/components/pattern/PatternStopCard.js

+64-23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import * as stopStrategiesActions from '../../actions/map/stopStrategies'
1919
import * as tripPatternActions from '../../actions/tripPattern'
2020
import {getEntityName, getAbbreviatedStopName} from '../../util/gtfs'
2121
import MinuteSecondInput from '../MinuteSecondInput'
22+
import {getComponentMessages} from '../../../common/util/config'
2223
import type {Feed, Pattern, PatternStop} from '../../../types'
2324

2425
import NormalizeStopTimesTip from './NormalizeStopTimesTip'
@@ -55,7 +56,7 @@ type PickupDropoffSelectProps = {
5556
activePattern: Pattern,
5657
controlLabel: string,
5758
onChange: (evt: SyntheticInputEvent<HTMLInputElement>) => void,
58-
selectType: string,
59+
selectType: "pickupType" | "dropOffType" | "continuousPickup" | "continuousDropOff",
5960
shouldHaveDisabledOption: boolean,
6061
title: string,
6162
value: string | number
@@ -67,22 +68,27 @@ type State = {
6768
update: boolean
6869
}
6970

71+
const patternStopCardMessages = getComponentMessages('PatternStopCard')
72+
7073
const pickupDropoffOptions = [
7174
{
72-
value: 0,
73-
text: 'Available (0)'
75+
value: '' // Default text is defined conditionally based on the type of select (continuous-service or pickup-dropoff)
76+
},
77+
{
78+
text: patternStopCardMessages('PickupDropOffSelect.available'),
79+
value: 0
7480
},
7581
{
76-
value: 1,
77-
text: 'Not available (1)'
82+
text: patternStopCardMessages('PickupDropOffSelect.notAvailable'),
83+
value: 1
7884
},
7985
{
80-
value: 2,
81-
text: 'Must phone agency to arrange (2)'
86+
text: patternStopCardMessages('PickupDropOffSelect.mustPhoneAgency'),
87+
value: 2
8288
},
8389
{
84-
value: 3,
85-
text: 'Must coordinate with driver to arrange (3)'
90+
text: patternStopCardMessages('PickupDropOffSelect.mustCoordinate'),
91+
value: 3
8692
}
8793
]
8894

@@ -117,7 +123,11 @@ const PickupDropoffSelect = (props: PickupDropoffSelectProps) => {
117123
value={value}
118124
>
119125
{pickupDropoffOptions.map(o => (
120-
<option key={o.value} value={o.value}>{o.text}</option>
126+
<option key={o.value} value={o.value}>
127+
{o.value !== '' ? o.text : selectType.includes('continuous')
128+
? patternStopCardMessages('PickupDropOffSelect.continuousServiceDefault')
129+
: patternStopCardMessages('PickupDropOffSelect.pickupDropOffDefault') }
130+
</option>
121131
))}
122132
</FormControl>
123133
</FormGroup>
@@ -334,6 +344,18 @@ class PatternStopContents extends Component<Props, State> {
334344
updatePatternStops(activePattern, patternStops)
335345
}
336346

347+
_onHeadsignChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
348+
const {activePattern, index, updatePatternStops} = this.props
349+
const patternStops = [...activePattern.patternStops]
350+
patternStops[index] = {
351+
...patternStops[index],
352+
stopHeadsign: e.target.value
353+
}
354+
355+
this.setState({update: true})
356+
updatePatternStops(activePattern, patternStops)
357+
}
358+
337359
render () {
338360
const {active, activePattern, patternEdited, patternStop} = this.props
339361
// This component has a special shouldComponentUpdate to ensure that state
@@ -350,7 +372,7 @@ class PatternStopContents extends Component<Props, State> {
350372
<Checkbox
351373
checked={patternStop.timepoint}
352374
onChange={this._onChangeTimepoint}>
353-
Timepoint?
375+
{patternStopCardMessages('PatternStopContents.timepoint')}
354376
</Checkbox>
355377
</Col>
356378
<Col xs={8}>
@@ -369,10 +391,10 @@ class PatternStopContents extends Component<Props, State> {
369391
bsSize='small'>
370392
<ControlLabel
371393
title={this.props.index === 0
372-
? 'Travel time for first stop must be zero'
373-
: 'Define the default time it takes to travel to this stop from the previous stop.'
394+
? patternStopCardMessages('PatternStopContents.firstStopTravelTime')
395+
: patternStopCardMessages('PatternStopContents.travelTimeHelp')
374396
}
375-
className='small'>Default travel time</ControlLabel>
397+
className='small'>{patternStopCardMessages('PatternStopContents.defaultTravelTime')}</ControlLabel>
376398
<MinuteSecondInput
377399
disabled={this.props.index === 0}
378400
seconds={this.state.initialTravelTime}
@@ -383,7 +405,7 @@ class PatternStopContents extends Component<Props, State> {
383405
<FormGroup
384406
controlId='defaultDwellTime'
385407
bsSize='small'>
386-
<ControlLabel className='small'>Default dwell time</ControlLabel>
408+
<ControlLabel className='small'>{patternStopCardMessages('PatternStopContents.defaultDwellTime')}</ControlLabel>
387409
<MinuteSecondInput
388410
seconds={this.state.initialDwellTime}
389411
onChange={this._onDwellTimeChange} />
@@ -399,8 +421,8 @@ class PatternStopContents extends Component<Props, State> {
399421
onChange={this._onPickupOrDropOffChange}
400422
selectType='pickupType'
401423
shouldHaveDisabledOption={false}
402-
title='Define the pickup method/availability at this stop.'
403-
value={patternStop.pickupType || ''}
424+
title={patternStopCardMessages('PickupDropOffSelect.pickupTitle')}
425+
value={(patternStop.pickupType || patternStop.pickupType === 0) ? patternStop.pickupType : ''}
404426
/>
405427
</Col>
406428
<Col xs={6}>
@@ -410,8 +432,8 @@ class PatternStopContents extends Component<Props, State> {
410432
onChange={this._onPickupOrDropOffChange}
411433
selectType='dropOffType'
412434
shouldHaveDisabledOption={false}
413-
title='Define the dropff method/availability at this stop.'
414-
value={patternStop.dropOffType || ''}
435+
title={patternStopCardMessages('PickupDropOffSelect.dropOffTitle')}
436+
value={(patternStop.dropOffType || patternStop.dropOffType === 0) ? patternStop.dropOffType : ''}
415437
/>
416438
</Col>
417439
</Row>
@@ -423,8 +445,8 @@ class PatternStopContents extends Component<Props, State> {
423445
onChange={this._onPickupOrDropOffChange}
424446
selectType='continuousPickup'
425447
shouldHaveDisabledOption
426-
title='Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path.'
427-
value={(patternStop.continuousPickup || patternStop.continuousPickup === 0) ? patternStop.continuousPickup : 1}
448+
title={patternStopCardMessages('PickupDropOffSelect.continuousPickupTitle')}
449+
value={(patternStop.continuousPickup || patternStop.continuousPickup === 0) ? patternStop.continuousPickup : ''}
428450
/>
429451
</Col>
430452
<Col xs={6}>
@@ -434,11 +456,30 @@ class PatternStopContents extends Component<Props, State> {
434456
onChange={this._onPickupOrDropOffChange}
435457
selectType='continuousDropOff'
436458
shouldHaveDisabledOption
437-
title='Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.'
438-
value={(patternStop.continuousDropOff || patternStop.continuousDropOff === 0) ? patternStop.continuousDropOff : 1}
459+
title={patternStopCardMessages('PickupDropOffSelect.continuousDropOffTitle')}
460+
value={(patternStop.continuousDropOff || patternStop.continuousDropOff === 0) ? patternStop.continuousDropOff : ''}
439461
/>
440462
</Col>
441463
</Row>
464+
<Row>
465+
<Col xs={12}>
466+
<FormGroup
467+
controlId='stopHeadsign'
468+
bsSize='small'>
469+
<ControlLabel
470+
className='small'
471+
title={patternStopCardMessages('PatternStopContents.stopHeadsignTitle')}>
472+
{patternStopCardMessages('PatternStopContents.stopHeadsignText')}
473+
</ControlLabel>
474+
<FormControl
475+
onChange={this._onHeadsignChange}
476+
placeholder={patternStopCardMessages('PatternStopContents.stopHeadsignPlaceholder')}
477+
type='text'
478+
value={patternStop.stopHeadsign || ''}
479+
/>
480+
</FormGroup>
481+
</Col >
482+
</Row>
442483
<NormalizeStopTimesTip />
443484
</div>
444485
}

lib/editor/util/map.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -754,16 +754,17 @@ export function stopToPatternStop (
754754
throw new Error('Stop Id not set')
755755
}
756756
return {
757-
id: generateUID(),
758-
stopSequence,
759-
stopId: stop.stop_id,
760757
continuousDropOff: 1,
761758
continuousPickup: 1,
762759
defaultDwellTime: 0,
763760
defaultTravelTime: 0,
764761
dropOffType: 0,
762+
id: generateUID(),
765763
pickupType: 0,
766764
shapeDistTraveled: null,
765+
stopHeadsign: '',
766+
stopId: stop.stop_id,
767+
stopSequence,
767768
timepoint: null
768769
}
769770
}

lib/gtfs/util/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
8080
timepoint
8181
continuous_pickup
8282
continuous_drop_off
83+
stop_headsign
8384
}`
8485
switch (type.toLowerCase()) {
8586
case 'stoptime':

lib/manager/actions/feeds.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function createFeedSource (newFeed: NewFeed) {
6767
return dispatch(secureFetch(url, 'post', newFeed))
6868
.then((res) => res.json())
6969
.then((createdFeed) => {
70-
return dispatch(fetchProjectWithFeeds(newFeed.projectId)).then(() => {
70+
return dispatch(fetchProjectWithFeeds(newFeed.projectId, false, true)).then(() => {
7171
browserHistory.push(`/feed/${createdFeed.id}`)
7272
})
7373
})

lib/manager/actions/projects.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function fetchProject (projectId: string, unsecure: ?boolean) {
107107
}
108108
}
109109

110-
export function fetchProjectWithFeeds (projectId: string, unsecure: ?boolean) {
110+
export function fetchProjectWithFeeds (projectId: string, unsecure: ?boolean, isSaving: ?boolean) {
111111
return function (dispatch: dispatchFn, getState: getStateFn) {
112112
dispatch(requestingProject())
113113
const apiRoot = unsecure ? 'public' : 'secure'

lib/types/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ export type PatternStop = {
586586
id: string | number,
587587
pickupType: number,
588588
shapeDistTraveled: ?number,
589+
stopHeadsign: ?string,
589590
stopId: string,
590591
stopSequence: number,
591592
stop_lat?: number,
@@ -908,6 +909,7 @@ export type Trip = {|
908909
route_id: string,
909910
service_id: string,
910911
shape_id: string,
912+
stopHeadsign: string,
911913
stopTimes: Array<StopTime>,
912914
tripHeadsign: string,
913915
tripId: string,

0 commit comments

Comments
 (0)