Using same serializer for standing order index and edit pages

This commit is contained in:
Rob Harrington
2016-11-30 09:37:40 +11:00
parent e8ee1dad04
commit 8f71b56c26
8 changed files with 32 additions and 39 deletions

View File

@@ -1,3 +1,3 @@
angular.module("admin.standingOrders").controller "ProductsPanelController", ($scope) ->
$scope.standingOrder = $scope.object
$scope.distributor_id = $scope.standingOrder.shop.id
$scope.distributor_id = $scope.standingOrder.shop_id

View File

@@ -1,12 +1,14 @@
angular.module("admin.standingOrders").controller "StandingOrdersController", ($scope, StandingOrders, Columns, shops) ->
angular.module("admin.standingOrders").controller "StandingOrdersController", ($scope, StandingOrders, Columns, shops, ShippingMethods, PaymentMethods) ->
$scope.columns = Columns.columns
$scope.shops = shops
$scope.shop_id = if shops.length == 1 then shops[0].id else null
$scope.shippingMethodsByID = ShippingMethods.byID
$scope.paymentMethodsByID = PaymentMethods.byID
$scope.$watch "shop_id", ->
if $scope.shop_id?
# CurrentShop.shop = $filter('filter')($scope.shops, {id: $scope.shop_id})[0]
$scope.standingOrders = StandingOrders.index("q[shop_id_eq]": $scope.shop_id, ams_prefix: 'index')
$scope.standingOrders = StandingOrders.index("q[shop_id_eq]": $scope.shop_id)
$scope.itemCount = (standingOrder) ->
standingOrder.standing_line_items.reduce (sum, sli) ->

View File

@@ -1,7 +1,7 @@
angular.module("admin.standingOrders").factory 'StandingOrderPrototype', ($http, InfoDialog, StatusMessage) ->
errors: {}
buildItem: (item, ams_prefix) ->
buildItem: (item) ->
return false unless item.variant_id > 0
return false unless item.quantity > 0
data = angular.extend({}, item, { shop_id: @shop_id, schedule_id: @schedule_id })