blacklight 7.26.0 → 7.27.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +15 -0
- data/app/components/blacklight/advanced_search_form_component.html.erb +21 -17
- data/app/components/blacklight/advanced_search_form_component.rb +12 -6
- data/app/components/blacklight/facet_component.rb +18 -3
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -1
- data/app/components/blacklight/search_context_component.html.erb +2 -2
- data/app/components/blacklight/search_context_component.rb +4 -4
- data/app/controllers/concerns/blacklight/catalog.rb +12 -3
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +19 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +4 -4
- data/app/presenters/blacklight/clause_presenter.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_advanced_search_help.html.erb +1 -1
- data/lib/blacklight/solr/response/facets.rb +6 -0
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +1 -0
- data/spec/components/blacklight/facet_component_spec.rb +102 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +16 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efe58070e4ce9981945726f50566d4f37929bb487ba5bc62b8e6763804b6e015
|
4
|
+
data.tar.gz: c0974d656e3be670ebd765eb8b725ca37178e2ec3c5524c668a0e554f7553439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5480cf9c3ce04ce4aac87f206cedcc22055f268616cd9015b0c22a0a245d14f43dba53959f8e479a3beb79e80df1f6ebf1dd8934169dfd4f75c18ddaf40d3f80
|
7
|
+
data.tar.gz: 25dc3a66c69247973770f8481b5969312bf37ec58f84e08458e7e69f9419f0ba2a758b9e0212d8c2839f02a785be6379365ea7d621560b8ea345822bc66f45bf
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.27.1
|
@@ -120,6 +120,21 @@
|
|
120
120
|
text-align: right;
|
121
121
|
width: 5em;
|
122
122
|
}
|
123
|
+
|
124
|
+
.facet-checkbox {
|
125
|
+
display: table-cell;
|
126
|
+
width: 1.25rem;
|
127
|
+
vertical-align: top;
|
128
|
+
}
|
129
|
+
|
130
|
+
.label-and-count {
|
131
|
+
display: table;
|
132
|
+
width: 100%;
|
133
|
+
}
|
134
|
+
|
135
|
+
.label-and-count label {
|
136
|
+
display: table-row;
|
137
|
+
}
|
123
138
|
}
|
124
139
|
|
125
140
|
.facet-extended-list {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if constraints
|
1
|
+
<% if constraints? %>
|
2
2
|
<div class="constraints well search_history">
|
3
3
|
<h4><%= t 'blacklight.advanced_search.form.search_context' %></h4>
|
4
4
|
<% constraints.each do |constraint| %>
|
@@ -11,8 +11,8 @@
|
|
11
11
|
<%= render_hash_as_hidden_fields(@params) %>
|
12
12
|
|
13
13
|
<div class="input-criteria">
|
14
|
-
<div class="query-criteria">
|
15
|
-
<h2 class="query-criteria-heading">
|
14
|
+
<div class="query-criteria mb-4">
|
15
|
+
<h2 class="query-criteria-heading h3 mb-4">
|
16
16
|
<%= t('blacklight.advanced_search.form.query_criteria_heading_html', select_menu: default_operator_menu) %>
|
17
17
|
</h2>
|
18
18
|
|
@@ -23,28 +23,32 @@
|
|
23
23
|
</div>
|
24
24
|
</div>
|
25
25
|
|
26
|
-
|
27
|
-
<
|
26
|
+
<% if search_filter_controls? %>
|
27
|
+
<div class="limit-criteria mb-4">
|
28
|
+
<h2 class="limit-criteria-heading h3"><%= t('blacklight.advanced_search.form.limit_criteria_heading_html')%></h2>
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
<div id="advanced_search_facets" class="limit_input row">
|
31
|
+
<div class="advanced-facet-limits panel-group col-md-9 offset-md-3">
|
32
|
+
<% search_filter_controls.each do |control| %>
|
33
|
+
<%= control %>
|
34
|
+
<% end %>
|
35
|
+
</div>
|
34
36
|
</div>
|
35
37
|
</div>
|
36
|
-
|
38
|
+
<% end %>
|
37
39
|
</div>
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
<% if sort_fields_select %>
|
42
|
+
<div class="form-group row mb-4">
|
43
|
+
<%= content_tag :h2, t('blacklight.advanced_search.form.sort_label'), class: 'col-md-3 col-form-label text-md-right' %>
|
44
|
+
<div class="col">
|
45
|
+
<%= sort_fields_select %>
|
46
|
+
</div>
|
43
47
|
</div>
|
44
|
-
|
48
|
+
<% end %>
|
45
49
|
|
46
50
|
<div class="form-group row">
|
47
|
-
<div class="submit-buttons col-
|
51
|
+
<div class="submit-buttons col-md-9 offset-md-3">
|
48
52
|
<%= submit_tag t('blacklight.advanced_search.form.search_btn_html'), class: 'btn btn-primary advanced-search-submit', id: "advanced-search-submit" %>
|
49
53
|
<%= button_tag t('blacklight.advanced_search.form.start_over_html'), type: 'reset', class: 'btn btn-link advanced-search-start-over' %>
|
50
54
|
</div>
|
@@ -31,7 +31,9 @@ module Blacklight
|
|
31
31
|
|
32
32
|
def sort_fields_select
|
33
33
|
options = sort_fields.values.map { |field_config| [helpers.sort_field_label(field_config.key), field_config.key] }
|
34
|
-
|
34
|
+
return unless options.any?
|
35
|
+
|
36
|
+
select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select w-auto")
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
@@ -41,7 +43,7 @@ module Blacklight
|
|
41
43
|
search_field_control do
|
42
44
|
fields_for('clause[]', i, include_id: false) do |f|
|
43
45
|
content_tag(:div, class: 'form-group advanced-search-field row') do
|
44
|
-
f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label") +
|
46
|
+
f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label text-md-right") +
|
45
47
|
content_tag(:div, class: 'col-sm-9') do
|
46
48
|
f.hidden_field(:field, value: field.key) +
|
47
49
|
f.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control')
|
@@ -62,12 +64,16 @@ module Blacklight
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def initialize_constraints
|
65
|
-
|
66
|
-
|
67
|
+
params = helpers.search_state.params_for_search.except :page, :f_inclusive, :q, :search_field, :op, :index, :sort
|
68
|
+
|
69
|
+
adv_search_context = helpers.search_state.reset(params)
|
67
70
|
|
68
|
-
|
71
|
+
constraints_text = render(Blacklight::ConstraintsComponent.for_search_history(search_state: adv_search_context))
|
69
72
|
|
70
|
-
|
73
|
+
return if constraints_text.blank?
|
74
|
+
|
75
|
+
constraint do
|
76
|
+
constraints_text
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
@@ -11,11 +11,19 @@ module Blacklight
|
|
11
11
|
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
12
12
|
# @param [Blacklight::Configuration] blacklight_config
|
13
13
|
# @param [Boolean] layout
|
14
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
14
15
|
def initialize(display_facet_or_field_config: nil, display_facet: nil, field_config: nil, response: nil, blacklight_config: nil, **component_args)
|
15
|
-
if display_facet_or_field_config.is_a?
|
16
|
+
if display_facet_or_field_config.is_a? Blacklight::FacetFieldPresenter
|
17
|
+
@facet_field_presenter = display_facet_or_field_config
|
18
|
+
@field_config = @facet_field_presenter.facet_field
|
19
|
+
@display_facet = @facet_field_presenter.display_facet
|
20
|
+
elsif display_facet_or_field_config.is_a?(Blacklight::Configuration::Field) || field_config
|
21
|
+
@facet_field_presenter = nil # we need the view context to generate this
|
16
22
|
@field_config = display_facet_or_field_config || field_config
|
17
|
-
@display_facet = display_facet ||
|
23
|
+
@display_facet = display_facet ||
|
24
|
+
response&.aggregations&.fetch(@field_config.field) { Blacklight::Solr::Response::Facets::NullFacetField.new(@field_config.field, response: response) }
|
18
25
|
elsif (display_facet || display_facet_or_field_config).respond_to?(:name)
|
26
|
+
@facet_field_presenter = nil # we need the view context to generate this
|
19
27
|
@display_facet = display_facet || display_facet_or_field_config
|
20
28
|
@field_config = field_config || blacklight_config&.facet_configuration_for_field(@display_facet.name)
|
21
29
|
else
|
@@ -24,20 +32,27 @@ module Blacklight
|
|
24
32
|
|
25
33
|
@component_args = component_args
|
26
34
|
end
|
35
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
27
36
|
|
28
37
|
def render?
|
29
38
|
helpers.should_render_field?(@field_config, @display_facet)
|
30
39
|
end
|
31
40
|
|
32
41
|
def call
|
42
|
+
return render_partial if @field_config.partial
|
43
|
+
|
33
44
|
component = @field_config.component == true ? Blacklight::FacetFieldListComponent : @field_config.component
|
34
45
|
|
35
46
|
render(
|
36
47
|
component.new(
|
37
|
-
facet_field: helpers.facet_field_presenter(@field_config, @display_facet),
|
48
|
+
facet_field: @facet_field_presenter || helpers.facet_field_presenter(@field_config, @display_facet),
|
38
49
|
**@component_args
|
39
50
|
)
|
40
51
|
)
|
41
52
|
end
|
53
|
+
|
54
|
+
def render_partial
|
55
|
+
helpers.render(@field_config.partial, locals: { field_name: @field_config.field, facet_field: @field_config, display_facet: @display_facet }.merge(@component_args))
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
@@ -13,7 +13,8 @@
|
|
13
13
|
|
14
14
|
<span class="label-and-count">
|
15
15
|
<%= label_tag "f_inclusive_#{@facet_field.key}_#{idx}" do %>
|
16
|
-
|
16
|
+
<span class="facet-label"><%= presenter.label %></span>
|
17
|
+
<span class="facet-count"><%= t('blacklight.search.facets.count', number: number_with_delimiter(presenter.hits)) %></span>
|
17
18
|
<% end %>
|
18
19
|
<span>
|
19
20
|
</li>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<div class='pagination-search-widgets'>
|
2
2
|
|
3
3
|
<div class="page-links">
|
4
|
-
<%= link_to_previous_document
|
4
|
+
<%= link_to_previous_document %> |
|
5
5
|
|
6
6
|
<%= item_page_entry_info %> |
|
7
7
|
|
8
|
-
<%= link_to_next_document
|
8
|
+
<%= link_to_next_document %>
|
9
9
|
</div>
|
10
10
|
</div>
|
@@ -19,15 +19,15 @@ module Blacklight
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def link_to_previous_document(*args)
|
22
|
+
def link_to_previous_document(document = nil, *args, **kwargs)
|
23
23
|
Deprecation.silence(Blacklight::UrlHelperBehavior) do
|
24
|
-
helpers.link_to_previous_document(*args)
|
24
|
+
helpers.link_to_previous_document(document || @search_context[:prev], *args, **kwargs)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def link_to_next_document(*args)
|
28
|
+
def link_to_next_document(document = nil, *args, **kwargs)
|
29
29
|
Deprecation.silence(Blacklight::UrlHelperBehavior) do
|
30
|
-
helpers.link_to_next_document(*args)
|
30
|
+
helpers.link_to_next_document(document || @search_context[:next], *args, **kwargs)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -60,9 +60,7 @@ module Blacklight::Catalog
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def advanced_search
|
63
|
-
|
64
|
-
|
65
|
-
(@response, _deprecated_document_list) = empty_service.search_results
|
63
|
+
(@response, _deprecated_document_list) = blacklight_advanced_search_form_search_service.search_results
|
66
64
|
end
|
67
65
|
|
68
66
|
# get a single document from the index
|
@@ -255,6 +253,7 @@ module Blacklight::Catalog
|
|
255
253
|
# By default, any search action from a Blacklight::Catalog controller
|
256
254
|
# should use the current controller when constructing the route.
|
257
255
|
def search_action_url options = {}
|
256
|
+
options = options.to_h if options.is_a? Blacklight::SearchState
|
258
257
|
url_for(options.reverse_merge(action: 'index'))
|
259
258
|
end
|
260
259
|
|
@@ -334,4 +333,14 @@ module Blacklight::Catalog
|
|
334
333
|
flash[:notice] = flash_notice
|
335
334
|
redirect_to search_action_url
|
336
335
|
end
|
336
|
+
|
337
|
+
def blacklight_advanced_search_form_search_service
|
338
|
+
form_search_state = search_state_class.new(blacklight_advanced_search_form_params, blacklight_config, self)
|
339
|
+
|
340
|
+
search_service_class.new(config: blacklight_config, search_state: form_search_state, user_params: form_search_state.to_h, **search_service_context)
|
341
|
+
end
|
342
|
+
|
343
|
+
def blacklight_advanced_search_form_params
|
344
|
+
{}
|
345
|
+
end
|
337
346
|
end
|
@@ -35,7 +35,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
35
35
|
end
|
36
36
|
|
37
37
|
Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
|
38
|
-
render_constraints_query(params_or_search_state) + render_constraints_filters(params_or_search_state)
|
38
|
+
render_constraints_query(params_or_search_state) + render_constraints_clauses(params_or_search_state) + render_constraints_filters(params_or_search_state)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -60,6 +60,24 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
##
|
64
|
+
# Render the query constraints
|
65
|
+
#
|
66
|
+
# @deprecated
|
67
|
+
# @param [Blacklight::SearchState,ActionController::Parameters] params_or_search_state query parameters
|
68
|
+
# @return [String]
|
69
|
+
def render_constraints_clauses(params_or_search_state = search_state)
|
70
|
+
search_state = convert_to_search_state(params_or_search_state)
|
71
|
+
|
72
|
+
clause_presenters = search_state.clause_params.map do |key, clause|
|
73
|
+
field_config = blacklight_config.search_fields[clause[:field]]
|
74
|
+
Blacklight::ClausePresenter.new(key, clause, field_config, self, search_state)
|
75
|
+
end
|
76
|
+
|
77
|
+
render(Blacklight::ConstraintComponent.with_collection(clause_presenters))
|
78
|
+
end
|
79
|
+
deprecation_deprecate :render_constraints_clauses
|
80
|
+
|
63
81
|
##
|
64
82
|
# Provide a url for removing a particular constraint. This can be overriden
|
65
83
|
# in the case that you want parameters other than the defaults to be removed
|
@@ -52,8 +52,8 @@ module Blacklight::UrlHelperBehavior
|
|
52
52
|
##
|
53
53
|
# Link to the previous document in the current search context
|
54
54
|
# @deprecated
|
55
|
-
def link_to_previous_document(previous_document)
|
56
|
-
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class:
|
55
|
+
def link_to_previous_document(previous_document, classes: 'previous', **addl_link_opts)
|
56
|
+
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: classes, rel: 'prev').merge(addl_link_opts)
|
57
57
|
link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
|
58
58
|
tag.span raw(t('views.pagination.previous')), class: 'previous'
|
59
59
|
end
|
@@ -63,8 +63,8 @@ module Blacklight::UrlHelperBehavior
|
|
63
63
|
##
|
64
64
|
# Link to the next document in the current search context
|
65
65
|
# @deprecated
|
66
|
-
def link_to_next_document(next_document)
|
67
|
-
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class:
|
66
|
+
def link_to_next_document(next_document, classes: 'next', **addl_link_opts)
|
67
|
+
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: classes, rel: 'next').merge(addl_link_opts)
|
68
68
|
link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
|
69
69
|
tag.span raw(t('views.pagination.next')), class: 'next'
|
70
70
|
end
|
@@ -25,7 +25,7 @@ module Blacklight
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def remove_href(path = search_state)
|
28
|
-
view_context.search_action_path(path.reset_search(clause: path.clause_params.except(key)))
|
28
|
+
view_context.search_action_path(path.reset_search(clause: path.clause_params.except(key)).to_h)
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if render_show_doc_actions_method_from_blacklight? %>
|
2
|
-
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: 'div', classes: "#{controller_name}Tools",
|
2
|
+
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: 'div', classes: "#{controller_name}Tools", link_classes: 'btn btn-outline-primary', actions: document_actions(document_list, options: { document: nil }), options: { document_list: @response.documents }, url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h))) %>
|
3
3
|
<% else %>
|
4
4
|
<% Deprecation.warn(self, '#render_show_doc_actions is deprecated; use ActionComponents instead') %>
|
5
5
|
<ul class="<%= controller_name %>Tools nav nav-pills">
|
@@ -99,6 +99,12 @@ module Blacklight::Solr::Response::Facets
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
class NullFacetField < FacetField
|
103
|
+
def initialize name, items = [], response: nil, **kwargs
|
104
|
+
super(name, items, response: response, **kwargs)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
102
108
|
##
|
103
109
|
# Get all the Solr facet data (fields, queries, pivots) as a hash keyed by
|
104
110
|
# both the Solr field name and/or by the blacklight field name
|
@@ -17,6 +17,7 @@
|
|
17
17
|
</updateHandler>
|
18
18
|
|
19
19
|
<!-- solr lib dirs -->
|
20
|
+
<lib dir="${solr.install.dir:../../../..}/contrib/modules/lib" />
|
20
21
|
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
|
21
22
|
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
|
22
23
|
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::FacetComponent, type: :component do
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(component)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:component) { described_class.new(**component_kwargs) }
|
11
|
+
let(:component_kwargs) { { field_config: facet_config, display_facet: display_facet } }
|
12
|
+
let(:items) { [{ label: "Book", value: 'Book', hits: 20 }] }
|
13
|
+
|
14
|
+
let(:display_facet) do
|
15
|
+
instance_double(Blacklight::Solr::Response::Facets::FacetField, name: 'field', items: items, limit: nil, sort: :index, offset: 0, prefix: nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'field', component: Blacklight::FacetFieldListComponent).normalize! }
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(controller).to receive(:view_context).and_return(controller.view_context)
|
22
|
+
allow(controller.view_context).to receive(:facet_limit_for).and_return(20)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'delegates to the configured component to render something' do
|
26
|
+
expect(rendered).to have_selector 'ul.facet-values'
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with a facet configured to use a partial' do
|
30
|
+
let(:facet_config) do
|
31
|
+
Blacklight::Configuration::FacetField.new(key: 'field', partial: 'catalog/facet_partial').normalize!
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
controller.view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for('catalog/_facet_partial.html.erb' => 'facet partial'))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'renders the partial' do
|
39
|
+
expect(rendered).to have_content 'facet partial'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with a field and response' do
|
44
|
+
let(:component_kwargs) do
|
45
|
+
{ display_facet_or_field_config: facet_config, response: response }
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:response) { instance_double(Blacklight::Solr::Response, aggregations: { 'field' => display_facet }) }
|
49
|
+
|
50
|
+
it 'extracts the facet data from the response to pass on to the rendering component' do
|
51
|
+
allow(facet_config.component).to receive(:new).and_call_original
|
52
|
+
|
53
|
+
rendered
|
54
|
+
|
55
|
+
expect(facet_config.component).to have_received(:new).with(facet_field: have_attributes(facet_field: facet_config, display_facet: display_facet))
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the field is not in the response' do
|
59
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'some_other_field', component: Blacklight::FacetFieldListComponent).normalize! }
|
60
|
+
|
61
|
+
it 'uses a null field to pass through the response information anyway' do
|
62
|
+
allow(facet_config.component).to receive(:new).and_call_original
|
63
|
+
|
64
|
+
rendered
|
65
|
+
|
66
|
+
expect(facet_config.component).to have_received(:new).with(facet_field: have_attributes(facet_field: facet_config, display_facet: have_attributes(items: [], response: response)))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with a display facet and configuration' do
|
72
|
+
let(:component_kwargs) do
|
73
|
+
{ display_facet_or_field_config: display_facet, blacklight_config: blacklight_config }
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:blacklight_config) { Blacklight::Configuration.new.tap { |config| config.facet_fields['field'] = facet_config } }
|
77
|
+
|
78
|
+
it 'pulls the facet config from the blacklight config' do
|
79
|
+
allow(facet_config.component).to receive(:new).and_call_original
|
80
|
+
|
81
|
+
rendered
|
82
|
+
|
83
|
+
expect(facet_config.component).to have_received(:new).with(facet_field: have_attributes(facet_field: facet_config, display_facet: display_facet))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with a presenter' do
|
88
|
+
let(:component_kwargs) do
|
89
|
+
{ display_facet_or_field_config: presenter }
|
90
|
+
end
|
91
|
+
|
92
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet_config, display_facet, controller.view_context) }
|
93
|
+
|
94
|
+
it 'renders the component with the provided presenter' do
|
95
|
+
allow(facet_config.component).to receive(:new).and_call_original
|
96
|
+
|
97
|
+
rendered
|
98
|
+
|
99
|
+
expect(facet_config.component).to have_received(:new).with(facet_field: presenter)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -6,6 +6,7 @@ RSpec.describe Blacklight::RenderConstraintsHelperBehavior do
|
|
6
6
|
let(:config) do
|
7
7
|
Blacklight::Configuration.new do |config|
|
8
8
|
config.add_facet_field 'type'
|
9
|
+
config.add_search_field 'title'
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -31,6 +32,21 @@ RSpec.describe Blacklight::RenderConstraintsHelperBehavior do
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
describe '#render_constraints_clauses' do
|
36
|
+
subject { helper.render_constraints_clauses(params) }
|
37
|
+
|
38
|
+
let(:my_engine) { double("Engine") }
|
39
|
+
let(:params) { ActionController::Parameters.new(clause: { "0": { field: 'title', query: 'nature' } }, f: { type: 'journal' }) }
|
40
|
+
|
41
|
+
it 'renders the clause constraint' do
|
42
|
+
expect(subject).to have_selector '.constraint-value', text: /Title\s+nature/
|
43
|
+
end
|
44
|
+
|
45
|
+
it "has a link relative to the current url" do
|
46
|
+
expect(subject).to have_link 'Remove constraint Title: nature', href: '/catalog?f%5Btype%5D%5B%5D=journal'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
34
50
|
describe '#render_filter_element' do
|
35
51
|
subject { helper.render_filter_element('type', ['journal'], path) }
|
36
52
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -14,10 +14,10 @@ authors:
|
|
14
14
|
- Dan Funk
|
15
15
|
- Naomi Dushay
|
16
16
|
- Justin Coyne
|
17
|
-
autorequire:
|
17
|
+
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2022-
|
20
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -780,6 +780,7 @@ files:
|
|
780
780
|
- spec/components/blacklight/document/group_component_spec.rb
|
781
781
|
- spec/components/blacklight/document_component_spec.rb
|
782
782
|
- spec/components/blacklight/document_metadata_component_spec.rb
|
783
|
+
- spec/components/blacklight/facet_component_spec.rb
|
783
784
|
- spec/components/blacklight/facet_field_checkboxes_component_spec.rb
|
784
785
|
- spec/components/blacklight/facet_field_list_component_spec.rb
|
785
786
|
- spec/components/blacklight/facet_item_component_spec.rb
|
@@ -932,7 +933,7 @@ homepage: http://projectblacklight.org/
|
|
932
933
|
licenses:
|
933
934
|
- Apache 2.0
|
934
935
|
metadata: {}
|
935
|
-
post_install_message:
|
936
|
+
post_install_message:
|
936
937
|
rdoc_options: []
|
937
938
|
require_paths:
|
938
939
|
- lib
|
@@ -947,8 +948,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
947
948
|
- !ruby/object:Gem::Version
|
948
949
|
version: '0'
|
949
950
|
requirements: []
|
950
|
-
rubygems_version: 3.2
|
951
|
-
signing_key:
|
951
|
+
rubygems_version: 3.1.2
|
952
|
+
signing_key:
|
952
953
|
specification_version: 4
|
953
954
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
954
955
|
index.
|
@@ -960,6 +961,7 @@ test_files:
|
|
960
961
|
- spec/components/blacklight/document/group_component_spec.rb
|
961
962
|
- spec/components/blacklight/document_component_spec.rb
|
962
963
|
- spec/components/blacklight/document_metadata_component_spec.rb
|
964
|
+
- spec/components/blacklight/facet_component_spec.rb
|
963
965
|
- spec/components/blacklight/facet_field_checkboxes_component_spec.rb
|
964
966
|
- spec/components/blacklight/facet_field_list_component_spec.rb
|
965
967
|
- spec/components/blacklight/facet_item_component_spec.rb
|