Skip to content

Commit dcc9bf7

Browse files
start adding support for faresMedia
1 parent 3801386 commit dcc9bf7

File tree

8 files changed

+137
-5
lines changed

8 files changed

+137
-5
lines changed

gtfs.yml

+73-2
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@
505505
helpContent: Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.
506506
- name: network_id
507507
columnWidth: 12
508-
helpContent: "The network_id field contains an ID that uniquely identifies a transit network."
508+
helpContent: "The network_id field contains an ID that uniquely identifies a transit network. Forbidden if the route_networks.txt file exists."
509509
inputType: TEXT
510510
- name: wheelchair_accessible
511511
required: false
@@ -999,6 +999,78 @@
999999
- name: "to_network_id"
10001000
required: false
10011001

1002+
- id: fare_media
1003+
name: fare_media.txt
1004+
helpContent: To describe the different fare media that can be employed to use fare products. Fare media are physical or virtual holders used for the representation and/or validation of a fare product.
1005+
fields:
1006+
- name: "fare_media_id"
1007+
required: true
1008+
inputType: GTFS_ID
1009+
- name: "fare_media_name"
1010+
required: false
1011+
inputType: TEXT
1012+
- name: "fare_media_type"
1013+
required: false
1014+
inputType: DROPDOWN
1015+
bulkEditEnabled: true
1016+
options:
1017+
- value: '0'
1018+
text: 'None (0)'
1019+
- value: '1'
1020+
text: 'Physical paper ticket (1)'
1021+
- value: '2'
1022+
text: 'Physical transit card (2)'
1023+
- value: '3'
1024+
text: 'cEMV (3)'
1025+
- value: '4'
1026+
text: 'Mobile app (4)'
1027+
1028+
- id: fare_products
1029+
name: fare_products.txt
1030+
helpContent: Used to describe the range of fares available for purchase by riders or taken into account when computing the total fare for journeys with multiple legs, such as transfer costs.
1031+
fields:
1032+
- name: "fare_product_id"
1033+
required: true
1034+
inputType: GTFS_ID
1035+
- name: "fare_product_name"
1036+
required: false
1037+
inputType: TEXT
1038+
- name: "fare_media_id"
1039+
required: false
1040+
inputType: GTFS_ID
1041+
- name: "amount"
1042+
required: true
1043+
inputType: NUMBER
1044+
- name: "currency"
1045+
required: true
1046+
inputType: DROPDOWN
1047+
bulkEditEnabled: true
1048+
options:
1049+
- value: USD
1050+
text: US dollar (USD)
1051+
- value: AUD
1052+
text: Australian dollar (AUD)
1053+
- value: CAD
1054+
text: Canadian dollar (CAD)
1055+
- value: CHF
1056+
text: Swiss franc (CHF)
1057+
- value: CNH
1058+
text: Chinese renminbi (CNH)
1059+
- value: EUR
1060+
text: Euro (EUR)
1061+
- value: GBP
1062+
text: Pound sterling (GBP)
1063+
- value: JPY
1064+
text: Japanese yen (JPY)
1065+
- value: MXN
1066+
text: Mexican peso (MXN)
1067+
- value: NZD
1068+
text: New Zealand dollar (NZD)
1069+
- value: SEK
1070+
text: Swedish krona (SEK)
1071+
columnWidth: 12
1072+
helpContent: "The currency field defines the currency used to pay the fare. Please use the ISO 4217 alphabetical currency codes which can be found at the following URL:http://en.wikipedia.org/wiki/ISO_4217."
1073+
10021074
- id: frequencies
10031075
name: frequencies.txt
10041076
helpContent: Headway (time between trips) for routes with variable frequency of service.
@@ -1147,4 +1219,3 @@
11471219
- name: service_id
11481220
required: true
11491221

1150-

lib/editor/actions/editor.js

+6
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ export function fetchBaseGtfs ({
498498
id
499499
fare_id
500500
}
501+
fareMedia {
502+
fare_media_id
503+
fare_media_name
504+
fare_media_type
505+
id
506+
}
501507
routes (limit: -1) {
502508
id
503509
route_id

lib/editor/components/EditorSidebar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class EditorSidebar extends Component<Props> {
1919
messages = getComponentMessages('EditorSidebar')
2020

2121
isActive (item: GtfsIcon, component: string) {
22-
return component === item.id || (component === 'scheduleexception' && item.id === 'calendar')
22+
return component === item.id || (component === 'scheduleexception' && item.id === 'calendar') || (component === 'faresv2' && item.id === 'fare')
2323
}
2424

2525
render () {

lib/editor/components/EntityListSecondaryActions.js

+33-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import React, {Component} from 'react'
44
import { Nav, NavItem } from 'react-bootstrap'
55

66
import * as activeActions from '../actions/active'
7-
import VirtualizedEntitySelect from './VirtualizedEntitySelect'
8-
97
import type {Entity, Feed} from '../../types'
108

9+
import VirtualizedEntitySelect from './VirtualizedEntitySelect'
10+
1111
type Props = {
1212
activeComponent: string,
1313
activeEntity: Entity,
@@ -97,6 +97,18 @@ export default class EntityListSecondaryActions extends Component<Props> {
9797
}
9898
}
9999

100+
_onSelectFaresv1 = () => {
101+
if (this.props.activeComponent !== 'fare') {
102+
this.props.setActiveEntity(this.props.feedSource.id, 'fare')
103+
}
104+
}
105+
106+
_onSelectFaresv2 = () => {
107+
if (this.props.activeComponent !== 'faresv2') {
108+
this.props.setActiveEntity(this.props.feedSource.id, 'faresv2')
109+
}
110+
}
111+
100112
render () {
101113
const {
102114
activeComponent,
@@ -135,6 +147,25 @@ export default class EntityListSecondaryActions extends Component<Props> {
135147
entities={entities}
136148
onChange={this._onChangeEntity} />
137149
)
150+
case 'fare':
151+
return (
152+
<Nav
153+
style={{marginBottom: '5px'}}
154+
bsStyle='pills'
155+
justified
156+
activeKey={activeComponent}>
157+
<NavItem
158+
eventKey={'fare'}
159+
onClick={this._onSelectFaresv1}>
160+
Fares v1
161+
</NavItem>
162+
<NavItem
163+
eventKey={'faresv2'}
164+
onClick={this._onSelectFaresv2}>
165+
Fares v2
166+
</NavItem>
167+
</Nav>
168+
)
138169
default:
139170
return null
140171
}

lib/editor/util/gtfs.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const COMPONENT_LIST = [
2727
{ id: 'route', tableName: 'routes' },
2828
{ id: 'stop', tableName: 'stops' },
2929
{ id: 'fare', tableName: 'fares' },
30+
{ id: 'faresv2', tableName: 'fareMedia' },
3031
{ id: 'feedinfo', tableName: 'feed_info' },
3132
// FIXME: table name for calendar, fare, and schedule exception
3233
{ id: 'calendar', tableName: 'calendar' },

lib/editor/util/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ export function getEditorTable (component: string) {
147147
if (!spec) {
148148
throw new Error('Editor spec could not be found!')
149149
}
150+
console.log('gtfs spec::::', spec)
151+
if (component === 'faresv2') {
152+
return spec.find(t => t.id === 'fare_products')
153+
}
150154
return spec.find(
151155
t =>
152156
component === 'fare' ? t.id === 'fare_attributes' : t.id === component

lib/types/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,20 @@ export type GtfsFare = {|
681681
transfers: number
682682
|}
683683

684+
export type GtfsFareProduct = {
685+
amount: number,
686+
currency: string,
687+
fare_media_id: ?number,
688+
fare_product_id: number,
689+
fare_product_name: ?string
690+
}
691+
692+
export type GtfsFareMedia = {
693+
fare_media_id: number,
694+
fare_media_name: ?string,
695+
fare_media_type: string
696+
}
697+
684698
export type GtfsSpecField = {
685699
adminOnly?: boolean,
686700
bulkEditEnabled?: boolean,

lib/types/reducers.js

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ export type EditorTables = {
121121
id: number,
122122
service_id: string
123123
}>,
124+
fareMedia: Array<{
125+
fare_media_id: string,
126+
fare_media_name?: string,
127+
fare_media_type: string
128+
}>,
124129
fares: Array<{
125130
fare_id: string,
126131
id: number,

0 commit comments

Comments
 (0)