Changing textToColor with the new tag coloration system
parent
18507708e0
commit
a810726516
|
@ -26,8 +26,6 @@ toggleText = @.taiga.toggleText
|
||||||
scopeDefer = @.taiga.scopeDefer
|
scopeDefer = @.taiga.scopeDefer
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
groupBy = @.taiga.groupBy
|
groupBy = @.taiga.groupBy
|
||||||
textToColor = @.taiga.textToColor
|
|
||||||
bindOnce = @.taiga.bindOnce
|
|
||||||
|
|
||||||
module = angular.module("taigaBacklog")
|
module = angular.module("taigaBacklog")
|
||||||
|
|
||||||
|
@ -321,12 +319,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
@scope.filters = {}
|
@scope.filters = {}
|
||||||
|
|
||||||
plainTags = _.flatten(_.map(@scope.userstories, "tags"))
|
plainTags = _.flatten(_.map(@scope.userstories, "tags"))
|
||||||
@scope.filters.tags = _.map _.countBy(plainTags), (v, k) ->
|
@scope.filters.tags = _.map _.countBy(plainTags), (v, k) =>
|
||||||
obj = {
|
obj = {
|
||||||
id: k,
|
id: k,
|
||||||
type: "tags",
|
type: "tags",
|
||||||
name: k,
|
name: k,
|
||||||
color: textToColor(k),
|
color: @scope.project.tags_colors[k],
|
||||||
count: v
|
count: v
|
||||||
}
|
}
|
||||||
obj.selected = true if isSelected("tags", obj.id)
|
obj.selected = true if isSelected("tags", obj.id)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
textToColor = @.taiga.textToColor
|
|
||||||
|
|
||||||
module = angular.module("taigaBase")
|
module = angular.module("taigaBase")
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ module.directive("tgTags", TagsDirective)
|
||||||
ColorizeTagBackgroundDirective = ->
|
ColorizeTagBackgroundDirective = ->
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
text = $scope.$eval($attrs.tgColorizeTagBackground)
|
text = $scope.$eval($attrs.tgColorizeTagBackground)
|
||||||
color = textToColor(text)
|
color = $scope.project.tags_colors[text]
|
||||||
$el.css("background", color)
|
$el.css("background", color)
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
@ -65,7 +64,7 @@ module.directive("tgColorizeTagBackground", ColorizeTagBackgroundDirective)
|
||||||
ColorizeTagBorderLeftDirective = ->
|
ColorizeTagBorderLeftDirective = ->
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
text = $scope.$eval($attrs.tgColorizeTagBorderLeft)
|
text = $scope.$eval($attrs.tgColorizeTagBorderLeft)
|
||||||
color = textToColor(text)
|
color = $scope.project.tags_colors[text]
|
||||||
$el.css("border-left", "5px solid #{color}")
|
$el.css("border-left", "5px solid #{color}")
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
|
@ -23,7 +23,6 @@ taiga = @.taiga
|
||||||
|
|
||||||
trim = @.taiga.trim
|
trim = @.taiga.trim
|
||||||
typeIsArray = @.taiga.typeIsArray
|
typeIsArray = @.taiga.typeIsArray
|
||||||
textToColor = @.taiga.textToColor
|
|
||||||
|
|
||||||
module = angular.module("taigaCommon", [])
|
module = angular.module("taigaCommon", [])
|
||||||
|
|
||||||
|
@ -50,9 +49,9 @@ TagLineDirective = ($log) ->
|
||||||
</div>
|
</div>
|
||||||
<% }); %>""")
|
<% }); %>""")
|
||||||
|
|
||||||
renderTags = ($el, tags, editable) ->
|
renderTags = ($el, tags, editable, tagsColors) ->
|
||||||
ctx = {
|
ctx = {
|
||||||
tags: _.map(tags, (t) -> {name: t, color: textToColor(t)})
|
tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]})
|
||||||
editable: editable
|
editable: editable
|
||||||
}
|
}
|
||||||
html = templateTags(ctx)
|
html = templateTags(ctx)
|
||||||
|
@ -68,7 +67,7 @@ TagLineDirective = ($log) ->
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (val) ->
|
$scope.$watch $attrs.ngModel, (val) ->
|
||||||
return if not val
|
return if not val
|
||||||
renderTags($el, val, editable)
|
renderTags($el, val, editable, $scope.project.tags_colors)
|
||||||
|
|
||||||
$el.find("input").remove() if not editable
|
$el.find("input").remove() if not editable
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ groupBy = @.taiga.groupBy
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
debounce = @.taiga.debounce
|
debounce = @.taiga.debounce
|
||||||
startswith = @.taiga.startswith
|
startswith = @.taiga.startswith
|
||||||
textToColor = @.taiga.textToColor
|
|
||||||
|
|
||||||
module = angular.module("taigaIssues")
|
module = angular.module("taigaIssues")
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
obj = {
|
obj = {
|
||||||
id: t[0],
|
id: t[0],
|
||||||
name: t[0],
|
name: t[0],
|
||||||
color: textToColor(t[0]),
|
color: @scope.project.tags_colors[t[0]],
|
||||||
count: t[1],
|
count: t[1],
|
||||||
type: "tags"
|
type: "tags"
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,20 +124,6 @@ sizeFormat = (input, precision=1) ->
|
||||||
typeIsArray = Array.isArray || ( value ) -> return {}.toString.call( value ) is '[object Array]'
|
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
|
# Generic method for generate hash from a arbitrary length
|
||||||
# collection of parameters.
|
# collection of parameters.
|
||||||
generateHash = (components=[]) ->
|
generateHash = (components=[]) ->
|
||||||
|
@ -161,5 +147,4 @@ taiga.debounce = debounce
|
||||||
taiga.startswith = startswith
|
taiga.startswith = startswith
|
||||||
taiga.sizeFormat = sizeFormat
|
taiga.sizeFormat = sizeFormat
|
||||||
taiga.typeIsArray = typeIsArray
|
taiga.typeIsArray = typeIsArray
|
||||||
taiga.textToColor = textToColor
|
|
||||||
taiga.generateHash = generateHash
|
taiga.generateHash = generateHash
|
||||||
|
|
Loading…
Reference in New Issue