Class: TinyAdmin::Views::Components::FiltersForm
- Inherits:
-
BasicComponent
- Object
- Phlex::HTML
- BasicComponent
- TinyAdmin::Views::Components::FiltersForm
- Defined in:
- lib/tiny_admin/views/components/filters_form.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#section_path ⇒ Object
Returns the value of attribute section_path.
Instance Method Summary collapse
Methods inherited from BasicComponent
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
7 8 9 |
# File 'lib/tiny_admin/views/components/filters_form.rb', line 7 def filters @filters end |
#section_path ⇒ Object
Returns the value of attribute section_path.
7 8 9 |
# File 'lib/tiny_admin/views/components/filters_form.rb', line 7 def section_path @section_path end |
Instance Method Details
#view_template ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tiny_admin/views/components/filters_form.rb', line 9 def view_template form(class: 'form_filters', method: 'get') { filters.each do |field, filter| name = field.name filter_data = filter[:filter] div(class: 'mb-3') { label(for: "filter-#{name}", class: 'form-label') { field.title } case filter_data[:type]&.to_sym || field.type when :boolean select(class: 'form-select', id: "filter-#{name}", name: "q[#{name}]") { option(value: '') { '-' } option(value: '0', selected: filter[:value] == '0') { TinyAdmin.settings.helper_class.label_for('false', options: ['components.filters_form.boolean.false']) } option(value: '1', selected: filter[:value] == '1') { TinyAdmin.settings.helper_class.label_for('true', options: ['components.filters_form.boolean.true']) } } when :date input(type: 'date', class: 'form-control', id: "filter-#{name}", name: "q[#{name}]", value: filter[:value]) when :datetime input(type: 'datetime-local', class: 'form-control', id: "filter-#{name}", name: "q[#{name}]", value: filter[:value]) when :integer input(type: 'number', class: 'form-control', id: "filter-#{name}", name: "q[#{name}]", value: filter[:value]) when :select select(class: 'form-select', id: "filter-#{name}", name: "q[#{name}]") { option(value: '') { '-' } filter_data[:values].each do |value| option(selected: filter[:value] == value) { value } end } else input(type: 'text', class: 'form-control', id: "filter-#{name}", name: "q[#{name}]", value: filter[:value]) end } end div(class: 'mt-3') { a(href: section_path, class: 'button_clear btn btn-secondary text-white') { TinyAdmin.settings.helper_class.label_for('Clear', options: ['components.filters_form.buttons.clear']) } whitespace (type: 'submit', class: 'button_filter btn btn-secondary') { TinyAdmin.settings.helper_class.label_for('Filter', options: ['components.filters_form.buttons.submit']) } } } end |