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

Make Table component more generic

This commit is contained in:
Tim Daubenschütz 2015-05-22 11:33:38 +02:00
parent 29d9572a37
commit 2c3b7c3025
4 changed files with 16 additions and 11 deletions

View File

@ -10,7 +10,7 @@ class PieceListActions {
);
}
fetchList(page, pageSize, search, orderBy, orderAsc) {
fetchPieceList(page, pageSize, search, orderBy, orderAsc) {
PieceListFetcher
.fetch(page, pageSize, search, orderBy, orderAsc)
.then((res) => {
@ -20,7 +20,7 @@ class PieceListActions {
search,
orderBy,
orderAsc,
'itemList': res.pieces
'pieceList': res.pieces
});
})
.catch((err) => {

View File

@ -12,8 +12,6 @@ let Table = React.createClass({
},
render() {
console.log(this.props);
if(this.props.itemList && this.props.itemList.length > 0) {
return (
<div className="ascribe-table">

View File

@ -22,7 +22,7 @@ let PieceList = React.createClass({
componentDidMount() {
let page = this.props.query.page || this.state.page;
PieceListActions.fetchList(page, this.state.pageSize, this.state.search,
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search,
this.state.orderBy, this.state.orderAsc);
},
@ -37,9 +37,16 @@ let PieceList = React.createClass({
<AltContainer
store={PieceListStore}
actions={PieceListActions}
transform={(x) => {
console.log('@@@@@@@', x);
return { a: 1, b: 2 };
transform={(props) => {
return {
'itemList': props.pieceList,
'fetchList': props.fetchPieceList,
'orderBy': props.orderBy,
'orderAsc': props.orderAsc,
'search': props.search,
'page': props.page,
'pageSize': props.pageSize
}
}}>
<Table columnList={columnList} />
<Pagination currentPage={this.props.query.page} />

View File

@ -4,7 +4,7 @@ import PieceListActions from '../actions/piece_list_actions';
class PieceListStore {
constructor() {
this.itemList = []; // rename this to pieceList after figuring out AltContainer transform
this.pieceList = []; // rename this to pieceList after figuring out AltContainer transform
this.page = 1;
this.pageSize = 10;
this.search = "";
@ -13,13 +13,13 @@ class PieceListStore {
this.bindActions(PieceListActions);
}
onUpdatePieceList({ page, pageSize, search, itemList, orderBy, orderAsc }) {
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc }) {
this.page = page;
this.pageSize = pageSize;
this.search = search;
this.orderAsc = orderAsc;
this.orderBy = orderBy;
this.itemList = itemList;
this.pieceList = pieceList;
}
};