Module: Kuppayam::ActionView::ThemeHelper
- Defined in:
- lib/kuppayam/action_view/theme_helper.rb
Overview
This module creates Bootstrap wrappers around basic View Tags
Instance Method Summary collapse
- #clear_tag(height = nil) ⇒ Object
- #drop_down_filter(text, items, **options) ⇒ Object
-
#theme_button(text, icon, url, options = {}) ⇒ Object
TBR: To Be Removed.
-
#theme_button_text(text) ⇒ Object
TBR: To Be Removed.
-
#theme_delete_button(url, options = {}) ⇒ Object
Example theme_delete_button(admin_project_path(@project)) is equivalent to: ————————— link_to raw(“<i class="fa fa-trash "></i> Delete”), admin_project_path(@project), method: :delete, data: { confirm: ‘Are you sure?’ }, :class=>“btn btn-danger btn-xs pull-right”, :remote=>true.
- #theme_drop_down(collection, method_name, **options) ⇒ Object
-
#theme_edit_button(url, options = {}) ⇒ Object
Example theme_edit_button(edit_admin_project_path(@project)) is equivalent to: ————————— link_to raw(“<i class="fa fa-edit mr-5"></i> Edit”), edit_admin_project_path(@project), :class=>“btn btn-default btn-xs pull-right ml-10”, :remote=>true %>.
-
#theme_fa_icon(icon_text, size = "") ⇒ Object
TBR: To Be Removed.
-
#theme_heading(heading, **options) ⇒ Object
theme_heading(heading) theme_heading(heading, icon=‘cog’) <div class=“row mb-10”> <div class=“fs-22 col-sm-12”><i class=‘fa fa-rub fa-lg mr-10’></i>Manage Projects</div> </div>.
-
#theme_item_description(text, limit = 120, classes = "text-color-grey fs-12") ⇒ Object
Example theme_item_description(project.customer.name, 120).
-
#theme_item_sub_title(text, classes = "text-color-red fs-14") ⇒ Object
Example theme_item_sub_title(project.customer.name).
-
#theme_item_title(title, url, classes = "text-color-blue fs-16", remote = true) ⇒ Object
Example theme_item_title(project.name, admin_project_path(project)).
-
#theme_panel_description(text, classes = "fs-14") ⇒ Object
Example theme_panel_description(@project.pretty_url, “fs-14”) theme_panel_description(@project.description, “fs-14 mt-10”) is equivalent to: ————————— <div class=“fs-14”><%= @project.pretty_url %></div> <div class=“fs-14 mt-10”><%= @project.description %></div>.
-
#theme_panel_heading(text, classes = "fs-24 text-color-green") ⇒ Object
Example theme_panel_heading(@project.name) is equivalent to: ————————— <div class=“fs-24 text-color-green”><%= @project.name %></div>.
-
#theme_panel_message(message) ⇒ Object
Example theme_panel_message(“No Results found”).
-
#theme_panel_sub_heading(text, url, classes = "fs-16 text-color-red") ⇒ Object
Example theme_panel_sub_heading(@project.name, admin_customer_path(@project.customer)) is equivalent to: ————————— link_to(@project.customer.name, admin_customer_path(@project.customer), class: “fs-16 text-color-red”).
-
#theme_panel_title(title, classes = "") ⇒ Object
Example theme_panel_title(“Team Members”).
Instance Method Details
#clear_tag(height = nil) ⇒ Object
125 126 127 128 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 125 def clear_tag(height=nil) height_class = height ? " cl-#{height}" : "" content_tag(:div, "", class: "clearfix#{height_class}") end |
#drop_down_filter(text, items, **options) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 214 def drop_down_filter(text, items, **) .reverse_merge!( color: "white", remote: false ) content_tag(:div, class: "btn-group") do content_tag(:button, text, class: "btn btn-#{[:color]}", type: :button) + content_tag(:button, class: "btn btn-#{[:color]} dropdown-toggle", type: :button, "data-toggle": "dropdown", "aria-haspopup": "true", "aria-expanded": "false") do content_tag(:span, "", class: "caret") + content_tag(:span, "Toggle Dropdown", class: "sr-only") end + content_tag(:ul, class: "dropdown-menu") do items.collect {|item, link| concat(content_tag(:li, link_to(item, link, remote: [:remote])))} end end end |
#theme_button(text, icon, url, options = {}) ⇒ Object
TBR: To Be Removed
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 33 def (text, icon, url, ={}) .reverse_merge!( method: :get, remote: true, btn_type: :primary, btn_size: :md, classes: "pull-right ml-5 mb-5", data: {} ) display_content = raw(theme_fa_icon(icon)+(text)) link_to(display_content, url, :class=>"btn btn-#{[:btn_type]} btn-#{[:btn_size]} #{[:classes]}", :remote=>[:remote], method: [:method], data: [:data]) end |
#theme_button_text(text) ⇒ Object
TBR: To Be Removed
20 21 22 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 20 def (text) "<span class='btn-text hidden-sm hidden-xs'> #{text}</span>" end |
#theme_delete_button(url, options = {}) ⇒ Object
Example
(admin_project_path(@project))
is equivalent to:
link_to raw(“<i class="fa fa-trash "></i> Delete”), admin_project_path(@project), method: :delete, data: { confirm: ‘Are you sure?’ }, :class=>“btn btn-danger btn-xs pull-right”, :remote=>true
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 69 def (url, ={}) .reverse_merge!( text: "Delete", icon: "trash", method: :delete, remote: true, btn_type: :danger, btn_size: :xs, classes: "pull-right ml-10", data: { confirm: 'Are you sure?' } ) ([:text], [:icon], url, ) end |
#theme_drop_down(collection, method_name, **options) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 101 def theme_drop_down(collection, method_name, **) .reverse_merge!( text: "Click to View Items", scope: :admin ) content_tag(:div, class: "btn-group mt-10 mb-10", style: "width:100%;") do (type: 'button', :class => "btn btn-default btn-block dropdown-toggle", "data-toggle" => "dropdown") do raw([:text] + content_tag(:span, "", class: "caret")) end + content_tag(:ul, class: "dropdown-menu", role: "menu") do li_array = [] collection.each do |item| li_array << content_tag(:li) do url = main_app.url_for([[:scope], item]) link_to item.send(method_name), url, :remote => true end end raw(li_array.join(" ")) + content_tag(:li, link_to_next_page(collection, 'Next Page', :remote => true)) + content_tag(:li, link_to_previous_page(collection, 'Previous Page', :remote => true)) end end end |
#theme_edit_button(url, options = {}) ⇒ Object
Example
(edit_admin_project_path(@project))
is equivalent to:
link_to raw(“<i class="fa fa-edit mr-5"></i> Edit”), edit_admin_project_path(@project), :class=>“btn btn-default btn-xs pull-right ml-10”, :remote=>true %>
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 51 def (url, ={}) .reverse_merge!( text: "Edit", icon: "edit", method: :get, remote: true, btn_type: :default, btn_size: :xs, classes: "pull-right ml-10" ) ([:text], [:icon], url, ) end |
#theme_fa_icon(icon_text, size = "") ⇒ Object
TBR: To Be Removed
11 12 13 14 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 11 def theme_fa_icon(icon_text, size="") size_class = %w{lg 2x 3x 4x 5x}.include?(size.strip) ? " fa-#{size.strip}" : "" "<i class='fa fa-#{icon_text}#{size_class}'></i>" end |
#theme_heading(heading, **options) ⇒ Object
theme_heading(heading) theme_heading(heading, icon=‘cog’) <div class=“row mb-10”>
<div class="fs-22 col-sm-12"><i class='fa fa-rub fa-lg mr-10'></i>Manage Projects</div>
</div>
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 88 def theme_heading(heading, **) .reverse_merge!( icon: '', row_class: "", col_class: "" ) content_tag :div, class: "row mb-10 #{[:row_class]}" do content_tag :div, class: "fs-22 col-sm-12 #{[:col_class]}" do raw(([:icon].blank? ? '' : theme_fa_icon([:icon], 'lg')) + " #{heading}") end end end |
#theme_item_description(text, limit = 120, classes = "text-color-grey fs-12") ⇒ Object
Example
theme_item_description(project.customer.name, 120)
is equivalent to:
<div class="text-color-grey fs-12"><%= project.customer.description %></div>
180 181 182 183 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 180 def theme_item_description(text, limit=120, classes = "text-color-grey fs-12") description = truncate(text, limit: limit) content_tag(:div, description, class: classes) end |
#theme_item_sub_title(text, classes = "text-color-red fs-14") ⇒ Object
Example
theme_item_sub_title(project.customer.name)
is equivalent to:
<div class="text-color-red fs-14"><%= project.customer.name if project.customer %></div>
170 171 172 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 170 def theme_item_sub_title(text, classes = "text-color-red fs-14") content_tag(:div, text, class: classes) end |
#theme_item_title(title, url, classes = "text-color-blue fs-16", remote = true) ⇒ Object
Example
theme_item_title(project.name, admin_project_path(project))
is equivalent to:
<%= link_to project.name, admin_project_path(project), :remote=>true, :class=>"text-color-blue fs-16" %>
160 161 162 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 160 def theme_item_title(title, url, classes = "text-color-blue fs-16", remote=true) link_to(title, url, :remote=>remote, :class=>classes) end |
#theme_panel_description(text, classes = "fs-14") ⇒ Object
Example
theme_panel_description(@project.pretty_url, "fs-14")
theme_panel_description(@project.description, "fs-14 mt-10")
is equivalent to:
<div class=“fs-14”><%= @project.pretty_url %></div> <div class=“fs-14 mt-10”><%= @project.description %></div>
210 211 212 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 210 def theme_panel_description(text, classes="fs-14") content_tag(:div, text, class: classes) end |
#theme_panel_heading(text, classes = "fs-24 text-color-green") ⇒ Object
Example
theme_panel_heading(@project.name)
is equivalent to:
<div class=“fs-24 text-color-green”><%= @project.name %></div>
190 191 192 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 190 def theme_panel_heading(text, classes="fs-24 text-color-green") content_tag(:div, text, class: classes) end |
#theme_panel_message(message) ⇒ Object
Example
("No Results found")
is equivalent to:
<div class="panel panel-default text-color-grey p-80 text-align-center" style="height:200px;">
"No Results found"
</div>
138 139 140 141 142 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 138 def () content_tag(:div, class: "panel panel-default panel-message text-color-grey p-80 text-align-center", style: "height:200px;width:100%;") do raw() end end |
#theme_panel_sub_heading(text, url, classes = "fs-16 text-color-red") ⇒ Object
Example
theme_panel_sub_heading(@project.name, admin_customer_path(@project.customer))
is equivalent to:
link_to(@project.customer.name, admin_customer_path(@project.customer), class: “fs-16 text-color-red”)
199 200 201 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 199 def theme_panel_sub_heading(text, url, classes="fs-16 text-color-red") link_to(text, url, class: classes) end |
#theme_panel_title(title, classes = "") ⇒ Object
Example
theme_panel_title("Team Members")
is equivalent to:
<h3 class="panel-title">Team Members</h3>
150 151 152 |
# File 'lib/kuppayam/action_view/theme_helper.rb', line 150 def theme_panel_title(title, classes="") content_tag(:h3, title, class: "panel-title #{classes}") end |