Class: ButtonsFor::Rails::ButtonsForHelper::ButtonsForBuilder
- Inherits:
-
Object
- Object
- ButtonsFor::Rails::ButtonsForHelper::ButtonsForBuilder
- Includes:
- ActionView::Helpers, FontAwesome::Rails::IconHelper
- Defined in:
- app/helpers/buttons_for/rails/buttons_for_helper.rb
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #button(text, url, options = {}, &block) ⇒ Object
- #delete(url, options = {}) ⇒ Object
- #dropdown(text, options = {}, &block) ⇒ Object
- #edit(url, options = {}) ⇒ Object
- #export(url, options = {}) ⇒ Object
-
#initialize(template) ⇒ ButtonsForBuilder
constructor
A new instance of ButtonsForBuilder.
- #link(text, path, options = {}) ⇒ Object
- #new(url, options = {}) ⇒ Object
Constructor Details
#initialize(template) ⇒ ButtonsForBuilder
Returns a new instance of ButtonsForBuilder.
17 18 19 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 17 def initialize(template) @template = template end |
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
15 16 17 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 15 def output_buffer @output_buffer end |
#template ⇒ Object
Returns the value of attribute template.
15 16 17 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 15 def template @template end |
Instance Method Details
#button(text, url, options = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 21 def (text, url, = {}, &block) = () link_to label(text, ), url, .merge( class: classes(), title: t(text), ) end |
#delete(url, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 57 def delete(url, = {}) [:label] ||= label(:delete) [:label], url, .reverse_merge( class: 'btn-danger', icon: 'trash-o', method: :delete, data: { confirm: t(:confirm) } ) end |
#dropdown(text, options = {}, &block) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 70 def dropdown(text, = {}, &block) raise ArgumentError, "Missing block" unless block_given? = () content_tag(:div, class: "btn-group") do concat(content_tag(:button, label(text), class: "btn btn-default dropdown-toggle", data: {toggle: "dropdown"}, aria: {haspopup: "true", expanded: "false"}) do "#{label(text, )} #{content_tag(:span, '', class: "caret")}".html_safe end) concat(content_tag(:ul, class: "dropdown-menu", "aria-labelledby" => text) do concat template.capture(&block) end) end end |
#edit(url, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 39 def edit(url, = {}) [:label] ||= label(:edit) [:label], url, .reverse_merge( class: 'btn-default', icon: 'pencil' ) end |
#export(url, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 48 def export(url, = {}) [:label] ||= label(:export) [:label], url, .reverse_merge( class: 'btn-default', icon: 'file-text-o' ) end |
#link(text, path, options = {}) ⇒ Object
85 86 87 88 89 90 91 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 85 def link(text, path, = {}) [:title] ||= label(text) = () content_tag(:li, link_to(label(text, ), path, )) end |
#new(url, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/helpers/buttons_for/rails/buttons_for_helper.rb', line 30 def new(url, = {}) [:label] ||= label(:new) [:label], url, .reverse_merge( icon: 'plus', class: 'btn-success' ) end |