diff --git a/app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee index fabc2c382a..546186f53d 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration/registration_form_controller.js.coffee @@ -1,15 +1,23 @@ Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, EnterpriseRegistrationService) -> $scope.submitted = false + $scope.isDisabled = false $scope.valid = (form) -> $scope.submitted = !form.$valid form.$valid $scope.create = (form) -> - EnterpriseRegistrationService.create() if $scope.valid(form) + $scope.disableButton() + EnterpriseRegistrationService.create($scope.enableButton) if $scope.valid(form) $scope.update = (nextStep, form) -> EnterpriseRegistrationService.update(nextStep) if $scope.valid(form) $scope.selectIfValid = (nextStep, form) -> RegistrationService.select(nextStep) if $scope.valid(form) + + $scope.disableButton = -> + $scope.isDisabled = true + + $scope.enableButton = -> + $scope.isDisabled = false diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index 1434ffa44f..de8d643711 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -11,7 +11,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, for key, value of enterpriseAttributes @enterprise[key] = value - create: => + create: (callback) => Loading.message = t('creating') + " " + @enterprise.name $http( method: "POST" @@ -25,6 +25,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, @enterprise.id = data EnterpriseImageService.configure(@enterprise) RegistrationService.select('about') + callback.call() ).error((data) => Loading.clear() if data?.errors? @@ -32,6 +33,8 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, alert t('failed_to_create_enterprise') + "\n" + errors.join('\n') else alert(t('failed_to_create_enterprise_unknown')) + + callback.call() ) update: (step) => diff --git a/app/views/registration/steps/_type.html.haml b/app/views/registration/steps/_type.html.haml index 4c93c441f4..5fcf6391b9 100644 --- a/app/views/registration/steps/_type.html.haml +++ b/app/views/registration/steps/_type.html.haml @@ -45,4 +45,4 @@ .row.buttons .small-12.columns %input.button.secondary{ type: "button", value: "{{'back' | t}}", ng: { click: "select('contact')" } } - %input.button.primary.right{ type: "submit", value: "{{'create_profile' | t}}" } + %input.button.primary.right{ ng: { disabled: 'isDisabled' }, type: "submit", value: "{{'create_profile' | t}}" }