BUG#2404 Check permissions for click the username label on kanban and taskboard

stable
Jesús Espino 2015-03-11 11:38:23 +01:00
parent 8aa88cf28d
commit 89e7811f81
2 changed files with 22 additions and 14 deletions

View File

@ -504,6 +504,9 @@ KanbanUserDirective = ($log) ->
clickable = false clickable = false
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
username_label = $el.parent().find("a.task-assigned")
username_label.addClass("not-clickable")
if not $attrs.tgKanbanUserAvatar if not $attrs.tgKanbanUserAvatar
return $log.error "KanbanUserDirective: no attr is defined" return $log.error "KanbanUserDirective: no attr is defined"
@ -523,15 +526,7 @@ KanbanUserDirective = ($log) ->
html = template(ctx) html = template(ctx)
$el.html(html) $el.html(html)
username_label = $el.parent().find("a.task-assigned")
username_label.text(ctx.name) username_label.text(ctx.name)
username_label.on "click", (event) ->
if $el.find("a").hasClass("noclick")
return
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.changeUsAssignedTo(us)
bindOnce $scope, "project", (project) -> bindOnce $scope, "project", (project) ->
if project.my_permissions.indexOf("modify_us") > -1 if project.my_permissions.indexOf("modify_us") > -1
@ -544,6 +539,15 @@ KanbanUserDirective = ($log) ->
$ctrl = $el.controller() $ctrl = $el.controller()
$ctrl.changeUsAssignedTo(us) $ctrl.changeUsAssignedTo(us)
username_label.removeClass("not-clickable")
username_label.on "click", (event) ->
if $el.find("a").hasClass("noclick")
return
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.changeUsAssignedTo(us)
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()

View File

@ -397,12 +397,7 @@ TaskboardUserDirective = ($log) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
username_label = $el.parent().find("a.task-assigned") username_label = $el.parent().find("a.task-assigned")
username_label.on "click", (event) -> username_label.addClass("not-clickable")
if $el.find('a').hasClass('noclick')
return
$ctrl = $el.controller()
$ctrl.editTaskAssignedTo($scope.task)
$scope.$watch 'task.assigned_to', (assigned_to) -> $scope.$watch 'task.assigned_to', (assigned_to) ->
user = $scope.usersById[assigned_to] user = $scope.usersById[assigned_to]
@ -425,6 +420,15 @@ TaskboardUserDirective = ($log) ->
$ctrl = $el.controller() $ctrl = $el.controller()
$ctrl.editTaskAssignedTo($scope.task) $ctrl.editTaskAssignedTo($scope.task)
username_label.removeClass("not-clickable")
username_label.on "click", (event) ->
if $el.find('a').hasClass('noclick')
return
$ctrl = $el.controller()
$ctrl.editTaskAssignedTo($scope.task)
return { return {
link: link, link: link,
templateUrl: "taskboard/taskboard-user.html", templateUrl: "taskboard/taskboard-user.html",