Module: Matestack::Ui::Bootstrap::Content::SmartCollection::Filter

Included in:
Collection
Defined in:
lib/matestack/ui/bootstrap/content/smart_collection/filter.rb

Instance Method Summary collapse

Instance Method Details

#filter_input(key, config) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/matestack/ui/bootstrap/content/smart_collection/filter.rb', line 19

def filter_input(key, config)
  attributes = {
    id: key,
    key: key,
    type: :text,
    placeholder: config[:placeholder] || key.to_s,
    label: config[:label]
  }
  case config[:type]
  when :select
    bs_form_select attributes.merge(options: config[:options])
  when :checkbox
    bs_form_checkbox attributes.merge(options: config[:options])
  else
    bs_form_input attributes.merge(class: 'smart-collection-filter')
  end
end

#filter_partialObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/matestack/ui/bootstrap/content/smart_collection/filter.rb', line 3

def filter_partial
  collection_filter collection.config do
    bs_row class: 'mt-2 mb-4' do
      div class: 'col-auto' do
        bs_row do
          processed_filters.each do |key, config|
            bs_col do
              filter_input key, config
            end
          end
        end
      end
    end
  end
end