2015-05-19 17:13:09 +02:00
|
|
|
import alt from '../alt';
|
|
|
|
import PieceListActions from '../actions/piece_list_actions';
|
|
|
|
|
2015-05-20 16:44:45 +02:00
|
|
|
|
2015-05-19 17:13:09 +02:00
|
|
|
class PieceListStore {
|
|
|
|
constructor() {
|
2015-05-22 13:43:53 +02:00
|
|
|
/**
|
|
|
|
* The store manages the state that is introduced by fetching
|
|
|
|
* the resource with certain parameters.
|
|
|
|
*
|
|
|
|
* This means that pieceList for example only contains pageSize-many items.
|
|
|
|
* Of course this can be altered by page as well.
|
|
|
|
*
|
|
|
|
* This is also the reason why we store a pieceListCount, which is essentially
|
|
|
|
* the number of items the resource actually - without pagination - provides.
|
|
|
|
*/
|
|
|
|
this.pieceList = [];
|
|
|
|
this.pieceListCount = 0;
|
2015-05-21 12:12:25 +02:00
|
|
|
this.page = 1;
|
|
|
|
this.pageSize = 10;
|
|
|
|
this.search = "";
|
|
|
|
this.orderBy = "artist_name";
|
|
|
|
this.orderAsc = true;
|
2015-05-19 17:13:09 +02:00
|
|
|
this.bindActions(PieceListActions);
|
|
|
|
}
|
|
|
|
|
2015-05-22 13:43:53 +02:00
|
|
|
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount }) {
|
2015-05-21 17:54:27 +02:00
|
|
|
this.page = page;
|
|
|
|
this.pageSize = pageSize;
|
|
|
|
this.search = search;
|
2015-05-21 12:12:25 +02:00
|
|
|
this.orderAsc = orderAsc;
|
|
|
|
this.orderBy = orderBy;
|
2015-05-22 11:33:38 +02:00
|
|
|
this.pieceList = pieceList;
|
2015-05-22 13:43:53 +02:00
|
|
|
this.pieceListCount = pieceListCount;
|
2015-05-19 17:13:09 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default alt.createStore(PieceListStore);
|