Skip to content

Commit

Permalink
fix(editor): add default route type and color to feed info
Browse files Browse the repository at this point in the history
fixes #95
  • Loading branch information
landonreed committed May 6, 2018
1 parent c82c5ff commit 89ecc70
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 2 additions & 3 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
inputType: DATE
columnWidth: 12
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."
- name: color
- name: default_route_color
displayName: Default color
datatools: true
required: false
inputType: COLOR
columnWidth: 6
# helpContent: "The stop_lat field contains the latitude of a stop or station. The field value must be a valid WGS 84 latitude."
- name: defaultRouteType
- name: default_route_type
displayName: Default route type
datatools: true
columnWidth: 6
Expand Down
2 changes: 2 additions & 0 deletions lib/editor/actions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export function fetchBaseGtfs ({namespace, component, newId, activeEntityId, fee
feed_start_date
feed_end_date
feed_version
default_route_color
default_route_type
}
agency {
id
Expand Down
8 changes: 5 additions & 3 deletions lib/editor/util/gtfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ export const generateProps = (component: string, editorState: any): any => {
const agencies = getTableById(editorState.data.tables, 'agency', false)
// FIXME: Should this be the agency_id field or ID
const agencyId = agencies && agencies[0] ? agencies[0].agency_id : null
const routeColor = generateRandomColor()
const routeColor = feedInfo && feedInfo.default_route_color
? feedInfo.default_route_color
: generateRandomColor()
return {
route_id: generateUID(),
agency_id: agencyId,
Expand All @@ -142,8 +144,8 @@ export const generateProps = (component: string, editorState: any): any => {
route_text_color: idealTextColor(routeColor),
publicly_visible: 0, // not public
status: 0, // IN_PROGRESS
route_type: feedInfo && feedInfo.defaultRouteType !== null
? feedInfo.defaultRouteType
route_type: feedInfo && feedInfo.default_route_type !== null
? feedInfo.default_route_type
: 3
}
case 'stop':
Expand Down
9 changes: 4 additions & 5 deletions lib/gtfs/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
fields = table
? table.fields
// Only filter required fields if not fetching for editor
// FIXME: This fetches only the required fields for feed info because there
// are missing fields in the GraphQL schema and database (default color and
// default route type).
.filter(field => type === 'feedinfo' ? !field.datatools : editor ? field : field.required && !field.datatools)
.filter(field => editor
// Include all fields for the editor.
? field
: field.required && !field.datatools)
.map(field => field.name)
.join('\n')
: ''
// stop_times are a special case because they must be requested as a
// nested list underneath a trip
console.log(type)
const shapeFields = `shape_points: shape (limit: -1) {
shape_pt_lon
shape_pt_lat
Expand Down

0 comments on commit 89ecc70

Please sign in to comment.