Match supplier of each line item with the list fetched from server

This commit is contained in:
Rob H
2014-01-17 17:14:05 +08:00
parent 94c375ad31
commit d6b4f8129c
4 changed files with 46 additions and 7 deletions

View File

@@ -42,7 +42,15 @@ orderManagementModule.controller "AdminOrderMgmtCtrl", [
$scope.resetLineItems = ->
$scope.lineItems = $scope.orders.reduce (lineItems,order) ->
for i,line_item of order.line_items
$scope.matchSupplier line_item
line_item.order = order
lineItems.concat order.line_items
, []
$scope.matchSupplier = (line_item) ->
for i of $scope.suppliers
supplier = $scope.suppliers[i]
if angular.equals(supplier, line_item.supplier)
line_item.supplier = supplier
break
]