Class: Blacklight::FacetItemPivotPresenter
- Inherits:
-
FacetItemPresenter
- Object
- FacetItemPresenter
- Blacklight::FacetItemPivotPresenter
- Defined in:
- app/presenters/blacklight/facet_item_pivot_presenter.rb
Instance Attribute Summary
Attributes inherited from FacetItemPresenter
#facet_config, #facet_field, #facet_item, #search_state, #view_context
Instance Method Summary collapse
- #facet_item_presenter(facet_item) ⇒ Object
- #facet_item_presenters ⇒ Object
-
#label ⇒ String
Get the displayable version of a facet's value.
-
#selected? ⇒ Boolean
Check if the query parameters have the given facet field with the given value.
- #shown? ⇒ Boolean
- #value ⇒ Object
Methods inherited from FacetItemPresenter
#add_href, #hits, #href, #initialize, #items, #remove_href
Constructor Details
This class inherits a constructor from Blacklight::FacetItemPresenter
Instance Method Details
#facet_item_presenter(facet_item) ⇒ Object
23 24 25 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 23 def facet_item_presenter(facet_item) view_context.facet_field_presenter(facet_config, {}).item_presenter(facet_item) end |
#facet_item_presenters ⇒ Object
16 17 18 19 20 21 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 16 def facet_item_presenters return to_enum(:facet_item_presenters) unless block_given? return [] unless items items.each { |i| yield facet_item_presenter(i) } end |
#label ⇒ String
Get the displayable version of a facet's value
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 31 def label label_source = facet_item.respond_to?(:label) ? facet_item.label : facet_item if facet_config.helper_method view_context.public_send(facet_config.helper_method, label_source) else item_fq = label_source.respond_to?(:fq) ? label_source.fq : {} item_fq = item_fq.symbolize_keys label_value = facet_config.pivot.map(&:to_sym).map { |k| item_fq[k] } if label_source.respond_to?(:field) label_value << value else label_value.unshift value end label_value.compact.join(" » ") end end |
#selected? ⇒ Boolean
Check if the query parameters have the given facet field with the given value.
8 9 10 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 8 def selected? search_state.filter(facet_config).include?(facet_item) end |
#shown? ⇒ Boolean
12 13 14 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 12 def shown? selected? || facet_item_presenters.any? { |x| x.try(:shown?) } end |
#value ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/presenters/blacklight/facet_item_pivot_presenter.rb', line 48 def value if facet_item.respond_to? :value facet_item.value else facet_item end end |