Rename Product service to more appropriate ExchangeProduct

This commit is contained in:
luisramos0
2019-11-22 14:54:12 +00:00
parent f5ddbfbac3
commit a4a2f98b6e
6 changed files with 25 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
angular.module('admin.orderCycles')
.controller 'AdminOrderCycleExchangesCtrl', ($scope, $controller, $filter, $window, $location, OrderCycle, Product, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
.controller 'AdminOrderCycleExchangesCtrl', ($scope, $controller, $filter, $window, $location, OrderCycle, ExchangeProduct, Enterprise, EnterpriseFee, Schedules, RequestMonitor, ocInstance, StatusMessage) ->
$controller('AdminEditOrderCycleCtrl', {$scope: $scope, ocInstance: ocInstance, $location: $location})
$scope.supplier_enterprises = Enterprise.producer_enterprises
@@ -42,7 +42,7 @@ 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}
Product.index params, (products) ->
ExchangeProduct.index params, (products) ->
$scope.enterprises[exchange.enterprise_id].supplied_products = products
# Register listeners to capture first toggle open of the products panel of the exchange

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, $controller, $window, OrderCycle, Enterprise, EnterpriseFee, Product, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, $controller, $window, OrderCycle, Enterprise, EnterpriseFee, ExchangeProduct, StatusMessage, Schedules, RequestMonitor, ocInstance) ->
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
$scope.order_cycle = OrderCycle.new {coordinator_id: ocInstance.coordinator_id}, =>
@@ -20,7 +20,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
$scope.incoming_exchange = OrderCycle.order_cycle.incoming_exchanges[0]
params = { enterprise_id: $scope.incoming_exchange.enterprise_id, incoming: true }
Product.index params, $scope.storeProductsAndSelectAllVariants
ExchangeProduct.index params, $scope.storeProductsAndSelectAllVariants
$scope.storeProductsAndSelectAllVariants = (products) ->
$scope.enterprises[$scope.incoming_exchange.enterprise_id].supplied_products = products

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $controller, $location, $window, OrderCycle, Enterprise, EnterpriseFee, Product, Schedules, RequestMonitor, StatusMessage, ocInstance) ->
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $controller, $location, $window, OrderCycle, Enterprise, EnterpriseFee, ExchangeProduct, Schedules, RequestMonitor, StatusMessage, ocInstance) ->
$controller('AdminOrderCycleBasicCtrl', {$scope: $scope, ocInstance: ocInstance})
$scope.orderCycleId = ->
@@ -15,7 +15,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
$scope.loadExchangeProducts = ->
exchange = OrderCycle.order_cycle.incoming_exchanges[0]
Product.index { exchange_id: exchange.id }, (products) ->
ExchangeProduct.index { exchange_id: exchange.id }, (products) ->
$scope.enterprises[exchange.enterprise_id].supplied_products = products
$scope.removeDistributionOfVariant = angular.noop

View File

@@ -0,0 +1,15 @@
angular.module('admin.orderCycles').factory('ExchangeProduct', ($resource) ->
ExchangeProductResource = $resource('/api/exchanges/:exchange_id/products.json', {}, {
'index':
method: 'GET'
isArray: true
})
{
ExchangeProductResource: ExchangeProductResource
loaded: false
index: (params={}, callback=null) ->
ExchangeProductResource.index params, (data) =>
@loaded = true
(callback || angular.noop)(data)
})

View File

@@ -1,15 +0,0 @@
angular.module('admin.orderCycles').factory('Product', ($resource) ->
ProductResource = $resource('/api/exchanges/:exchange_id/products.json', {}, {
'index':
method: 'GET'
isArray: true
})
{
ProductResource: ProductResource
loaded: false
index: (params={}, callback=null) ->
ProductResource.index params, (data) =>
@loaded = true
(callback || angular.noop)(data)
})