Extract filter list fetching into a separate endpoint

This commit is contained in:
Matt-Yorkley
2019-10-02 11:06:05 +01:00
parent fe0de98821
commit 06e1f56ae9
5 changed files with 77 additions and 7 deletions

View File

@@ -32,3 +32,4 @@ Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Prod
Products.update()
Cart.reloadFinalisedLineItems()
ChangeableOrdersAlert.reload()
# Reload Filters from new endpoint after changing OC here

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, OrderCycle, FilterSelectorsService, Cart, Dereferencer, Taxons, Properties, currentHub, $timeout) ->
Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, OrderCycle, OrderCycleResource, FilterSelectorsService, Cart, Dereferencer, Taxons, Properties, currentHub, $timeout) ->
$scope.Products = Products
$scope.Cart = Cart
$scope.query = ""
@@ -12,17 +12,31 @@ Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, Ord
$scope.supplied_taxons = ->
return $scope.memoized_taxons if $scope.memoized_taxons != undefined
$scope.memoized_taxons = {}
currentHub.supplied_taxons.map( (taxon) ->
$scope.memoized_taxons[taxon.id] = Taxons.taxons_by_id[taxon.id]
)
params = {
id: OrderCycle.order_cycle.order_cycle_id,
distributor: currentHub.id
}
OrderCycleResource.taxons params, (data)=>
data.map( (taxon) ->
$scope.memoized_taxons[taxon.id] = Taxons.taxons_by_id[taxon.id]
)
$scope.memoized_taxons
$scope.supplied_properties = ->
return $scope.memoized_properties if $scope.memoized_properties != undefined
$scope.memoized_properties = {}
currentHub.supplied_properties.map( (property) ->
$scope.memoized_properties[property.id] = Properties.properties_by_id[property.id]
)
params = {
id: OrderCycle.order_cycle.order_cycle_id,
distributor: currentHub.id
}
OrderCycleResource.properties params, (data)=>
data.map( (property) ->
$scope.memoized_properties[property.id] = Properties.properties_by_id[property.id]
)
$scope.memoized_properties
$scope.loadMore = ->

View File

@@ -6,4 +6,16 @@ Darkswarm.factory 'OrderCycleResource', ($resource) ->
url: '/api/order_cycles/:id/products'
params:
id: '@id'
'taxons':
method: 'GET'
isArray: true
url: '/api/order_cycles/:id/taxons'
params:
id: '@id'
'properties':
method: 'GET'
isArray: true
url: '/api/order_cycles/:id/properties'
params:
id: '@id'
})