mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
import alt from '../alt';
|
|
|
|
import EditionListFetcher from '../fetchers/edition_list_fetcher.js';
|
|
|
|
class EditionListActions {
|
|
constructor() {
|
|
this.generateActions(
|
|
'updateEditionList',
|
|
'selectEdition',
|
|
'clearAllEditionSelections',
|
|
'closeAllEditionLists',
|
|
'toggleEditionList'
|
|
);
|
|
}
|
|
|
|
fetchEditionList(pieceId, orderBy, orderAsc) {
|
|
if(!orderBy && typeof orderAsc == 'undefined') {
|
|
orderBy = 'edition_number';
|
|
orderAsc = true;
|
|
}
|
|
|
|
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);
|
|
});
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
export default alt.createActions(EditionListActions);
|