Skip to content

Commit

Permalink
start adding support for faresMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-willis-arcadis committed Nov 6, 2024
1 parent 3801386 commit dcc9bf7
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 5 deletions.
75 changes: 73 additions & 2 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
helpContent: Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.
- name: network_id
columnWidth: 12
helpContent: "The network_id field contains an ID that uniquely identifies a transit network."
helpContent: "The network_id field contains an ID that uniquely identifies a transit network. Forbidden if the route_networks.txt file exists."
inputType: TEXT
- name: wheelchair_accessible
required: false
Expand Down Expand Up @@ -999,6 +999,78 @@
- name: "to_network_id"
required: false

- id: fare_media
name: fare_media.txt
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.
fields:
- name: "fare_media_id"
required: true
inputType: GTFS_ID
- name: "fare_media_name"
required: false
inputType: TEXT
- name: "fare_media_type"
required: false
inputType: DROPDOWN
bulkEditEnabled: true
options:
- value: '0'
text: 'None (0)'
- value: '1'
text: 'Physical paper ticket (1)'
- value: '2'
text: 'Physical transit card (2)'
- value: '3'
text: 'cEMV (3)'
- value: '4'
text: 'Mobile app (4)'

- id: fare_products
name: fare_products.txt
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.
fields:
- name: "fare_product_id"
required: true
inputType: GTFS_ID
- name: "fare_product_name"
required: false
inputType: TEXT
- name: "fare_media_id"
required: false
inputType: GTFS_ID
- name: "amount"
required: true
inputType: NUMBER
- name: "currency"
required: true
inputType: DROPDOWN
bulkEditEnabled: true
options:
- value: USD
text: US dollar (USD)
- value: AUD
text: Australian dollar (AUD)
- value: CAD
text: Canadian dollar (CAD)
- value: CHF
text: Swiss franc (CHF)
- value: CNH
text: Chinese renminbi (CNH)
- value: EUR
text: Euro (EUR)
- value: GBP
text: Pound sterling (GBP)
- value: JPY
text: Japanese yen (JPY)
- value: MXN
text: Mexican peso (MXN)
- value: NZD
text: New Zealand dollar (NZD)
- value: SEK
text: Swedish krona (SEK)
columnWidth: 12
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."

- id: frequencies
name: frequencies.txt
helpContent: Headway (time between trips) for routes with variable frequency of service.
Expand Down Expand Up @@ -1147,4 +1219,3 @@
- name: service_id
required: true


6 changes: 6 additions & 0 deletions lib/editor/actions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@ export function fetchBaseGtfs ({
id
fare_id
}
fareMedia {
fare_media_id
fare_media_name
fare_media_type
id
}
routes (limit: -1) {
id
route_id
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/components/EditorSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class EditorSidebar extends Component<Props> {
messages = getComponentMessages('EditorSidebar')

isActive (item: GtfsIcon, component: string) {
return component === item.id || (component === 'scheduleexception' && item.id === 'calendar')
return component === item.id || (component === 'scheduleexception' && item.id === 'calendar') || (component === 'faresv2' && item.id === 'fare')
}

render () {
Expand Down
35 changes: 33 additions & 2 deletions lib/editor/components/EntityListSecondaryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import React, {Component} from 'react'
import { Nav, NavItem } from 'react-bootstrap'

import * as activeActions from '../actions/active'
import VirtualizedEntitySelect from './VirtualizedEntitySelect'

import type {Entity, Feed} from '../../types'

import VirtualizedEntitySelect from './VirtualizedEntitySelect'

type Props = {
activeComponent: string,
activeEntity: Entity,
Expand Down Expand Up @@ -97,6 +97,18 @@ export default class EntityListSecondaryActions extends Component<Props> {
}
}

_onSelectFaresv1 = () => {
if (this.props.activeComponent !== 'fare') {
this.props.setActiveEntity(this.props.feedSource.id, 'fare')
}
}

_onSelectFaresv2 = () => {
if (this.props.activeComponent !== 'faresv2') {
this.props.setActiveEntity(this.props.feedSource.id, 'faresv2')
}
}

render () {
const {
activeComponent,
Expand Down Expand Up @@ -135,6 +147,25 @@ export default class EntityListSecondaryActions extends Component<Props> {
entities={entities}
onChange={this._onChangeEntity} />
)
case 'fare':
return (
<Nav
style={{marginBottom: '5px'}}
bsStyle='pills'
justified
activeKey={activeComponent}>
<NavItem
eventKey={'fare'}
onClick={this._onSelectFaresv1}>
Fares v1
</NavItem>
<NavItem
eventKey={'faresv2'}
onClick={this._onSelectFaresv2}>
Fares v2
</NavItem>
</Nav>
)
default:
return null
}
Expand Down
1 change: 1 addition & 0 deletions lib/editor/util/gtfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const COMPONENT_LIST = [
{ id: 'route', tableName: 'routes' },
{ id: 'stop', tableName: 'stops' },
{ id: 'fare', tableName: 'fares' },
{ id: 'faresv2', tableName: 'fareMedia' },
{ id: 'feedinfo', tableName: 'feed_info' },
// FIXME: table name for calendar, fare, and schedule exception
{ id: 'calendar', tableName: 'calendar' },
Expand Down
4 changes: 4 additions & 0 deletions lib/editor/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export function getEditorTable (component: string) {
if (!spec) {
throw new Error('Editor spec could not be found!')
}
console.log('gtfs spec::::', spec)
if (component === 'faresv2') {
return spec.find(t => t.id === 'fare_products')
}
return spec.find(
t =>
component === 'fare' ? t.id === 'fare_attributes' : t.id === component
Expand Down
14 changes: 14 additions & 0 deletions lib/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,20 @@ export type GtfsFare = {|
transfers: number
|}

export type GtfsFareProduct = {
amount: number,
currency: string,
fare_media_id: ?number,
fare_product_id: number,
fare_product_name: ?string
}

export type GtfsFareMedia = {
fare_media_id: number,
fare_media_name: ?string,
fare_media_type: string
}

export type GtfsSpecField = {
adminOnly?: boolean,
bulkEditEnabled?: boolean,
Expand Down
5 changes: 5 additions & 0 deletions lib/types/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ export type EditorTables = {
id: number,
service_id: string
}>,
fareMedia: Array<{
fare_media_id: string,
fare_media_name?: string,
fare_media_type: string
}>,
fares: Array<{
fare_id: string,
id: number,
Expand Down

0 comments on commit dcc9bf7

Please sign in to comment.