Module: Base::Project::App::Helpers::BaseHelper
- Defined in:
- lib/base/project/app/helpers/base_helper.rb
Instance Method Summary collapse
- #bootstrap_class_for(flash_type) ⇒ Object
- #brand_link ⇒ Object
- #cancel_link(destination) ⇒ Object
- #edit_link(destination) ⇒ Object
- #icon_link(path, icon, text) ⇒ Object
- #link_image(image, options = {}) ⇒ Object
- #log_out_menu_item(path, icon, text) ⇒ Object
- #menu_item(path, icon, text, additional = {}) ⇒ Object
- #nested_select(options = {}) ⇒ Object
- #nested_text_field(options = {}) ⇒ Object
- #page_title(text) ⇒ Object
- #round_icon_link(params) ⇒ Object
- #show_flash(type, message) ⇒ Object
- #show_flashes(flash) ⇒ Object
- #submit_link ⇒ Object
- #text_icon_link(params) ⇒ Object
Instance Method Details
#bootstrap_class_for(flash_type) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 3 def bootstrap_class_for(flash_type) case flash_type.to_sym when :success 'alert-success' # Green when :error 'alert-danger' # Red when :alert 'alert-warning' # Yellow when :notice 'alert-success' # Blue when :info 'alert-info' # Blue else flash_type.to_s end end |
#brand_link ⇒ Object
81 82 83 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 81 def brand_link link_to(t('application_name'), authenticated_user_path, class: 'navbar-brand') end |
#cancel_link(destination) ⇒ Object
95 96 97 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 95 def cancel_link(destination) round_icon_link(path: destination, type: :button, icon: 'fa-close', button: 'btn-default', class: 'pull-right m-l-5', title: t('wizard.button.cancel')) end |
#edit_link(destination) ⇒ Object
91 92 93 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 91 def edit_link(destination) link_to(content_tag(:span, '', class: 'fa fa-pencil'), destination, class: 'pull-right') end |
#icon_link(path, icon, text) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 73 def icon_link(path, icon, text) link_to(path) do concat content_tag(:span, '', class: icon) concat ' ' concat text end end |
#link_image(image, options = {}) ⇒ Object
85 86 87 88 89 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 85 def link_image(image, = {}) link_to(image.url(:big), target: '_blank', title: [:title]) do image_tag(image.url(:thumb), class: 'text-center img-circle', title: [:title]) end end |
#log_out_menu_item(path, icon, text) ⇒ Object
69 70 71 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 69 def (path, icon, text) (path, icon, text, method: :delete) end |
#menu_item(path, icon, text, additional = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 58 def (path, icon, text, additional = {}) = { method: :get, remote: false }.merge(additional) content_tag(:li) do link_to path, method: [:method], remote: [:remote] do concat(content_tag(:i, '', class: "#{icon.split('-').first} #{icon}")) concat(text) end end end |
#nested_select(options = {}) ⇒ Object
54 55 56 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 54 def nested_select( = {}) select_tag([:field_name], [:value], class: "form-control tag-select #{options[:class]}") end |
#nested_text_field(options = {}) ⇒ Object
50 51 52 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 50 def nested_text_field( = {}) text_field_tag([:field_name], [:value], type: :text, class: "form-control #{options[:class]}") end |
#page_title(text) ⇒ Object
45 46 47 48 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 45 def page_title(text) title = t('application_name') text.blank? ? title : "#{title} - #{text}" end |
#round_icon_link(params) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 103 def round_icon_link(params) params[:method] ||= :get params[:remote] ||= false data = {} data[:confirm] = params[:confirm] if params[:confirm] link_to(params[:path], method: params[:method], data: data, remote: params[:remote]) do (params) end end |
#show_flash(type, message) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 20 def show_flash(type, ) klass = bootstrap_class_for(type) content_tag(:div, class: "alert alert-dismissible fade in #{klass} flash-message", role: 'alert') do concat((type: 'button', class: 'close', data: { dismiss: 'alert', label: 'Close' }) do content_tag(:span, 'x', aria: { hidden: true }) end) concat() end end |
#show_flashes(flash) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 32 def show_flashes(flash) flash.each do |type, | if .is_a?(Array) .each do |text| show_flash(type, text) end else show_flash(type, ) end end end |
#submit_link ⇒ Object
99 100 101 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 99 def submit_link type: :submit, icon: 'fa-save', button: 'btn-success', class: 'pull-right', title: t('wizard.button.finish') end |
#text_icon_link(params) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/base/project/app/helpers/base_helper.rb', line 115 def text_icon_link(params) params[:shape] = '' params[:text] = params[:title] params[:method] ||= :get params[:remote] ||= false data = {} data[:confirm] = params[:confirm] if params[:confirm] link_to(params[:path], method: params[:method], data: data, remote: params[:remote]) do (params) end end |