Module: SearchFu::ViewHelper
- Defined in:
- lib/search_fu/view_helper.rb
Instance Method Summary collapse
- #filter_footer(add_apply_button_class) ⇒ Object
- #filter_header ⇒ Object
- #filter_table(model_klass, button_class) ⇒ Object
- #render_fields(model_klass, remove_button_class) ⇒ Object
- #search_fields_blueprint(model_klass, remove_button_class) ⇒ Object
- #search_fu_form_for(model_klass, element = "#content", options = {}) ⇒ Object
Instance Method Details
#filter_footer(add_apply_button_class) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/search_fu/view_helper.rb', line 45 def () content_tag(:tr) do content_tag(:td, link_to("Add", "#", id: "search_fu_add", class: ) + submit_tag("Apply", name: "search_fu_commit", class: , disable_with: "Searching..."), colspan: 3) end end |
#filter_header ⇒ Object
38 39 40 41 42 43 |
# File 'lib/search_fu/view_helper.rb', line 38 def filter_header content_tag(:tr) do content_tag(:td, "Filter") + content_tag(:td, "Value", colspan: 2) end end |
#filter_table(model_klass, button_class) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/search_fu/view_helper.rb', line 17 def filter_table(model_klass, ) content_tag(:table, id: 'search_fu_table') do content_tag(:thead, filter_header, id: "search_fu_thead") + content_tag(:tbody, render_fields(model_klass, [:remove]), id: "search_fu_tbody") + content_tag(:tfoot, ([:add_apply]), id: "search_fu_tfoot") end end |
#render_fields(model_klass, remove_button_class) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/search_fu/view_helper.rb', line 25 def render_fields(model_klass, ) html = "" (session["#{model_klass.name.underscore}_search_fu"] || params[:search_fu] || {}).each do |k,v| rand_id = (DateTime.now.to_i * rand * 100).to_i html << content_tag(:tr, id: "search_fu_row_new_#{rand_id}", class: "search_fu_rows") do content_tag(:td, select_tag("search_fu[_new_#{rand_id}][name]", (model_klass.search_fu_view_names, v[:name]))) + content_tag(:td, text_field_tag("search_fu[_new_#{rand_id}][value]", v[:value])) + content_tag(:td, link_to("X", "#", class: "search_fu_remove #{remove_button_class}")) end end html.html_safe end |
#search_fields_blueprint(model_klass, remove_button_class) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/search_fu/view_helper.rb', line 52 def search_fields_blueprint(model_klass, ) content_tag(:table, style: "display:none") do content_tag(:tbody, id: "hidden_search_fields") do content_tag(:tr, id: "search_fu_row_NEW_", class: "search_fu_rows") do content_tag(:td, select_tag("search_fu[_NEW_][name]", (model_klass.search_fu_view_names))) + content_tag(:td, text_field_tag("search_fu[_NEW_][value]")) + content_tag(:td, link_to("X", "#", class: "search_fu_remove #{remove_button_class}")) end end end end |
#search_fu_form_for(model_klass, element = "#content", options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/search_fu/view_helper.rb', line 6 def search_fu_form_for(model_klass, element="#content", ={}) = .delete(:button_class) ||= {} [:remove] ||= "" [:add_apply] ||= "" search_fields_blueprint(model_klass, [:remove]) + form_tag(polymorphic_path(model_klass), .merge(method: :get, remote: true, id: 'search_fu_form', element: element)) do filter_table model_klass, end end |