Skip to content

Commit 89ecc70

Browse files
committed
fix(editor): add default route type and color to feed info
fixes #95
1 parent c82c5ff commit 89ecc70

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

gtfs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
inputType: DATE
2929
columnWidth: 12
3030
helpContent: "The feed provides complete and reliable schedule information for service in the period from the beginning of the feed_start_date day to the end of the feed_end_date day. Both days are given as dates in YYYYMMDD format as for calendar.txt, or left empty if unavailable. The feed_end_date date must not precede the feed_start_date date if both are given. Feed providers are encouraged to give schedule data outside this period to advise of likely future service, but feed consumers should treat it mindful of its non-authoritative status. If feed_start_date or feed_end_date extend beyond the active calendar dates defined in calendar.txt and calendar_dates.txt, the feed is making an explicit assertion that there is no service for dates within the feed_start_date or feed_end_date range but not included in the active calendar dates."
31-
- name: color
31+
- name: default_route_color
3232
displayName: Default color
3333
datatools: true
3434
required: false
3535
inputType: COLOR
3636
columnWidth: 6
37-
# helpContent: "The stop_lat field contains the latitude of a stop or station. The field value must be a valid WGS 84 latitude."
38-
- name: defaultRouteType
37+
- name: default_route_type
3938
displayName: Default route type
4039
datatools: true
4140
columnWidth: 6

lib/editor/actions/editor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ export function fetchBaseGtfs ({namespace, component, newId, activeEntityId, fee
283283
feed_start_date
284284
feed_end_date
285285
feed_version
286+
default_route_color
287+
default_route_type
286288
}
287289
agency {
288290
id

lib/editor/util/gtfs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ export const generateProps = (component: string, editorState: any): any => {
132132
const agencies = getTableById(editorState.data.tables, 'agency', false)
133133
// FIXME: Should this be the agency_id field or ID
134134
const agencyId = agencies && agencies[0] ? agencies[0].agency_id : null
135-
const routeColor = generateRandomColor()
135+
const routeColor = feedInfo && feedInfo.default_route_color
136+
? feedInfo.default_route_color
137+
: generateRandomColor()
136138
return {
137139
route_id: generateUID(),
138140
agency_id: agencyId,
@@ -142,8 +144,8 @@ export const generateProps = (component: string, editorState: any): any => {
142144
route_text_color: idealTextColor(routeColor),
143145
publicly_visible: 0, // not public
144146
status: 0, // IN_PROGRESS
145-
route_type: feedInfo && feedInfo.defaultRouteType !== null
146-
? feedInfo.defaultRouteType
147+
route_type: feedInfo && feedInfo.default_route_type !== null
148+
? feedInfo.default_route_type
147149
: 3
148150
}
149151
case 'stop':

lib/gtfs/util/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
4646
fields = table
4747
? table.fields
4848
// Only filter required fields if not fetching for editor
49-
// FIXME: This fetches only the required fields for feed info because there
50-
// are missing fields in the GraphQL schema and database (default color and
51-
// default route type).
52-
.filter(field => type === 'feedinfo' ? !field.datatools : editor ? field : field.required && !field.datatools)
49+
.filter(field => editor
50+
// Include all fields for the editor.
51+
? field
52+
: field.required && !field.datatools)
5353
.map(field => field.name)
5454
.join('\n')
5555
: ''
5656
// stop_times are a special case because they must be requested as a
5757
// nested list underneath a trip
58-
console.log(type)
5958
const shapeFields = `shape_points: shape (limit: -1) {
6059
shape_pt_lon
6160
shape_pt_lat

0 commit comments

Comments
 (0)