2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-21 17:59:38 +02:00
|
|
|
import alt from '../alt';
|
|
|
|
|
|
|
|
import EditionListFetcher from '../fetchers/edition_list_fetcher.js';
|
|
|
|
|
|
|
|
class EditionListActions {
|
|
|
|
constructor() {
|
|
|
|
this.generateActions(
|
2015-05-26 16:48:48 +02:00
|
|
|
'updateEditionList',
|
2015-06-01 15:12:31 +02:00
|
|
|
'selectEdition',
|
2015-06-12 17:18:40 +02:00
|
|
|
'clearAllEditionSelections',
|
2015-06-15 09:29:34 +02:00
|
|
|
'closeAllEditionLists',
|
2015-06-12 17:18:40 +02:00
|
|
|
'toggleEditionList'
|
2015-05-21 17:59:38 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-06-04 09:16:30 +02:00
|
|
|
fetchEditionList(pieceId, orderBy, orderAsc) {
|
2015-06-05 11:06:36 +02:00
|
|
|
if(!orderBy && typeof orderAsc == 'undefined') {
|
2015-06-04 16:41:14 +02:00
|
|
|
orderBy = 'edition_number';
|
|
|
|
orderAsc = true;
|
|
|
|
}
|
|
|
|
|
2015-06-12 17:18:40 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
EditionListFetcher
|
|
|
|
.fetch(pieceId, orderBy, orderAsc)
|
|
|
|
.then((res) => {
|
|
|
|
this.actions.updateEditionList({
|
|
|
|
'editionListOfPiece': res.editions,
|
|
|
|
pieceId,
|
|
|
|
orderBy,
|
|
|
|
orderAsc
|
|
|
|
});
|
|
|
|
resolve(res);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
reject(err);
|
|
|
|
console.log(err);
|
2015-05-26 13:14:35 +02:00
|
|
|
});
|
2015-06-12 17:18:40 +02:00
|
|
|
});
|
|
|
|
|
2015-05-21 17:59:38 +02:00
|
|
|
}
|
2015-05-26 13:33:35 +02:00
|
|
|
}
|
2015-05-21 17:59:38 +02:00
|
|
|
|
2015-06-05 14:14:59 +02:00
|
|
|
export default alt.createActions(EditionListActions);
|