mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Make Table component more generic
This commit is contained in:
parent
29d9572a37
commit
2c3b7c3025
@ -10,7 +10,7 @@ class PieceListActions {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchList(page, pageSize, search, orderBy, orderAsc) {
|
fetchPieceList(page, pageSize, search, orderBy, orderAsc) {
|
||||||
PieceListFetcher
|
PieceListFetcher
|
||||||
.fetch(page, pageSize, search, orderBy, orderAsc)
|
.fetch(page, pageSize, search, orderBy, orderAsc)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -20,7 +20,7 @@ class PieceListActions {
|
|||||||
search,
|
search,
|
||||||
orderBy,
|
orderBy,
|
||||||
orderAsc,
|
orderAsc,
|
||||||
'itemList': res.pieces
|
'pieceList': res.pieces
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -12,8 +12,6 @@ let Table = React.createClass({
|
|||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
console.log(this.props);
|
|
||||||
|
|
||||||
if(this.props.itemList && this.props.itemList.length > 0) {
|
if(this.props.itemList && this.props.itemList.length > 0) {
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-table">
|
<div className="ascribe-table">
|
||||||
|
@ -22,7 +22,7 @@ let PieceList = React.createClass({
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let page = this.props.query.page || this.state.page;
|
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);
|
this.state.orderBy, this.state.orderAsc);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -37,9 +37,16 @@ let PieceList = React.createClass({
|
|||||||
<AltContainer
|
<AltContainer
|
||||||
store={PieceListStore}
|
store={PieceListStore}
|
||||||
actions={PieceListActions}
|
actions={PieceListActions}
|
||||||
transform={(x) => {
|
transform={(props) => {
|
||||||
console.log('@@@@@@@', x);
|
return {
|
||||||
return { a: 1, b: 2 };
|
'itemList': props.pieceList,
|
||||||
|
'fetchList': props.fetchPieceList,
|
||||||
|
'orderBy': props.orderBy,
|
||||||
|
'orderAsc': props.orderAsc,
|
||||||
|
'search': props.search,
|
||||||
|
'page': props.page,
|
||||||
|
'pageSize': props.pageSize
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
<Table columnList={columnList} />
|
<Table columnList={columnList} />
|
||||||
<Pagination currentPage={this.props.query.page} />
|
<Pagination currentPage={this.props.query.page} />
|
||||||
|
@ -4,7 +4,7 @@ import PieceListActions from '../actions/piece_list_actions';
|
|||||||
|
|
||||||
class PieceListStore {
|
class PieceListStore {
|
||||||
constructor() {
|
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.page = 1;
|
||||||
this.pageSize = 10;
|
this.pageSize = 10;
|
||||||
this.search = "";
|
this.search = "";
|
||||||
@ -13,13 +13,13 @@ class PieceListStore {
|
|||||||
this.bindActions(PieceListActions);
|
this.bindActions(PieceListActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdatePieceList({ page, pageSize, search, itemList, orderBy, orderAsc }) {
|
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc }) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.orderAsc = orderAsc;
|
this.orderAsc = orderAsc;
|
||||||
this.orderBy = orderBy;
|
this.orderBy = orderBy;
|
||||||
this.itemList = itemList;
|
this.pieceList = pieceList;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user