lockaz_app/app/helpers/qi_sorting_helper.rb
Nicolas Bally f20fe482c6 initial
2020-04-06 10:38:07 +02:00

56 lines
1.1 KiB
Ruby
Executable File

module QiSortingHelper
def boolean_search_field(attribute, label=nil, include_nil=false)
r = ""
r += "<td>"
r += label.to_s
options = [[""], "Oui", "Non"]
r +=select_tag("search[#{attribute}]", options_for_select(options, params[:search][attribute.to_sym]))
r += "</td>"
raw r
end
def text_search_field(attribute, label=nil, include_nil=false)
r = ""
r += "<td>"
r +=text_field_tag("search[#{attribute}]", params[:search][attribute.to_sym],:class => "form-control", :placeholder => label.to_s)
r += "</td>"
raw r
end
def option_search_field(attribute, label, collection, for_label, include_nil=false)
r = ""
r += "<td>"
r += label.to_s
options = []
options << [""]
options << ["Aucune","null"]
options = options + collection.map{|a| [eval("a.#{for_label}"), a.id]}
r +=select_tag("search[#{attribute}]", options_for_select(options, params[:search][attribute.to_sym]))
r += "</td>"
raw r
end
end