Skip to content

Commit 7d9e556

Browse files
feat(gtfs): add initial CRUD for fare_products
1 parent f044bbb commit 7d9e556

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

gtfs.yml

+20
Original file line numberDiff line numberDiff line change
@@ -1017,3 +1017,23 @@
10171017
required: false
10181018
- name: added_service
10191019
required: false
1020+
1021+
- id: fare_products
1022+
name: fare_products.txt
1023+
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.
1024+
fields:
1025+
- name: fare_product_id
1026+
required: true
1027+
inputType: GTFS_ID
1028+
- name: fare_product_name
1029+
required: false
1030+
inputType: TEXT
1031+
- name: fare_product_id
1032+
required: false
1033+
inputType: TEXT # FARE-TODO: Needs to reference an actual fare media id. need custom type
1034+
- name: amount
1035+
inputType: NUMBER
1036+
required: true
1037+
- name: currency
1038+
required: true
1039+
inputType: TEXT # FARE-TODO: Dropdownx

lib/editor/actions/editor.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,13 @@ export function fetchBaseGtfs ({
498498
id
499499
fare_id
500500
}
501+
fare_product (limit: -1) {
502+
id
503+
fare_product_id
504+
}
501505
routes (limit: -1) {
502506
id
503-
route_id
507+
route_id
504508
route_short_name
505509
route_long_name
506510
# Ensure that we know route type when setting active entity (for edit

lib/editor/util/gtfs.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const COMPONENT_LIST = [
3131
// FIXME: table name for calendar, fare, and schedule exception
3232
{ id: 'calendar', tableName: 'calendar' },
3333
{ id: 'scheduleexception', tableName: 'schedule_exceptions' },
34-
{ id: 'agency', tableName: 'agency' }
34+
{ id: 'agency', tableName: 'agency' },
35+
{ id: 'fare_product', tableName: 'fare_products' }
3536
]
3637

3738
export function getTableById (tableData: any, id?: string, emptyArrayOnNull: boolean = true): any {
@@ -240,7 +241,9 @@ export function getEntityName (entity: any): string {
240241
nameKey = 'description'
241242
} else if (typeof entity.fare_id !== 'undefined') {
242243
nameKey = 'fare_id'
243-
} else if (typeof entity.exemplar !== 'undefined') {
244+
} else if (typeof entity.fare_product_id !== 'undefined') {
245+
nameKey = 'fare_product_id'
246+
} if (typeof entity.exemplar !== 'undefined') {
244247
nameKey = 'name'
245248
}
246249

lib/editor/util/ui.js

+8
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ export const GTFS_ICONS = [
7373
addable: true,
7474
title: messages('fare.title'),
7575
label: messages('fare.label')
76+
},
77+
{
78+
id: 'fare_product',
79+
tableName: 'fare_products',
80+
icon: 'ticket',
81+
addable: true,
82+
title: 'FARE PRODUCTS TEST TITLE',
83+
label: 'FARE PRODUCTS TEST LABEL'
7684
}
7785
]
7886

lib/gtfs/util/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export function getEntityIdField (type: string): string {
1515
return 'agency_id'
1616
case 'fare':
1717
return 'fare_id'
18+
case 'fare_product':
19+
return 'fare_product_id'
1820
case 'calendar':
1921
return 'service_id'
2022
case 'stop':
@@ -103,6 +105,10 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
103105
contains_id
104106
}
105107
`
108+
case 'fare_product':
109+
return `
110+
${fields}
111+
`
106112
case 'pattern':
107113
return `
108114
shape_id
@@ -142,6 +148,8 @@ export function getEntityGraphQLRoot (type: string): string {
142148
return 'calendar'
143149
case 'fare':
144150
return 'fares'
151+
case 'fare_product':
152+
return 'fare_products'
145153
case 'feedinfo':
146154
return 'feed_info'
147155
case 'stop':
@@ -175,6 +183,8 @@ export function getEntityTableString (type: string): string {
175183
return 'calendar'
176184
case 'fare':
177185
return 'fare_attributes'
186+
case 'fare_product':
187+
return 'fare_products'
178188
case 'fare_rules':
179189
return 'fare_rules'
180190
case 'feedinfo':

lib/types/reducers.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ export type EditorTables = {
121121
id: number,
122122
service_id: string
123123
}>,
124+
fare_products: Array<{}>,
124125
fares: Array<{
125126
fare_id: string,
126127
id: number,
127-
}>,
128+
}>, // TODO: Do this
128129
feed_info: Array<{
129130
default_route_color: ?any,
130131
default_route_type: ?any,

0 commit comments

Comments
 (0)