Class: AdminWidgets::FiltersWidget
- Inherits:
-
BaseFormWidget
- Object
- Erector::Widget
- BaseWidget
- BaseFormWidget
- AdminWidgets::FiltersWidget
- Defined in:
- lib/admin_widgets/filters_widget.rb
Instance Attribute Summary
Attributes inherited from BaseFormWidget
Instance Method Summary collapse
- #buttons ⇒ Object
-
#field(name, operator, options = {}) ⇒ Object
DSL methods.
- #form_content ⇒ Object
- #hidden_fields ⇒ Object
Methods inherited from BaseFormWidget
#around_form, #autofocus!, #autofocus_done?, #builder, #content
Methods inherited from BaseWidget
#capture, #content_block, #helper, #method_missing, #root
Methods included from Memoization
Methods included from Delegation
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AdminWidgets::BaseWidget
Instance Method Details
#buttons ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/admin_widgets/filters_widget.rb', line 48 def div :class => ['group', 'navform', 'wat-cf'] do rawtext helper.(:class => 'button', :name => 'filter', :value => as) { helper.image_tag('search-button.png') + helper.t('resources.actions.filter') } rawtext helper.link_to(helper.t('resources.actions.reset_filter'), cancel_url, :class => "text_button_padding link_button") if cancel_url end end |
#field(name, operator, options = {}) ⇒ Object
DSL methods
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/admin_widgets/filters_widget.rb', line 18 def field(name, operator, = {}) field_name = "#{name}_#{operator}" field_label = resource_class.human_attribute_name(name) field_value = params[as][field_name] rescue '' multiple = [:in, :all].include?(operator.to_sym) field_value = field_value.to_s.split(',') if multiple && field_value && !field_value.is_a?(Array) if [:collection].present? value = nil selected = field_value include_blank = true else value = field_value selected = nil include_blank = nil end = { :required => false, :label => field_label, :input_html => { :value => value, :multiple => multiple }, :selected => selected, :include_blank => include_blank, :hidden_field => false } rawtext form.input(field_name, .merge()) end |
#form_content ⇒ Object
10 11 12 13 14 |
# File 'lib/admin_widgets/filters_widget.rb', line 10 def form_content hidden_fields content_block end |
#hidden_fields ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/admin_widgets/filters_widget.rb', line 40 def hidden_fields div :class => ['hidden-fields'] do %w[scope sort_field sort_direction].each do |hidden_field| rawtext form.input(hidden_field, :input_html => { :name => hidden_field, :value => params[hidden_field] }, :as => :hidden) end end end |