Add `role_priveleges` helper method

pull/32923/head
Matt Jankowski 2024-11-15 17:12:47 -05:00
parent 44d92fa4f6
commit ab4c4a02c8
2 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,13 @@ module Admin
) )
end end
def role_priveleges(role)
role
.permissions_as_keys
.map { |privilege| t("admin.roles.privileges.#{privilege}") }
.join(', ')
end
def disable_permissions?(permissions) def disable_permissions?(permissions)
permissions.filter { |privilege| role_flag_value(privilege).zero? } permissions.filter { |privilege| role_flag_value(privilege).zero? }
end end

View File

@ -25,6 +25,6 @@
- else - else
= link_to t('admin.roles.assigned_users', count: role.users.count), admin_accounts_path(role_ids: role.id) = link_to t('admin.roles.assigned_users', count: role.users.count), admin_accounts_path(role_ids: role.id)
· ·
%abbr{ title: role.permissions_as_keys.map { |privilege| I18n.t("admin.roles.privileges.#{privilege}") }.join(', ') }= t('admin.roles.permissions_count', count: role.permissions_as_keys.size) %abbr{ title: role_priveleges(role) }= t('admin.roles.permissions_count', count: role.permissions_as_keys.size)
%div %div
= table_link_to 'edit', t('admin.accounts.edit'), edit_admin_role_path(role) if can?(:update, role) = table_link_to 'edit', t('admin.accounts.edit'), edit_admin_role_path(role) if can?(:update, role)