blacklight 9.0.0.beta6 → 9.0.0.beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +21 -3
- data/.solr_wrapper.yml +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +9 -5
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +9 -5
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +2 -1
- data/app/components/blacklight/constraints_component.html.erb +3 -8
- data/app/components/blacklight/constraints_component.rb +57 -14
- data/app/components/blacklight/document/bookmark_component.rb +1 -1
- data/app/components/blacklight/document/page_header_component.rb +1 -1
- data/app/components/blacklight/document_component.rb +20 -24
- data/app/components/blacklight/facet_item_pivot_component.rb +4 -0
- data/app/components/blacklight/facets/filters_component.rb +1 -1
- data/app/components/blacklight/facets/item_component.rb +3 -0
- data/app/components/blacklight/facets/selected_value_component.rb +1 -1
- data/app/components/blacklight/facets/suggest_component.rb +2 -3
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +8 -4
- data/app/javascript/blacklight-frontend/facet_suggest.js +2 -1
- data/app/javascript/blacklight-frontend/modal.js +7 -4
- data/app/presenters/blacklight/constraint_presenter.rb +22 -0
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_presenter.rb +0 -18
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/join.rb +9 -5
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_document.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +9 -5
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/show.html.erb +2 -2
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.ar.yml +1 -2
- data/config/locales/blacklight.ca.yml +1 -2
- data/config/locales/blacklight.de.yml +1 -2
- data/config/locales/blacklight.en.yml +2 -3
- data/config/locales/blacklight.es.yml +1 -2
- data/config/locales/blacklight.fr.yml +1 -2
- data/config/locales/blacklight.hu.yml +1 -2
- data/config/locales/blacklight.it.yml +1 -2
- data/config/locales/blacklight.nl.yml +1 -2
- data/config/locales/blacklight.pt-BR.yml +1 -2
- data/config/locales/blacklight.sq.yml +1 -2
- data/config/locales/blacklight.zh.yml +1 -2
- data/lib/blacklight/component.rb +7 -1
- data/lib/blacklight/configuration/facet_field.rb +4 -0
- data/lib/blacklight/configuration/view_config.rb +30 -16
- data/lib/blacklight/configuration.rb +58 -5
- data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
- data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +5 -5
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -2
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +26 -4
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
- data/package.json +1 -1
- data/spec/components/blacklight/constraints_component_spec.rb +2 -2
- data/spec/components/blacklight/document_component_spec.rb +8 -15
- data/spec/components/blacklight/facets/filters_component_spec.rb +2 -2
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +2 -1
- data/spec/components/blacklight/facets/suggest_component_spec.rb +15 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/features/advanced_search_spec.rb +39 -20
- data/spec/features/search_filters_spec.rb +3 -3
- data/spec/features/search_spec.rb +3 -3
- data/spec/models/blacklight/configuration_spec.rb +126 -0
- data/spec/models/blacklight/solr/repository_spec.rb +6 -0
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +52 -6
- data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -0
- metadata +18 -10
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
|
@@ -10,7 +10,7 @@ module Blacklight::Solr
|
|
|
10
10
|
:add_query_to_solr, :add_facet_fq_to_solr,
|
|
11
11
|
:add_facetting_to_solr, :add_solr_fields_to_query, :add_paging_to_solr,
|
|
12
12
|
:add_sorting_to_solr, :add_group_config_to_solr,
|
|
13
|
-
:add_adv_search_clauses,
|
|
13
|
+
:add_adv_search_clauses, :add_facets_for_advanced_search_form,
|
|
14
14
|
:add_additional_filters
|
|
15
15
|
]
|
|
16
16
|
end
|
|
@@ -95,6 +95,13 @@ module Blacklight::Solr
|
|
|
95
95
|
def add_adv_search_clauses(solr_parameters)
|
|
96
96
|
return if search_state.clause_params.blank?
|
|
97
97
|
|
|
98
|
+
# We need to specify lucene as the top-level defType when using JSON Query DSL in Solr versions
|
|
99
|
+
# between 7.2.0 & 9.4.0. After 9.4.0 this is no longer necessary, but also not harmful to include.
|
|
100
|
+
solr_parameters[:defType] = 'lucene'
|
|
101
|
+
|
|
102
|
+
# Disable spellcheck, which doesn't work when using JSON Query DSL
|
|
103
|
+
solr_parameters[:spellcheck] = 'false'
|
|
104
|
+
|
|
98
105
|
defaults = { must: [], must_not: [], should: [] }
|
|
99
106
|
default_op = blacklight_params[:op]&.to_sym || :must
|
|
100
107
|
solr_parameters[:mm] = 1 if default_op == :should && search_state.clause_params.values.any? { |clause| }
|
|
@@ -117,6 +124,16 @@ module Blacklight::Solr
|
|
|
117
124
|
[op, field.clause_params.transform_values { |v| v.merge(query: clause[:query]) }]
|
|
118
125
|
end
|
|
119
126
|
|
|
127
|
+
# Merge the advanced search form parameters into the solr parameters
|
|
128
|
+
# @param [Hash] solr_parameters the current solr parameters
|
|
129
|
+
# @return [Hash] the solr parameters with the additional advanced search form parameters
|
|
130
|
+
def add_facets_for_advanced_search_form(solr_parameters)
|
|
131
|
+
return unless search_state.controller&.action_name == 'advanced_search' &&
|
|
132
|
+
blacklight_config.advanced_search[:form_solr_parameters]
|
|
133
|
+
|
|
134
|
+
solr_parameters.merge!(blacklight_config.advanced_search[:form_solr_parameters])
|
|
135
|
+
end
|
|
136
|
+
|
|
120
137
|
##
|
|
121
138
|
# Add any existing facet limits, stored in app-level HTTP query
|
|
122
139
|
# as :f, to solr as appropriate :fq query.
|
|
@@ -243,7 +260,7 @@ module Blacklight::Solr
|
|
|
243
260
|
|
|
244
261
|
# Look up facet limit for given facet_field. Will look at config, and
|
|
245
262
|
# if config is 'true' will look up from Solr @response if available. If
|
|
246
|
-
# no limit is
|
|
263
|
+
# no limit is available, returns nil. Used from #add_facetting_to_solr
|
|
247
264
|
# to supply f.fieldname.facet.limit values in solr request (no @response
|
|
248
265
|
# available), and used in display (with @response available) to create
|
|
249
266
|
# a facet paginator with the right limit.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight::Solr
|
|
4
|
+
class SingleDocSearchBuilder < SearchBuilder
|
|
5
|
+
self.default_processor_chain = [:add_defaults, :add_qt, :add_unique_id]
|
|
6
|
+
|
|
7
|
+
def initialize(scope, id, other_params)
|
|
8
|
+
@other_params = other_params
|
|
9
|
+
@id = id
|
|
10
|
+
super(scope)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def add_defaults(request)
|
|
14
|
+
request.reverse_merge!(blacklight_config.default_document_solr_params).reverse_merge!(@other_params)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_qt(request)
|
|
18
|
+
request[:qt] ||= blacklight_config.document_solr_request_handler if blacklight_config.document_solr_request_handler
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def add_unique_id(request)
|
|
22
|
+
request[blacklight_config.document_unique_id_param] = @id
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -29,6 +29,13 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
29
29
|
#
|
|
30
30
|
## Should the raw solr document endpoint (e.g. /catalog/:id/raw) be enabled
|
|
31
31
|
# config.raw_endpoint.enabled = false
|
|
32
|
+
#
|
|
33
|
+
## Should advanced search be enabled
|
|
34
|
+
# config.advanced_search.enabled = true
|
|
35
|
+
#
|
|
36
|
+
## Optional fine-tuning for advanced search, e.g., set different limits for
|
|
37
|
+
## different facets.
|
|
38
|
+
# config.advanced_search.form_solr_parameters = {}
|
|
32
39
|
|
|
33
40
|
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
|
34
41
|
config.default_solr_params = {
|
|
@@ -38,7 +45,7 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
38
45
|
# solr path which will be added to solr base url before the other solr params.
|
|
39
46
|
#config.solr_path = 'select'
|
|
40
47
|
#config.document_solr_path = 'get'
|
|
41
|
-
#config.json_solr_path = '
|
|
48
|
+
#config.json_solr_path = 'select'
|
|
42
49
|
|
|
43
50
|
# items to show per page, each number in the array represent another option to choose from.
|
|
44
51
|
#config.per_page = [10,20,50,100]
|
|
@@ -105,6 +112,12 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
105
112
|
# :show may be set to false if you don't want the facet to be drawn in the
|
|
106
113
|
# facet bar
|
|
107
114
|
#
|
|
115
|
+
# Set :include_in_advanced_search to false for any search field or facet field
|
|
116
|
+
# that you want to exclude from appearing in the advanced search page.
|
|
117
|
+
#
|
|
118
|
+
# Set :include_in_simple_select to false for any search field you want to render
|
|
119
|
+
# in the Advanced Search page but exclude from the main search box scope selector.
|
|
120
|
+
#
|
|
108
121
|
# Set :index_range to true if you want the facet pagination view to have facet prefix-based navigation.
|
|
109
122
|
# (useful when user clicks "more" on a large facet and wants to navigate alphabetically across a large set of results)
|
|
110
123
|
# :index_range can be an array or range of prefixes that will be used to create the navigation (note: It is case sensitive when searching values)
|
|
@@ -121,7 +134,9 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
121
134
|
|
|
122
135
|
config.add_facet_field 'example_pivot_field',
|
|
123
136
|
label: 'Pivot Field',
|
|
124
|
-
pivot: ['language_ssim', 'subject_geo_ssim', 'subject_ssim'],
|
|
137
|
+
pivot: ['language_ssim', 'subject_geo_ssim', 'subject_ssim'],
|
|
138
|
+
collapsing: true,
|
|
139
|
+
include_in_advanced_search: false
|
|
125
140
|
|
|
126
141
|
config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
|
|
127
142
|
:years_5 => { label: 'within 5 Years', fq: "pub_date_ssim:[#{Time.zone.now.year - 5 } TO *]" },
|
|
@@ -165,7 +180,7 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
165
180
|
config.add_show_field 'isbn_ssim', label: 'ISBN'
|
|
166
181
|
|
|
167
182
|
# "fielded" search configuration. Used by pulldown among other places.
|
|
168
|
-
# For supported keys in hash, see rdoc for Blacklight::
|
|
183
|
+
# For supported keys in hash, see rdoc for Blacklight::Configuration::SearchField
|
|
169
184
|
#
|
|
170
185
|
# Search fields will inherit the :qt solr request handler from
|
|
171
186
|
# config[:default_solr_parameters], OR can specify a different one
|
|
@@ -208,7 +223,7 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
208
223
|
|
|
209
224
|
# Specifying a :qt only to show it's possible, and so our internal automated
|
|
210
225
|
# tests can test it. In this case it's the same as
|
|
211
|
-
# config[:default_solr_parameters][:qt], so isn't actually
|
|
226
|
+
# config[:default_solr_parameters][:qt], so isn't actually necessary.
|
|
212
227
|
config.add_search_field('subject') do |field|
|
|
213
228
|
field.qt = 'search'
|
|
214
229
|
field.solr_parameters = {
|
|
@@ -218,6 +233,13 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
218
233
|
}
|
|
219
234
|
end
|
|
220
235
|
|
|
236
|
+
# Set up a default advanced search configuration by using the current
|
|
237
|
+
# search_fields and facet_fields configs.
|
|
238
|
+
if config.advanced_search.enabled
|
|
239
|
+
config.copy_search_field_config_to_advanced!
|
|
240
|
+
config.copy_facet_field_config_to_advanced!
|
|
241
|
+
end
|
|
242
|
+
|
|
221
243
|
# "sort results by" select (pulldown)
|
|
222
244
|
# label in pulldown is followed by the name of the Solr field to sort by and
|
|
223
245
|
# whether the sort is ascending or descending (it must be asc or desc
|
|
@@ -98,73 +98,6 @@
|
|
|
98
98
|
</arr>
|
|
99
99
|
</requestHandler>
|
|
100
100
|
|
|
101
|
-
<requestHandler name="/advanced" class="solr.SearchHandler">
|
|
102
|
-
<!-- a lucene request handler for using the JSON Query DSL,
|
|
103
|
-
specifically for advanced search.
|
|
104
|
-
Using a separate requestHandler is a workaround to
|
|
105
|
-
https://issues.apache.org/jira/browse/SOLR-16916, although
|
|
106
|
-
it could be desirable for other reasons as well.
|
|
107
|
-
-->
|
|
108
|
-
<lst name="defaults">
|
|
109
|
-
<str name="defType">lucene</str>
|
|
110
|
-
<str name="echoParams">explicit</str>
|
|
111
|
-
<str name="df">title_tsim</str>
|
|
112
|
-
<str name="qf">
|
|
113
|
-
id
|
|
114
|
-
full_title_tsim
|
|
115
|
-
short_title_tsim
|
|
116
|
-
alternative_title_tsim
|
|
117
|
-
title_tsim
|
|
118
|
-
author_tsim
|
|
119
|
-
subject_tsim
|
|
120
|
-
all_text_timv
|
|
121
|
-
</str>
|
|
122
|
-
<str name="pf">
|
|
123
|
-
all_text_timv^10
|
|
124
|
-
</str>
|
|
125
|
-
|
|
126
|
-
<str name="author_qf">
|
|
127
|
-
author_tsim
|
|
128
|
-
</str>
|
|
129
|
-
<str name="author_pf">
|
|
130
|
-
</str>
|
|
131
|
-
<str name="title_qf">
|
|
132
|
-
title_tsim
|
|
133
|
-
full_title_tsim
|
|
134
|
-
short_title_tsim
|
|
135
|
-
alternative_title_tsim
|
|
136
|
-
</str>
|
|
137
|
-
<str name="title_pf">
|
|
138
|
-
</str>
|
|
139
|
-
<str name="subject_qf">
|
|
140
|
-
subject_tsim
|
|
141
|
-
</str>
|
|
142
|
-
<str name="subject_pf">
|
|
143
|
-
</str>
|
|
144
|
-
|
|
145
|
-
<str name="fl">
|
|
146
|
-
*,
|
|
147
|
-
score
|
|
148
|
-
</str>
|
|
149
|
-
|
|
150
|
-
<str name="facet">true</str>
|
|
151
|
-
<str name="facet.mincount">1</str>
|
|
152
|
-
<str name="facet.limit">10</str>
|
|
153
|
-
<str name="facet.field">subject_ssim</str>
|
|
154
|
-
|
|
155
|
-
<str name="spellcheck">true</str>
|
|
156
|
-
<str name="spellcheck.dictionary">default</str>
|
|
157
|
-
<str name="spellcheck.onlyMorePopular">true</str>
|
|
158
|
-
<str name="spellcheck.extendedResults">true</str>
|
|
159
|
-
<str name="spellcheck.collate">false</str>
|
|
160
|
-
<str name="spellcheck.count">5</str>
|
|
161
|
-
|
|
162
|
-
</lst>
|
|
163
|
-
<arr name="last-components">
|
|
164
|
-
<str>spellcheck</str>
|
|
165
|
-
</arr>
|
|
166
|
-
</requestHandler>
|
|
167
|
-
|
|
168
101
|
<requestHandler name="permissions" class="solr.SearchHandler" >
|
|
169
102
|
<lst name="defaults">
|
|
170
103
|
<str name="facet">off</str>
|
data/package.json
CHANGED
|
@@ -36,7 +36,7 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'has a header' do
|
|
39
|
-
expect(page).to have_css('h2', text: '
|
|
39
|
+
expect(page).to have_css('h2', text: 'Your selections:')
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'wraps the output in a div' do
|
|
@@ -79,7 +79,7 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it 'omits the headers' do
|
|
82
|
-
expect(page).to have_no_css('h2', text: '
|
|
82
|
+
expect(page).to have_no_css('h2', text: 'Your selections:')
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -34,11 +34,11 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'has some defined content areas' do
|
|
37
|
-
component.
|
|
38
|
-
component.
|
|
39
|
-
component.
|
|
40
|
-
component.
|
|
41
|
-
component.
|
|
37
|
+
component.with_title { 'Title' }
|
|
38
|
+
component.with_embed('Embed')
|
|
39
|
+
component.with_metadata('Metadata')
|
|
40
|
+
component.with_thumbnail('Thumbnail')
|
|
41
|
+
component.with_actions { 'Actions' }
|
|
42
42
|
render_inline component
|
|
43
43
|
|
|
44
44
|
expect(page).to have_content 'Title'
|
|
@@ -49,7 +49,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it 'has schema.org properties' do
|
|
52
|
-
component.
|
|
52
|
+
component.with_body { '-' }
|
|
53
53
|
render_inline component
|
|
54
54
|
|
|
55
55
|
expect(page).to have_css 'article[@itemtype="http://schema.org/Thing"]'
|
|
@@ -58,7 +58,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
58
58
|
|
|
59
59
|
context 'with a provided body' do
|
|
60
60
|
it 'opts-out of normal component content' do
|
|
61
|
-
component.
|
|
61
|
+
component.with_body { 'Body content' }
|
|
62
62
|
render_inline component
|
|
63
63
|
|
|
64
64
|
expect(page).to have_content 'Body content'
|
|
@@ -75,7 +75,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
75
75
|
let(:attr) { { counter: 5 } }
|
|
76
76
|
|
|
77
77
|
it 'has data properties' do
|
|
78
|
-
component.
|
|
78
|
+
component.with_body { '-' }
|
|
79
79
|
render_inline component
|
|
80
80
|
|
|
81
81
|
expect(page).to have_css 'article[@data-document-id="x"]'
|
|
@@ -136,13 +136,6 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
136
136
|
vc_test_controller.action_name = "show"
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
it 'renders with an id' do
|
|
140
|
-
component.set_slot(:body) { '-' }
|
|
141
|
-
render_inline component
|
|
142
|
-
|
|
143
|
-
expect(page).to have_css 'article#document'
|
|
144
|
-
end
|
|
145
|
-
|
|
146
139
|
it 'renders a title' do
|
|
147
140
|
render_inline component
|
|
148
141
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::Facets::FiltersComponent, type: :component do
|
|
6
|
-
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest
|
|
6
|
+
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest?: true }
|
|
7
7
|
let(:presenter) do
|
|
8
8
|
instance_double(Blacklight::FacetFieldPresenter, facet_field: facet_field, label: 'Lang',
|
|
9
|
-
view_context: view_context, suggest
|
|
9
|
+
view_context: view_context, suggest?: true, key: 'lang')
|
|
10
10
|
end
|
|
11
11
|
let(:view_context) { vc_test_controller.view_context }
|
|
12
12
|
|
|
@@ -16,7 +16,8 @@ RSpec.describe Blacklight::Facets::IndexNavigationComponent, type: :component do
|
|
|
16
16
|
|
|
17
17
|
it 'renders the facet index navigation range' do
|
|
18
18
|
expect(page).to have_css '.pagination'
|
|
19
|
-
|
|
19
|
+
facet_path = ViewComponent::VERSION::MAJOR == 3 ? '/catalog/facet/language.html' : '/catalog/facet/language'
|
|
20
|
+
expect(page).to have_link '0', href: "#{facet_path}?facet.prefix=0&facet.sort=index"
|
|
20
21
|
expect(page).to have_link '1'
|
|
21
22
|
expect(page).to have_link '8'
|
|
22
23
|
expect(page).to have_link '9'
|
|
@@ -28,7 +28,8 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
28
28
|
it 'has an input with the data-facet-search-context attribute, which the javascript needs to determine the current search context' do
|
|
29
29
|
with_request_url "/catalog/facet/language_facet?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields" do
|
|
30
30
|
rendered = render_inline component
|
|
31
|
-
|
|
31
|
+
facet_path = ViewComponent::VERSION::MAJOR == 3 ? '/catalog/facet/language_facet.html' : '/catalog/facet/language_facet'
|
|
32
|
+
expect(rendered.css("input[data-facet-search-context=\"#{facet_path}?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields\"]").count).to eq 1
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -57,6 +58,7 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
57
58
|
|
|
58
59
|
context 'when the facet is not explicitly configured with a suggest key' do
|
|
59
60
|
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
|
61
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet, nil, vc_test_controller.view_context, nil) }
|
|
60
62
|
|
|
61
63
|
it 'displays' do
|
|
62
64
|
with_request_url "/catalog/facet/language_facet" do
|
|
@@ -64,5 +66,17 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
64
66
|
expect(rendered.css("input.facet-suggest").count).to eq 1
|
|
65
67
|
end
|
|
66
68
|
end
|
|
69
|
+
|
|
70
|
+
context "with blacklight_config.default_facet_suggest = false" do
|
|
71
|
+
before do
|
|
72
|
+
allow(vc_test_controller.view_context.blacklight_config).to receive(:default_facet_suggest).and_return(false)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'does not display' do
|
|
76
|
+
with_request_url "/catalog/facet/language_facet" do
|
|
77
|
+
expect(render_inline(component).to_s).to eq ''
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
67
81
|
end
|
|
68
82
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
6
|
-
let(:instance) { described_class.new(url: search_action_url, params: params_for_search) }
|
|
6
|
+
let(:instance) { described_class.new(url: search_action_url, params: params_for_search, advanced_search_url: '/advanced') }
|
|
7
7
|
|
|
8
8
|
let(:search_action_url) { '/catalog' }
|
|
9
9
|
let(:params_for_search) { { q: 'testParamValue' } }
|
|
@@ -104,4 +104,27 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
|
104
104
|
expect(render.css('.rounded-0')).to be_present
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
+
|
|
108
|
+
context 'advanced search link' do
|
|
109
|
+
subject(:render) { render_inline(instance) }
|
|
110
|
+
|
|
111
|
+
context 'when enabled (default)' do
|
|
112
|
+
it 'renders the advanced search link' do
|
|
113
|
+
expect(render.css("a.advanced_search.btn.btn-link[href='/advanced']")).to be_present
|
|
114
|
+
expect(render.css("a.advanced_search").text).to eq('Advanced search')
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context 'when disabled via configuration' do
|
|
119
|
+
let(:blacklight_config) do
|
|
120
|
+
Blacklight::Configuration.new.configure do |config|
|
|
121
|
+
config.advanced_search.enabled = false
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'does not render the advanced search link' do
|
|
126
|
+
expect(render.css("a.advanced_search")).not_to be_present
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
107
130
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.describe Blacklight::Catalog do
|
|
4
4
|
subject { controller }
|
|
5
5
|
|
|
6
|
-
let(:controller) {
|
|
6
|
+
let(:controller) { Class.new(ApplicationController) { include Blacklight::Catalog }.new }
|
|
7
7
|
|
|
8
8
|
describe "#search_state" do
|
|
9
9
|
subject { controller.send(:search_state) }
|
|
@@ -5,25 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe "Blacklight Advanced Search Form" do
|
|
6
6
|
describe "advanced search form" do
|
|
7
7
|
before do
|
|
8
|
-
|
|
9
|
-
edismax: {}
|
|
10
|
-
}
|
|
11
|
-
CatalogController.blacklight_config.search_fields['author']['clause_params'] = {
|
|
12
|
-
edismax: { qf: '${author_qf}' }
|
|
13
|
-
}
|
|
14
|
-
CatalogController.blacklight_config.search_fields['title']['clause_params'] = {
|
|
15
|
-
edismax: { qf: '${title_qf}' }
|
|
16
|
-
}
|
|
17
|
-
CatalogController.blacklight_config.search_fields['subject']['clause_params'] = {
|
|
18
|
-
edismax: { qf: '${subject_qf}' }
|
|
19
|
-
}
|
|
20
|
-
visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
after do
|
|
24
|
-
%w[all_fields author title subject].each do |field|
|
|
25
|
-
CatalogController.blacklight_config.search_fields[field].delete(:clause_params)
|
|
26
|
-
end
|
|
8
|
+
visit '/catalog/advanced'
|
|
27
9
|
end
|
|
28
10
|
|
|
29
11
|
it "has field and facet blocks" do
|
|
@@ -56,6 +38,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
56
38
|
expect(page).to have_content 'Language'
|
|
57
39
|
end
|
|
58
40
|
end
|
|
41
|
+
|
|
42
|
+
it "omits facets configured with include_in_advanced_search: false" do
|
|
43
|
+
expect(page).to have_no_css('.blacklight-example_pivot_field')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "lists all the values for an included facet" do
|
|
47
|
+
within('.blacklight-subject_ssim') do
|
|
48
|
+
expect(page).to have_css('ul.facet-values li', count: 45)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
it 'scopes searches to fields' do
|
|
@@ -66,6 +58,14 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
66
58
|
expect(page).to have_css('article.document', count: 1)
|
|
67
59
|
end
|
|
68
60
|
|
|
61
|
+
it 'does not render spellcheck/did you mean? section' do
|
|
62
|
+
fill_in 'All Fields', with: 'tibet'
|
|
63
|
+
click_on 'advanced-search-submit'
|
|
64
|
+
expect(page).to have_content 'Remove constraint All Fields: tibet'
|
|
65
|
+
expect(page).to have_css('article.document', count: 2)
|
|
66
|
+
expect(page).to have_no_css('#spell')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
69
|
it 'can limit to facets' do
|
|
70
70
|
fill_in 'Subject', with: 'Women'
|
|
71
71
|
click_on 'Language'
|
|
@@ -107,7 +107,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
107
107
|
|
|
108
108
|
describe "prepopulated advanced search form" do
|
|
109
109
|
before do
|
|
110
|
-
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&sort=author'
|
|
110
|
+
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&f[format][]=Book&sort=author'
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'prepopulates the expected fields' do
|
|
@@ -117,6 +117,12 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
117
117
|
expect(page).to have_select 'sort', selected: 'author'
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
it 'creates hidden inputs for fields not included in the advanced search form' do
|
|
121
|
+
within('form.advanced') do
|
|
122
|
+
expect(page).to have_field 'f[format][]', type: :hidden, with: 'Book'
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
120
126
|
it "does not create hidden inputs for fields included in adv search form" do
|
|
121
127
|
within('form.advanced') do
|
|
122
128
|
expect(page).to have_no_field('clause[1][query]', type: :hidden, with: 'medicine')
|
|
@@ -140,5 +146,18 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
140
146
|
expect(page).to have_no_field 'Title', with: 'medicine'
|
|
141
147
|
expect(page).to have_no_field 'Tibetan', checked: true
|
|
142
148
|
end
|
|
149
|
+
|
|
150
|
+
it 'creates constraints for fields not included in advanced search form' do
|
|
151
|
+
within('div.constraints') do
|
|
152
|
+
expect(page).to have_content('Format:Book')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'does not create constraints for fields included in the advanced search form' do
|
|
157
|
+
within('div.constraints') do
|
|
158
|
+
expect(page).to have_no_content('Title:medicine')
|
|
159
|
+
expect(page).to have_no_content('Language:Tibetan')
|
|
160
|
+
end
|
|
161
|
+
end
|
|
143
162
|
end
|
|
144
163
|
end
|
|
@@ -53,7 +53,7 @@ RSpec.describe "Facets" do
|
|
|
53
53
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
54
54
|
end
|
|
55
55
|
within "#appliedParams" do
|
|
56
|
-
expect(page).to have_content "
|
|
56
|
+
expect(page).to have_content "Your selections:"
|
|
57
57
|
expect(page).to have_content "history"
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -140,7 +140,7 @@ RSpec.describe "Facets" do
|
|
|
140
140
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
141
141
|
end
|
|
142
142
|
within "#appliedParams" do
|
|
143
|
-
expect(page).to have_content "
|
|
143
|
+
expect(page).to have_content "Your selections:"
|
|
144
144
|
expect(page).to have_content "history"
|
|
145
145
|
end
|
|
146
146
|
end
|
|
@@ -164,7 +164,7 @@ RSpec.describe "Facets" do
|
|
|
164
164
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
165
165
|
end
|
|
166
166
|
within "#appliedParams" do
|
|
167
|
-
expect(page).to have_content "
|
|
167
|
+
expect(page).to have_content "Your selections:"
|
|
168
168
|
expect(page).to have_content "history"
|
|
169
169
|
end
|
|
170
170
|
end
|
|
@@ -44,7 +44,7 @@ RSpec.describe "Search Page" do
|
|
|
44
44
|
Capybara.ignore_hidden_elements = tmp_value
|
|
45
45
|
|
|
46
46
|
within "#appliedParams" do
|
|
47
|
-
expect(page).to have_content "
|
|
47
|
+
expect(page).to have_content "Your selections:"
|
|
48
48
|
expect(page).to have_content "history"
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -74,7 +74,7 @@ RSpec.describe "Search Page" do
|
|
|
74
74
|
click_on 'search'
|
|
75
75
|
|
|
76
76
|
within "#appliedParams" do
|
|
77
|
-
expect(page).to have_content "
|
|
77
|
+
expect(page).to have_content "Your selections:"
|
|
78
78
|
expect(page).to have_content "Title"
|
|
79
79
|
expect(page).to have_content "inmul"
|
|
80
80
|
end
|
|
@@ -104,7 +104,7 @@ RSpec.describe "Search Page" do
|
|
|
104
104
|
fill_in "q", with: 'history'
|
|
105
105
|
click_on 'search'
|
|
106
106
|
within "#appliedParams" do
|
|
107
|
-
expect(page).to have_content "
|
|
107
|
+
expect(page).to have_content "Your selections:"
|
|
108
108
|
expect(page).to have_content "history"
|
|
109
109
|
end
|
|
110
110
|
|