12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/helpers/solidus_admin/permission_sets_helper.rb', line 12
def organize_permissions(permission_sets:, view_label:, edit_label:)
return {} if permission_sets.blank?
permission_sets.each_with_object({}) do |permission, grouped_permissions|
group_key = permission.category.to_sym
case permission.privilege
when "display"
grouped_permissions[group_key] ||= []
grouped_permissions[group_key] << { label: view_label, id: permission.id }
when "management"
grouped_permissions[group_key] ||= []
grouped_permissions[group_key] << { label: edit_label, id: permission.id }
else
grouped_permissions[:other] ||= []
grouped_permissions[:other] << { label: permission.name, id: permission.id }
end
end
end
|