Extract countryStates logic from customer_address modal and re-use new CountryStates service

This commit is contained in:
luisramos0
2018-10-16 22:45:38 +01:00
parent 5c5a2194d6
commit 1804bf5a2b
3 changed files with 10 additions and 14 deletions

View File

@@ -3,6 +3,9 @@ angular.module("ofn.admin").factory "CountryStates", ($filter) ->
statesFor: (countries, country_id) ->
return [] unless country_id
country = $filter('filter')(countries, {id: country_id}, true)[0]
country = $filter('filter')(countries, {id: parseInt(country_id)}, true)[0]
return [] unless country
country.states
addressStateMatchesCountryStates: (countryStates, stateId) ->
countryStates.some (state) -> state.id == stateId