Class: Listings::FilterView
Instance Attribute Summary
#field, #listing
Instance Method Summary
collapse
#descriptor, #human_name, #is_field?, #key, #path
Constructor Details
#initialize(listing, filter_description) ⇒ FilterView
Returns a new instance of FilterView.
3
4
5
|
# File 'lib/listings/filter_view.rb', line 3
def initialize(listing, filter_description)
super
end
|
Instance Method Details
#apply_filter(value) ⇒ Object
23
24
25
|
# File 'lib/listings/filter_view.rb', line 23
def apply_filter(value)
listing.data_source.filter(field, value)
end
|
#partial_name ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/listings/filter_view.rb', line 35
def partial_name
if render_option.is_a?(String)
render_option
else
"#{listing.layout_options[:filters]}_filter"
end
end
|
#prepare_values ⇒ Object
7
8
9
|
# File 'lib/listings/filter_view.rb', line 7
def prepare_values
values
end
|
#render? ⇒ Boolean
27
28
29
30
31
32
33
|
# File 'lib/listings/filter_view.rb', line 27
def render?
if render_option.is_a?(String)
true
else
render_option
end
end
|
#render_option ⇒ Object
43
44
45
|
# File 'lib/listings/filter_view.rb', line 43
def render_option
@field_description.props.fetch(:render, true)
end
|
#value_for(value) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/listings/filter_view.rb', line 15
def value_for(value)
if @field_description.proc
listing.instance_exec value, &@field_description.proc
else
value
end
end
|
#values ⇒ Object
11
12
13
|
# File 'lib/listings/filter_view.rb', line 11
def values
@values ||= listing.data_source.values_for_filter(field)
end
|