diff --git a/js/actions/piece_list_actions.js b/js/actions/piece_list_actions.js index 7ef9cb59..75abfd8f 100644 --- a/js/actions/piece_list_actions.js +++ b/js/actions/piece_list_actions.js @@ -15,7 +15,7 @@ class PieceListActions { ); } - fetchPieceList(page, pageSize, search, orderBy, orderAsc, filterBy) { + fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}) { // To prevent flickering on a pagination request, // we overwrite the piecelist with an empty list before // pieceListCount === -1 defines the loading state @@ -34,7 +34,7 @@ class PieceListActions { // afterwards, we can load the list return Q.Promise((resolve, reject) => { PieceListFetcher - .fetch(page, pageSize, search, orderBy, orderAsc, filterBy) + .fetch({page, pageSize, search, orderBy, orderAsc, filterBy}) .then((res) => { this.actions.updatePieceList({ page, diff --git a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js index a8cab166..aa52d8be 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js @@ -88,8 +88,9 @@ let AccordionListItemWallet = React.createClass({ }, onPollingSuccess(pieceId) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); EditionListActions.toggleEditionList(pieceId); let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); diff --git a/js/components/ascribe_detail/edition_action_panel.js b/js/components/ascribe_detail/edition_action_panel.js index 36a79e7c..04838bcd 100644 --- a/js/components/ascribe_detail/edition_action_panel.js +++ b/js/components/ascribe_detail/edition_action_panel.js @@ -79,8 +79,9 @@ let EditionActionPanel = React.createClass({ }, refreshCollection() { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); EditionListActions.refreshEditionList({pieceId: this.props.edition.parent}); }, diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 74584ba3..f6a9fa7e 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -140,15 +140,17 @@ let PieceContainer = React.createClass({ }, handleEditionCreationSuccess() { + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + PieceActions.updateProperty({key: 'num_editions', value: 0}); - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); this.toggleCreateEditionsDialog(); }, handleDeleteSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); // since we're deleting a piece, we just need to close // all editions dialogs and not reload them @@ -177,6 +179,7 @@ let PieceContainer = React.createClass({ }, handlePollingSuccess(pieceId, numEditions) { + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; // we need to refresh the num_editions property of the actual piece we're looking at PieceActions.updateProperty({ @@ -188,8 +191,7 @@ let PieceContainer = React.createClass({ // btw.: It's not sufficient to just set num_editions to numEditions, since a single accordion // list item also uses the firstEdition property which we can only get from the server in that case. // Therefore we need to at least refetch the changed piece from the server or on our case simply all - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 9424117c..33bd4004 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -206,15 +206,15 @@ let PieceList = React.createClass({ }, applyOrderBy(orderBy) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, page, pageSize, search } = this.state; + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) { + const { orderAsc, pageSize } = this.state; const orderBy = this.state.orderBy || this.props.orderBy; - return PieceListActions.fetchPieceList(page, this.state.pageSize, search, - orderBy, this.state.orderAsc, filterBy); + return PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, fetchSelectedPieceEditionList() { @@ -240,8 +240,9 @@ let PieceList = React.createClass({ }, handleAclSuccess() { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderBy, orderAsc, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); this.fetchSelectedPieceEditionList() .forEach((pieceId) => { diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 8211e91e..984b5d7c 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -65,20 +65,15 @@ let RegisterPiece = React.createClass( { this.setState(state); }, - handleSuccess(response){ + handleSuccess(response) { + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + let notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); // once the user was able to register a piece successfully, we need to make sure to keep // the piece list up to date - PieceListActions.fetchPieceList( - this.state.page, - this.state.pageSize, - this.state.searchTerm, - this.state.orderBy, - this.state.orderAsc, - this.state.filterBy - ); + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); this.history.pushState(null, `/pieces/${response.piece.id}`); }, diff --git a/js/components/whitelabel/prize/simple_prize/components/ascribe_accordion_list/accordion_list_item_prize.js b/js/components/whitelabel/prize/simple_prize/components/ascribe_accordion_list/accordion_list_item_prize.js index 965b9012..d4f32f5f 100644 --- a/js/components/whitelabel/prize/simple_prize/components/ascribe_accordion_list/accordion_list_item_prize.js +++ b/js/components/whitelabel/prize/simple_prize/components/ascribe_accordion_list/accordion_list_item_prize.js @@ -58,8 +58,9 @@ let AccordionListItemPrize = React.createClass({ }, handleSubmitPrizeSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); let notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); @@ -138,8 +139,9 @@ let AccordionListItemPrize = React.createClass({ }, refreshPieceData() { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, onSelectChange(){ diff --git a/js/components/whitelabel/prize/simple_prize/components/ascribe_detail/prize_piece_container.js b/js/components/whitelabel/prize/simple_prize/components/ascribe_detail/prize_piece_container.js index 982af7b0..1cfab049 100644 --- a/js/components/whitelabel/prize/simple_prize/components/ascribe_detail/prize_piece_container.js +++ b/js/components/whitelabel/prize/simple_prize/components/ascribe_detail/prize_piece_container.js @@ -305,9 +305,10 @@ let PrizePieceRatings = React.createClass({ }, refreshPieceData() { + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + this.props.loadPiece(); - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, onSelectChange() { diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js b/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js index 9d88408f..e3874c8b 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js @@ -52,8 +52,9 @@ let CylandAccordionListItem = React.createClass({ }, handleSubmitSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); let notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js index d211d3e8..a9311ad2 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js @@ -74,8 +74,9 @@ let CylandPieceContainer = React.createClass({ }, handleDeleteSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); // since we're deleting a piece, we just need to close // all editions dialogs and not reload them diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js index 42b7c1ad..eaba6e54 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -140,14 +140,9 @@ let CylandRegisterPiece = React.createClass({ }, refreshPieceList() { - PieceListActions.fetchPieceList( - this.state.page, - this.state.pageSize, - this.state.searchTerm, - this.state.orderBy, - this.state.orderAsc, - this.state.filterBy - ); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, changeSlide() { diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js index ce8cebf5..dcbfee09 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js @@ -53,8 +53,9 @@ let IkonotvAccordionListItem = React.createClass({ }, handleSubmitSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); let notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js index df58b7c7..31b1d27f 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js @@ -83,8 +83,9 @@ let IkonotvPieceContainer = React.createClass({ }, handleDeleteSuccess(response) { - PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, this.state.filterBy); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); // since we're deleting a piece, we just need to close // all editions dialogs and not reload them diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js index c40d779d..7ead4fa7 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js @@ -147,14 +147,9 @@ let IkonotvRegisterPiece = React.createClass({ }, refreshPieceList() { - PieceListActions.fetchPieceList( - this.state.page, - this.state.pageSize, - this.state.searchTerm, - this.state.orderBy, - this.state.orderAsc, - this.state.filterBy - ); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, canSubmit() { diff --git a/js/components/whitelabel/wallet/components/market/market_register_piece.js b/js/components/whitelabel/wallet/components/market/market_register_piece.js index 387934f9..f7c46864 100644 --- a/js/components/whitelabel/wallet/components/market/market_register_piece.js +++ b/js/components/whitelabel/wallet/components/market/market_register_piece.js @@ -103,14 +103,9 @@ let MarketRegisterPiece = React.createClass({ }, refreshPieceList() { - PieceListActions.fetchPieceList( - this.state.page, - this.state.pageSize, - this.state.searchTerm, - this.state.orderBy, - this.state.orderAsc, - this.state.filterBy - ); + const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state; + + PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}); }, render() { diff --git a/js/fetchers/piece_list_fetcher.js b/js/fetchers/piece_list_fetcher.js index 6bd4eb3a..9bea14c5 100644 --- a/js/fetchers/piece_list_fetcher.js +++ b/js/fetchers/piece_list_fetcher.js @@ -10,7 +10,7 @@ let PieceListFetcher = { * Fetches a list of pieces from the API. * Can be called with all supplied queryparams the API. */ - fetch(page, pageSize, search, orderBy, orderAsc, filterBy) { + fetch({page, pageSize, search, orderBy, orderAsc, filterBy}) { let ordering = generateOrderingQueryParams(orderBy, orderAsc); // filterBy is an object of acl key-value pairs. diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js index 94c57113..bb246f9d 100644 --- a/js/stores/piece_list_store.js +++ b/js/stores/piece_list_store.js @@ -31,7 +31,7 @@ class PieceListStore { this.requestActions = {}; this.bindActions(PieceListActions); } - + onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount, unfilteredPieceListCount, filterBy }) { this.page = page; this.pageSize = pageSize; @@ -66,7 +66,7 @@ class PieceListStore { show: { $set: oldPiece.show } }); } - + }); this.pieceList = pieceList;