diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee
index 3ef16461..1dc16c29 100644
--- a/app/coffee/modules/common/attachments.coffee
+++ b/app/coffee/modules/common/attachments.coffee
@@ -172,11 +172,13 @@ AttachmentDirective = ($log, $repo, $confirm) ->
<% if (isDeprecated){ %> (deprecated) <% } %>
<%- description %>
+ <% if (modifyPermission) {%>
+ <% } %>
""") #TODO: i18n
singleAttachmentEditable = _.template("""
@@ -207,6 +209,7 @@ AttachmentDirective = ($log, $repo, $confirm) ->
$ctrl = $el.controller()
render = (attachment, isEditable=false) ->
+ modifyPermission = $scope.project.my_permissions.indexOf("modify_#{$attrs.ngModel}") > -1
ctx = {
id: attachment.id
name: attachment.name
@@ -214,6 +217,7 @@ AttachmentDirective = ($log, $repo, $confirm) ->
size: sizeFormat(attachment.size)
description: attachment.description
isDeprecated: attachment.is_deprecated
+ modifyPermission: modifyPermission
}
if isEditable
diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee
index ae69cd23..02dec85c 100644
--- a/app/coffee/modules/kanban/main.coffee
+++ b/app/coffee/modules/kanban/main.coffee
@@ -290,7 +290,6 @@ KanbanUserDirective = ($log) ->
""")
- uniqueId = _.uniqueId("user_photo")
clickable = false
link = ($scope, $el, $attrs, $model) ->
@@ -312,7 +311,6 @@ KanbanUserDirective = ($log) ->
ctx = {name: user.full_name_display, imgurl: user.photo, clickable: clickable}
html = template(ctx)
- $el.off(".#{uniqueId}")
$el.html(html)
bindOnce $scope, "project", (project) ->
diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee
index 9099f987..121c742d 100644
--- a/app/coffee/modules/taskboard/main.coffee
+++ b/app/coffee/modules/taskboard/main.coffee
@@ -230,16 +230,16 @@ module.directive("tgTaskboardRowSizeFixer", TaskboardRowSizeFixer)
TaskboardUserDirective = ($log) ->
template = _.template("""
-
+ class="not-clickable"<% } %>>
<%- name %>
""")
- uniqueId = _.uniqueId("user_photo")
+ clickable = false
- link = ($scope, $el, $attrs) ->
+ link = ($scope, $el, $attrs, $model) ->
if not $attrs.tgTaskboardUserAvatar?
return $log.error "TaskboardUserDirective: no attr is defined"
@@ -253,22 +253,23 @@ TaskboardUserDirective = ($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 "TaskboardUserDirective: No click attr is defined."
- $scope.$apply ->
- $scope.$eval($attrs.click)
+ bindOnce $scope, "project", (project) ->
+ if project.my_permissions.indexOf("modify_task") > -1
+ clickable = true
+ $el.on "click", (event) =>
+ us = $model.$modelValue
+ $ctrl = $el.controller()
+ $ctrl.editTaskAssignedTo(us)
- return {link: link}
+ return {link: link, require:"ngModel"}
module.directive("tgTaskboardUserAvatar", ["$log", TaskboardUserDirective])
diff --git a/app/partials/issues-detail-edit.jade b/app/partials/issues-detail-edit.jade
index 2a822ae5..cea56fe1 100644
--- a/app/partials/issues-detail-edit.jade
+++ b/app/partials/issues-detail-edit.jade
@@ -36,7 +36,7 @@ block content
section.us-detail-settings
a.button.button-gray.clickable(ng-show="!issue.is_blocked", ng-click="ctrl.block()") Block
- a.button.button-red(ng-click="ctrl.delete()", href="") Delete
+ a.button.button-red(tg-check-permission, permission="delete_issue", ng-click="ctrl.delete()", href="") Delete
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="issue")
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade
index 5d7752a5..4a946cf8 100644
--- a/app/partials/issues-detail.jade
+++ b/app/partials/issues-detail.jade
@@ -9,7 +9,7 @@ block content
div.main.us-detail
div.us-detail-header
include views/components/mainTitle
- a.button.button-green(href="", title="Edit", tg-nav="project-issues-detail-edit:project=project.slug,ref=issue.ref") Edit
+ a.button.button-green(tg-check-permission, permission="modify_issue", href="", title="Edit", tg-nav="project-issues-detail-edit:project=project.slug,ref=issue.ref") Edit
section.us-story-main-data
div.us-title(ng-class="{blocked: issue.is_blocked}")
@@ -42,6 +42,7 @@ block content
span.icon.icon-issues
span.tab-title Activity
+ - var commentModel = "issue"
include views/modules/comments
include views/modules/activity
diff --git a/app/partials/task-detail-edit.jade b/app/partials/task-detail-edit.jade
index 1ccb29e6..112e7394 100644
--- a/app/partials/task-detail-edit.jade
+++ b/app/partials/task-detail-edit.jade
@@ -39,8 +39,8 @@ block content
label.clickable.button.button-gray(for="is-iocaine", ng-class="{true:'active', false:''}[task.is_iocaine]") Iocaine
input(ng-model="task.is_iocaine", type="checkbox", id="is-iocaine", name="is-iocaine")
- a.button.button-gray.clickable(ng-show="!task.is_blocked", ng-click="ctrl.block()") Block
- a.button.button-red(ng-click="ctrl.delete()", href="") Delete
+ a.button.button-gray.clickable(ng-show="!task.is_blocked", ng-click="ctrl.block()") Block
+ a.button.button-red(tg-check-permission, permission="delete_task", ng-click="ctrl.delete()", href="") Delete
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking task", ng-model="task")
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
diff --git a/app/partials/task-detail.jade b/app/partials/task-detail.jade
index 1cd7ef53..714b621f 100644
--- a/app/partials/task-detail.jade
+++ b/app/partials/task-detail.jade
@@ -9,7 +9,7 @@ block content
div.main.us-detail
div.us-detail-header
include views/components/mainTitle
- a.button.button-green(href="", title="Edit", tg-nav="project-tasks-detail-edit:project=project.slug,ref=task.ref") Edit
+ a.button.button-green(tg-check-permission, permission="modify_task", href="", title="Edit", tg-nav="project-tasks-detail-edit:project=project.slug,ref=task.ref") Edit
section.us-story-main-data
div.us-title(ng-class="{blocked: task.is_blocked}")
@@ -42,6 +42,7 @@ block content
span.icon.icon-issues
span.tab-title Activity
+ - var commentModel = "task"
include views/modules/comments
include views/modules/activity
diff --git a/app/partials/us-detail-edit.jade b/app/partials/us-detail-edit.jade
index 68c674fb..477c9e83 100644
--- a/app/partials/us-detail-edit.jade
+++ b/app/partials/us-detail-edit.jade
@@ -43,7 +43,7 @@ block content
input(ng-model="us.team_requirement", type="checkbox", id="team-requirement", name="team-requirement")
a.button.button-gray.clickable(ng-show="!us.is_blocked", ng-click="ctrl.block()") Block
- a.button.button-red(ng-click="ctrl.delete()", href="") Delete
+ a.button.button-red(tg-check-permission, permission="delete_us", ng-click="ctrl.delete()", href="") Delete
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="us")
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
diff --git a/app/partials/us-detail.jade b/app/partials/us-detail.jade
index 82469d24..047662d2 100644
--- a/app/partials/us-detail.jade
+++ b/app/partials/us-detail.jade
@@ -9,7 +9,7 @@ block content
div.main.us-detail
div.us-detail-header
include views/components/mainTitle
- a.button.button-green(href="", title="Edit", tg-nav="project-userstories-detail-edit:project=project.slug,ref=us.ref") Edit
+ a.button.button-green(tg-check-permission, permission="modify_us", href="", title="Edit", tg-nav="project-userstories-detail-edit:project=project.slug,ref=us.ref") Edit
section.us-story-main-data
div.us-title(ng-class="{blocked: us.is_blocked}")
@@ -43,6 +43,8 @@ block content
a(href="#")
span.icon.icon-issues
span.tab-title Activity
+
+ - var commentModel = "us"
include views/modules/comments
include views/modules/activity
diff --git a/app/partials/views/components/taskboard-task.jade b/app/partials/views/components/taskboard-task.jade
index 50f34db6..d7f44fa3 100644
--- a/app/partials/views/components/taskboard-task.jade
+++ b/app/partials/views/components/taskboard-task.jade
@@ -1,11 +1,14 @@
div.taskboard-tagline
a.taskboard-tag(ng-repeat="tag in task.tags", href="", tg-bo-title="tag", tg-colorize-tag="tag")
div.taskboard-task-inner
- div(tg-taskboard-user-avatar="task.assigned_to", click="ctrl.editTaskAssignedTo(task)")
+ div(tg-taskboard-user-avatar="task.assigned_to", ng-model="task", click="ctrl.editTaskAssignedTo(task)")
p.taskboard-text
span.task-assigned Username
span.task-num(tg-bo-ref="task.ref")
a.task-name(href="", title="See task details", tg-bind-html="task.subject",
tg-nav="project-tasks-detail:project=project.slug,ref=task.ref")
- a.icon.icon-edit(href="", title="Edit task", ng-click="ctrl.editTask(task)")
- a.icon.icon-drag-h(href="", title="Drag&Drop")
+ a.icon.icon-edit(tg-check-permission, permission="modify_task",
+ href="", title="Edit task", ng-click="ctrl.editTask(task)")
+
+ a.icon.icon-drag-h(tg-check-permission, permission="modify_task",
+ href="", title="Drag&Drop")
diff --git a/app/partials/views/modules/attachments.jade b/app/partials/views/modules/attachments.jade
index 8cd2cb60..f8100608 100644
--- a/app/partials/views/modules/attachments.jade
+++ b/app/partials/views/modules/attachments.jade
@@ -7,13 +7,13 @@ section.attachments(tg-attachments, ng-model=attachModel, ng-if="#{attachModel}.
span.icon.icon-attachments
span.attachments-num 0
span.attachments-text attachments
- a.button.button-gray.add-attach(href="", title="Add new attachment")
+ a.button.button-gray.add-attach(tg-check-permission, permission="modify_"+attachModel, href="", title="Add new attachment")
span +new file
input.hidden.add-attach(type="file", multiple="multiple")
div.attachment-body.sortable
div.hidden.single-attachment(ng-repeat="attach in attachments",
- tg-attachment="attach")
+ tg-attachment="attach", ng-model=attachModel)
//- See modules/common/attachments.coffee - AttachmentDirective
diff --git a/app/partials/views/modules/comments.jade b/app/partials/views/modules/comments.jade
index 713a9fc9..00b69a1c 100644
--- a/app/partials/views/modules/comments.jade
+++ b/app/partials/views/modules/comments.jade
@@ -1,5 +1,7 @@
+//- NOTE: You must to define 'var commentModel' with the object model
+
section.us-comments
- div.add-comment
+ div.add-comment(tg-check-permission, permission="modify_"+commentModel)
textarea(placeholder="Write here a new commet", ng-model="commentModel.comment")
a.button.button-green(href="", title="Comment") Comment
div.comment-list
diff --git a/app/partials/views/modules/kanban-table.jade b/app/partials/views/modules/kanban-table.jade
index 927eacb5..27d27de7 100644
--- a/app/partials/views/modules/kanban-table.jade
+++ b/app/partials/views/modules/kanban-table.jade
@@ -5,7 +5,7 @@ div.kanban-table
ng-style="{'border-top-color':s.color}")
span(tg-bo-bind="s.name")
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)")
+ 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)
diff --git a/app/partials/views/modules/taskboard-table.jade b/app/partials/views/modules/taskboard-table.jade
index 64cfe0d9..9f17324e 100644
--- a/app/partials/views/modules/taskboard-table.jade
+++ b/app/partials/views/modules/taskboard-table.jade
@@ -19,9 +19,11 @@ div.taskboard-table
span(ng-bind="us.total_points")
span points
- a.icon.icon-plus(href="", title="Add new task",
+ a.icon.icon-plus(tg-check-permission, permission="add_task",
+ href="", title="Add new task",
ng-click="ctrl.addNewTask('standard', us)")
- a.icon.icon-bulk(href="", title="Add new tasks in bulk",
+ a.icon.icon-bulk(tg-check-permission, permission="add_task",
+ href="", title="Add new tasks in bulk",
ng-click="ctrl.addNewTask('bulk', us)")
div.taskboard-tasks-box.task-column(ng-repeat="st in taskStatusList track by st.id",
@@ -34,9 +36,11 @@ div.taskboard-table
div.taskboard-userstory-box.task-column
h3.us-title
span Unassigned tasks
- a.icon.icon-plus(href="", title="Add new task",
+ a.icon.icon-plus(tg-check-permission, permission="add_task",
+ href="", title="Add new task",
ng-click="ctrl.addNewTask('standard', us)")
- a.icon.icon-bulk(href="", title="Add new tasks in bulk",
+ a.icon.icon-bulk(tg-check-permission, permission="add_task",
+ href="", title="Add new tasks in bulk",
ng-click="ctrl.addNewTask('bulk', us)")
div.taskboard-tasks-box.task-column(ng-repeat="st in taskStatusList track by st.id", tg-taskboard-sortable)