Class: TableSettings::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/table_settings/table_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_settings) ⇒ Action

Returns a new instance of Action.



5
6
7
8
9
10
# File 'lib/table_settings/table_action.rb', line 5

def initialize(table_settings)
  @table_settings = table_settings
  @action_hash = {}

  add_defaults
end

Instance Attribute Details

#action_hashObject

Returns the value of attribute action_hash.



3
4
5
# File 'lib/table_settings/table_action.rb', line 3

def action_hash
  @action_hash
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/table_settings/table_action.rb', line 3

def name
  @name
end

Instance Method Details

#action(name) ⇒ Object



32
33
34
35
# File 'lib/table_settings/table_action.rb', line 32

def action(name)
  @action_hash[:symlink_action] = name
  self
end

#add_defaultsObject



22
23
24
25
# File 'lib/table_settings/table_action.rb', line 22

def add_defaults
  @action_hash[:symlink_remote] = true
  self
end

#confirm(text) ⇒ Object



61
62
63
64
# File 'lib/table_settings/table_action.rb', line 61

def confirm(text)
  @action_hash[:confirm] = text
  self
end

#controller(name) ⇒ Object



27
28
29
30
# File 'lib/table_settings/table_action.rb', line 27

def controller(name)
  @action_hash[:symlink_controller] = name
  self
end

#css_class(name) ⇒ Object



56
57
58
59
# File 'lib/table_settings/table_action.rb', line 56

def css_class(name)
  @action_hash[:class] = name
  self
end

#css_class_type(type) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/table_settings/table_action.rb', line 71

def css_class_type(type)
  css=case type
        when :show then "btn btn-success"
        when :edit then "btn btn-warning"
        when :delete then "btn btn-danger"
        when :destroy then "btn btn-danger"
        else "btn"
      end
  @action_hash[:class] = css
  self
end

#http_method(name) ⇒ Object

Parameters:

  • - (Symbol|String)

    :get|:put|:post|:delete



51
52
53
54
# File 'lib/table_settings/table_action.rb', line 51

def http_method(name)
  @action_hash[:method] = name
  self
end

#label(label) ⇒ Object



12
13
14
15
# File 'lib/table_settings/table_action.rb', line 12

def label(label)
  @action_hash[:name] = label
  self
end

#onclick(text) ⇒ Object



66
67
68
69
# File 'lib/table_settings/table_action.rb', line 66

def onclick(text)
  @action_hash[:js_code] = text
  self
end

#outer_controller(name) ⇒ Object



36
37
38
39
# File 'lib/table_settings/table_action.rb', line 36

def outer_controller(name)
  @action_hash[:symlink_outer_controller] = name
  self
end

#outer_id(name) ⇒ Object



40
41
42
43
# File 'lib/table_settings/table_action.rb', line 40

def outer_id(name)
  @action_hash[:symlink_outer_id] = name
  self
end

#position(pos) ⇒ Object

Position of button

Parameters:

  • pos (Symbol)
    • :left | :right



86
87
88
89
# File 'lib/table_settings/table_action.rb', line 86

def position(pos)
  @action_hash[:position] = pos
  self
end

#remote(bool) ⇒ Object



45
46
47
48
# File 'lib/table_settings/table_action.rb', line 45

def remote(bool)
  @action_hash[:symlink_remote] = bool
  self
end

#title(title) ⇒ Object



17
18
19
20
# File 'lib/table_settings/table_action.rb', line 17

def title(title)
  @action_hash[:title] = title
  self
end