Class: UsefullFilter::FilterFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- UsefullFilter::FilterFormBuilder
- Defined in:
- lib/usefull_filter/filter_form_builder.rb
Constant Summary collapse
- DEFAULT_TYPES =
["equals", "does_not_equal", "in", "not_in"]
- STRING_TYPES =
["contains", "does_not_contain", "starts_with", "does_not_start_with", "ends_with", "does_not_end_with"]
- NUMBER_TYPES =
["greater_than", "greater_than_or_equal_to", "less_than", "less_than_or_equal_to"]
- BOOLEAN_TYPES =
["is_true", "is_false"]
- OTHER_TYPES =
["is_present", "is_blank"]
Instance Method Summary collapse
-
#between_field(object_name, *args) ⇒ Object
Genera una doppia text_box per gestire i filtri tra due.
-
#select(object_name, array, *args) ⇒ Object
Utilizza come filtro una combo, con i valori passati nell’array.
- #submit ⇒ Object
-
#text_field(object_name, *args) ⇒ Object
Ridefinisco il metodo per wrapparlo all’interno di una lista Accetta i seguenti parametri: * :default_filter => “equals” * :filters => [“equals”, .…].
Instance Method Details
#between_field(object_name, *args) ⇒ Object
Genera una doppia text_box per gestire i filtri tra due
54 55 56 57 58 59 60 |
# File 'lib/usefull_filter/filter_form_builder.rb', line 54 def between_field(object_name, *args) opt = define_args(args, object_name) name = object_name.to_s.gsub(/\./, "_") @template.content_tag(:li, multiparameter_field(name.to_s + "_between", {:field_type => :text_field}, {:field_type => :text_field}, :size => 5)) end |
#select(object_name, array, *args) ⇒ Object
Utilizza come filtro una combo, con i valori passati nell’array
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/usefull_filter/filter_form_builder.rb', line 33 def select(object_name, array, *args) opt = define_args(args, object_name) name = object_name.to_s.gsub(/\./, "_") opt.merge!([:html_1][:input]) @template.content_tag(:li) do @template.concat filter_list(name, opt[:default_filter], opt) @template.concat " " #@template.concat select("search", default(name, opt[:default_filter]), array.collect {|p| [p,p]}, opt) @template.concat super(default(name, opt[:default_filter]), array, opt) ##UserSession.log("FilterHelper#text_field:object_name=#{object_name.inspect}") end end |
#submit ⇒ Object
62 63 64 65 |
# File 'lib/usefull_filter/filter_form_builder.rb', line 62 def submit applay_filter_label = I18n.t(:applay_filter, :scope => "meta_search.buttons") super(applay_filter_label, :class => "usefull_filter_push-1") end |
#text_field(object_name, *args) ⇒ Object
Ridefinisco il metodo per wrapparlo all’interno di una lista Accetta i seguenti parametri:
-
:default_filter => “equals”
-
:filters => [“equals”, .…]
Il nome sarà del tipo
-
:ART
-
“document.activity.id” (come per la tabelle)
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/usefull_filter/filter_form_builder.rb', line 18 def text_field(object_name, *args) opt = define_args(args, object_name) name = object_name.to_s.gsub(/\./, "_") opt.merge!([:html_1][:input]) #UserSession.log("FilterHelper#text_field:opt=#{opt.inspect}") @template.content_tag(:li) do @template.concat filter_list(name, opt[:default_filter], opt) @template.concat " " @template.concat super(default(name, opt[:default_filter]), opt) ##UserSession.log("FilterHelper#text_field:object_name=#{object_name.inspect}") #@template.concat attribute_type(object_name) == :Date ? @template.link_to(@template.image_tag('calendar16.png'), '#', :onclick => "show_calendar('search_data_prevista_equals')") : '' end end |