mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Merge pull request #1816 from coopdevs/disable-create-profile-on-submit
Disable create profile on submit
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -11,7 +11,11 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
|
||||
for key, value of enterpriseAttributes
|
||||
@enterprise[key] = value
|
||||
|
||||
create: =>
|
||||
# Creates the enterprise and redirects to the about step on success.
|
||||
#
|
||||
# @param callback [Function] executed at the end of the operation both in
|
||||
# case of success or failure.
|
||||
create: (callback) =>
|
||||
Loading.message = t('creating') + " " + @enterprise.name
|
||||
$http(
|
||||
method: "POST"
|
||||
@@ -33,6 +37,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
|
||||
else
|
||||
alert(t('failed_to_create_enterprise_unknown'))
|
||||
)
|
||||
callback.call() if callback?
|
||||
|
||||
update: (step) =>
|
||||
Loading.message = t('updating') + " " + @enterprise.name
|
||||
|
||||
@@ -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}}" }
|
||||
|
||||
Reference in New Issue
Block a user