Class: Blacklight::ConstraintsComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::ConstraintsComponent
- Includes:
- ContentAreasShim
- Defined in:
- app/components/blacklight/constraints_component.rb
Class Method Summary collapse
Instance Method Summary collapse
- #facet_constraints ⇒ Object
-
#initialize(search_state:, tag: :div, render_headers: true, id: 'appliedParams', classes: 'clearfix constraints-container', query_constraint_component: Blacklight::ConstraintLayoutComponent, query_constraint_component_options: {}, facet_constraint_component: Blacklight::ConstraintComponent, facet_constraint_component_options: {}, start_over_component: Blacklight::StartOverButtonComponent) ⇒ ConstraintsComponent
constructor
rubocop:disable Metrics/ParameterLists.
-
#query_constraints ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #render? ⇒ Boolean
Methods included from ContentAreasShim
Constructor Details
#initialize(search_state:, tag: :div, render_headers: true, id: 'appliedParams', classes: 'clearfix constraints-container', query_constraint_component: Blacklight::ConstraintLayoutComponent, query_constraint_component_options: {}, facet_constraint_component: Blacklight::ConstraintComponent, facet_constraint_component_options: {}, start_over_component: Blacklight::StartOverButtonComponent) ⇒ ConstraintsComponent
rubocop:disable Metrics/ParameterLists
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/blacklight/constraints_component.rb', line 22 def initialize(search_state:, tag: :div, render_headers: true, id: 'appliedParams', classes: 'clearfix constraints-container', query_constraint_component: Blacklight::ConstraintLayoutComponent, query_constraint_component_options: {}, facet_constraint_component: Blacklight::ConstraintComponent, facet_constraint_component_options: {}, start_over_component: Blacklight::StartOverButtonComponent) @search_state = search_state @query_constraint_component = query_constraint_component @query_constraint_component_options = @facet_constraint_component = facet_constraint_component @facet_constraint_component_options = @start_over_component = start_over_component @render_headers = render_headers @tag = tag @id = id @classes = classes end |
Class Method Details
.for_search_history(**kwargs) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/components/blacklight/constraints_component.rb', line 11 def self.for_search_history(**kwargs) new(tag: :span, render_headers: false, id: nil, query_constraint_component: Blacklight::SearchHistoryConstraintLayoutComponent, facet_constraint_component_options: { layout: Blacklight::SearchHistoryConstraintLayoutComponent }, start_over_component: nil, **kwargs) end |
Instance Method Details
#facet_constraints ⇒ Object
63 64 65 |
# File 'app/components/blacklight/constraints_component.rb', line 63 def facet_constraints helpers.render(@facet_constraint_component.with_collection(facet_item_presenters.to_a, **@facet_constraint_component_options)) end |
#query_constraints ⇒ Object
rubocop:enable Metrics/ParameterLists
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/blacklight/constraints_component.rb', line 44 def query_constraints Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do if @search_state.query_param.present? helpers.render( @query_constraint_component.new( search_state: @search_state, value: @search_state.query_param, label: label, remove_path: helpers.remove_constraint_url(@search_state), classes: 'query', **@query_constraint_component_options ) ) else ''.html_safe end end + helpers.render(@facet_constraint_component.with_collection(clause_presenters.to_a, **@facet_constraint_component_options)) end |
#render? ⇒ Boolean
67 68 69 |
# File 'app/components/blacklight/constraints_component.rb', line 67 def render? Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) { helpers.query_has_constraints?(@search_state.params) } end |