2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-19 17:13:09 +02:00
|
|
|
import alt from '../alt';
|
2015-05-21 17:59:38 +02:00
|
|
|
|
2015-05-19 17:13:09 +02:00
|
|
|
import PieceListFetcher from '../fetchers/piece_list_fetcher';
|
|
|
|
|
2015-05-20 16:44:45 +02:00
|
|
|
|
2015-05-19 17:13:09 +02:00
|
|
|
class PieceListActions {
|
|
|
|
constructor() {
|
|
|
|
this.generateActions(
|
2015-07-01 19:05:47 +02:00
|
|
|
'updatePieceList',
|
|
|
|
'updatePieceListRequestActions'
|
2015-05-19 17:13:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-22 11:33:38 +02:00
|
|
|
fetchPieceList(page, pageSize, search, orderBy, orderAsc) {
|
2015-07-01 19:05:47 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
PieceListFetcher
|
|
|
|
.fetch(page, pageSize, search, orderBy, orderAsc)
|
|
|
|
.then((res) => {
|
|
|
|
this.actions.updatePieceList({
|
|
|
|
page,
|
|
|
|
pageSize,
|
|
|
|
search,
|
|
|
|
orderBy,
|
|
|
|
orderAsc,
|
|
|
|
'pieceList': res.pieces,
|
|
|
|
'pieceListCount': res.count
|
|
|
|
});
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
fetchPieceRequestActions() {
|
2015-05-21 17:59:38 +02:00
|
|
|
PieceListFetcher
|
2015-07-01 19:05:47 +02:00
|
|
|
.fetchRequestActions()
|
2015-05-19 17:13:09 +02:00
|
|
|
.then((res) => {
|
2015-07-01 19:05:47 +02:00
|
|
|
this.actions.updatePieceListRequestActions(res.piece_ids);
|
2015-05-19 17:13:09 +02:00
|
|
|
});
|
|
|
|
}
|
2015-05-21 17:54:27 +02:00
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
}
|
2015-05-19 17:13:09 +02:00
|
|
|
|
|
|
|
export default alt.createActions(PieceListActions);
|