2014-06-11 12:45:09 -04:00
|
|
|
|
|
|
|
app = angular.module("userProfileInformationApp", [])
|
|
|
|
|
|
|
|
app.controller "UpdateForm", ($scope, $http)->
|
|
|
|
|
|
|
|
$scope.hidePersonalInfoSection = true
|
|
|
|
|
|
|
|
$http.get("/user/personal_info").success (data)->
|
|
|
|
$scope.userInfoForm =
|
|
|
|
first_name: data.first_name
|
|
|
|
last_name: data.last_name
|
|
|
|
role: data.role
|
|
|
|
institution: data.institution
|
|
|
|
_csrf : window.csrfToken
|
|
|
|
|
|
|
|
if getPercentComplete() != 100
|
|
|
|
$scope.percentComplete = getPercentComplete()
|
|
|
|
$scope.hidePersonalInfoSection = false
|
|
|
|
|
|
|
|
$scope.sendUpdate = ->
|
2014-06-12 05:23:42 -04:00
|
|
|
request = $http.post "/user/personal_info", $scope.userInfoForm
|
|
|
|
request.success (data, status)->
|
|
|
|
console.log "the post worked"
|
|
|
|
request.error (data, status)->
|
|
|
|
console.log "the request failed"
|
2014-06-11 12:45:09 -04:00
|
|
|
$scope.percentComplete = getPercentComplete()
|
|
|
|
|
|
|
|
getPercentComplete = ->
|
|
|
|
results = _.filter $scope.userInfoForm, (value)-> value? and value?.length != 0
|
|
|
|
results.length * 20
|
2014-06-12 05:23:42 -04:00
|
|
|
|
|
|
|
|