StandingLineItems can be removed when creating a StandingOrder

This commit is contained in:
Rob Harrington
2016-10-20 08:12:27 +11:00
parent 1b711bcd46
commit 594bec1b37
4 changed files with 37 additions and 12 deletions

View File

@@ -21,8 +21,13 @@ angular.module("admin.standingOrders").controller "StandingOrderController", ($s
$scope.stepTitleFor = (step) -> t("admin.standing_orders.steps.#{step}")
$scope.addStandingLineItem = ->
$scope.standing_order_form.$setDirty()
StandingOrder.buildItem($scope.newItem)
$scope.removeStandingLineItem = (item) ->
$scope.standing_order_form.$setDirty()
StandingOrder.removeItem(item)
$scope.estimatedSubtotal = ->
$scope.standingOrder.standing_line_items.reduce (subtotal, item) ->
subtotal += item.price_estimate * item.quantity

View File

@@ -16,6 +16,10 @@ angular.module("admin.standingOrders").factory "StandingOrder", ($injector, $htt
, (response) =>
InfoDialog.open 'error', response.data.errors[0]
removeItem: (item) ->
index = @standingOrder.standing_line_items.indexOf(item)
@standingOrder.standing_line_items.splice(index,1)
create: ->
StatusMessage.display 'progress', 'Saving...'
delete @errors[k] for k, v of @errors