Catch server errors in edit US form

stable
David Barragán Merino 2014-08-07 12:45:45 +02:00
parent 771ed5fc25
commit a1067ad503
1 changed files with 13 additions and 2 deletions

View File

@ -151,15 +151,26 @@ UsDirective = ($tgrepo, $log, $location, $confirm) ->
if not form.validate()
return
$tgrepo.save($scope.us).then ->
onSuccess = ->
$confirm.notify("success")
$location.path("/project/#{$scope.project.slug}/us/#{$scope.us.ref}")
onError = ->
$confirm.notify("error")
$tgrepo.save($scope.us).then(onSuccess, onError)
$el.on "click", ".add-comment a.button-green", (event) ->
event.preventDefault()
$tgrepo.save($scope.us).then ->
onSuccess = ->
$ctrl.loadHistory()
onError = ->
$confirm.notify("error")
$tgrepo.save($scope.us).then(onSuccess, onError)
$el.on "click", ".us-activity-tabs li a", (event) ->
$el.find(".us-activity-tabs li a").toggleClass("active")
$el.find(".us-activity section").toggleClass("hidden")