diff --git a/app/assets/javascripts/admin/order_cycles/controllers/order_cycle_exchanges_controller.js.coffee b/app/assets/javascripts/admin/order_cycles/controllers/order_cycle_exchanges_controller.js.coffee index bd233106ee..1953754cbf 100644 --- a/app/assets/javascripts/admin/order_cycles/controllers/order_cycle_exchanges_controller.js.coffee +++ b/app/assets/javascripts/admin/order_cycles/controllers/order_cycle_exchanges_controller.js.coffee @@ -44,12 +44,18 @@ angular.module('admin.orderCycles') incoming = true if $scope.view == 'incoming' params = { exchange_id: exchange.id, enterprise_id: exchange.enterprise_id, order_cycle_id: $scope.order_cycle.id, incoming: incoming, page: page} - ExchangeProduct.index params, (products) -> + ExchangeProduct.index params, (products, last_page) -> + enterprise.last_page = last_page enterprise.supplied_products = [] unless enterprise.supplied_products? enterprise.supplied_products.push products... $scope.loadMoreExchangeProducts = -> - $scope.loadExchangeProducts(this.exchange, this.enterprises[this.exchange.enterprise_id].last_page_loaded + 1) + $scope.loadExchangeProducts(this.exchange, $scope.enterprises[this.exchange.enterprise_id].last_page_loaded + 1) + + $scope.loadAllExchangeProducts = -> + enterprise = $scope.enterprises[this.exchange.enterprise_id] + for page_to_load in [(enterprise.last_page_loaded + 1)..enterprise.last_page] + $scope.loadExchangeProducts(this.exchange, page_to_load) # initialize exchange products panel if not yet done $scope.exchangeProdutsPanelInitialized = [] diff --git a/app/assets/javascripts/admin/order_cycles/services/exchange_product.js.coffee b/app/assets/javascripts/admin/order_cycles/services/exchange_product.js.coffee index 7f9b3989fe..92df8f8e84 100644 --- a/app/assets/javascripts/admin/order_cycles/services/exchange_product.js.coffee +++ b/app/assets/javascripts/admin/order_cycles/services/exchange_product.js.coffee @@ -10,7 +10,7 @@ angular.module('admin.orderCycles').factory('ExchangeProduct', ($resource) -> index: (params={}, callback=null) -> ExchangeProductResource.index params, (data) => @loaded = true - (callback || angular.noop)(data.products) + (callback || angular.noop)(data.products, data.pagination.pages) countVariants: (params={}, callback=null) -> ExchangeProductResource.variant_count params, (data) => diff --git a/app/assets/javascripts/templates/admin/panels/exchange_distributed_products.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_distributed_products.html.haml index 5cfb64526c..45650d94db 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_distributed_products.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_distributed_products.html.haml @@ -29,3 +29,5 @@ .pagination .button{ 'ng-click' => 'loadMoreExchangeProducts()' } {{ 'js.admin.panels.exchange_products.load_more_products' | t }} + .button{ 'ng-click' => 'loadAllExchangeProducts()' } + {{ 'js.admin.panels.exchange_products.load_all_products' | t }} diff --git a/app/assets/javascripts/templates/admin/panels/exchange_supplied_products.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_supplied_products.html.haml index a1930bc9ad..c2dc200772 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_supplied_products.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_supplied_products.html.haml @@ -30,3 +30,5 @@ .pagination .button{ 'ng-click' => 'loadMoreExchangeProducts()' } {{ 'js.admin.panels.exchange_products.load_more_products' | t }} + .button{ 'ng-click' => 'loadAllExchangeProducts()' } + {{ 'js.admin.panels.exchange_products.load_all_products' | t }} diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index 19c0172165..634262028d 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -35,10 +35,10 @@ - if type == 'supplier' %tr.panel-row{ object: "exchange", panels: "{products: 'exchange_supplied_products'}", - locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,suppliedVariants,removeDistributionOfVariant,initializeExchangeProductsPanel,loadMoreExchangeProducts", + locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,suppliedVariants,removeDistributionOfVariant,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts", colspan: 4 } - if type == 'distributor' %tr.panel-row{ object: "exchange", panels: "{products: 'exchange_distributed_products', tags: 'exchange_tags'}", - locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts", + locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts", colspan: 5 } diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ca682af94..b07869f3a1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2562,6 +2562,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using resolve: Resolve exchange_products: load_more_products: "Load More Products" + load_all_products: "Load All Products" tag_rules: shipping_method_tagged_top: "Shipping methods tagged" shipping_method_tagged_bottom: "are:"