Module: BlacklightFacetExtras::Filter::ViewHelperExtension

Defined in:
lib/blacklight_facet_extras/filter/view_helper_extension.rb

Instance Method Summary collapse

Instance Method Details

#facet_values_for(solr_field) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/blacklight_facet_extras/filter/view_helper_extension.rb', line 2

def facet_values_for(solr_field)
  config = facet_filter_config(solr_field)
  facet_field = super(solr_field)
  return facet_field unless config

  items = facet_field.items.map do  |i|
    value = config.call(i.value)
    value = i.value if value === true
    next unless value
    BlacklightFacetExtras::FacetItem.new(i.value, i.hits, :display_label => value)
  end

  facet_field.items.replace(items)

  facet_field
end

#render_constraint_element(label, value, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/blacklight_facet_extras/filter/view_helper_extension.rb', line 19

def render_constraint_element(label, value, options = {})
  options[:classes] ||= []
  config = blacklight_filter_config.keys.select { |y| options[:classes].include? "filter-#{y.parameterize}" }.first
  return super(label, value, options) unless config

  display_label = blacklight_filter_config[config].call(value)
  display_label = value if label === true
  return ''.html_safe if label.blank?
  render(:partial => "catalog/filter_constraints_element", :locals => {:label => label, :display_label => display_label, :value => value, :options => options})
end