diff --git a/js/actions/piece_list_actions.js b/js/actions/piece_list_actions.js index 87304ca7..f4231a0b 100644 --- a/js/actions/piece_list_actions.js +++ b/js/actions/piece_list_actions.js @@ -22,10 +22,10 @@ class PieceListActions { this.actions.updatePieceList({ page, pageSize, - search, orderBy, orderAsc, filterBy, + search: '', pieceList: [], pieceListCount: -1, unfilteredPieceListCount: -1 diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js index d2c3265f..8f65fb31 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js @@ -11,6 +11,7 @@ let PieceListToolbar = React.createClass({ propTypes: { className: React.PropTypes.string, searchFor: React.PropTypes.func, + searchQuery: React.PropTypes.string, filterParams: React.PropTypes.arrayOf( React.PropTypes.shape({ label: React.PropTypes.string, @@ -61,7 +62,7 @@ let PieceListToolbar = React.createClass({ }, render() { - const { className, children, searchFor } = this.props; + const { className, children, searchFor, searchQuery } = this.props; return (
@@ -74,7 +75,8 @@ let PieceListToolbar = React.createClass({ + searchQuery={searchQuery} + threshold={500}/> {this.getOrderWidget()} {this.getFilterWidget()} diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 35dcaba0..908c2821 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -157,6 +157,7 @@ let PieceList = React.createClass({ { + const { timers } = this.state; + + if(timers.length <= timerIndex + 1) { + // clean the timers array + this.setState({ timers: [], searching: true }, () => { + // search for the query + this.props.searchFor(searchQuery); + }); + } + }; }, handleChange({ target: { value }}) { this.startTimers(value); - this.setState({ currentSearchQuery: value }); + this.setState({ searchQuery: value }); }, render() { - const searchIcon = ; + let searchIcon = ; const { className } = this.props; + const { searching } = this.state; + + if(searching) { + searchIcon = ; + } return (