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
29
30
31
|
# File 'lib/listings/filter_view.rb', line 29
def apply_filter(value)
listing.data_source.filter(field, value)
end
|
#partial_name ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/listings/filter_view.rb', line 41
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
33
34
35
36
37
38
39
|
# File 'lib/listings/filter_view.rb', line 33
def render?
if render_option.is_a?(String)
true
else
render_option
end
end
|
#render_option ⇒ Object
49
50
51
|
# File 'lib/listings/filter_view.rb', line 49
def render_option
@field_description.props.fetch(:render, true)
end
|
#value_for(value) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/listings/filter_view.rb', line 21
def value_for(value)
if @field_description.proc
listing.instance_exec value, &@field_description.proc
else
value
end
end
|
#values ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/listings/filter_view.rb', line 11
def values
@values ||= begin
if method = @field_description.props[:values]
listing.send(method)
else
listing.data_source.values_for_filter(field)
end
end
end
|