Add loading to block button directive and lightbox
parent
c0a1acb40f
commit
02c0b38bff
|
@ -339,7 +339,7 @@ module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", "$tgRepo", Assigne
|
|||
## Block Button directive
|
||||
#############################################################################
|
||||
|
||||
BlockButtonDirective = ($rootscope) ->
|
||||
BlockButtonDirective = ($rootscope, $loading) ->
|
||||
template = _.template("""
|
||||
<a class="button button-gray item-block">Block</a>
|
||||
<a class="button button-red item-unblock">Unblock</a>
|
||||
|
@ -366,7 +366,11 @@ BlockButtonDirective = ($rootscope) ->
|
|||
$rootscope.$broadcast("block", $model.$modelValue)
|
||||
|
||||
$el.on "click", ".item-unblock", (event) ->
|
||||
$rootscope.$broadcast("unblock", $model.$modelValue)
|
||||
$loading.start($el.find(".item-unblock"))
|
||||
finish = ->
|
||||
$loading.finish($el.find(".item-unblock"))
|
||||
|
||||
$rootscope.$broadcast("unblock", $model.$modelValue, finish)
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
$el.off()
|
||||
|
@ -377,7 +381,7 @@ BlockButtonDirective = ($rootscope) ->
|
|||
require: "ngModel"
|
||||
}
|
||||
|
||||
module.directive("tgBlockButton", ["$rootScope", BlockButtonDirective])
|
||||
module.directive("tgBlockButton", ["$rootScope", "$tgLoading", BlockButtonDirective])
|
||||
|
||||
#############################################################################
|
||||
## Delete Button directive
|
||||
|
|
|
@ -127,7 +127,7 @@ module.directive("lightbox", ["lightboxService", LightboxDirective])
|
|||
|
||||
# Issue/Userstory blocking message lightbox directive.
|
||||
|
||||
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService) ->
|
||||
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading) ->
|
||||
link = ($scope, $el, $attrs, $model) ->
|
||||
$el.find("h2.title").text($attrs.title)
|
||||
|
||||
|
@ -135,22 +135,26 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService) ->
|
|||
$el.find(".reason").val($model.$modelValue.blocked_note)
|
||||
lightboxService.open($el)
|
||||
|
||||
$scope.$on "unblock", ->
|
||||
$scope.$on "unblock", (event, model, finishCallback) ->
|
||||
item = $model.$modelValue.clone()
|
||||
item.is_blocked = false
|
||||
item.blocked_note = ""
|
||||
$model.$setViewValue(item)
|
||||
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise = $tgrepo.save(item)
|
||||
promise.then ->
|
||||
$confirm.notify("success")
|
||||
$rootscope.$broadcast("history:reload")
|
||||
$model.$setViewValue(item)
|
||||
finishCallback()
|
||||
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
item.revert()
|
||||
$model.$setViewValue(item)
|
||||
|
||||
promise.finally ->
|
||||
finishCallback()
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
$el.off()
|
||||
|
||||
|
@ -162,6 +166,8 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService) ->
|
|||
item.blocked_note = $el.find(".reason").val()
|
||||
$model.$setViewValue(item)
|
||||
|
||||
$loading.start($el.find(".button-green"))
|
||||
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$confirm.notify("success")
|
||||
|
@ -172,7 +178,9 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService) ->
|
|||
item.revert()
|
||||
$model.$setViewValue(item)
|
||||
|
||||
lightboxService.close($el)
|
||||
promise.finally ->
|
||||
$loading.finish($el.find(".button-green"))
|
||||
lightboxService.close($el)
|
||||
|
||||
return {
|
||||
templateUrl: "/partials/views/modules/lightbox-block.html"
|
||||
|
@ -180,7 +188,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService) ->
|
|||
require: "ngModel"
|
||||
}
|
||||
|
||||
module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", BlockLightboxDirective])
|
||||
module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", "$tgLoading", BlockLightboxDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
Loading…
Reference in New Issue