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::ALL_ROLES, Permissions::REQ_ROLES

Instance Method Summary collapse

Methods included from Permissions

can_perform_action?, can_perform_actions, current_user_roles, has_any_perm?, has_marty_permissions

Instance Method Details

#class_can?(op) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/components/marty/grid.rb', line 27

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

#configure(c) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/marty/grid.rb', line 31

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}
end

#configure_form_window(c) ⇒ Object



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

def configure_form_window(c)
  super
  # 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



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

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

#has_search_action?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/components/marty/grid.rb', line 45

def has_search_action?
  false
end