-
Notifications
You must be signed in to change notification settings - Fork 88
Updates to gtfs spec changes - front end UI fields only #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is a first draft at the changes, so there are a few console logs and other bits I will remove when completed. Just wanted to see if I was on the right track, and I have a few questions:
datatools-ui/lib/editor/util/validation.js Lines 259 to 271 in b299745
|
@robertgregg3 Not all paths in that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some bits of logic I am not sure to follow. If I got it wrong, then a code comment would help people follow the reasoning. Also see my refactoring suggestions so far and my comment for making the lint check pass.
lib/editor/util/validation.js
Outdated
console.log(idList.length) | ||
console.log({entity}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console statements.
lib/editor/util/validation.js
Outdated
) | ||
console.log(idList.length) | ||
console.log({entity}) | ||
if (agencies.length > 1 && entity.agency_id === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using valueDoesNotExist
, isOptionalAndEmpty
defined for the function that already checked for null
/undefined
/empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
if (isNotLat) { | ||
reason = 'Field must be valid latitude.' | ||
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the range check from isNotLat
be enforced here regardless of stop type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup it is being enforced regardless. Line 189 is the conditional for the location_type:
lib/editor/util/validation.js
Outdated
reason = 'Field must be valid latitude.' | ||
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason} | ||
} | ||
if (entity && entity.location_type >= 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<= 2
rather?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! 🤦♂️
lib/editor/util/validation.js
Outdated
reason = 'Field must be valid longitude.' | ||
return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason} | ||
} | ||
if (entity && entity.location_type >= 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<= 2
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! 🤦♂️
lib/editor/util/validation.js
Outdated
} | ||
if (entity && entity.location_type >= 2) { | ||
if (isOptionalAndEmpty) { | ||
reason = '1 Latitude and Longitude are required for your current location type' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove leading 1
lib/editor/util/validation.js
Outdated
} | ||
if (entity && entity.location_type >= 2) { | ||
if (isOptionalAndEmpty) { | ||
reason = '1 Latitude and Longitude are required for your current location type' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove leading 1
Codecov Report
@@ Coverage Diff @@
## dev #668 +/- ##
=======================================
Coverage 15.68% 15.68%
=======================================
Files 329 329
Lines 16797 16823 +26
Branches 5062 5071 +9
=======================================
+ Hits 2634 2639 +5
- Misses 12113 12133 +20
- Partials 2050 2051 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
lib/editor/util/validation.js
Outdated
return {field: name, invalid: isNotLat, reason} | ||
} | ||
if (entity && entity.location_type >= 2) { | ||
if (!locationType || locationType < 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the GTFS reference for the location types, I think the condition should be <= 2
: https://developers.google.com/transit/gtfs/reference#stopstxt
…rious GTFS changes and updates gtfs.yml
Added defult_lang, feed_contact_email, feed_contact_url #663
Reassign and request reviews when done, thanks! |
….js): Update to the GTFS Spec U Added the changes where applicable to the gtfs.yml file. Added the new types for continuous drop off/pick up and added fields as well as basic validation in the patternStopCard file. BREAKING CHANGE: There have been added fields that need to coincide with changes on the backend as the api will be looking for the new fields and those fields need to be present on the Front end #663
Removed spaces. Improved boolean ternary #663
@robertgregg3 there are still build errors, could you fix them, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like my previous comment regarding enforcing lat/lon values even for stop types that don't require it was not resolved? Also, the build needs to be fixed, and some long lines need to be broken out.
lib/editor/util/validation.js
Outdated
* Returns false if the value is ok. | ||
* Returns an EditorValidationIssue object if the value is not ok. | ||
*/ | ||
// eslint-disable-next-line complexity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an error-level eslint rule with our eslint config, however, I think there is a lot of value in having it warn the developer because having functions with tons of complexity will make code very difficult to read and maintain in the future. It's not your fault that this method is bloated in the first place, but it will significantly improve the future readability and maintainability of this code to refactor this method into smaller chunks right now.
Changed wheelchairBoarding to a string. Added continuous fields to the map.js. #663
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See formatting and refactoring suggestions.
componentClass='select' | ||
placeholder='select' | ||
disabled={hasShapeId} | ||
defaultValue={1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultValue
is no longer needed (we set the value
prop instead). (Also, sort props alphabetically)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! Thanks.
</FormGroup> | ||
</Col> | ||
<Col xs={6}> | ||
<FormGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend extracting this <FormGroup>
and its contents into a component and reuse in all 4 instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any progress on this one, by curiosity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation of stop_name is interfering with editing of stop data on existing feeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, sorry it fell off the radar due to lack of assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go after addressing this comment: #668 (comment)
Requested changes were added from #690.
…fields, address comments
fix(saveEntity, saveTripsForCalendar): Resolve missing defaults with GTFS spec changes
Relating to #663
Also fix #716, fix #717.