diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index 5887216d..52f3911b 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -64,6 +64,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, tgLoader) -> _.bindAll(@) @scope.sectionName = "Kanban" + @scope.statusViewModes = {} promise = @.loadInitialData() @@ -160,7 +161,8 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi @scope.usStatusById = groupBy(project.us_statuses, (x) -> x.id) @scope.usStatusList = _.sortBy(project.us_statuses, "order") - @.loadStatusViewMode() + @.generateStatusViewModes() + @scope.$emit("project:loaded", project) return project @@ -177,13 +179,22 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi ## View Mode methods - loadStatusViewMode: -> + generateStatusViewModes: -> + storedStatusViewModes = @rs.kanban.getStatusViewModes(@scope.projectId) + @scope.statusViewModes = {} for status in @scope.usStatusList - @scope.statusViewModes[status.id] = defaultViewMode + mode = storedStatusViewModes[status.id] + @scope.statusViewModes[status.id] = if _.has(defaultViewModes, mode) then mode else defaultViewMode + + @.storeStatusViewModes() + + storeStatusViewModes: -> + @rs.kanban.storeStatusViewModes(@scope.projectId, @scope.statusViewModes) updateStatusViewMode: (statusId, newViewMode) -> @scope.statusViewModes[statusId] = newViewMode + @.storeStatusViewModes() getCardClass: (statusId)-> mode = @scope.statusViewModes[statusId] or defaultViewMode diff --git a/app/coffee/modules/resources.coffee b/app/coffee/modules/resources.coffee index 6ee34072..aa486d60 100644 --- a/app/coffee/modules/resources.coffee +++ b/app/coffee/modules/resources.coffee @@ -133,5 +133,6 @@ module.run([ "$tgAttachmentsResourcesProvider", "$tgMdRenderResourcesProvider", "$tgHistoryResourcesProvider", + "$tgKanbanResourcesProvider", initResources ]) diff --git a/app/coffee/modules/resources/kanban.coffee b/app/coffee/modules/resources/kanban.coffee new file mode 100644 index 00000000..a5c1fd53 --- /dev/null +++ b/app/coffee/modules/resources/kanban.coffee @@ -0,0 +1,46 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/resources/kanban.coffee +### + + +taiga = @.taiga + +generateHash = taiga.generateHash + +resourceProvider = ($storage) -> + service = {} + hashSuffixStatusViewModes = "kanban-statusviewmodels" + + service.storeStatusViewModes = (projectId, params) -> + ns = "#{projectId}:#{hashSuffixStatusViewModes}" + hash = generateHash([projectId, ns]) + $storage.set(hash, params) + + service.getStatusViewModes = (projectId) -> + ns = "#{projectId}:#{hashSuffixStatusViewModes}" + hash = generateHash([projectId, ns]) + return $storage.get(hash) or {} + + return (instance) -> + instance.kanban = service + + +module = angular.module("taigaResources") +module.factory("$tgKanbanResourcesProvider", ["$tgStorage", resourceProvider])