Skip to content

Commit

Permalink
feat(GtfsPlusField): remove case sensitivity for GTFS+ fields
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed May 30, 2017
1 parent 8944deb commit 84b6233
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/gtfsplus/components/GtfsPlusField.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ export default class GtfsPlusField extends Component {
table: PropTypes.object
}

_onChangeRoute = evt => {
_onChangeRoute = ({route}) => {
const {field, fieldEdited, gtfsEntitySelected, row, table} = this.props
fieldEdited(table.id, row, field.name, evt.route.route_id)
gtfsEntitySelected('route', evt.route)
fieldEdited(table.id, row, field.name, route.route_id)
gtfsEntitySelected('route', route)
}

_onChangeStop = evt => {
_onChangeStop = ({stop}) => {
const {field, fieldEdited, gtfsEntitySelected, row, table} = this.props
fieldEdited(table.id, row, field.name, evt.stop.stop_id)
gtfsEntitySelected('stop', evt.stop)
fieldEdited(table.id, row, field.name, stop.stop_id)
gtfsEntitySelected('stop', stop)
}

_onChangeValue = (value) => {
const {field, fieldEdited, row, table} = this.props
fieldEdited(table.id, row, field.name, value)
}

_onChange = evt => {
_onChange = ({target}) => {
const {field, fieldEdited, row, table} = this.props
fieldEdited(table.id, row, field.name, evt.target.value)
fieldEdited(table.id, row, field.name, target.value)
}

render () {
Expand All @@ -52,16 +52,19 @@ export default class GtfsPlusField extends Component {
onChange={this._onChangeValue} />
)
case 'DROPDOWN':
// NOTE: client has requested that GTFS+ fields be case insensitive (hence the toUpperCase call)
let option = currentValue !== null && field.options.find(o => o.value.toUpperCase() === currentValue.toUpperCase())
return (
<FormControl componentClass='select'
value={currentValue !== null ? currentValue : undefined}
value={option ? option.value : undefined}
onChange={this._onChange}>
{/* Add field for empty string value if that is not an allowable option so that user selection triggers onChange */}
{field.options.findIndex(option => option.value === '') === -1
? <option disabled value=''>{field.required ? '-- select an option --' : '(optional)' }</option>
: null
}
{field.options.map(option => {
// NOTE: client has requested that GTFS+ fields be case insensitive (hence the toLowerCase call)
return <option value={option.value} key={option.value}>
{option.text || option.value}
</option>
Expand Down

0 comments on commit 84b6233

Please sign in to comment.