Adding countries and states to registration

This commit is contained in:
Rob H
2014-08-21 14:06:41 +10:00
parent 7dc42c9e39
commit ef8f611458
10 changed files with 56 additions and 45 deletions

View File

@@ -1,39 +1,13 @@
Darkswarm.controller "RegistrationCtrl", ($scope, $http, RegistrationService, CurrentUser, SpreeApiKey) ->
$scope.current_user = CurrentUser
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseCreationService, availableCountries) ->
$scope.currentStep = RegistrationService.currentStep
$scope.select = RegistrationService.select
$scope.enterprise = EnterpriseCreationService.enterprise
$scope.create = EnterpriseCreationService.create
$scope.steps = ['details','address','contact','about']
# ,'images','social'
$scope.enterprise =
user_ids: [CurrentUser.id]
email: CurrentUser.email
address: {
country_id: 12
state_id: 1061493592
}
$scope.countries = availableCountries
$scope.createEnterprise = ->
$http(
method: "POST"
url: "/api/enterprises"
data:
enterprise: $scope.prepare($scope.enterprise)
params:
token: SpreeApiKey
).success((data) ->
$scope.select('about')
).error((data) ->
console.log angular.toJson(data)
alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.')
)
# $scope.select('about')
$scope.prepare = (ent_obj) ->
enterprise = {}
for a, v of ent_obj when a isnt 'address'
enterprise[a] = v
enterprise.address_attributes = ent_obj.address
enterprise
$scope.countryHasStates = ->
$scope.enterprise.country.states.length > 0