From 7ea37decfb163c6c4a86febd3b59b3b4ba6b55af Mon Sep 17 00:00:00 2001 From: Juanfran Date: Wed, 10 Sep 2014 16:45:05 +0200 Subject: [PATCH] fix #925 --- app/coffee/modules/backlog/main.coffee | 28 +++++++++++++++---- .../modules/resources/userstories.coffee | 8 ++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 802a1357..d7d1aa3f 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -59,6 +59,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F # On Success promise.then => @appTitle.set("Backlog - " + @scope.project.name) + + if @rs.userstories.getShowTags(@scope.projectId) + @showTags = true + + @scope.$broadcast("showTags", @showTags) + tgLoader.pageLoaded() # $(".backlog, .sidebar").mCustomScrollbar({ @@ -89,6 +95,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F toggleShowTags: -> @scope.$apply () => @showTags = !@showTags + @rs.userstories.storeShowTags(@scope.projectId, @showTags) loadProjectStats: -> return @rs.projects.stats(@scope.projectId).then (stats) => @@ -510,12 +517,20 @@ BacklogDirective = ($repo, $rootscope) -> $el.on "click", "#show-tags", (event) -> event.preventDefault() - target = angular.element(event.currentTarget) - # $el.find(".user-story-tags").toggle() - $ctrl.toggleShowTags() - target.toggleClass("active") - toggleText(target.find(".text"), ["Hide Tags", "Show Tags"]) # TODO: i18n + $ctrl.toggleShowTags() + + showHideTags($ctrl); + + showHideTags = ($ctrl) -> + elm = angular.element("#show-tags") + + if $ctrl.showTags + elm.addClass("active") + elm.find(".text").text("Hide Tags") # TODO: i18n + else + elm.removeClass("active") + elm.find(".text").text("Show Tags") # TODO: i18n showHideFilter = ($scope, $el, $ctrl) -> sidebar = $el.find("sidebar.filters-bar") @@ -558,6 +573,9 @@ BacklogDirective = ($repo, $rootscope) -> filters.q showHideFilter($scope, $el, $ctrl) + $scope.$on "showTags", () -> + showHideTags($ctrl) + $scope.$on "$destroy", -> $el.off() diff --git a/app/coffee/modules/resources/userstories.coffee b/app/coffee/modules/resources/userstories.coffee index caeda114..c0a2d9fe 100644 --- a/app/coffee/modules/resources/userstories.coffee +++ b/app/coffee/modules/resources/userstories.coffee @@ -69,6 +69,14 @@ resourceProvider = ($repo, $http, $urls, $storage) -> hash = generateHash([projectId, ns]) return $storage.get(hash) or {} + service.storeShowTags = (projectId, showTags) -> + hash = generateHash([projectId, 'showTags']) + $storage.set(hash, showTags) + + service.getShowTags = (projectId) -> + hash = generateHash([projectId, 'showTags']) + return $storage.get(hash) or null + return (instance) -> instance.userstories = service