2021-04-18 23:19:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UserAssignmentsHelper
|
|
|
|
def current_assignee_name(assignee)
|
|
|
|
display_name = if assignee == current_user
|
|
|
|
[assignee.name, t('user_assignment.current_assignee')].join(' ')
|
|
|
|
else
|
|
|
|
assignee.name
|
|
|
|
end
|
|
|
|
sanitize_input(display_name)
|
|
|
|
end
|
2021-05-09 00:06:07 +08:00
|
|
|
|
2021-11-15 22:02:22 +08:00
|
|
|
def user_assignment_resource_role_name(user, resource, inherit = '')
|
|
|
|
user_assignment = resource.user_assignments.find_by(user: user)
|
|
|
|
if resource.class != Project && user_assignment.automatically_assigned?
|
|
|
|
parent = resource.permission_parent
|
|
|
|
return user_assignment_resource_role_name(user, parent, '_inherit')
|
2021-05-09 00:06:07 +08:00
|
|
|
end
|
2021-11-15 22:02:22 +08:00
|
|
|
|
|
|
|
"#{user_assignment.user_role.name}
|
|
|
|
<span class='permission-object-tag'
|
|
|
|
title='#{t("access_permissions.partials.#{resource.class.to_s.downcase}_tooltip#{inherit}")}'>
|
|
|
|
#{t("access_permissions.partials.#{resource.class.to_s.downcase}")}
|
|
|
|
</span>".html_safe
|
2021-05-09 00:06:07 +08:00
|
|
|
end
|
2021-04-18 23:19:16 +08:00
|
|
|
end
|