Class: FoxTail::FilterSummaryComponent
Instance Attribute Summary
#html_attributes
Instance Method Summary
collapse
classname_merger, #initialize, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
fox_tail_config
Instance Method Details
#before_render ⇒ Object
54
55
56
57
58
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 54
def before_render
super
html_attributes[:class] = classnames theme.apply(:root, self), html_class
end
|
#call ⇒ Object
60
61
62
63
64
65
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 60
def call
content_tag :div, html_attributes do
filters.each { |filter| concat filter }
concat clear_button if clear_button?
end
end
|
#clear_url ⇒ Object
67
68
69
70
71
72
73
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 67
def clear_url
uri = URI(url)
params = Rack::Utils.parse_nested_query uri.query
param_names.each { |name| params.delete name.to_s }
uri.query = Rack::Utils.build_nested_query params
uri.to_s
end
|
#remove_filter(params, name, options = {}) ⇒ Object
83
84
85
86
87
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 83
def remove_filter(params, name, options = {})
return params.delete(name.to_s) unless options.key? :value
params[name.to_s]&.delete options[:value].to_s
end
|
#remove_filter_url(name, options = {}) ⇒ Object
75
76
77
78
79
80
81
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 75
def remove_filter_url(name, options = {})
uri = URI(url)
params = Rack::Utils.parse_nested_query uri.query
remove_filter params, name, options
uri.query = Rack::Utils.build_nested_query params
uri.to_s
end
|
#render? ⇒ Boolean
50
51
52
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 50
def render?
filters?
end
|
#url ⇒ Object
46
47
48
|
# File 'app/components/fox_tail/filter_summary_component.rb', line 46
def url
options[:url] ||= request.original_fullpath
end
|