From bfa5ce2f3500bf0b4fd88b71c38d9057405a66c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Thu, 7 Aug 2014 12:43:40 +0200 Subject: [PATCH] Catch server errors in edit issue form --- app/coffee/modules/issues/detail.coffee | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index dc5f76a0..5e5e38f8 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -147,15 +147,25 @@ IssueDirective = ($tgrepo, $log, $location, $confirm) -> if not form.validate() return - $tgrepo.save($scope.issue).then -> + onSuccess = -> $confirm.notify("success") $location.path("/project/#{$scope.project.slug}/issues/#{$scope.issue.ref}") + onError = -> + $confirm.notify("error") + + $tgrepo.save($scope.issue).then(onSuccess, onError) + $el.on "click", ".add-comment a.button-green", (event) -> event.preventDefault() - $tgrepo.save($scope.issue).then -> + onSuccess = -> $ctrl.loadHistory() + onError = -> + $confirm.notify("error") + + $tgrepo.save($scope.issue).then(onSuccess, onError) + $el.on "focus", ".add-comment textarea", (event) -> $(this).addClass('active')