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 fde1436745..14813c1806 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 @@ -8,6 +8,13 @@ angular.module('admin.orderCycles') $scope.productsLoading = -> RequestMonitor.loading + $scope.exchangeLoadedVariants = (exchange) -> + loaded_variants = 0 + angular.forEach $scope.enterprises[exchange.enterprise_id].supplied_products, (product) -> + loaded_variants += product.variants.length + + loaded_variants + $scope.setSelectAllVariantsCheckboxValue = (exchange, totalNumberOfVariants) -> exchange.select_all_variants = $scope.exchangeSelectedVariants(exchange) >= totalNumberOfVariants diff --git a/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml index d26bc2346c..2e05c6493b 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml @@ -9,7 +9,7 @@ 'ng-model' => 'exchange.select_all_variants', 'ng-change' => 'setExchangeVariants(exchange, incomingExchangeVariantsFor(exchange.enterprise_id), exchange.select_all_variants)', 'id' => 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants' } - {{ 'js.admin.panels.exchange_products.select_all_products' | t:{ total_number_of_products: enterprises[exchange.enterprise_id].num_of_products } }} + {{ 'js.admin.panels.exchange_products.select_all_products' | t:{ total_number_of_products: exchangeTotalVariants(exchange) } }} .exchange-products{ 'ng-hide' => 'productsLoading()' } .exchange-product{'ng-repeat' => 'product in enterprises[exchange.enterprise_id].supplied_products | filter:visibleProducts:exchange:order_cycle.visible_variants_for_outgoing_exchanges' } diff --git a/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml index 5d08888456..ad21ee869c 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml @@ -1,5 +1,5 @@ .exchange-load-all-variants %div - {{ 'js.admin.panels.exchange_products.products_loaded' | t:{ num_of_products_loaded: enterprises[exchange.enterprise_id].supplied_products.length, total_number_of_products: enterprises[exchange.enterprise_id].num_of_products } }} + {{ 'js.admin.panels.exchange_products.products_loaded' | t:{ num_of_products_loaded: exchangeLoadedVariants(exchange), total_number_of_products: exchangeTotalVariants(exchange) } }} %a{ 'ng-click' => 'loadAllExchangeProducts(exchange)', 'ng-show' => 'enterprises[exchange.enterprise_id].last_page_loaded < enterprises[exchange.enterprise_id].num_of_pages' } {{ 'js.admin.panels.exchange_products.load_all_products' | t }} diff --git a/app/assets/javascripts/templates/admin/panels/exchange_products_supplied.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_products_supplied.html.haml index ffc5277168..c4be5e082c 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_products_supplied.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_products_supplied.html.haml @@ -9,7 +9,7 @@ 'ng-model' => 'exchange.select_all_variants', 'ng-change' => 'selectAllVariants(exchange, exchange.select_all_variants)', 'id' => 'order_cycle_incoming_exchange_{{ $index }}_select_all_variants' } - {{ 'js.admin.panels.exchange_products.select_all_products' | t:{ total_number_of_products: enterprises[exchange.enterprise_id].num_of_products } }} + {{ 'js.admin.panels.exchange_products.select_all_products' | t:{ total_number_of_products: exchangeTotalVariants(exchange) } }} %div{ 'ng-include' => "'admin/panels/exchange_products_supplied_list.html'" } diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index 1713555840..e6f8b65b97 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -31,10 +31,10 @@ - if type == 'supplier' %tr.panel-row{ object: "exchange", panels: "{products: 'exchange_products_supplied'}", - locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,selectAllVariants,suppliedVariants,removeDistributionOfVariant,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading", + locals: "$index,exchangeLoadedVariants,exchangeTotalVariants,order_cycle,exchange,enterprises,setExchangeVariants,selectAllVariants,suppliedVariants,removeDistributionOfVariant,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading", colspan: 4 } - if type == 'distributor' %tr.panel-row{ object: "exchange", panels: "{products: 'exchange_products_distributed', tags: 'exchange_tags'}", - locals: "$index,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading", + locals: "$index,exchangeLoadedVariants,exchangeTotalVariants,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading", colspan: 5 }