Make sure to send description before publishing

This commit is contained in:
James Allen 2014-11-07 10:20:29 +00:00
parent c9e5583394
commit a59a2dcf39
2 changed files with 20 additions and 19 deletions

View file

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

View file

@ -38,30 +38,32 @@ define [
problemTalkingToTemplateApi()
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.state.publishInflight = true
$http
.post("/project/#{ide.project_id}/template/publish", {
_csrf: window.csrfToken
})
.success () ->
refreshPublishedStatus()
$scope.state.publishInflight = false
updateProjectDescription()
.error () ->
problemTalkingToTemplateApi()
.success () ->
$http
.post("/project/#{ide.project_id}/template/publish", {
_csrf: window.csrfToken
})
.error () ->
problemTalkingToTemplateApi()
.success () ->
refreshPublishedStatus()
$scope.state.publishInflight = false
$scope.unpublishTemplate = ->
$scope.state.unpublishInflight = true