From a9bedf710f6642b33a7b258bb2c39bd7c5abaf18 Mon Sep 17 00:00:00 2001 From: Josh Willis <168561922+josh-willis-arcadis@users.noreply.github.com> Date: Thu, 30 Jan 2025 13:22:42 -0600 Subject: [PATCH] add fare_media, fare_products fare_transfer_rule to sidebar to view data --- gtfs.yml | 59 ++++++++++++++++++++++++++++++++++-- lib/editor/actions/editor.js | 12 ++++++++ lib/editor/util/gtfs.js | 12 ++++++-- lib/editor/util/ui.js | 24 ++++++++++++--- lib/gtfs/util/index.js | 25 +++++++++++++-- lib/types/reducers.js | 6 ++-- 6 files changed, 124 insertions(+), 14 deletions(-) diff --git a/gtfs.yml b/gtfs.yml index 7de639e3e..9d13aac6c 100644 --- a/gtfs.yml +++ b/gtfs.yml @@ -1018,7 +1018,9 @@ - name: added_service required: false -- id: fare_products +# Fares v2 + +- id: fare_product 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: @@ -1028,7 +1030,7 @@ - name: fare_product_name required: false inputType: TEXT - - name: fare_product_id + - name: fare_media_id required: false inputType: TEXT # FARE-TODO: Needs to reference an actual fare media id. need custom type - name: amount @@ -1036,4 +1038,55 @@ required: true - name: currency required: true - inputType: TEXT # FARE-TODO: Dropdownx \ No newline at end of file + inputType: TEXT # FARE-TODO: Dropdownx +- 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 + inputType: TEXT + - name: fare_media_type + required: true + inputType: DROPDOWN + # FARE-TODO: Some help content? + options: + - value: '0' + - value: '1' + - value: '2' + - value: '3' + - value: '4' +- id: fare_transfer_rule + name: fare_transfer_rules.txt + helpContent: Fare rules for transfers between legs of travel defined in fare_leg_rules.txt. + fields: + - name: from_leg_group_id + required: false + inputType: TEXT # FARE-TODO: Needs to reference fare_leg_rules + - name: to_leg_group_id + required: false + inputType: TEXT # FARE-TODO: Needs to reference fare_leg_rules + - name: transfer_count + inputType: NUMBER # FARE-TODO: NON-ZERO INT + - name: duration_limit + inputType: POSITIVE_INT + - name: duration_limit_type + inputType: DROPDOWN + # FARE-TODO: Some help content? + options: + - value: '0' + - value: '1' + - value: '2' + - value: '3' + - name: fare_transfer_type + inputType: DROPDOWN + # FARE-TODO: Some help content? + options: + - value: '0' + - value: '1' + - value: '2' + - name: fare_product_id + required: false + inputType: TEXT # FARE-TODO: Needs to reference fare_products \ No newline at end of file diff --git a/lib/editor/actions/editor.js b/lib/editor/actions/editor.js index eb2dbaf26..5de1ab833 100644 --- a/lib/editor/actions/editor.js +++ b/lib/editor/actions/editor.js @@ -501,6 +501,18 @@ export function fetchBaseGtfs ({ fare_product (limit: -1) { id fare_product_id + fare_media_id + } + fare_media (limit: -1) { + id + fare_media_id + } + fare_transfer_rule (limit: -1) { + from_leg_group_id + to_leg_group_id + fare_product_id + transfer_count + duration_limit } routes (limit: -1) { id diff --git a/lib/editor/util/gtfs.js b/lib/editor/util/gtfs.js index 730724854..882710c31 100644 --- a/lib/editor/util/gtfs.js +++ b/lib/editor/util/gtfs.js @@ -32,7 +32,9 @@ export const COMPONENT_LIST = [ { id: 'calendar', tableName: 'calendar' }, { id: 'scheduleexception', tableName: 'schedule_exceptions' }, { id: 'agency', tableName: 'agency' }, - { id: 'fare_product', tableName: 'fare_products' } + { id: 'fare_product', tableName: 'fare_product' }, + { id: 'fare_media', tableName: 'fare_media' }, + { id: 'fare_transfer_rule', tableName: 'fare_transfer_rule' } ] export function getTableById (tableData: any, id?: string, emptyArrayOnNull: boolean = true): any { @@ -242,8 +244,12 @@ export function getEntityName (entity: any): string { } else if (typeof entity.fare_id !== 'undefined') { nameKey = 'fare_id' } else if (typeof entity.fare_product_id !== 'undefined') { - nameKey = 'fare_product_id' - } if (typeof entity.exemplar !== 'undefined') { + nameKey = 'fare_product_id' // FARE-TODO: fare_product_name? + } else if (typeof entity.fare_media_id !== 'undefined') { + nameKey = 'fare_media_id' // FARE-TODO: fare_media_name? Some combo? + } + // FARE-TODO: what to do with fare_transfer_rules.txt? + if (typeof entity.exemplar !== 'undefined') { nameKey = 'name' } diff --git a/lib/editor/util/ui.js b/lib/editor/util/ui.js index 28242758e..a311c874d 100644 --- a/lib/editor/util/ui.js +++ b/lib/editor/util/ui.js @@ -76,11 +76,27 @@ export const GTFS_ICONS = [ }, { id: 'fare_product', - tableName: 'fare_products', - icon: 'ticket', + tableName: 'fare_product', + icon: 'shopping-cart', + addable: true, + title: 'FARE PRODUCT TEST TITLE', + label: 'FARE PRODUCT TEST LABEL' + }, + { + id: 'fare_media', + tableName: 'fare_media', + icon: 'id-card', + addable: true, + title: 'FARE MEDIA TEST TITLE', + label: 'FARE MEDIA TEST LABEL' + }, + { + id: 'fare_transfer_rule', + tableName: 'fare_transfer_rule', + icon: 'link', addable: true, - title: 'FARE PRODUCTS TEST TITLE', - label: 'FARE PRODUCTS TEST LABEL' + title: 'FARE TRANSFER RULE TEST TITLE', + label: 'FARE TRANSFER RULE TEST LABEL' } ] diff --git a/lib/gtfs/util/index.js b/lib/gtfs/util/index.js index 39dbf3b5a..893edee14 100644 --- a/lib/gtfs/util/index.js +++ b/lib/gtfs/util/index.js @@ -17,6 +17,11 @@ export function getEntityIdField (type: string): string { return 'fare_id' case 'fare_product': return 'fare_product_id' + case 'fare_media': + return 'fare_media_id' + case 'fare_transfer_rule': + return 'id' + // FARE-TODO: what to do with fare_transfer_rules.txt case 'calendar': return 'service_id' case 'stop': @@ -109,6 +114,14 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false return ` ${fields} ` + case 'fare_media': + return ` + ${fields} + ` + case 'fare_transfer_rule': + return ` + ${fields} + ` case 'pattern': return ` shape_id @@ -149,7 +162,11 @@ export function getEntityGraphQLRoot (type: string): string { case 'fare': return 'fares' case 'fare_product': - return 'fare_products' + return 'fare_product' + case 'fare_media': + return 'fare_media' + case 'fare_transer_rule': + return 'fare_transfer_rule' case 'feedinfo': return 'feed_info' case 'stop': @@ -184,9 +201,13 @@ export function getEntityTableString (type: string): string { case 'fare': return 'fare_attributes' case 'fare_product': - return 'fare_products' + return 'fare_product' + case 'fare_media': + return 'fare_media' case 'fare_rules': return 'fare_rules' + case 'fare_transfer_rule': + return 'fare_transfer_rules' case 'feedinfo': return 'feedinfo' case 'stop': diff --git a/lib/types/reducers.js b/lib/types/reducers.js index b1c7ceb4e..e31e7a2e0 100644 --- a/lib/types/reducers.js +++ b/lib/types/reducers.js @@ -121,11 +121,13 @@ export type EditorTables = { id: number, service_id: string }>, - fare_products: Array<{}>, + fare_media: Array<{}>, // FARE-TODO: Do this + fare_product: Array<{}>, // FARE-TODO: Do this + fare_transfer_rule: Array<{}>, // FARE-TODO: Do this fares: Array<{ fare_id: string, id: number, - }>, // TODO: Do this + }>, feed_info: Array<{ default_route_color: ?any, default_route_type: ?any,