Skip to content

Commit

Permalink
fix(gtfs-plus): fix visibility filter
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed Jan 10, 2019
1 parent 96b2f7d commit 4036302
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/gtfsplus/actions/gtfsplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {getGtfsPlusSpec} from '../../common/util/config'
import {uploadFile} from '../../common/util/upload-file'
import {stopsAndRoutes, compose} from '../../gtfs/util/graphql'
import {getHeaders} from '../../common/util/util'
import {VISIBILITY} from '../components/GtfsPlusTable'
import {startJobMonitor} from '../../manager/actions/status'
import {fetchFeedVersions} from '../../manager/actions/versions'

Expand Down Expand Up @@ -59,7 +60,7 @@ export const setCurrentPage = createAction(
)
export const setVisibilityFilter = createAction(
'SET_GTFSPLUS_VISIBILITY',
(payload: { visibility: boolean }) => payload
(payload: { visibility: $Values<typeof VISIBILITY> }) => payload
)
export const updateGtfsPlusField = createAction(
'UPDATE_GTFSPLUS_FIELD',
Expand Down
19 changes: 13 additions & 6 deletions lib/gtfsplus/components/GtfsPlusTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export type Props = GtfsPlusEditorProps & {
tableValidation: Array<any>
}

export const VISIBILITY = Object.freeze({
ALL: 'all',
VALIDATION: 'validation'
})

export default class GtfsPlusTable extends Component<Props> {
componentDidMount () {
this.props.newRowsDisplayed(this.props.rows)
Expand All @@ -27,10 +32,12 @@ export default class GtfsPlusTable extends Component<Props> {
componentDidUpdate () {
this.props.newRowsDisplayed(this.props.rows)
}

_onChangeVisibleRows = (evt: SyntheticInputEvent<HTMLInputElement>) =>
this.props.setVisibilityFilter({visibility: !!evt.target.value})

_onChangeVisibleRows = (evt: SyntheticInputEvent<HTMLInputElement>) => {
const {setVisibilityFilter} = this.props
const visibility = evt.target.value
// $FlowFixMe: This should be one of $Values<typeof VISIBILITY>
setVisibilityFilter({visibility})
}
_onClickNewRow = () => this.props.addGtfsPlusRow({tableId: this.props.table.id})

_onClickShowTableHelp = () => this.props.showHelpClicked(this.props.table.id)
Expand Down Expand Up @@ -114,8 +121,8 @@ export default class GtfsPlusTable extends Component<Props> {
componentClass='select'
value={visibility}
onChange={this._onChangeVisibleRows}>
<option value='all'>All Records</option>
<option value='validation'>Validation Issues Only</option>
<option value={VISIBILITY.ALL}>All Records</option>
<option value={VISIBILITY.VALIDATION}>Validation Issues Only</option>
</FormControl>
</span>
</div>
Expand Down

0 comments on commit 4036302

Please sign in to comment.