diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index ae487649..5bb01b02 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -257,13 +257,16 @@ module.controller("KanbanController", KanbanController) KanbanDirective = ($repo, $rootscope) -> link = ($scope, $el, $attrs) -> - tableBodyDom = $el.find(".kanban-table-body") + tableBodyDom.on "scroll", (event) -> target = angular.element(event.currentTarget) tableHeaderDom = $el.find(".kanban-table-header .kanban-table-inner") tableHeaderDom.css("left", -1 * target.scrollLeft()) + $scope.$on "$destroy", -> + $el.off() + return {link: link} module.directive("tgKanban", ["$tgRepo", "$rootScope", KanbanDirective]) @@ -280,10 +283,14 @@ KanbanRowWidthFixerDirective = -> size = (statuses.length * itemSize) - 10 $el.css("width", "#{size}px") + $scope.$on "$destroy", -> + $el.off() + return {link: link} module.directive("tgKanbanRowWidthFixer", KanbanRowWidthFixerDirective) + ############################################################################# ## Kanban Column Height Fixer Directive ############################################################################# @@ -301,6 +308,9 @@ KanbanColumnHeightFixerDirective = -> link = ($scope, $el, $attrs) -> timeout(500, -> renderSize($el)) + $scope.$on "$destroy", -> + $el.off() + return {link:link} @@ -312,14 +322,23 @@ module.directive("tgKanbanColumnHeightFixer", KanbanColumnHeightFixerDirective) KanbanUserstoryDirective = ($rootscope) -> link = ($scope, $el, $attrs, $model) -> + $el.disableSelection() + + $scope.$watch "us", (us) -> + if us.is_blocked and not $el.hasClass("blocked") + $el.addClass("blocked") + else if not us.is_blocked and $el.hasClass("blocked") + $el.removeClass("blocked") + $el.find(".icon-edit").on "click", (event) -> if $el.find(".icon-edit").hasClass("noclick") return + $scope.$apply -> $rootscope.$broadcast("usform:edit", $model.$modelValue) - if $scope.us.is_blocked - $el.addClass("blocked") - $el.disableSelection() + + $scope.$on "$destroy", -> + $el.off() return { templateUrl: "/partials/views/components/kanban-task.html" @@ -327,7 +346,6 @@ KanbanUserstoryDirective = ($rootscope) -> require: "ngModel" } - module.directive("tgKanbanUserstory", ["$rootScope", KanbanUserstoryDirective]) @@ -351,6 +369,9 @@ KanbanWipLimitDirective = -> $scope.$on "usform:new:success", redrawWipLimit $scope.$on "usform:bulk:success", redrawWipLimit + $scope.$on "$destroy", -> + $el.off() + return {link: link} module.directive("tgKanbanWipLimit", KanbanWipLimitDirective) @@ -412,7 +433,9 @@ KanbanUserDirective = ($log) -> $ctrl = $el.controller() $ctrl.changeUsAssignedTo(us) + $scope.$on "$destroy", -> + $el.off() + return {link: link, require:"ngModel"} - module.directive("tgKanbanUserAvatar", ["$log", KanbanUserDirective])