diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index d13882cd..fb0a2249 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -33,6 +33,10 @@ class EditionListActions { EditionListFetcher .fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy) .then((res) => { + if(res && !res.editions) { + throw new Error('Piece has no editions to fetch.'); + } + this.actions.updateEditionList({ pieceId, page, @@ -46,6 +50,7 @@ class EditionListActions { resolve(res); }) .catch((err) => { + console.logGlobal(err); reject(err); }); }); diff --git a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js index 452a9bd8..3e5b6495 100644 --- a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js +++ b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js @@ -33,21 +33,28 @@ let PieceListBulkModal = React.createClass({ ); }, - onChange(state) { - this.setState(state); - }, + componentDidMount() { EditionListStore.listen(this.onChange); UserStore.listen(this.onChange); + PieceListStore.listen(this.onChange); + UserActions.fetchCurrentUser(); + PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, + this.state.orderBy, this.state.orderAsc, this.state.filterBy); }, componentWillUnmount() { EditionListStore.unlisten(this.onChange); + PieceListStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); }, + onChange(state) { + this.setState(state); + }, + fetchSelectedPieceEditionList() { let filteredPieceIdList = Object.keys(this.state.editionList) .filter((pieceId) => { diff --git a/js/stores/edition_list_store.js b/js/stores/edition_list_store.js index 87b4df76..b3b152d3 100644 --- a/js/stores/edition_list_store.js +++ b/js/stores/edition_list_store.js @@ -13,7 +13,6 @@ class EditionListStore { } onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count, filterBy}) { - /* Basically there are two modes an edition list can be updated.