Module: UsefullFilterHelper
- Defined in:
- app/helpers/usefull_filter_helper.rb
Overview
require “usefull_filter/filter_form_builder” L’helper si occupa di wrappare la classe MetaSearch permettendo l’utilizzo di Filtri selezionabili dall’utente
- documents_controller
-
Vedi TableHelper
- index.html.erb
-
<%=filter_for_new @search, :url => magazzino_documents_path do |f| %>
<%= f.text_field :data, :size => 10, :filters => ["equals", "less_than_or_equal_to", "greater_than_or_equal_to"] %> <%= f.text_field :DoCNr, :filters_type => :number %> <%= f.text_field :TbDoC, :filters_only => ["equals"] %> <%= f.text_field :BollaXENrDoC, filters_except => ["equals", "does_not_equal"] %> <%= f.text_field :DoCSit %> <%= f.submit %><% end %>
Instance Method Summary collapse
-
#filter_button_tag(name, url, method = :get) ⇒ Object
Contatta l’url passato ripassando i filtri attivi in @search.
-
#filter_for(obj, *args, &proc) ⇒ Object
Cerca una serie di filtri utilizzando MetaSearch di cui fa il wrapper obj è una istanza metashearch.
- #filter_for_new(obj, *args, &proc) ⇒ Object
Instance Method Details
#filter_button_tag(name, url, method = :get) ⇒ Object
Contatta l’url passato ripassando i filtri attivi in @search
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/usefull_filter_helper.rb', line 18 def (name, url, method = :get) if @search.kind_of?(MetaSearch::Builder) form_tag(url, :method => method) do @search.search_attributes.each do |k,v| if v.kind_of?(Array) v.each{|vv| concat hidden_field_tag("search[#{k}][]", vv)} else concat hidden_field_tag("search[#{k}]", v) end end concat submit_tag(name) end end end |
#filter_for(obj, *args, &proc) ⇒ Object
Cerca una serie di filtri utilizzando MetaSearch di cui fa il wrapper obj è una istanza metashearch
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/usefull_filter_helper.rb', line 39 def filter_for(obj, *args, &proc) unless obj.blank? = args. [:html] ||= {} [:html][:select] ||= {} [:html][:input] ||= {} [:html][:method] ||= :get [:html][:class] ||= "usefull_filter_container" [:html_1] = .delete(:html) .merge!(:builder => UsefullFilter::FilterFormBuilder) remove_filter_label = I18n.t("remove_filter", :scope => "meta_search.buttons") filter_title = I18n.t("filter_title", :scope => "meta_search.buttons") #Estraggo le options che mi interessano, perchè una volta passate al builder #per qulache arcano motivo vengono alterate.... classe = [:html_1].delete(:class) url = [:url] #UserSession.log("FilterHelper#filter_for_new: options=#{options.inspect}") content_tag(:div, content_tag(:h3, filter_title) + content_tag(:ul, form_for(obj, *(args << ), &proc) + form_tag(url_for(url), :method => :get) do obj.search_attributes.each_key {|k| concat hidden_field_tag("search[#{k}]") } concat submit_tag(remove_filter_label, :class => "usefull_filter_push-2") end ), :class => classe) end end |
#filter_for_new(obj, *args, &proc) ⇒ Object
33 34 35 |
# File 'app/helpers/usefull_filter_helper.rb', line 33 def filter_for_new(obj, *args, &proc) filter_for(obj, *args, &proc) end |