Module: RbacRls::PermissionsHelper

Defined in:
app/helpers/rbac_rls/permissions_helper.rb

Instance Method Summary collapse

Instance Method Details

#permission_options_for_select(form) ⇒ Object



4
5
6
7
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 4

def permission_options_for_select(form)
  c = RbacRls::Permission.all
  options_for_select(c.collect { |p| [p.name, p.id] }, form.object.permission_id)
end

#role_options_for_select(form) ⇒ Object



21
22
23
24
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 21

def role_options_for_select(form)
  c = RbacRls::Role.all
  options_for_select(c.collect { |p| [p.name, p.id] }, form.object.role_id)
end

#table_name_options_for_select(form) ⇒ Object



36
37
38
39
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 36

def table_name_options_for_select(form)
  c = RbacRls::Permission.all_tables
  options_for_select(c.collect { |t| [t, t] }, form.object.table_name)
end

#table_selected_key_options_for_select(form) ⇒ Object



9
10
11
12
13
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 9

def table_selected_key_options_for_select(form)
  return options_for_select({}, nil) if form.object.permission_id.nil?
  c = RbacRls::GroupPermission.all
  options_for_select(c.collect { |p| [p.table_key, p.table_key] }, form.object.table_key)
end

#table_selected_value_options_for_select(form) ⇒ Object



15
16
17
18
19
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 15

def table_selected_value_options_for_select(form)
  return options_for_select({}, nil) if form.object.permission_id.nil?
  c = RbacRls::GroupPermission.all
  options_for_select(c.collect { |p| [p.table_value, p.table_value] }, form.object.table_value)
end

#user_options_for_select(form) ⇒ Object



31
32
33
34
# File 'app/helpers/rbac_rls/permissions_helper.rb', line 31

def user_options_for_select(form)
  c = User.all
  options_for_select(c.collect { |p| [p.email, p.id] }, form.object.user_id)
end