Small refactor on colors
parent
db69206231
commit
f7507aacbc
|
@ -50,38 +50,42 @@ TagsDirective = ->
|
|||
module.directive("tgTags", TagsDirective)
|
||||
|
||||
|
||||
ColorizeTagBackgroundDirective = ->
|
||||
link = ($scope, $el, $attrs, $ctrl) ->
|
||||
text = $scope.$eval($attrs.tgColorizeTagBackground)
|
||||
color = $scope.project.tags_colors[text]
|
||||
$el.css("background", color)
|
||||
|
||||
return {link: link}
|
||||
|
||||
module.directive("tgColorizeTagBackground", ColorizeTagBackgroundDirective)
|
||||
|
||||
|
||||
ColorizeTagsBorderLeftDirective = ->
|
||||
template = _.template("""
|
||||
ColorizeTagsDirective = ->
|
||||
templates = {
|
||||
backlog: _.template("""
|
||||
<% _.each(tags, function(tag) { %>
|
||||
<span class="tag" style="border-left: 5px solid <%- tag.color %>"><%- tag.name %></span>
|
||||
<% }) %>
|
||||
""")
|
||||
kanban: _.template("""
|
||||
<% _.each(tags, function(tag) { %>
|
||||
<a class="kanban-tag" href="" style="background: <%- tag.color %>" title="<%- tag.name %>" />
|
||||
<% }) %>
|
||||
""")
|
||||
taskboard: _.template("""
|
||||
<% _.each(tags, function(tag) { %>
|
||||
<a class="taskboard-tag" href="" style="background: <%- tag.color %>" title="<%- tag.name %>" />
|
||||
<% }) %>
|
||||
""")
|
||||
}
|
||||
link = ($scope, $el, $attrs, $ctrl) ->
|
||||
render = (srcTags) ->
|
||||
template = templates[$attrs.tgColorizeTagsType]
|
||||
tags = []
|
||||
for tag in srcTags
|
||||
color = $scope.project.tags_colors[tag]
|
||||
tags.push({name: tag, color: color})
|
||||
$el.html template({tags: tags})
|
||||
|
||||
$scope.$watch $attrs.tgColorizeTagsBorderLeft, ->
|
||||
tags = $scope.$eval($attrs.tgColorizeTagsBorderLeft)
|
||||
$scope.$watch $attrs.tgColorizeTags, ->
|
||||
tags = $scope.$eval($attrs.tgColorizeTags)
|
||||
if tags?
|
||||
render(tags)
|
||||
|
||||
tags = $scope.$eval($attrs.tgColorizeTagsBorderLeft)
|
||||
tags = $scope.$eval($attrs.tgColorizeTags)
|
||||
if tags?
|
||||
render(tags)
|
||||
|
||||
return {link: link}
|
||||
|
||||
module.directive("tgColorizeTagsBorderLeft", ColorizeTagsBorderLeftDirective)
|
||||
module.directive("tgColorizeTags", ColorizeTagsDirective)
|
||||
|
|
|
@ -59,9 +59,9 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
promise.then null, =>
|
||||
console.log "FAIL"
|
||||
|
||||
@scope.$on("usform:new:success", @.onNewUserstory)
|
||||
@scope.$on("usform:bulk:success", @.onNewUserstory)
|
||||
@scope.$on("usform:edit:success", @.onUserstoryEdited)
|
||||
@scope.$on("usform:new:success", @.loadUserstories)
|
||||
@scope.$on("usform:bulk:success", @.loadUserstories)
|
||||
@scope.$on("usform:edit:success", @.loadUserstories)
|
||||
@scope.$on("assigned-to:added", @.onAssignedToChanged)
|
||||
@scope.$on("kanban:us:move", @.moveUs)
|
||||
|
||||
|
@ -80,24 +80,12 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
|
||||
# Scope Events Handlers
|
||||
|
||||
onNewUserstory: (ctx, result) ->
|
||||
if result.data
|
||||
items = result.data
|
||||
else
|
||||
items = [result]
|
||||
|
||||
for us in items
|
||||
@scope.usByStatus[us.status].splice(0, 0, us)
|
||||
|
||||
onAssignedToChanged: (ctx, userid, us) ->
|
||||
us.assigned_to = userid
|
||||
promise = @repo.save(us)
|
||||
promise.then null, ->
|
||||
console.log "FAIL" # TODO
|
||||
|
||||
onUserstoryEdited: (ctx, us) ->
|
||||
@.loadUserstories()
|
||||
|
||||
# Load data methods
|
||||
|
||||
loadProjectStats: ->
|
||||
|
@ -112,7 +100,12 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
@scope.stats.completedPercentage = "#{completedPercentage}%"
|
||||
return stats
|
||||
|
||||
refreshTagsColors: ->
|
||||
return @rs.projects.tagsColors(@scope.projectId).then (tags_colors) =>
|
||||
@scope.project.tags_colors = tags_colors
|
||||
|
||||
loadUserstories: ->
|
||||
return @.refreshTagsColors().then =>
|
||||
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
|
||||
@scope.userstories = userstories
|
||||
|
||||
|
|
|
@ -85,6 +85,10 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|||
@scope.stats.remainingTasks = remainingTasks
|
||||
return stats
|
||||
|
||||
refreshTagsColors: ->
|
||||
return @rs.projects.tagsColors(@scope.projectId).then (tags_colors) =>
|
||||
@scope.project.tags_colors = tags_colors
|
||||
|
||||
loadSprint: ->
|
||||
return @rs.sprints.get(@scope.projectId, @scope.sprintId).then (sprint) =>
|
||||
@scope.sprint = sprint
|
||||
|
@ -92,6 +96,7 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|||
return sprint
|
||||
|
||||
loadTasks: ->
|
||||
return @.refreshTagsColors().then =>
|
||||
return @rs.tasks.list(@scope.projectId, @scope.sprintId).then (tasks) =>
|
||||
@scope.tasks = tasks
|
||||
@scope.usTasks = {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
div.row.us-item-row(ng-repeat="us in visibleUserstories|orderBy:order track by us.id", tg-draggable, ng-class="{blocked: us.is_blocked}")
|
||||
div.user-stories
|
||||
div.user-story-tags(tg-colorize-tags-border-left="us.tags")
|
||||
div.user-story-tags(tg-colorize-tags="us.tags", tg-colorize-tags-type="backlog")
|
||||
div.user-story-name
|
||||
input(tg-check-permission, permission="modify_us", type="checkbox", name="")
|
||||
a.clickable(tg-nav="project-userstories-detail:project=project.slug,ref=us.ref",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
div.kanban-tagline
|
||||
a.kanban-tag(ng-repeat="tag in us.tags", href="", tg-bo-title="tag", tg-colorize-tag-background="tag")
|
||||
div.kanban-tagline(tg-colorize-tags="us.tags" tg-colorize-tags-type="kanban")
|
||||
div.kanban-task-inner
|
||||
div(tg-kanban-user-avatar="us.assigned_to", ng-model="us", click="ctrl.editUsAssignedTo(task)")
|
||||
div.task-text
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
div.taskboard-tagline
|
||||
a.taskboard-tag(ng-repeat="tag in task.tags", href="", tg-bo-title="tag", tg-colorize-tag-background="tag")
|
||||
div.taskboard-tagline(tg-colorize-tags="task.tags", tg-colorize-tags-type="taskboard")
|
||||
div.taskboard-task-inner
|
||||
div(tg-taskboard-user-avatar="task.assigned_to", ng-model="task", click="ctrl.editTaskAssignedTo(task)")
|
||||
p.taskboard-text
|
||||
|
|
Loading…
Reference in New Issue