roles_helper.rb 570 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. module Admin
  3. module RolesHelper
  4. def privilege_label(privilege)
  5. safe_join(
  6. [
  7. t("admin.roles.privileges.#{privilege}"),
  8. content_tag(:span, t("admin.roles.privileges.#{privilege}_description"), class: 'hint'),
  9. ]
  10. )
  11. end
  12. def disable_permissions?(permissions)
  13. permissions.filter { |privilege| role_flag_value(privilege).zero? }
  14. end
  15. private
  16. def role_flag_value(privilege)
  17. UserRole::FLAGS[privilege] & current_user.role.computed_permissions
  18. end
  19. end
  20. end