Class: Godmin::FormBuilders::FilterFormBuilder
- Inherits:
-
BootstrapForm::FormBuilder
- Object
- BootstrapForm::FormBuilder
- Godmin::FormBuilders::FilterFormBuilder
- Defined in:
- lib/godmin/helpers/filters.rb
Instance Method Summary collapse
- #apply_filters_button ⇒ Object
- #clear_filters_button ⇒ Object
- #filter_field(name, options, html_options = {}) ⇒ Object
- #multiselect_filter_field(name, options, html_options = {}) ⇒ Object
- #select_filter_field(name, options, html_options = {}) ⇒ Object
- #string_filter_field(name, _options, html_options = {}) ⇒ Object
Instance Method Details
#apply_filters_button ⇒ Object
60 61 62 |
# File 'lib/godmin/helpers/filters.rb', line 60 def submit @template.translate_scoped("filters.buttons.apply") end |
#clear_filters_button ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/godmin/helpers/filters.rb', line 64 def @template.link_to( @template.translate_scoped("filters.buttons.clear"), @template.url_for( @template.params.slice(:scope, :order) ), class: "btn btn-default" ) end |
#filter_field(name, options, html_options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/godmin/helpers/filters.rb', line 14 def filter_field(name, , = {}) case [:as] when :string string_filter_field(name, , ) when :select select_filter_field(name, , ) when :multiselect multiselect_filter_field(name, , ) end end |
#multiselect_filter_field(name, options, html_options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/godmin/helpers/filters.rb', line 48 def multiselect_filter_field(name, , = {}) filter_select( name, , { name: "filter[#{name}][]", multiple: true, data: { placeholder: @template.translate_scoped("filters.select.placeholder.many") } }.deep_merge() ) end |
#select_filter_field(name, options, html_options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/godmin/helpers/filters.rb', line 37 def select_filter_field(name, , = {}) filter_select( name, , { name: "filter[#{name}]", data: { placeholder: @template.translate_scoped("filters.select.placeholder.one") } }.deep_merge() ) end |
#string_filter_field(name, _options, html_options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/godmin/helpers/filters.rb', line 25 def string_filter_field(name, , = {}) text_field( name, { name: "filter[#{name}]", label: @template.translate_scoped("filters.labels.#{name}", default: name.to_s.titleize), value: default_filter_value(name), placeholder: @template.translate_scoped("filters.labels.#{name}", default: name.to_s.titleize), wrapper_class: "filter" }.deep_merge() ) end |