-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from SmartColumbusOS/smrt-1245
Smrt 1245 - Accepts url params for route filtering
- Loading branch information
Showing
26 changed files
with
1,702 additions
and
618 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import React from 'react' | ||
import COTAPositionMap from './components/cota-position-map' | ||
import RouteFilter from './components/route-filter' | ||
import DropdownRouteFilter from './components/dropdown-route-filter' | ||
import UrlRouteFilter from './components/url-route-filter' | ||
import Header from './components/header' | ||
import { HashRouter as Router, Route } from 'react-router-dom' | ||
|
||
import './App.scss' | ||
|
||
export default () => ( | ||
<main-app-element> | ||
<Header /> | ||
<div className='main-content'> | ||
<RouteFilter /> | ||
<COTAPositionMap /> | ||
<Router> | ||
<DropdownRouteFilter /> | ||
<Route path='/:routeId?' component={UrlRouteFilter} /> | ||
<COTAPositionMap /> | ||
</Router> | ||
</div> | ||
</main-app-element> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
import { applyStreamFilter, fetchAvailableRoutes } from '../../actions' | ||
import DropdownRouteFilter from './dropdown-route-filter' | ||
import _ from 'lodash' | ||
|
||
const mapStateToProps = state => ({ | ||
availableRoutes: state.availableRoutes, | ||
selectedRouteId: _.first(state.filter) | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => bindActionCreators({ applyStreamFilter, fetchAvailableRoutes }, dispatch) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DropdownRouteFilter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...components/route-filter/route-filter.scss → ...n-route-filter/dropdown-route-filter.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import DropdownRouteFilter from './connect' | ||
|
||
export default DropdownRouteFilter |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
import { applyStreamFilter, fetchAvailableRoutes } from '../../actions' | ||
import UrlRouteFilter from './url-route-filter' | ||
import _ from 'lodash' | ||
|
||
const mapStateToProps = state => ({ | ||
availableRoutes: state.availableRoutes, | ||
selectedRouteId: _.first(state.filter) | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => bindActionCreators({ applyStreamFilter, fetchAvailableRoutes }, dispatch) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(UrlRouteFilter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import UrlRouteFilter from './connect' | ||
|
||
export default UrlRouteFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import _ from 'lodash' | ||
|
||
const CMAX_LINE_NUMBER = '101' | ||
|
||
export default class extends React.Component { | ||
componentDidMount = () => { | ||
this.props.fetchAvailableRoutes() | ||
} | ||
|
||
updateUrl = (id) => { | ||
return this.props.history.push(id) | ||
} | ||
|
||
updateState = (id) => { | ||
return this.props.applyStreamFilter([id]) | ||
} | ||
|
||
routeIsNotValid = (id) => { | ||
return _.find(this.props.availableRoutes, { value: id }) === undefined | ||
} | ||
|
||
componentDidUpdate = (previousProps) => { | ||
const { selectedRouteId, match: { params: { routeId: urlRouteId } } } = this.props | ||
|
||
const stateAndUrlOutOfSync = selectedRouteId !== urlRouteId | ||
const stateWasUpdated = selectedRouteId !== previousProps.selectedRouteId | ||
|
||
if (this.routeIsNotValid(urlRouteId)) { | ||
this.updateState(CMAX_LINE_NUMBER) | ||
return this.updateUrl(CMAX_LINE_NUMBER) | ||
} | ||
|
||
if (stateAndUrlOutOfSync) { | ||
if (stateWasUpdated) { | ||
return this.updateUrl(selectedRouteId) | ||
} else { | ||
return this.updateState(urlRouteId) | ||
} | ||
} | ||
} | ||
|
||
render = () => { | ||
return <url-route-filter /> | ||
} | ||
} |
Oops, something went wrong.