1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Fix pagination on search bug

This commit is contained in:
Tim Daubenschütz 2015-06-16 09:27:04 +02:00
parent 7910384d99
commit 1ce9b90fff
3 changed files with 14 additions and 24 deletions

View File

@ -9,7 +9,6 @@ let Pagination = React.createClass({
goToPage: React.PropTypes.func.isRequired,
currentPage: React.PropTypes.number.isRequired,
totalPages: React.PropTypes.number.isRequired
//itemListCount: React.PropTypes.number.isRequired
},
render() {

View File

@ -2,37 +2,19 @@
import React from 'react';
import PieceListStore from '../../stores/piece_list_store';
import PieceListActions from '../../actions/piece_list_actions';
import Input from 'react-bootstrap/lib/Input';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
let PieceListToolbar = React.createClass({
propTypes: {
className: React.PropTypes.string
},
getInitialState() {
return PieceListStore.getState();
},
componentDidMount() {
PieceListStore.listen(this.onChange);
},
componentWillUnmount() {
PieceListStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
className: React.PropTypes.string,
searchFor: React.PropTypes.func
},
searchFor() {
let searchTerm = this.refs.search.getInputDOMNode().value;
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc);
this.props.searchFor(searchTerm);
},
render() {

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import Router from 'react-router';
import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions';
@ -20,6 +21,8 @@ let PieceList = React.createClass({
query: React.PropTypes.object
},
mixins: [Router.Navigation, Router.State],
getInitialState() {
return PieceListStore.getState();
},
@ -30,7 +33,6 @@ let PieceList = React.createClass({
if (this.state.pieceList.length === 0){
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
}
},
componentWillUnmount() {
@ -47,6 +49,11 @@ let PieceList = React.createClass({
this.state.orderAsc);
},
searchFor(searchTerm) {
PieceListActions.fetchPieceList(1, this.state.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc);
this.transitionTo(this.getPathname(), {page: 1});
},
accordionChangeOrder(orderBy, orderAsc) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize,
this.state.search, orderBy, orderAsc);
@ -58,7 +65,9 @@ let PieceList = React.createClass({
return (
<div>
<PieceListToolbar className="ascribe-piece-list-toolbar" />
<PieceListToolbar
className="ascribe-piece-list-toolbar"
searchFor={this.searchFor} />
<PieceListBulkModal className="ascribe-piece-list-bulk-modal" />
<AccordionList
className="ascribe-accordion-list"