From 53745273e65c39568e83a1bbc89f84ad8e4e186f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Juli=C3=A1n?= Date: Mon, 17 Nov 2014 12:30:16 +0100 Subject: [PATCH] Save fold unfold status on storage --- app/coffee/modules/kanban/main.coffee | 14 +++++++------- app/coffee/modules/resources/kanban.coffee | 11 +++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index 5aa50532..6d65de4c 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -359,22 +359,22 @@ module.directive("tgKanbanUserstory", ["$rootScope", KanbanUserstoryDirective]) ## Kanban Squish Column Directive ############################################################################# -KanbanSquishColumnDirective = -> +KanbanSquishColumnDirective = (rs) -> #TODO: Only header is folding/unfolding so - # 1. Save folded/unfolded column status. - # 2. Recalculate container width. + # 1. Recalculate container width. link = ($scope, $el, $attrs) -> - $scope.folds = [] + $scope.$on "project:loaded", (event, project) -> + $scope.folds = rs.kanban.getStatusColumnModes(project.id) + $scope.foldStatus = (status) -> $scope.folds[status.id] = !!!$scope.folds[status.id] - if $scope.folds[status.id] - fold() + rs.kanban.storeStatusColumnModes($scope.projectId, $scope.folds) return {link: link} -module.directive("tgKanbanSquishColumn", KanbanSquishColumnDirective) +module.directive("tgKanbanSquishColumn", ["$tgResources", KanbanSquishColumnDirective]) ############################################################################# ## Kaban WIP Limit Directive diff --git a/app/coffee/modules/resources/kanban.coffee b/app/coffee/modules/resources/kanban.coffee index a5c1fd53..b1268dfe 100644 --- a/app/coffee/modules/resources/kanban.coffee +++ b/app/coffee/modules/resources/kanban.coffee @@ -27,6 +27,7 @@ generateHash = taiga.generateHash resourceProvider = ($storage) -> service = {} hashSuffixStatusViewModes = "kanban-statusviewmodels" + hashSuffixStatusColumnModes = "kanban-statuscolumnmodels" service.storeStatusViewModes = (projectId, params) -> ns = "#{projectId}:#{hashSuffixStatusViewModes}" @@ -38,6 +39,16 @@ resourceProvider = ($storage) -> hash = generateHash([projectId, ns]) return $storage.get(hash) or {} + service.storeStatusColumnModes = (projectId, params) -> + ns = "#{projectId}:#{hashSuffixStatusColumnModes}" + hash = generateHash([projectId, ns]) + $storage.set(hash, params) + + service.getStatusColumnModes = (projectId) -> + ns = "#{projectId}:#{hashSuffixStatusColumnModes}" + hash = generateHash([projectId, ns]) + return $storage.get(hash) or {} + return (instance) -> instance.kanban = service