mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Fix subscription address form. It now clears the state selection when a different country is selected
This commit is contained in:
@@ -8,7 +8,8 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
|
||||
scope.$watch 'address.country_id', (newCountryID) ->
|
||||
return unless newCountryID
|
||||
scope.states = CountryStates.statesFor(scope.availableCountries, newCountryID)
|
||||
scope.clearState() unless CountryStates.addressStateMatchesCountryStates(scope.states, scope.address.state_id)
|
||||
unless CountryStates.addressStateMatchesCountryStates(scope.states, scope.address.state_id)
|
||||
scope.address.state_id = ""
|
||||
|
||||
scope.updateAddress = ->
|
||||
scope.edit_address_form.$setPristine()
|
||||
@@ -33,6 +34,3 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
|
||||
template.dialog(DialogDefaults)
|
||||
template.dialog('open')
|
||||
scope.$apply()
|
||||
|
||||
scope.clearState = ->
|
||||
scope.address.state_id = ""
|
||||
|
||||
@@ -4,11 +4,17 @@ angular.module("admin.subscriptions").controller "AddressController", ($scope, S
|
||||
$scope.billStates = CountryStates.statesFor(availableCountries, $scope.subscription.bill_address.country_id)
|
||||
$scope.shipStates = CountryStates.statesFor(availableCountries, $scope.subscription.ship_address.country_id)
|
||||
|
||||
$scope.$watch 'subscription.bill_address.country_id', (newValue, oldValue) ->
|
||||
$scope.billStates = CountryStates.statesFor(availableCountries, newValue) if newValue?
|
||||
$scope.$watch 'subscription.bill_address.country_id', (newCountryID) ->
|
||||
return unless newCountryID
|
||||
$scope.billStates = CountryStates.statesFor(availableCountries, newCountryID)
|
||||
unless CountryStates.addressStateMatchesCountryStates($scope.billStates, $scope.subscription.bill_address.state_id)
|
||||
$scope.subscription.bill_address.state_id = ""
|
||||
|
||||
$scope.$watch 'subscription.ship_address.country_id', (newValue, oldValue) ->
|
||||
$scope.shipStates = CountryStates.statesFor(availableCountries, newValue) if newValue?
|
||||
$scope.$watch 'subscription.ship_address.country_id', (newCountryID) ->
|
||||
return unless newCountryID
|
||||
$scope.shipStates = CountryStates.statesFor(availableCountries, newCountryID)
|
||||
unless CountryStates.addressStateMatchesCountryStates($scope.shipStates, $scope.subscription.ship_address.state_id)
|
||||
$scope.subscription.ship_address.state_id = ""
|
||||
|
||||
$scope.registerNextCallback 'address', ->
|
||||
$scope.subscription_form.$submitted = true
|
||||
|
||||
Reference in New Issue
Block a user