Class: FoxTail::FilterBarComponent

Inherits:
BaseComponent show all
Includes:
Concerns::Identifiable
Defined in:
app/components/fox_tail/filter_bar_component.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from BaseComponent

classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

#initialize(html_attributes = {}) ⇒ FilterBarComponent

Returns a new instance of FilterBarComponent.



104
105
106
# File 'app/components/fox_tail/filter_bar_component.rb', line 104

def initialize(html_attributes = {})
  super
end

Instance Method Details

#autocomplete_filter_component(name, url, options = {}) ⇒ Object



134
135
136
137
# File 'app/components/fox_tail/filter_bar_component.rb', line 134

def autocomplete_filter_component(name, url, options = {})
  add_default_filter_options name, :autocomplete, options
  FoxTail::AutocompleteComponent.new url, options
end

#before_renderObject



116
117
118
119
120
121
122
123
124
# File 'app/components/fox_tail/filter_bar_component.rb', line 116

def before_render
  super

  with_submit_button.with_content(t(".submit")) unless submit_buttons?
  with_filter_icon_button_trigger unless filter_toggle?

  html_attributes[:class] = classnames theme.apply(:root, self), html_class
  html_attributes[:method] ||= :get
end

#button_filter_component(options = {}) ⇒ Object



144
145
146
147
148
149
150
# File 'app/components/fox_tail/filter_bar_component.rb', line 144

def button_filter_component(options = {})
  options[:color] ||= :neutral
  options[:size] = size
  options[:class] = filter_classnames :button, options

  FoxTail::ButtonComponent.new(options)
end

#collapsible_idObject



156
157
158
# File 'app/components/fox_tail/filter_bar_component.rb', line 156

def collapsible_id
  "#{id}_collapsible"
end

#filter_trigger_component(options = {}) ⇒ Object



152
153
154
# File 'app/components/fox_tail/filter_bar_component.rb', line 152

def filter_trigger_component(options = {})
  FoxTail::CollapsibleTriggerComponent.new "##{collapsible_id}", options
end

#keyword_filter_component(name, options = {}) ⇒ Object



126
127
128
129
130
131
132
# File 'app/components/fox_tail/filter_bar_component.rb', line 126

def keyword_filter_component(name, options = {})
  add_default_filter_options name, :keyword, options
  icon = options.delete(:icon) { :magnifying_glass }
  component = FoxTail::InputComponent.new options
  component.with_left_icon icon if icon.present?
  component
end

#paramsObject



112
113
114
# File 'app/components/fox_tail/filter_bar_component.rb', line 112

def params
  options[:params] ||= view_context.try(:params)
end

#select_filter_component(name, options = {}) ⇒ Object



139
140
141
142
# File 'app/components/fox_tail/filter_bar_component.rb', line 139

def select_filter_component(name, options = {})
  add_default_filter_options name, :select, options
  FoxTail::SelectComponent.new options
end

#urlObject



108
109
110
# File 'app/components/fox_tail/filter_bar_component.rb', line 108

def url
  options[:url] ||= request.path
end