mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
12 lines
428 B
CoffeeScript
12 lines
428 B
CoffeeScript
angular.module("admin.utils").factory "CountryStates", ($filter) ->
|
|
new class CountryStates
|
|
|
|
statesFor: (countries, country_id) ->
|
|
return [] unless country_id
|
|
country = $filter('filter')(countries, {id: parseInt(country_id)}, true)[0]
|
|
return [] unless country
|
|
country.states
|
|
|
|
addressStateMatchesCountryStates: (countryStates, stateId) ->
|
|
countryStates.some (state) -> state.id == stateId
|