retrospring/app/views/modal/privileges/_item.html.haml
2023-01-05 10:35:52 +01:00

13 lines
655 B
Text

:ruby
description ||= ""
role_mapping = { admin: "administrator" }
requires_role = %w[admin moderator].include?(privilege)
checked = requires_role ? user.has_cached_role?(role_mapping.fetch(privilege, privilege).to_sym) : user.public_send("#{privilege}?")
%li.list-group-item{ id: "privilege-#{privilege}" }
.d-flex
.flex-shrink-0
%input{ type: :checkbox, name: "check-your-privileges", data: { type: privilege, user: user.screen_name }, checked: checked, autocomplete: :off }
.flex-grow-1
.list-group-item-heading= privilege.capitalize
- unless description.blank?
.list-group-item-text.text-muted= description