scinote-web/app/helpers/user_assignments_helper.rb
2023-01-03 14:43:03 +01:00

26 lines
1 KiB
Ruby

# 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
def user_assignment_resource_role_name(user, resource, inherit = '')
user_assignment = resource.user_assignments.find_by(user: user)
if ![Project, Protocol].include?(resource.class) && user_assignment.automatically_assigned?
parent = resource.permission_parent
return user_assignment_resource_role_name(user, parent, '_inherit')
end
"#{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
end
end