diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 59999cae..de9f2100 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -26,8 +26,6 @@ toggleText = @.taiga.toggleText scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy -textToColor = @.taiga.textToColor -bindOnce = @.taiga.bindOnce module = angular.module("taigaBacklog") @@ -321,12 +319,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F @scope.filters = {} plainTags = _.flatten(_.map(@scope.userstories, "tags")) - @scope.filters.tags = _.map _.countBy(plainTags), (v, k) -> + @scope.filters.tags = _.map _.countBy(plainTags), (v, k) => obj = { id: k, type: "tags", name: k, - color: textToColor(k), + color: @scope.project.tags_colors[k], count: v } obj.selected = true if isSelected("tags", obj.id) diff --git a/app/coffee/modules/base/tags.coffee b/app/coffee/modules/base/tags.coffee index 0ce25457..0bb34b9e 100644 --- a/app/coffee/modules/base/tags.coffee +++ b/app/coffee/modules/base/tags.coffee @@ -20,7 +20,6 @@ ### taiga = @.taiga -textToColor = @.taiga.textToColor module = angular.module("taigaBase") @@ -54,7 +53,7 @@ module.directive("tgTags", TagsDirective) ColorizeTagBackgroundDirective = -> link = ($scope, $el, $attrs, $ctrl) -> text = $scope.$eval($attrs.tgColorizeTagBackground) - color = textToColor(text) + color = $scope.project.tags_colors[text] $el.css("background", color) return {link: link} @@ -65,7 +64,7 @@ module.directive("tgColorizeTagBackground", ColorizeTagBackgroundDirective) ColorizeTagBorderLeftDirective = -> link = ($scope, $el, $attrs, $ctrl) -> text = $scope.$eval($attrs.tgColorizeTagBorderLeft) - color = textToColor(text) + color = $scope.project.tags_colors[text] $el.css("border-left", "5px solid #{color}") return {link: link} diff --git a/app/coffee/modules/common.coffee b/app/coffee/modules/common.coffee index 3600f4a3..e5fa975a 100644 --- a/app/coffee/modules/common.coffee +++ b/app/coffee/modules/common.coffee @@ -23,7 +23,6 @@ taiga = @.taiga trim = @.taiga.trim typeIsArray = @.taiga.typeIsArray -textToColor = @.taiga.textToColor module = angular.module("taigaCommon", []) @@ -50,9 +49,9 @@ TagLineDirective = ($log) -> <% }); %>""") - renderTags = ($el, tags, editable) -> + renderTags = ($el, tags, editable, tagsColors) -> ctx = { - tags: _.map(tags, (t) -> {name: t, color: textToColor(t)}) + tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]}) editable: editable } html = templateTags(ctx) @@ -68,7 +67,7 @@ TagLineDirective = ($log) -> $scope.$watch $attrs.ngModel, (val) -> return if not val - renderTags($el, val, editable) + renderTags($el, val, editable, $scope.project.tags_colors) $el.find("input").remove() if not editable diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index 3dff59d0..4e261cc3 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -29,7 +29,6 @@ groupBy = @.taiga.groupBy bindOnce = @.taiga.bindOnce debounce = @.taiga.debounce startswith = @.taiga.startswith -textToColor = @.taiga.textToColor module = angular.module("taigaIssues") @@ -169,7 +168,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi obj = { id: t[0], name: t[0], - color: textToColor(t[0]), + color: @scope.project.tags_colors[t[0]], count: t[1], type: "tags" } diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index 668b8d12..30e60284 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -124,20 +124,6 @@ sizeFormat = (input, precision=1) -> typeIsArray = Array.isArray || ( value ) -> return {}.toString.call( value ) is '[object Array]' -textToColor = (text) -> - hash = hex_sha1(text.trim().toLowerCase()) - color = hash.substring(0,6) - .replace("0","8") - .replace("1","9") - .replace("2","a") - .replace("3","b") - .replace("4","c") - .replace("5","d") - .replace("6","e") - .replace("7","f") - return "##{color}" - - # Generic method for generate hash from a arbitrary length # collection of parameters. generateHash = (components=[]) -> @@ -161,5 +147,4 @@ taiga.debounce = debounce taiga.startswith = startswith taiga.sizeFormat = sizeFormat taiga.typeIsArray = typeIsArray -taiga.textToColor = textToColor taiga.generateHash = generateHash