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
|
2023-03-14 01:00:30 +08:00
|
|
|
escape_input(display_name)
|
2021-04-18 23:19:16 +08:00
|
|
|
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)
|
2023-02-07 22:19:20 +08:00
|
|
|
|
|
|
|
return '' if [Project, Protocol].include?(resource.class) && inherit.blank?
|
|
|
|
|
|
|
|
if user_assignment.automatically_assigned?
|
2021-11-15 22:02:22 +08:00
|
|
|
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
|
|
|
|
2023-02-07 22:19:20 +08:00
|
|
|
t("access_permissions.partials.#{resource.class.to_s.downcase}_tooltip#{inherit}")
|
2021-05-09 00:06:07 +08:00
|
|
|
end
|
2021-04-18 23:19:16 +08:00
|
|
|
end
|