Adding loading to add bulk of uss

stable
Jesús Espino 2014-08-29 14:12:56 +02:00
parent cbcba41ab8
commit 5e3f91d024
1 changed files with 8 additions and 1 deletions

View File

@ -262,7 +262,7 @@ module.directive("tgLbCreateEditUserstory", [
## Creare Bulk Userstories Lightbox Directive ## Creare Bulk Userstories Lightbox Directive
############################################################################# #############################################################################
CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService) -> CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService, $loading) ->
link = ($scope, $el, attrs) -> link = ($scope, $el, attrs) ->
$scope.$on "usform:bulk", (ctx, projectId, status) -> $scope.$on "usform:bulk", (ctx, projectId, status) ->
$scope.new = { $scope.new = {
@ -281,12 +281,18 @@ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService) ->
if not form.validate() if not form.validate()
return return
target = angular.element(event.currentTarget)
$loading.start(target)
promise = $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk) promise = $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk)
promise.then (result) -> promise.then (result) ->
$loading.finish(target)
$rootscope.$broadcast("usform:bulk:success", result) $rootscope.$broadcast("usform:bulk:success", result)
lightboxService.close($el) lightboxService.close($el)
promise.then null, (data) -> promise.then null, (data) ->
$loading.finish(target)
form.setErrors(data) form.setErrors(data)
if data._error_message if data._error_message
$confirm.notify("error", data._error_message) $confirm.notify("error", data._error_message)
@ -301,6 +307,7 @@ module.directive("tgLbCreateBulkUserstories", [
"$tgResources", "$tgResources",
"$rootScope", "$rootScope",
"lightboxService", "lightboxService",
"$tgLoading",
CreateBulkUserstoriesDirective CreateBulkUserstoriesDirective
]) ])