Class: Marty::DataGridUserView

Inherits:
DataGridView show all
Defined in:
app/components/marty/data_grid_user_view.rb

Constant Summary

Constants included from Extras::Layout

Extras::Layout::BOOL_MAP, Extras::Layout::MAP_BOOL

Constants included from Permissions

Permissions::NETZKE_ENDPOINTS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataGridView

client_show_grid_js, #default_context_menu, #default_form_items, edit_grid_js, #set_perms, show_grid_js

Methods included from Extras::Layout

#bool_getter, #bool_setter, #dispfield, #enum_array, #enum_column, #enum_setter, #fieldset, #get_sorter, #hbox, #hspacer, #jsonb_field, #nullable_bool_column, #range_column, #range_field, #range_getter, #range_setter, #textarea_field, #tooltip, #vbox, #vspacer

Methods inherited from McflyGridPanel

#augment_attribute_config

Methods inherited from Grid

#child_components, #class_can?, #configure_form_window, #get_json_sorter, #has_search_action?, #initialize, #linked_components

Methods included from Permissions

#can_call_endpoint?, #can_perform_action?, #can_perform_actions, #current_user_roles, extended, #has_any_perm?, #has_marty_permissions, #has_perm?

Constructor Details

This class inherits a constructor from Marty::Grid

Class Method Details

.get_edit_permission(permissions) ⇒ Object



48
49
50
51
52
53
# File 'app/components/marty/data_grid_user_view.rb', line 48

def self.get_edit_permission(permissions)
  cur_perms = current_user_roles.map(&:to_s)
  ['edit_all', 'edit_data', 'view'].detect do |p|
    permissions[p] - cur_perms != permissions[p]
  end
end

Instance Method Details

#configure(c) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/marty/data_grid_user_view.rb', line 7

def configure(c)
  super

  c.attributes =
    [
      :name,
      :created_dt,
    ]
  c.title = I18n.t('data_grid_user_view')
  c.editing = :in_form
end

#default_bbarObject



34
35
36
# File 'app/components/marty/data_grid_user_view.rb', line 34

def default_bbar
  [:edit_grid]
end

#get_records(params) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/components/marty/data_grid_user_view.rb', line 38

def get_records(params)
  cur_perms = Mcfly.whodunnit.roles.map(&:to_sym)
  model.where("permissions->'view'      ?| ARRAY[:roles] OR "\
              "permissions->'edit_data' ?| ARRAY[:roles] OR "\
              "permissions->'edit_all'  ?| ARRAY[:roles]",
              roles: cur_perms).scoping do
    super
  end
end