From d60660c4bee7ab6eede27d84f2226ac70ea34449 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 21 Jul 2014 20:53:38 +0200 Subject: [PATCH] Add user avatar kanban directive. --- app/coffee/modules/kanban/main.coffee | 57 +++++++++++++++++++ .../views/components/kanban-task.jade | 13 ++--- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index 4dc534f5..cbb7fcaf 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -271,3 +271,60 @@ KanbanDirective = ($repo, $rootscope) -> module.directive("tgKanban", ["$tgRepo", "$rootScope", KanbanDirective]) + + + +############################################################################# +## Kanban User Directive +############################################################################# + + +KanbanUserDirective = ($log) -> + template = _.template(""" +
+ + <%- name %> + + <%- name %> + + +
+ """) + + uniqueId = _.uniqueId("user_photo") + + link = ($scope, $el, $attrs) -> + if not $attrs.model? + return $log.error "KanbanUserDirective: no model attr is defined" + + wtid = $scope.$watch $attrs.model, (v) -> + if not $scope.usersById? + $log.error "KanbanUserDirective requires userById set in scope." + wtid() + else + user = $scope.usersById[v] + render(user) + + render = (user) -> + if user is undefined + ctx = {name: "Unassigned", imgurl: "http://thecodeplayer.com/u/uifaces/12.jpg"} + else + ctx = {name: user.full_name_display, imgurl: user.photo} + + html = template(ctx) + $el.off(".#{uniqueId}") + $el.html(html) + $el.on "click.#{uniqueId}", "figure.avatar > a", (event) -> + if not $attrs.click? + return $log.error "KanbanUserDirective: No click attr is defined." + + $scope.$apply -> + $scope.$eval($attrs.click) + + return { + link: link + restrict: "AE" + } + + +module.directive("tgKanbanUserAvatar", ["$log", KanbanUserDirective]) diff --git a/app/partials/views/components/kanban-task.jade b/app/partials/views/components/kanban-task.jade index 8a121b1f..ad42399b 100644 --- a/app/partials/views/components/kanban-task.jade +++ b/app/partials/views/components/kanban-task.jade @@ -2,14 +2,11 @@ div.kanban-tagline a.taskboard-tag div.kanban-task-inner p.task-text - span.task-num #37 - a.task-name(href="", title="task.subject"). - Para IDE de desarrollo (al menos front end) yo recomiendo Aptana Studio. - figure.avatar - a(href="", title="UserName") - img.avatar(src="http://thecodeplayer.com/u/uifaces/12.jpg", alt="") - span.assigned-to - a(href="", title="Change assignation") Username + span.task-num(tg-bo-ref="us.ref") + a.task-name(href="", title="", tg-bo-html="us.subject") + + tg-kanban-user-avatar(model="us.assigned_to") + a.icon.icon-edit(href="", title="Edit", ng-click="ctrl.editTask(task)") a.icon.icon-drag-h(href="", title="Drag&Drop") a.task-points(href="", title="task points", tg-bo-html="us.total_points") --