From ab4c4a02c8fb746ab4c8342c1e9e3ff613c62240 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 15 Nov 2024 17:12:47 -0500 Subject: [PATCH] Add `role_priveleges` helper method --- app/helpers/admin/roles_helper.rb | 7 +++++++ app/views/admin/roles/_role.html.haml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/admin/roles_helper.rb b/app/helpers/admin/roles_helper.rb index 7b4702e268..144a5b7e6f 100644 --- a/app/helpers/admin/roles_helper.rb +++ b/app/helpers/admin/roles_helper.rb @@ -11,6 +11,13 @@ module Admin ) end + def role_priveleges(role) + role + .permissions_as_keys + .map { |privilege| t("admin.roles.privileges.#{privilege}") } + .join(', ') + end + def disable_permissions?(permissions) permissions.filter { |privilege| role_flag_value(privilege).zero? } end diff --git a/app/views/admin/roles/_role.html.haml b/app/views/admin/roles/_role.html.haml index 636127354b..884e84b2e6 100644 --- a/app/views/admin/roles/_role.html.haml +++ b/app/views/admin/roles/_role.html.haml @@ -25,6 +25,6 @@ - else = 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 = table_link_to 'edit', t('admin.accounts.edit'), edit_admin_role_path(role) if can?(:update, role)