Commit 5e48d324 authored by Randall Leeds's avatar Randall Leeds

Show spinner on account and auth form submits

Close #1213
parent 7f693bfa
...@@ -31,6 +31,11 @@ class AuthController ...@@ -31,6 +31,11 @@ class AuthController
angular.bind(this, failure, form) angular.bind(this, failure, form)
session.$resolved = false session.$resolved = false
# Update status btn
$scope.$broadcast 'formState', form.$name, 'loading'
session.$promise.finally ->
$scope.$broadcast 'formState', form.$name, ''
$scope.$on '$destroy', -> $scope.$on '$destroy', ->
if timeout if timeout
$timeout.cancel timeout $timeout.cancel timeout
......
...@@ -14,7 +14,7 @@ class AccountManagement ...@@ -14,7 +14,7 @@ class AccountManagement
form.$setPristine() form.$setPristine()
formModel = form.$name.slice(0, -4) formModel = form.$name.slice(0, -4)
$scope[formModel] = {} # Reset form fields. $scope[formModel] = {} # Reset form fields.
$scope.$broadcast 'formState', form.$name, 'success' # Update status btn
onDelete = (form, response) -> onDelete = (form, response) ->
identity.logout() identity.logout()
...@@ -29,6 +29,8 @@ class AccountManagement ...@@ -29,6 +29,8 @@ class AccountManagement
else else
flash('error', 'Sorry, we were unable to perform your request') flash('error', 'Sorry, we were unable to perform your request')
$scope.$broadcast 'formState', form.$name, '' # Update status btn
# Data for each of the forms # Data for each of the forms
$scope.editProfile = {} $scope.editProfile = {}
$scope.changePassword = {} $scope.changePassword = {}
...@@ -67,6 +69,7 @@ class AccountManagement ...@@ -67,6 +69,7 @@ class AccountManagement
successHandler = angular.bind(null, onSuccess, form) successHandler = angular.bind(null, onSuccess, form)
errorHandler = angular.bind(null, onError, form) errorHandler = angular.bind(null, onError, form)
$scope.$broadcast 'formState', form.$name, 'loading' # Update status btn
promise = profile.edit_profile(packet) promise = profile.edit_profile(packet)
promise.$promise.then(successHandler, errorHandler) promise.$promise.then(successHandler, errorHandler)
......
...@@ -29,7 +29,7 @@ statusButton = -> ...@@ -29,7 +29,7 @@ statusButton = ->
unless targetForm unless targetForm
throw new Error('status-button attribute should provide a form name') throw new Error('status-button attribute should provide a form name')
elem = angular.element(template) elem = angular.element(template).attr(STATE_ATTRIBUTE, '')
placeholder.after(elem) placeholder.after(elem)
transclude(scope, (clone) -> elem.append(clone)) transclude(scope, (clone) -> elem.append(clone))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment