parent
dfcc1b567d
commit
4a68f728f6
|
@ -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
|
||||
|
|
|
@ -133,5 +133,6 @@ module.run([
|
|||
"$tgAttachmentsResourcesProvider",
|
||||
"$tgMdRenderResourcesProvider",
|
||||
"$tgHistoryResourcesProvider",
|
||||
"$tgKanbanResourcesProvider",
|
||||
initResources
|
||||
])
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
###
|
||||
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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])
|
Loading…
Reference in New Issue