Module: Base::Project::App::Helpers::ButtonHelper
- Defined in:
- lib/base/project/app/helpers/button_helper.rb
Instance Method Summary collapse
- #cancel_button ⇒ Object
- #command_button(path, row_id, message, additional = { }) ⇒ Object
- #command_button_item(klass, icon, text, data) ⇒ Object
- #delete_button(path, row_id, message, additional = { }) ⇒ Object
- #do_filter_button ⇒ Object
- #edit_button(path, row_id, message, additional = { }) ⇒ Object
- #new_button(path, message, additional = { }) ⇒ Object
- #open_filter_button ⇒ Object
- #round_icon_button(params) ⇒ Object
- #show_button(path, row_id, message, additional = { }) ⇒ Object
- #text_icon_button(params) ⇒ Object
Instance Method Details
#cancel_button ⇒ Object
67 68 69 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 67 def (type: :button, icon: 'fa-close', button: 'btn-default', class: 'pull-right', title: 'Cancelar') end |
#command_button(path, row_id, message, additional = { }) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 3 def ( path, row_id, , additional = { } ) = { remote: false, role: :get, target: '_self', klass: '', text: "", confirm: false, data: { } }.merge( additional ) text = [:text] role = [:role] icon = [:icon] klass = [:klass] is_remote = [:remote] html_data = [:data] data_params = html_data.merge( { toggle: 'tooltip', placement: 'top', 'row-id': row_id, 'original-title': } ) data_params[:confirm] = I18n.t('confirmation') if [:confirm] = ( klass, icon, text, data_params ) if path.present? link_to(path, remote: is_remote, data: data_params, target: [:target], method: role) do concat( ) end else end end |
#command_button_item(klass, icon, text, data) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 29 def ( klass, icon, text, data ) text = " #{text}" if text.present? ( role: 'button', type: 'button', class: "btn btn-primary #{ klass }", data: data ) do content_tag( :span, text, class: icon ) end end |
#delete_button(path, row_id, message, additional = { }) ⇒ Object
47 48 49 50 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 47 def ( path, row_id, , additional = { } ) = { role: :delete, icon: 'zmdi zmdi-delete', klass: 'command-delete', confirm: true }.merge( additional ) ( path, row_id, I18n.t('simple_form.delete', message: ), ) end |
#do_filter_button ⇒ Object
62 63 64 65 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 62 def ( t('simple_form.search'), id: 'enable-filter', class: 'btn btn-primary pull-right' ) end |
#edit_button(path, row_id, message, additional = { }) ⇒ Object
37 38 39 40 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 37 def ( path, row_id, , additional = { } ) = { role: :get, icon: 'zmdi zmdi-edit' }.merge( additional ) ( path, row_id, I18n.t('simple_form.edit', message: ), ) end |
#new_button(path, message, additional = { }) ⇒ Object
42 43 44 45 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 42 def ( path, , additional = { } ) = { role: :get, icon: 'zmdi zmdi-plus' }.merge( additional ) ( path, 0, I18n.t('simple_form.new', message: ), ) end |
#open_filter_button ⇒ Object
57 58 59 60 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 57 def ( t('simple_form.filter'), id: 'enable-filter', class: 'btn btn-regular pull-left' ) end |
#round_icon_button(params) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 71 def (params) params[:shape] = 'btn-circle' params[:text] = '' (params) end |
#show_button(path, row_id, message, additional = { }) ⇒ Object
52 53 54 55 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 52 def ( path, row_id, , additional = { } ) = { role: :get, icon: 'zmdi zmdi-search' }.merge( additional ) ( path, row_id, I18n.t('simple_form.show', message: ), ) end |
#text_icon_button(params) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/base/project/app/helpers/button_helper.rb', line 78 def (params) params[:size] ||= 'btn-lg' content = content_tag(:span) do concat(content_tag(:span, '', class: "fa #{params[:icon]}")) concat(" #{params[:text]}") if params[:text] && params[:text].length > 0 end = { type: params[:type], class: "btn #{params[:button]} #{params[:shape]} #{params[:size]} #{params[:class]} text-center", title: params[:title], data: { toggle: 'tooltip', placement: 'bottom' } } [:id] = params[:id] if params[:id] [:data] = [:data].merge(params[:data]) if params[:data] (content, ) end |