mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Add load all prouducts button to list of exchange products
This commit is contained in:
@@ -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 = []
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user