Module: ToolButtonsHelper
- Defined in:
- app/helpers/tool_buttons_helper.rb
Instance Method Summary collapse
- #add_button(url, options = {}) ⇒ Object
- #cancel_button(options = {}) ⇒ Object
- #edit_button(options = {}) ⇒ Object
-
#remove_button(object, options = {}) ⇒ Object
options: - show_only_in_edit_mode, default: true - confirm, confirm message, e.g.
- #save_button(options = {}) ⇒ Object
Instance Method Details
permalink #add_button(url, options = {}) ⇒ Object
[View source]
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/tool_buttons_helper.rb', line 24 def ( url, = {} ) # label for the button = icon + "add" label = tool_icon( "plus black" ) + " " + t( :add ) # default options = { :class => 'add_button tool show_only_in_edit_mode btn btn-default', :remote => true }.merge( ) # create the link_to tag link_to( label, url.to_s, ) end |
permalink #cancel_button(options = {}) ⇒ Object
[View source]
49 50 51 52 |
# File 'app/helpers/tool_buttons_helper.rb', line 49 def ( = {} ) ( :cancel, "remove black", "", :title => t(:cancel) ) end |
permalink #edit_button(options = {}) ⇒ Object
[View source]
40 41 42 |
# File 'app/helpers/tool_buttons_helper.rb', line 40 def ( = {} ) :edit, "edit black", t(:edit), end |
permalink #remove_button(object, options = {}) ⇒ Object
options:
- show_only_in_edit_mode, default: true
- confirm, confirm message, e.g. "are you sure?", default: nil
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/tool_buttons_helper.rb', line 7 def (object, = {}) [:show_only_in_edit_mode] = true if [:show_only_in_edit_mode].nil? show_only_in_edit_mode_class = [:show_only_in_edit_mode] ? "show_only_in_edit_mode" : "" title = t(:remove) title += ": " + object.title if object.respond_to?(:title) && object.title.present? link_to( tool_icon( "trash white" ), object, method: 'delete', :class => "remove_button tool #{show_only_in_edit_mode_class} btn btn-danger btn-sm", :title => title, :remote => true, 'aria-label' => I18n.t(:remove), :confirm => [:confirm] ) end |
permalink #save_button(options = {}) ⇒ Object
[View source]
44 45 46 47 |
# File 'app/helpers/tool_buttons_helper.rb', line 44 def ( = {} ) ( :save, "ok white", "", :class => "save_button button btn btn-primary", :title => t(:save) ) end |