mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make Product service more simple, there's no need to keep the data structure, that is already kept in the controller
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
angular.module('admin.orderCycles').factory('Product', ($resource) ->
|
||||
Product = $resource('/api/exchanges/:exchange_id/products.json', {}, {
|
||||
ProductResource = $resource('/api/exchanges/:exchange_id/products.json', {}, {
|
||||
'index':
|
||||
method: 'GET'
|
||||
isArray: true
|
||||
})
|
||||
{
|
||||
Product: Product
|
||||
products: {}
|
||||
ProductResource: ProductResource
|
||||
loaded: false
|
||||
|
||||
index: (params={}, callback=null) ->
|
||||
Product.index params, (data) =>
|
||||
@products[params.enterprise_id] = []
|
||||
for product in data
|
||||
@products[params.enterprise_id].push(product)
|
||||
|
||||
ProductResource.index params, (data) =>
|
||||
@loaded = true
|
||||
(callback || angular.noop)(@products[params.enterprise_id])
|
||||
|
||||
this.products
|
||||
(callback || angular.noop)(data)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user