Class: TableSettings::Button

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, label, url_path) ⇒ Button

Returns a new instance of Button.



87
88
89
90
91
92
# File 'lib/table_settings/table_button.rb', line 87

def initialize(id, label, url_path)
  @id = id
  @hash = {:name => label}
  remote(true)
  url(url_path)
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



85
86
87
# File 'lib/table_settings/table_button.rb', line 85

def hash
  @hash
end

Instance Method Details

#action(name) ⇒ Object



119
120
121
122
# File 'lib/table_settings/table_button.rb', line 119

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

#confirm(string) ⇒ Object



129
130
131
132
# File 'lib/table_settings/table_button.rb', line 129

def confirm(string)
  @hash[:confirm] = string
  self
end

#controller(name) ⇒ Object



114
115
116
117
# File 'lib/table_settings/table_button.rb', line 114

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

#css_class(name) ⇒ Object



134
135
136
137
# File 'lib/table_settings/table_button.rb', line 134

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

#css_class_type(type) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/table_settings/table_button.rb', line 149

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"
        when :log then "btn btn-inverse"
        else "btn"
      end
  @hash[:class] = css
  self
end

#css_td_class(name) ⇒ Object



162
163
164
165
# File 'lib/table_settings/table_button.rb', line 162

def css_td_class(name)
  @hash[:td_class] = name
  self
end

#css_tr_class(name) ⇒ Object



166
167
168
# File 'lib/table_settings/table_button.rb', line 166

def css_tr_class(name)
  @hash[:tr_class] = name
end

#js_code(string) ⇒ Object

javascript code for button onclick



145
146
147
# File 'lib/table_settings/table_button.rb', line 145

def js_code(string)
  @hash[:js_code] = string
end

#js_method(string) ⇒ Object

javascript method for button



140
141
142
# File 'lib/table_settings/table_button.rb', line 140

def js_method(string)
  @hash[:js_method] = string
end

#method(symbol) ⇒ Object



124
125
126
127
# File 'lib/table_settings/table_button.rb', line 124

def method(symbol)
  @hash[:method] = symbol
  self
end

#outer_controller(name) ⇒ Object



104
105
106
107
# File 'lib/table_settings/table_button.rb', line 104

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

#outer_id(id) ⇒ Object



109
110
111
112
# File 'lib/table_settings/table_button.rb', line 109

def outer_id(id)
  @hash[:symlink_outer_id] = id
  self
end

#remote(boolean) ⇒ Object



99
100
101
102
# File 'lib/table_settings/table_button.rb', line 99

def remote(boolean)
  @hash[:symlink_remote] = boolean
  self
end

#title(string) ⇒ Object

Help Title (for mouseover) of buttons, no title means usage of button name



171
172
173
# File 'lib/table_settings/table_button.rb', line 171

def title(string)
  @hash[:title] = string
end

#url(path) ⇒ Object



94
95
96
97
# File 'lib/table_settings/table_button.rb', line 94

def url(path)
  @hash[:url] = path
  self
end