Răsfoiți Sursa

cleaned it up a touch, showed how to handle http errors

Henry Oswald 12 ani în urmă
părinte
comite
c075716b0f

+ 9 - 10
services/web/app/views/project/list.jade

@@ -101,21 +101,20 @@ block content
 						ul#projectList
 							mixin projectList(projects)
 
-					#userProfileInformation(ng-app="userProfileInformationApp")
+					.span3#userProfileInformation(ng-app="userProfileInformationApp")
 						div(ng-controller="UpdateForm")
 							div(ng-hide="hidePersonalInfoSection")
-								div(ng-show="percentComplete == 100")
+								div(ng-show="percentComplete >= 100")
 									span Thanks!
-								div(ng-hide="percentComplete == 100")
-									.span3
-										.span8
-											.progress
-												.bar.bar-success(ng-style="{'width' : (percentComplete+'%')}")
-											span Account {{percentComplete}}% complete
+								div(ng-hide="percentComplete >= 100")
+									.span8
+										.progress
+											.bar.bar-success(ng-style="{'width' : (percentComplete+'%')}")
+										span Account {{percentComplete}}% complete
 
-											button.btn(ng-hide="formVisable", ng-click="formVisable = true") Complete now
+										button.btn(ng-hide="formVisable", ng-click="formVisable = true") Complete now
 
-									.span3(ng-show="formVisable")
+									.span8(ng-show="formVisable")
 										form(enctype='multipart/form-data', method='post')
 											.input
 												input(type='text',  name='first_name', ng-model="userInfoForm.first_name",  ng-blur="sendUpdate()")

+ 7 - 8
services/web/public/coffee/UserDetailsUpdater.coffee

@@ -1,8 +1,6 @@
 
 app = angular.module("userProfileInformationApp", [])
 
-
-
 app.controller "UpdateForm", ($scope, $http)->
 
 	$scope.hidePersonalInfoSection = true
@@ -16,18 +14,19 @@ app.controller "UpdateForm", ($scope, $http)->
 			_csrf : window.csrfToken
 
 		if getPercentComplete() != 100
-			console.log "!!!!!!!"
 			$scope.percentComplete = getPercentComplete()
 			$scope.hidePersonalInfoSection = false
-			
-			console.log $scope.percentComplete
-
 
 	$scope.sendUpdate = ->
-		$http.post "/user/personal_info", $scope.userInfoForm
+		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"
 		$scope.percentComplete = getPercentComplete()
 
 	getPercentComplete = ->
 		results = _.filter $scope.userInfoForm, (value)-> value? and value?.length != 0
-		console.log results.length * 20
 		results.length * 20
+
+