Jelajahi Sumber

Make sure to send description before publishing

James Allen 12 tahun lalu
induk
melakukan
a59a2dcf39

+ 0 - 1
services/web/app/views/project/editor/publish-template.jade

@@ -15,7 +15,6 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
 					rows=5,
 					rows=5,
 					name='Description',
 					name='Description',
 					ng-model="templateDetails.description",
 					ng-model="templateDetails.description",
-					ng-blur="updateProjectDescription()",
 					value=""
 					value=""
 				)
 				)
 			div(ng-show="templateDetails.exists").text-center.templateDetails
 			div(ng-show="templateDetails.exists").text-center.templateDetails

+ 20 - 18
services/web/public/coffee/ide/templates/controllers/TemplatesController.coffee

@@ -38,30 +38,32 @@ define [
 					problemTalkingToTemplateApi()
 					problemTalkingToTemplateApi()
 
 
 		refreshPublishedStatus()
 		refreshPublishedStatus()
-		$scope.$watch $scope.problemTalkingToTemplateApi, refreshPublishedStatus
+		$scope.$watch $scope.problemTalkingToTemplateApi, (value) ->
+			if value?
+				refreshPublishedStatus()
 
 
-		$scope.updateProjectDescription = ->
-			description = $scope.templateDetails.description
-			if description?
-				$http
-					.post("/project/#{ide.project_id}/template/description", {
-						description: description
-						_csrf: window.csrfToken
-					})
-					.error () ->
-						problemTalkingToTemplateApi()
+		updateProjectDescription = ->
+			$http.post("/project/#{ide.project_id}/template/description", {
+				description: $scope.templateDetails.description
+				_csrf: window.csrfToken
+			})
 
 
 		$scope.publishTemplate = ->
 		$scope.publishTemplate = ->
 			$scope.state.publishInflight = true
 			$scope.state.publishInflight = true
-			$http
-				.post("/project/#{ide.project_id}/template/publish", {
-					_csrf: window.csrfToken
-				})
-				.success () ->
-					refreshPublishedStatus()
-					$scope.state.publishInflight = false
+			updateProjectDescription()
 				.error () ->
 				.error () ->
 					problemTalkingToTemplateApi()
 					problemTalkingToTemplateApi()
+				.success () ->
+					$http
+						.post("/project/#{ide.project_id}/template/publish", {
+							_csrf: window.csrfToken
+						})
+						.error () ->
+							problemTalkingToTemplateApi()
+						.success () ->
+							refreshPublishedStatus()
+							$scope.state.publishInflight = false
+					
 
 
 		$scope.unpublishTemplate = ->
 		$scope.unpublishTemplate = ->
 			$scope.state.unpublishInflight = true
 			$scope.state.unpublishInflight = true