Class: Blacklight::FacetGroupedItemPresenter
- Inherits:
-
FacetItemPresenter
- Object
- FacetItemPresenter
- Blacklight::FacetGroupedItemPresenter
- Defined in:
- app/presenters/blacklight/facet_grouped_item_presenter.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
Attributes inherited from FacetItemPresenter
#facet_config, #facet_field, #facet_item, #search_state, #view_context
Instance Method Summary collapse
- #add_href(_path_options = {}) ⇒ Object
-
#initialize(group, facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state) ⇒ FacetGroupedItemPresenter
constructor
A new instance of FacetGroupedItemPresenter.
- #remove_href(path = search_state) ⇒ Object
-
#selected? ⇒ Boolean
Check if the query parameters have the given facet field with the given value.
Methods inherited from FacetItemPresenter
#constraint_label, #field_label, #hits, #href, #items, #label, #value
Constructor Details
#initialize(group, facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state) ⇒ FacetGroupedItemPresenter
Returns a new instance of FacetGroupedItemPresenter.
9 10 11 12 |
# File 'app/presenters/blacklight/facet_grouped_item_presenter.rb', line 9 def initialize(group, facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state) super(facet_item, facet_config, view_context, facet_field, search_state) @group = group end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'app/presenters/blacklight/facet_grouped_item_presenter.rb', line 5 def group @group end |
Instance Method Details
#add_href(_path_options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/presenters/blacklight/facet_grouped_item_presenter.rb', line 30 def add_href( = {}) if facet_config.url_method return view_context.public_send(facet_config.url_method, facet_config.key, facet_item) end new_state = search_state.filter(facet_config).remove(@group) new_state = new_state.filter(facet_config).add(@group + [facet_item]) view_context.search_action_path(new_state) end |
#remove_href(path = search_state) ⇒ Object
22 23 24 25 26 27 |
# File 'app/presenters/blacklight/facet_grouped_item_presenter.rb', line 22 def remove_href(path = search_state) new_state = path.filter(facet_config).remove(group) new_state = new_state.filter(facet_config).add(group - [facet_item]) view_context.search_action_path(new_state) end |
#selected? ⇒ Boolean
Check if the query parameters have the given facet field with the given value.
17 18 19 |
# File 'app/presenters/blacklight/facet_grouped_item_presenter.rb', line 17 def selected? group.include?(facet_item) end |