Class: Marty::Grid

Inherits:
Netzke::Grid::Base
  • Object
show all
Extended by:
Permissions
Defined in:
app/components/marty/grid.rb

Constant Summary

Constants included from Permissions

Permissions::NETZKE_ENDPOINTS

Instance Method Summary collapse

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

#initialize(args, kwargs = nil) ⇒ Grid

parent grid is the grid in which child/linked_components is defined child components are components dependent on the selected parent row linked components will update whenever the parent is updated



9
10
11
12
13
# File 'app/components/marty/grid.rb', line 9

def initialize args, kwargs = nil
  super(args, kwargs)
  client_config[:child_components]  = child_components  || []
  client_config[:linked_components] = linked_components || []
end

Instance Method Details

#child_componentsObject



103
104
105
# File 'app/components/marty/grid.rb', line 103

def child_components
  []
end

#class_can?(op) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/marty/grid.rb', line 21

def class_can?(op)
  self.class.can_perform_action?(op)
end

#configure(c) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/components/marty/grid.rb', line 25

def configure(c)
  super

  c.permissions = {
    create: class_can?(:create),
    read:   class_can?(:read),
    update: class_can?(:update),
    delete: class_can?(:delete)
  }

  c.editing      = :both
  c.store_config = { page_size: 30 }
  c.view_config  = { preserve_scroll_on_reload: true }

  # disable buffered renderer plugin to avoid white space on reload
  c.buffered_renderer = false
end

#configure_form_window(c) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'app/components/marty/grid.rb', line 111

def configure_form_window(c)
  super

  c.klass = Marty::RecordFormWindow

  # Fix Add in form/Edit in form modal popup width
  # Netzke 0.10.1 defaults width to 80% of screen which is too wide
  # for a form where the fields are stacked top to bottom
  # Netzke 0.8.4 defaulted width to 400px - let's make it a bit wider
  c.width = 475
end

#get_json_sorter(json_col, field) ⇒ Object



53
54
55
56
57
# File 'app/components/marty/grid.rb', line 53

def get_json_sorter(json_col, field)
  lambda do |r, dir|
    r.order(Arel.sql("#{json_col} ->> '#{field}' " + dir.to_s))
  end
end

#has_search_action?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/components/marty/grid.rb', line 43

def has_search_action?
  false
end

#linked_componentsObject



107
108
109
# File 'app/components/marty/grid.rb', line 107

def linked_components
  []
end