From 8a5bd7164f3ad53abf2af0201d8ebc743c465282 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 7 Aug 2014 10:43:17 +0200 Subject: [PATCH] Adding kanban layout permissions check --- app/coffee/modules/kanban/main.coffee | 23 +++++++++++-------- app/partials/kanban.jade | 4 ++-- .../views/components/kanban-task.jade | 6 ++--- app/partials/views/modules/kanban-table.jade | 4 ++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index c36e2c9c..ae69cd23 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -281,7 +281,7 @@ module.directive("tgKanbanWipLimit", KanbanWipLimitDirective) KanbanUserDirective = ($log) -> template = _.template("""
- + class="not-clickable"<% } %>> <%- name %> <%- name %> @@ -291,8 +291,9 @@ KanbanUserDirective = ($log) -> """) uniqueId = _.uniqueId("user_photo") + clickable = false - link = ($scope, $el, $attrs) -> + link = ($scope, $el, $attrs, $model) -> if not $attrs.tgKanbanUserAvatar return $log.error "KanbanUserDirective: no attr is defined" @@ -306,21 +307,23 @@ KanbanUserDirective = ($log) -> render = (user) -> if user is undefined - ctx = {name: "Unassigned", imgurl: "/images/unnamed.png"} + ctx = {name: "Unassigned", imgurl: "/images/unnamed.png", clickable: clickable} else - ctx = {name: user.full_name_display, imgurl: user.photo} + ctx = {name: user.full_name_display, imgurl: user.photo, clickable: clickable} 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) + bindOnce $scope, "project", (project) -> + if project.my_permissions.indexOf("modify_us") > -1 + clickable = true + $el.on "click", (event) => + us = $model.$modelValue + $ctrl = $el.controller() + $ctrl.changeUsAssignedTo(us) - return {link: link} + return {link: link, require:"ngModel"} module.directive("tgKanbanUserAvatar", ["$log", KanbanUserDirective]) diff --git a/app/partials/kanban.jade b/app/partials/kanban.jade index 55b738dd..b0cb7fb9 100644 --- a/app/partials/kanban.jade +++ b/app/partials/kanban.jade @@ -15,8 +15,8 @@ block content // a.button.button-trans(href="", title="Filter") // span.icon.icon-filter // span Filters - a.button.button-gray(href="", title="Filter") - span Show Statistics + //a.button.button-gray(href="", title="Filter") + // span Show Statistics //-include views/components/large-summary //-include views/modules/burndown //-include views/modules/list-filters-kanban diff --git a/app/partials/views/components/kanban-task.jade b/app/partials/views/components/kanban-task.jade index 968fb498..b402555b 100644 --- a/app/partials/views/components/kanban-task.jade +++ b/app/partials/views/components/kanban-task.jade @@ -1,7 +1,7 @@ div.kanban-tagline a.taskboard-tag(ng-repeat="tag in us.tags", href="", tg-bo-title="tag", tg-colorize-tag="tag") div.kanban-task-inner - div(tg-kanban-user-avatar="us.assigned_to", click="ctrl.changeUsAssignedTo(us)") + div(tg-kanban-user-avatar="us.assigned_to", ng-model="us") div.task-text span.task-assigned Username span.task-num(tg-bo-ref="us.ref") @@ -10,5 +10,5 @@ div.kanban-task-inner p.task-points span(tg-bind-html="us.total_points") -- span points - a.icon.icon-edit(href="", title="Edit", ng-click="ctrl.editUserStory(us)") - a.icon.icon-drag-h(href="", title="Drag&Drop") + a.icon.icon-edit(tg-check-permission, permission="modify_us", href="", title="Edit", ng-click="ctrl.editUserStory(us)") + a.icon.icon-drag-h(tg-check-permission, permission="modify_us", href="", title="Drag&Drop") diff --git a/app/partials/views/modules/kanban-table.jade b/app/partials/views/modules/kanban-table.jade index d6a4014b..927eacb5 100644 --- a/app/partials/views/modules/kanban-table.jade +++ b/app/partials/views/modules/kanban-table.jade @@ -4,8 +4,8 @@ div.kanban-table h2.task-colum_name(ng-repeat="s in usStatusList track by s.id", ng-style="{'border-top-color':s.color}") span(tg-bo-bind="s.name") - a.icon.icon-plus(href="", title="Add New task", ng-click="ctrl.addNewUs('standard', s.id)") - a.icon.icon-bulk(href="", title="Add New bulk", ng-click="ctrl.addNewUs('bulk', s.id)") + a.icon.icon-plus(tg-check-permission, permission="add_us", href="", title="Add New task", ng-click="ctrl.addNewUs('standard', s.id)") + a.icon.icon-bulk(tg-check-permission, permission="add_us",href="", title="Add New bulk", ng-click="ctrl.addNewUs('bulk', s.id)") div.kanban-table-body div.kanban-table-inner(tg-kanban-row-size-fixer)