Commit 7e708fdd authored by Aron Carroll's avatar Aron Carroll Committed by Randall Leeds

Update all account management forms for consistency

Now all forms use the profile view name plus "form". For example
the form for the edit_profile view would be editProfileForm. Each
ngModel is namespaced on the scope by the form name. So again this
would be $scope.editProfile. Lastly each field name uses the
corresponding field in the request payload. All fields are camel case.

This should make it far easier in future to read a form and match it
to the http request.
parent 8ca5aa3a
......@@ -4,14 +4,14 @@ class AccountManagement
constructor: ($scope, $rootScope, $filter, flash, profile, identity, util) ->
persona_filter = $filter('persona')
onSuccess = (response) ->
onSuccess = (form, response) ->
# Fire flash messages.
for type, msgs of response.flash
flash(type, msgs)
onDelete = (response) ->
onDelete = (form, response) ->
identity.logout()
onSuccess(response)
onSuccess(form, response)
onError = (form, data) ->
if 400 >= data.status < 500
......@@ -27,10 +27,13 @@ class AccountManagement
username = persona_filter $scope.session.userid
packet =
username: username
pwd: form.deleteaccountpassword.$modelValue
pwd: form.pwd.$modelValue
successHandler = angular.bind(null, onDelete, form)
errorHandler = angular.bind(null, onError, form)
promise = profile.disable_user(packet)
promise.$promise.then(onDelete, angular.bind(null, onError, form))
promise.$promise.then(successHandler, errorHandler)
$scope.submit = (form) ->
# In the frontend change_email and change_password are two different
......@@ -46,11 +49,14 @@ class AccountManagement
else
packet =
username: username
pwd: form.oldpassword.$modelValue
password: form.newpassword.$modelValue
pwd: form.pwd.$modelValue
password: form.password.$modelValue
successHandler = angular.bind(null, onSuccess, form)
errorHandler = angular.bind(null, onError, form)
promise = profile.edit_profile(packet)
promise.$promise.then(onSuccess, angular.bind(null, onError, form))
promise.$promise.then(successHandler, errorHandler)
$rootScope.$on 'nav:account', ->
$scope.$apply -> $scope.sheet = true
......
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