Billing and Shipping addresses can be set on new standing orders

This commit is contained in:
Rob Harrington
2016-10-14 16:59:48 +11:00
parent b701ca43f4
commit 4ad6b1a65e
12 changed files with 170 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
angular.module("admin.standingOrders").controller "AddressController", ($scope, $filter, StatusMessage, availableCountries) ->
$scope.submitted = false
$scope.countries = availableCountries
$scope.statesFor = (country_id) ->
return [] unless country_id
$filter('filter')(availableCountries, {id: country_id})[0].states
$scope.billStates = $scope.statesFor($scope.standingOrder.bill_address.country_id)
$scope.shipStates = $scope.statesFor($scope.standingOrder.ship_address.country_id)
$scope.next = ->
$scope.submitted = true
if $scope.standing_order_address_form.$valid
StatusMessage.clear()
$scope.setView('products')
else
StatusMessage.display 'failure', t('admin.standing_orders.details.invalid_error')
$scope.back = -> $scope.setView('details')
$scope.$watch 'standingOrder.bill_address.country_id', (newValue, oldValue) ->
$scope.billStates = $scope.statesFor(newValue) if newValue?
$scope.$watch 'standingOrder.ship_address.country_id', (newValue, oldValue) ->
$scope.shipStates = $scope.statesFor(newValue) if newValue?

View File

@@ -5,6 +5,6 @@ angular.module("admin.standingOrders").controller "DetailsController", ($scope,
$scope.submitted = true
if $scope.standing_order_details_form.$valid
StatusMessage.clear()
$scope.setView('products')
$scope.setView('address')
else
StatusMessage.display 'failure', t('admin.standing_orders.details.invalid_error')

View File

@@ -6,4 +6,4 @@ angular.module("admin.standingOrders").controller "ProductsController", ($scope,
else
StatusMessage.display 'failure', 'Please add at least one product'
$scope.back = -> $scope.setView('details')
$scope.back = -> $scope.setView('address')