From a59a2dcf39cd9cfaefd69f8c6b5f2395ebf7dc2b Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 7 Nov 2014 10:20:29 +0000 Subject: [PATCH] Make sure to send description before publishing --- .../project/editor/publish-template.jade | 1 - .../controllers/TemplatesController.coffee | 38 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/services/web/app/views/project/editor/publish-template.jade b/services/web/app/views/project/editor/publish-template.jade index 69c50fd52c..7fd2c1a0f4 100644 --- a/services/web/app/views/project/editor/publish-template.jade +++ b/services/web/app/views/project/editor/publish-template.jade @@ -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 diff --git a/services/web/public/coffee/ide/templates/controllers/TemplatesController.coffee b/services/web/public/coffee/ide/templates/controllers/TemplatesController.coffee index 01636d6c1a..f5e9f0777b 100644 --- a/services/web/public/coffee/ide/templates/controllers/TemplatesController.coffee +++ b/services/web/public/coffee/ide/templates/controllers/TemplatesController.coffee @@ -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