Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6236f13
fix(EditorInput.js gtfs.yml): Added missing GTFS Extended Route Types
Apr 8, 2021
07a06a6
refactor(gtfs.yml, EditorInput.js): Refactored code
Apr 20, 2021
5289c80
Merge branch 'dev' into add-gtfs-extended-route-types
Apr 20, 2021
c6989f8
refactor(EditorInput): suggest changes for #656
landonreed Apr 20, 2021
ec0d4c1
Merge pull request #659 from ibi-group/add-gtfs-extended-route-types-ltr
Apr 23, 2021
8bf1037
refactor: Apply suggestions from code review
landonreed May 7, 2021
ec1c526
fix(lib/types/index.js): Replaced the gtfs field option type from val…
Jul 19, 2021
da0bda5
fix(EditorInput.js): Refactored the argument to compare a number with…
Jul 19, 2021
d85268b
refactor(EditorInput.js): Aded a radix argunment to the parseInt
Jul 19, 2021
a86e8be
refactor(EditorInput): Extract route type rendering, pass route type …
binh-dam-ibigroup Sep 24, 2021
1061f1f
refactor(EditorInput): Reorder imports
binh-dam-ibigroup Sep 24, 2021
9b26e23
chore(gtfs.yml): Tweak route types.
binh-dam-ibigroup Feb 11, 2022
5509225
feat(RouteTypeSelect): Add route type selector with new extended GTFS…
binh-dam-ibigroup Feb 14, 2022
52d1c40
Merge branch 'dev' into add-gtfs-extended-route-types
binh-dam-ibigroup Feb 14, 2022
51f8848
improvement(RouteTypeSelect): Improve rendering.
binh-dam-ibigroup Feb 14, 2022
008d7e7
refactor(EditorInput): Do first refactor of class.
binh-dam-ibigroup Feb 14, 2022
73c48e0
refactor(EditorInput): Do a light refactor.
binh-dam-ibigroup Feb 14, 2022
7d7928f
test(e2e): Make e2e tests for route editing pass.
binh-dam-ibigroup Feb 15, 2022
bc14fed
refactor(lib/styles.css): Adjust styles for RouteTypeSelect.
binh-dam-ibigroup Feb 15, 2022
e78eb65
improvement(editor/util/validation): Add GTFS route type UI validation.
binh-dam-ibigroup Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,253 @@
options:
- value: 3
text: Bus
group: Standard
- value: 0
text: Tram
group: Standard
- value: 1
text: Subway
group: Standard
- value: 2
text: Rail
group: Standard
- value: 4
text: Ferry
group: Standard
- value: 5
text: Cable car
group: Standard
- value: 6
text: Gondola
group: Standard
- value: 7
text: Funicular
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add options 11 and 12 (they were recently added to the standard set)? See the spec for routes.txt: https://developers.google.com/transit/gtfs/reference#routestxt for more info

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

group: Extended
- value: 100
text: Railway Service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this value duplicated?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. And there was a word missing. Going to check the rest now.

group: Extended
- value: 100
text: Railway Service
group: Extended
- value: 101
text: High Speed Rail Service
group: Extended
- value: 102
text: Long Distance Trains
group: Extended
- value: 103
text: Inter Regional Rail Service
group: Extended
- value: 104
text: Car Transport Rail Service
group: Extended
- value: 105
text: Sleeper Rail Service
group: Extended
- value: 106
text: Regional Rail Service
group: Extended
- value: 107
text: Tourist Railway Service
group: Extended
- value: 108
text: Rail Shuttle (Within Complex)
group: Extended
- value: 109
text: Suburban Railway
group: Extended
- value: 110
text: Replacement Rail Service
group: Extended
- value: 111
text: Special Rail Service
group: Extended
- value: 112
text: Lorry Transport Rail Service
group: Extended
- value: 113
text: All Rail Services
group: Extended
- value: 114
text: Cross-Country Rail Service
group: Extended
- value: 115
text: Vehicle Transport Rail Service
group: Extended
- value: 116
text: Rack and Pinion Railway
group: Extended
- value: 117
text: Additional Rail Service
group: Extended
- value: 200
text: Coach Service
group: Extended
- value: 201
text: International Coach Service
group: Extended
- value: 202
text: National Coach Service
group: Extended
- value: 203
text: Shuttle Coach Service
group: Extended
- value: 204
text: Regional Coach Service
group: Extended
- value: 205
text: Special Coach Service
group: Extended
- value: 206
text: Sightseeing Coach Service
group: Extended
- value: 207
text: Tourist Coach Service
group: Extended
- value: 208
text: Commuter Coach Service
group: Extended
- value: 209
text: All Coach Services
group: Extended
- value: 400
text: Urban Railway Service
group: Extended
- value: 401
text: Metro Service
group: Extended
- value: 402
text: Underground Service
group: Extended
- value: 403
text: Urban Railway Service
group: Extended
- value: 404
text: All Urban Railway Services
group: Extended
- value: 405
text: Monorail
group: Extended
- value: 700
text: Bus Service
group: Extended
- value: 701
text: Regional Bus Service
group: Extended
- value: 702
text: Express Bus Service
group: Extended
- value: 703
text: Stopping Bus Service
group: Extended
- value: 704
text: Local Bus Service
group: Extended
- value: 705
text: Night Bus Service
group: Extended
- value: 706
text: Post Bus Service
group: Extended
- value: 707
text: Special Needs Bus
group: Extended
- value: 708
text: Mobility Bus Service
group: Extended
- value: 709
text: Mobility Bus for Registered Disabled
group: Extended
- value: 710
text: Sightseeing Bus
group: Extended
- value: 711
text: Shuttle Bus
group: Extended
- value: 712
text: School Bus
group: Extended
- value: 713
text: School and Public Service Bus
group: Extended
- value: 714
text: Rail Replacement Bus Service
group: Extended
- value: 715
text: Demand and Response Bus Service
group: Extended
- value: 716
text: All Bus Services
group: Extended
- value: 800
text: Trolleybus Service
group: Extended
- value: 900
text: Tram Service
group: Extended
- value: 901
text: City Tram Service
group: Extended
- value: 902
text: Local Tram Service
group: Extended
- value: 903
text: Regional Tram Service
group: Extended
- value: 904
text: Sightseeing Tram Service
group: Extended
- value: 905
text: Shuttle Tram Service
group: Extended
- value: 906
text: All Tram Services
group: Extended
- value: 1000
text: Water Transport Service
group: Extended
- value: 1100
text: Air Service
group: Extended
- value: 1200
text: Ferry Service
group: Extended
- value: 1300
text: Aerial Lift Service
group: Extended
- value: 1400
text: Funicular Service
group: Extended
- value: 1500
text: Taxi Service
group: Extended
- value: 1501
text: Communal Taxi Service
group: Extended
- value: 1502
text: Water Taxi Service
group: Extended
- value: 1503
text: Rail Taxi Service
group: Extended
- value: 1504
text: Bike Taxi Service
group: Extended
- value: 1505
text: Licensed Taxi Service
group: Extended
- value: 1506
text: Private Hire Service Vehicle
group: Extended
- value: 1507
text: All Taxi Services
group: Extended
- value: 1700
text: Miscellaneous Service
group: Extended
- value: 1702
text: Horse-drawn Carriage
group: Extended
columnWidth: 6
helpContent: The route_type field describes the type of transportation used on a route. Valid values for this field are...
- name: route_sort_order
Expand Down
32 changes: 31 additions & 1 deletion lib/editor/components/EditorInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,33 @@ export default class EditorInput extends Component<Props> {
}
}

_renderRouteTypeOptions = (field: any) => {
const standardTypes = []
const extendedTypes = []
const routeTypes = ['Standard', 'Extended']
const fieldOptions = field.options
for (const option in fieldOptions) {
if (fieldOptions[option].group === 'Standard') {
standardTypes.push(fieldOptions[option])
} else {
extendedTypes.push(fieldOptions[option])
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified:

const standardTypes = Object.values(fieldOptions).filter(fieldOption => fieldOption.group === 'Standard')
// same for extendedTypes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, in the return statement, try this:

return routeTypes
.map(type => Object.values(fieldOptions).filter(/*see above*/))
.map(routeTypes => {
  <optgroup>
    {routeTypes.map(routeType => /*what you already have for each std/extended types*/)}
  </optgroup>
})

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like it! Thanks Binh

return (
routeTypes.map<any>(type => (
<optgroup key={type} label={type}>
{type === 'Standard'
? standardTypes.map<any>(sType => (
<option key={sType.value}>{sType.text}</option>
))
: extendedTypes.map<any>(exType => (
<option key={exType.value}>{exType.text}</option>
))
}
</optgroup>
)))
}

render () {
const {
activeEntity,
Expand Down Expand Up @@ -314,7 +341,10 @@ export default class EditorInput extends Component<Props> {
? <option disabled value=''>{field.required ? '-- select an option --' : '(optional)' }</option>
: null
}
{field.options && field.options.map(o => (<option value={o.value} key={o.value}>{o.text || o.value}</option>))}
{field.name === 'route_type' && (
this._renderRouteTypeOptions(field)
)}
{field.name !== 'route_type' && field.options && field.options.map(o => (<option value={o.value} key={o.value}>{o.text || o.value}</option>))}}
</FormControl>
</FormGroup>
)
Expand Down