Changing textToColor with the new tag coloration system
parent
18507708e0
commit
a810726516
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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) ->
|
|||
</div>
|
||||
<% }); %>""")
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue