blacklight 7.14.0 → 7.15.0
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/README.md +0 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_header.scss +0 -5
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +46 -0
- data/app/components/blacklight/advanced_search_form_component.rb +75 -0
- data/app/components/blacklight/constraint_component.html.erb +1 -1
- data/app/components/blacklight/constraints_component.rb +36 -17
- data/app/components/blacklight/document/thumbnail_component.html.erb +1 -1
- data/app/components/blacklight/document/thumbnail_component.rb +4 -1
- data/app/components/blacklight/document_component.rb +7 -2
- data/app/components/blacklight/document_metadata_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +23 -0
- data/app/components/blacklight/facet_field_checkboxes_component.rb +24 -0
- data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +6 -0
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +29 -0
- data/app/components/blacklight/facet_field_list_component.html.erb +1 -0
- data/app/components/blacklight/facet_item_component.rb +2 -0
- data/app/components/blacklight/search_bar_component.html.erb +4 -0
- data/app/components/blacklight/search_bar_component.rb +4 -2
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +6 -0
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/models/concerns/blacklight/suggest/response.rb +1 -1
- data/app/presenters/blacklight/clause_presenter.rb +37 -0
- data/app/presenters/blacklight/document_presenter.rb +5 -1
- data/app/presenters/blacklight/facet_field_presenter.rb +4 -0
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +45 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +32 -20
- data/app/presenters/blacklight/field_presenter.rb +1 -1
- data/app/presenters/blacklight/inclusive_facet_item_presenter.rb +16 -0
- data/app/presenters/blacklight/search_bar_presenter.rb +4 -0
- data/app/views/catalog/_advanced_search_form.html.erb +7 -0
- data/app/views/catalog/_advanced_search_help.html.erb +24 -0
- data/app/views/catalog/_search_form.html.erb +1 -0
- data/app/views/catalog/_zero_results.html.erb +1 -1
- data/app/views/catalog/advanced_search.html.erb +17 -0
- data/blacklight.gemspec +1 -1
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/blacklight.en.yml +17 -0
- data/lib/blacklight/configuration/field.rb +1 -1
- data/lib/blacklight/configuration/sort_field.rb +1 -1
- data/lib/blacklight/configuration.rb +2 -1
- data/lib/blacklight/routes/searchable.rb +1 -0
- data/lib/blacklight/search_builder.rb +2 -0
- data/lib/blacklight/search_state/filter_field.rb +17 -7
- data/lib/blacklight/search_state.rb +5 -1
- data/lib/blacklight/solr/repository.rb +11 -2
- data/lib/blacklight/solr/search_builder_behavior.rb +87 -23
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +51 -0
- data/spec/components/blacklight/document_component_spec.rb +15 -0
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +55 -0
- data/spec/components/blacklight/facet_field_list_component_spec.rb +39 -4
- data/spec/controllers/catalog_controller_spec.rb +9 -0
- data/spec/features/advanced_search_spec.rb +67 -0
- data/spec/features/bookmarks_spec.rb +1 -9
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +65 -0
- data/spec/models/blacklight/solr/repository_spec.rb +12 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +28 -0
- data/spec/presenters/blacklight/clause_presenter_spec.rb +34 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +13 -0
- data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +41 -0
- metadata +25 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
6
|
+
subject(:render) do
|
|
7
|
+
render_inline(described_class.new(facet_field: facet_field))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:rendered) do
|
|
11
|
+
Capybara::Node::Simple.new(render)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:facet_field) do
|
|
15
|
+
instance_double(
|
|
16
|
+
Blacklight::FacetFieldPresenter,
|
|
17
|
+
facet_field: Blacklight::Configuration::NullField.new(key: 'field'),
|
|
18
|
+
paginator: paginator,
|
|
19
|
+
key: 'field',
|
|
20
|
+
label: 'Field',
|
|
21
|
+
active?: false,
|
|
22
|
+
collapsed?: false,
|
|
23
|
+
modal_path: nil,
|
|
24
|
+
html_id: 'facet-field',
|
|
25
|
+
search_state: search_state
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
let(:paginator) do
|
|
30
|
+
instance_double(Blacklight::FacetPaginator, items: [
|
|
31
|
+
double(label: 'a', hits: 10, value: 'a'),
|
|
32
|
+
double(label: 'b', hits: 33, value: 'b'),
|
|
33
|
+
double(label: 'c', hits: 3, value: 'c')
|
|
34
|
+
])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
|
38
|
+
let(:params) { { f: { field: ['a'] } } }
|
|
39
|
+
|
|
40
|
+
it 'renders a collapsible card' do
|
|
41
|
+
expect(rendered).to have_selector '.card'
|
|
42
|
+
expect(rendered).to have_button 'Field'
|
|
43
|
+
expect(rendered).to have_selector 'button[data-target="#facet-field"]'
|
|
44
|
+
expect(rendered).to have_selector '#facet-field.collapse.show'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'renders the facet items' do
|
|
48
|
+
expect(rendered).to have_selector 'ul.facet-values'
|
|
49
|
+
expect(rendered).to have_selector 'li', count: 3
|
|
50
|
+
|
|
51
|
+
expect(rendered).to have_field 'f_inclusive[field][]', with: 'a'
|
|
52
|
+
expect(rendered).to have_field 'f_inclusive[field][]', with: 'b'
|
|
53
|
+
expect(rendered).to have_field 'f_inclusive[field][]', with: 'c'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -20,7 +20,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
|
20
20
|
active?: false,
|
|
21
21
|
collapsed?: false,
|
|
22
22
|
modal_path: nil,
|
|
23
|
-
html_id: 'facet-field'
|
|
23
|
+
html_id: 'facet-field',
|
|
24
|
+
values: []
|
|
24
25
|
)
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -53,7 +54,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
|
53
54
|
active?: true,
|
|
54
55
|
collapsed?: false,
|
|
55
56
|
modal_path: nil,
|
|
56
|
-
html_id: 'facet-field'
|
|
57
|
+
html_id: 'facet-field',
|
|
58
|
+
values: []
|
|
57
59
|
)
|
|
58
60
|
end
|
|
59
61
|
|
|
@@ -72,7 +74,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
|
72
74
|
active?: false,
|
|
73
75
|
collapsed?: true,
|
|
74
76
|
modal_path: nil,
|
|
75
|
-
html_id: 'facet-field'
|
|
77
|
+
html_id: 'facet-field',
|
|
78
|
+
values: []
|
|
76
79
|
)
|
|
77
80
|
end
|
|
78
81
|
|
|
@@ -97,7 +100,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
|
97
100
|
active?: false,
|
|
98
101
|
collapsed?: false,
|
|
99
102
|
modal_path: '/catalog/facet/modal',
|
|
100
|
-
html_id: 'facet-field'
|
|
103
|
+
html_id: 'facet-field',
|
|
104
|
+
values: []
|
|
101
105
|
)
|
|
102
106
|
end
|
|
103
107
|
|
|
@@ -105,4 +109,35 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
|
105
109
|
expect(rendered).to have_link 'more Field', href: '/catalog/facet/modal'
|
|
106
110
|
end
|
|
107
111
|
end
|
|
112
|
+
|
|
113
|
+
context 'with inclusive facets' do
|
|
114
|
+
let(:facet_field) do
|
|
115
|
+
instance_double(
|
|
116
|
+
Blacklight::FacetFieldPresenter,
|
|
117
|
+
paginator: paginator,
|
|
118
|
+
facet_field: Blacklight::Configuration::NullField.new(key: 'field'),
|
|
119
|
+
key: 'field',
|
|
120
|
+
label: 'Field',
|
|
121
|
+
active?: false,
|
|
122
|
+
collapsed?: false,
|
|
123
|
+
modal_path: nil,
|
|
124
|
+
html_id: 'facet-field',
|
|
125
|
+
values: [%w[a b c]],
|
|
126
|
+
search_state: search_state
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
|
131
|
+
let(:params) { { f_inclusive: { field: %w[a b c] } } }
|
|
132
|
+
|
|
133
|
+
it 'displays the constraint above the list' do
|
|
134
|
+
expect(rendered).to have_content 'Any of:'
|
|
135
|
+
expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'a'
|
|
136
|
+
expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=b&f_inclusive%5Bfield%5D%5B%5D=c'
|
|
137
|
+
expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'b'
|
|
138
|
+
expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=c'
|
|
139
|
+
expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'c'
|
|
140
|
+
expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=b'
|
|
141
|
+
end
|
|
142
|
+
end
|
|
108
143
|
end
|
|
@@ -301,6 +301,15 @@ RSpec.describe CatalogController, api: true do
|
|
|
301
301
|
end
|
|
302
302
|
end
|
|
303
303
|
|
|
304
|
+
describe 'GET advanced_search' do
|
|
305
|
+
it 'renders an advanced search form' do
|
|
306
|
+
get :advanced_search
|
|
307
|
+
expect(response).to be_successful
|
|
308
|
+
|
|
309
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
304
313
|
# SHOW ACTION
|
|
305
314
|
describe "show action" do
|
|
306
315
|
describe "with format :html" do
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe "Blacklight Advanced Search Form" do
|
|
6
|
+
describe "advanced search form" do
|
|
7
|
+
before do
|
|
8
|
+
visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "has field and facet blocks" do
|
|
12
|
+
expect(page).to have_selector('.query-criteria')
|
|
13
|
+
expect(page).to have_selector('.limit-criteria')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "query column" do
|
|
17
|
+
it "gives the user a choice between and/or queries" do
|
|
18
|
+
expect(page).to have_selector('#op')
|
|
19
|
+
within('#op') do
|
|
20
|
+
expect(page).to have_selector('option[value="must"]')
|
|
21
|
+
expect(page).to have_selector('option[value="should"]')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "lists the configured search fields" do
|
|
26
|
+
expect(page).to have_field 'All Fields'
|
|
27
|
+
expect(page).to have_field 'Title'
|
|
28
|
+
expect(page).to have_field 'Author'
|
|
29
|
+
expect(page).to have_field 'Subject'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "facet column" do
|
|
34
|
+
it "lists facets" do
|
|
35
|
+
expect(page).to have_selector('.blacklight-language_ssim')
|
|
36
|
+
|
|
37
|
+
within('.blacklight-language_ssim') do
|
|
38
|
+
expect(page).to have_content 'Language'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'scopes searches to fields' do
|
|
44
|
+
fill_in 'Title', with: 'Medicine'
|
|
45
|
+
click_on 'advanced-search-submit'
|
|
46
|
+
expect(page).to have_content 'Remove constraint Title: Medicine'
|
|
47
|
+
expect(page).to have_content 'Strong Medicine speaks'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "prepopulated advanced search form" do
|
|
52
|
+
before do
|
|
53
|
+
visit '/catalog/advanced?op=must&clause[0][field]=title&clause[0]query=medicine'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "does not create hidden inputs for search fields" do
|
|
57
|
+
expect(page).to have_field 'Title', with: 'medicine'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "does not have multiple parameters for a search field" do
|
|
61
|
+
fill_in 'Title', with: 'bread'
|
|
62
|
+
click_on 'advanced-search-submit'
|
|
63
|
+
expect(page.current_url).to match(/bread/)
|
|
64
|
+
expect(page.current_url).not_to match(/medicine/)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -57,7 +57,7 @@ RSpec.describe "Bookmarks" do
|
|
|
57
57
|
expect(page).to have_content 'Strong Medicine speaks'
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
it "cites items in current bookmarks
|
|
60
|
+
it "cites all items in current bookmarks" do
|
|
61
61
|
visit solr_document_path('2009373513') # Ci an zhou bian
|
|
62
62
|
click_button 'Bookmark'
|
|
63
63
|
|
|
@@ -70,14 +70,6 @@ RSpec.describe "Bookmarks" do
|
|
|
70
70
|
|
|
71
71
|
click_link 'Cite'
|
|
72
72
|
expect(page).to have_content 'Strong Medicine speaks'
|
|
73
|
-
expect(page).not_to have_content 'Ci an zhou bian'
|
|
74
|
-
|
|
75
|
-
visit "/bookmarks?per_page=1"
|
|
76
|
-
click_link "2"
|
|
77
|
-
expect(page).to have_content 'Ci an zhou bian'
|
|
78
|
-
|
|
79
|
-
click_link 'Cite'
|
|
80
|
-
expect(page).not_to have_content 'Strong Medicine speaks'
|
|
81
73
|
expect(page).to have_content 'Ci an zhou bian'
|
|
82
74
|
end
|
|
83
75
|
end
|
|
@@ -72,6 +72,33 @@ RSpec.describe Blacklight::SearchState::FilterField do
|
|
|
72
72
|
expect(new_state.filter('some_field').values).to eq %w[1 2 4]
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
|
+
|
|
76
|
+
context 'with an array' do
|
|
77
|
+
let(:params) do
|
|
78
|
+
{ f: { another_field: ['3'] }, f_inclusive: { some_field: %w[a b c] } }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'creates a new group with the new values' do
|
|
82
|
+
filter = search_state.filter('new_field')
|
|
83
|
+
new_state = filter.add(%w[x y z])
|
|
84
|
+
|
|
85
|
+
expect(new_state.filter('new_field').values).to eq [%w[x y z]]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'updates any existing groups with the new values' do
|
|
89
|
+
filter = search_state.filter('some_field')
|
|
90
|
+
new_state = filter.add(%w[x y z])
|
|
91
|
+
|
|
92
|
+
expect(new_state.filter('some_field').values).to eq [%w[x y z]]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'leaves existing filters alone' do
|
|
96
|
+
filter = search_state.filter('another_field')
|
|
97
|
+
new_state = filter.add(%w[x y z])
|
|
98
|
+
|
|
99
|
+
expect(new_state.filter('another_field').values).to eq ['3', %w[x y z]]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
75
102
|
end
|
|
76
103
|
|
|
77
104
|
describe '#remove' do
|
|
@@ -104,12 +131,50 @@ RSpec.describe Blacklight::SearchState::FilterField do
|
|
|
104
131
|
|
|
105
132
|
expect(new_state.filter('some_field').values).to eq ['2']
|
|
106
133
|
end
|
|
134
|
+
|
|
135
|
+
context 'with an array' do
|
|
136
|
+
let(:params) do
|
|
137
|
+
{ f: { another_field: ['3'] }, f_inclusive: { some_field: %w[a b c], another_field: %w[x y z] } }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'removes groups of values' do
|
|
141
|
+
filter = search_state.filter('some_field')
|
|
142
|
+
new_state = filter.remove(%w[a b c])
|
|
143
|
+
|
|
144
|
+
expect(new_state.params[:f_inclusive]).not_to include :some_field
|
|
145
|
+
expect(new_state.filter('some_field').values).to eq []
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'can remove single values' do
|
|
149
|
+
filter = search_state.filter('some_field')
|
|
150
|
+
new_state = filter.remove(%w[a])
|
|
151
|
+
|
|
152
|
+
expect(new_state.filter('some_field').values).to eq [%w[b c]]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'leaves existing filters alone' do
|
|
156
|
+
filter = search_state.filter('another_field')
|
|
157
|
+
new_state = filter.remove(%w[x y z])
|
|
158
|
+
|
|
159
|
+
expect(new_state.filter('another_field').values).to eq ['3']
|
|
160
|
+
end
|
|
161
|
+
end
|
|
107
162
|
end
|
|
108
163
|
|
|
109
164
|
describe '#values' do
|
|
110
165
|
it 'returns the currently selected values of the filter' do
|
|
111
166
|
expect(search_state.filter('some_field').values).to eq %w[1 2]
|
|
112
167
|
end
|
|
168
|
+
|
|
169
|
+
context 'with an array' do
|
|
170
|
+
let(:params) do
|
|
171
|
+
{ f: { some_field: ['3'] }, f_inclusive: { some_field: %w[a b c] } }
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'combines the exclusive and inclusive values' do
|
|
175
|
+
expect(search_state.filter('some_field').values).to eq ['3', %w[a b c]]
|
|
176
|
+
end
|
|
177
|
+
end
|
|
113
178
|
end
|
|
114
179
|
|
|
115
180
|
describe '#include?' do
|
|
@@ -134,6 +134,18 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
|
+
|
|
138
|
+
context 'with json parameters' do
|
|
139
|
+
it 'sends a post request with some json' do
|
|
140
|
+
allow(subject.connection).to receive(:send_and_receive) do |path, params|
|
|
141
|
+
expect(path).to eq 'select'
|
|
142
|
+
expect(params[:method]).to eq :post
|
|
143
|
+
expect(JSON.parse(params[:data]).with_indifferent_access).to include(query: { bool: {} })
|
|
144
|
+
expect(params[:headers]).to include({ 'Content-Type' => 'application/json' })
|
|
145
|
+
end.and_return('response' => { 'docs' => [] })
|
|
146
|
+
subject.search(json: { query: { bool: {} } })
|
|
147
|
+
end
|
|
148
|
+
end
|
|
137
149
|
end
|
|
138
150
|
|
|
139
151
|
describe "http_method configuration", integration: true do
|
|
@@ -259,6 +259,17 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
|
259
259
|
end
|
|
260
260
|
end
|
|
261
261
|
|
|
262
|
+
describe 'with multi-valued facets' do
|
|
263
|
+
let(:user_params) { { f_inclusive: { format: %w[Book Movie CD] } } }
|
|
264
|
+
|
|
265
|
+
it "has proper solr parameters" do
|
|
266
|
+
expect(subject[:fq]).to include('{!lucene}{!query v=$f_inclusive.format.0} OR {!query v=$f_inclusive.format.1} OR {!query v=$f_inclusive.format.2}')
|
|
267
|
+
expect(subject['f_inclusive.format.0']).to eq '{!term f=format}Book'
|
|
268
|
+
expect(subject['f_inclusive.format.1']).to eq '{!term f=format}Movie'
|
|
269
|
+
expect(subject['f_inclusive.format.2']).to eq '{!term f=format}CD'
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
262
273
|
describe "solr parameters for a field search from config (subject)" do
|
|
263
274
|
let(:user_params) { subject_search_params }
|
|
264
275
|
|
|
@@ -723,4 +734,21 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
|
723
734
|
expect(subject.with_ex_local_param(nil, "some-value")).to eq "some-value"
|
|
724
735
|
end
|
|
725
736
|
end
|
|
737
|
+
|
|
738
|
+
context 'with advanced search clause parameters' do
|
|
739
|
+
before do
|
|
740
|
+
blacklight_config.search_fields.each_value do |v|
|
|
741
|
+
v.clause_params = { edismax: v.solr_parameters.dup }
|
|
742
|
+
end
|
|
743
|
+
end
|
|
744
|
+
|
|
745
|
+
let(:user_params) { { op: 'must', clause: { '0': { field: 'title', query: 'the book' }, '1': { field: 'author', query: 'the person' } } } }
|
|
746
|
+
|
|
747
|
+
it "has proper solr parameters" do
|
|
748
|
+
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 0, :edismax, :query)).to eq 'the book'
|
|
749
|
+
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 0, :edismax, :qf)).to eq '${title_qf}'
|
|
750
|
+
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 1, :edismax, :query)).to eq 'the person'
|
|
751
|
+
expect(subject.to_hash.with_indifferent_access.dig(:json, :query, :bool, :must, 1, :edismax, :qf)).to eq '${author_qf}'
|
|
752
|
+
end
|
|
753
|
+
end
|
|
726
754
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Blacklight::ClausePresenter, type: :presenter do
|
|
5
|
+
subject(:presenter) do
|
|
6
|
+
described_class.new('0', params.with_indifferent_access.dig(:clause, '0'), field_config, controller.view_context, search_state)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
let(:field_config) { Blacklight::Configuration::NullField.new key: 'some_field' }
|
|
10
|
+
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
|
11
|
+
let(:params) { {} }
|
|
12
|
+
|
|
13
|
+
describe '#field_label' do
|
|
14
|
+
it 'returns a label for the field' do
|
|
15
|
+
expect(subject.field_label).to eq 'Some Field'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#label' do
|
|
20
|
+
let(:params) { { clause: { '0' => { query: 'some search string' } } } }
|
|
21
|
+
|
|
22
|
+
it 'returns the query value for the clause' do
|
|
23
|
+
expect(subject.label).to eq 'some search string'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#remove_href' do
|
|
28
|
+
let(:params) { { clause: { '0' => { query: 'some_search_string' } } } }
|
|
29
|
+
|
|
30
|
+
it 'returns the href to remove the search clause' do
|
|
31
|
+
expect(subject.remove_href).not_to include 'some_search_string'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -47,4 +47,17 @@ RSpec.describe Blacklight::DocumentPresenter do
|
|
|
47
47
|
expect(presenter.field_value(field_config, options)).to eq 'abc'
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
describe '#thumbnail' do
|
|
52
|
+
it 'returns a thumbnail presenter' do
|
|
53
|
+
expect(presenter.thumbnail).to be_a_kind_of(Blacklight::ThumbnailPresenter)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'use the configured thumbnail presenter' do
|
|
57
|
+
custom_presenter_class = Class.new(Blacklight::ThumbnailPresenter)
|
|
58
|
+
blacklight_config.index.thumbnail_presenter = custom_presenter_class
|
|
59
|
+
|
|
60
|
+
expect(presenter.thumbnail).to be_a_kind_of custom_presenter_class
|
|
61
|
+
end
|
|
62
|
+
end
|
|
50
63
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Blacklight::FacetGroupedItemPresenter, type: :presenter do
|
|
5
|
+
subject(:presenter) do
|
|
6
|
+
described_class.new(group, facet_item, facet_config, view_context, facet_field, search_state)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'key') }
|
|
10
|
+
let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
|
|
11
|
+
let(:view_context) { controller.view_context }
|
|
12
|
+
|
|
13
|
+
let(:facet_item) { 'a' }
|
|
14
|
+
let(:group) { %w[a b c] }
|
|
15
|
+
let(:search_state) { Blacklight::SearchState.new(params, Blacklight::Configuration.new) }
|
|
16
|
+
let(:params) { { f_inclusive: { key: group } } }
|
|
17
|
+
|
|
18
|
+
describe '#selected' do
|
|
19
|
+
it { is_expected.to be_selected }
|
|
20
|
+
|
|
21
|
+
context 'when the item is not in the group' do
|
|
22
|
+
let(:facet_item) { 'd' }
|
|
23
|
+
|
|
24
|
+
it { is_expected.not_to be_selected }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#href' do
|
|
28
|
+
it 'removes the item from the "group" of filters' do
|
|
29
|
+
expect(Rack::Utils.parse_query(URI(presenter.href).query)).to include 'f_inclusive[key][]' => %w[b c]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'when the item is not in the group' do
|
|
33
|
+
let(:facet_item) { 'd' }
|
|
34
|
+
|
|
35
|
+
it 'adds the item to the "group" of filters' do
|
|
36
|
+
expect(Rack::Utils.parse_query(URI(presenter.href).query)).to include 'f_inclusive[key][]' => %w[a b c d]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
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.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Rochkind
|
|
@@ -17,7 +17,7 @@ authors:
|
|
|
17
17
|
autorequire:
|
|
18
18
|
bindir: exe
|
|
19
19
|
cert_chain: []
|
|
20
|
-
date: 2021-01-
|
|
20
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
23
23
|
name: rails
|
|
@@ -394,6 +394,8 @@ files:
|
|
|
394
394
|
- app/assets/stylesheets/blacklight/blacklight.scss
|
|
395
395
|
- app/assets/stylesheets/blacklight/blacklight_defaults.scss
|
|
396
396
|
- app/builders/blacklight/action_builder.rb
|
|
397
|
+
- app/components/blacklight/advanced_search_form_component.html.erb
|
|
398
|
+
- app/components/blacklight/advanced_search_form_component.rb
|
|
397
399
|
- app/components/blacklight/constraint_component.html.erb
|
|
398
400
|
- app/components/blacklight/constraint_component.rb
|
|
399
401
|
- app/components/blacklight/constraint_layout_component.html.erb
|
|
@@ -418,10 +420,14 @@ files:
|
|
|
418
420
|
- app/components/blacklight/document_component.rb
|
|
419
421
|
- app/components/blacklight/document_metadata_component.html.erb
|
|
420
422
|
- app/components/blacklight/document_metadata_component.rb
|
|
423
|
+
- app/components/blacklight/facet_field_checkboxes_component.html.erb
|
|
424
|
+
- app/components/blacklight/facet_field_checkboxes_component.rb
|
|
421
425
|
- app/components/blacklight/facet_field_component.html.erb
|
|
422
426
|
- app/components/blacklight/facet_field_component.rb
|
|
423
427
|
- app/components/blacklight/facet_field_filter_component.html.erb
|
|
424
428
|
- app/components/blacklight/facet_field_filter_component.rb
|
|
429
|
+
- app/components/blacklight/facet_field_inclusive_constraint_component.html.erb
|
|
430
|
+
- app/components/blacklight/facet_field_inclusive_constraint_component.rb
|
|
425
431
|
- app/components/blacklight/facet_field_list_component.html.erb
|
|
426
432
|
- app/components/blacklight/facet_field_list_component.rb
|
|
427
433
|
- app/components/blacklight/facet_field_no_layout_component.rb
|
|
@@ -511,10 +517,13 @@ files:
|
|
|
511
517
|
- app/models/record_mailer.rb
|
|
512
518
|
- app/models/search.rb
|
|
513
519
|
- app/models/solr_document.rb
|
|
520
|
+
- app/presenters/blacklight/clause_presenter.rb
|
|
514
521
|
- app/presenters/blacklight/document_presenter.rb
|
|
515
522
|
- app/presenters/blacklight/facet_field_presenter.rb
|
|
523
|
+
- app/presenters/blacklight/facet_grouped_item_presenter.rb
|
|
516
524
|
- app/presenters/blacklight/facet_item_presenter.rb
|
|
517
525
|
- app/presenters/blacklight/field_presenter.rb
|
|
526
|
+
- app/presenters/blacklight/inclusive_facet_item_presenter.rb
|
|
518
527
|
- app/presenters/blacklight/index_presenter.rb
|
|
519
528
|
- app/presenters/blacklight/json_presenter.rb
|
|
520
529
|
- app/presenters/blacklight/link_alternate_presenter.rb
|
|
@@ -537,6 +546,8 @@ files:
|
|
|
537
546
|
- app/views/bookmarks/_clear_bookmarks_widget.html.erb
|
|
538
547
|
- app/views/bookmarks/_tools.html.erb
|
|
539
548
|
- app/views/bookmarks/index.html.erb
|
|
549
|
+
- app/views/catalog/_advanced_search_form.html.erb
|
|
550
|
+
- app/views/catalog/_advanced_search_help.html.erb
|
|
540
551
|
- app/views/catalog/_bookmark_control.html.erb
|
|
541
552
|
- app/views/catalog/_citation.html.erb
|
|
542
553
|
- app/views/catalog/_constraints.html.erb
|
|
@@ -583,6 +594,7 @@ files:
|
|
|
583
594
|
- app/views/catalog/_thumbnail.html.erb
|
|
584
595
|
- app/views/catalog/_view_type_group.html.erb
|
|
585
596
|
- app/views/catalog/_zero_results.html.erb
|
|
597
|
+
- app/views/catalog/advanced_search.html.erb
|
|
586
598
|
- app/views/catalog/citation.html.erb
|
|
587
599
|
- app/views/catalog/citation.js.erb
|
|
588
600
|
- app/views/catalog/email.html.erb
|
|
@@ -719,11 +731,13 @@ files:
|
|
|
719
731
|
- lib/generators/blacklight/user_generator.rb
|
|
720
732
|
- lib/railties/blacklight.rake
|
|
721
733
|
- package.json
|
|
734
|
+
- spec/components/blacklight/advanced_search_form_component_spec.rb
|
|
722
735
|
- spec/components/blacklight/constraint_layout_component_spec.rb
|
|
723
736
|
- spec/components/blacklight/document/action_component_spec.rb
|
|
724
737
|
- spec/components/blacklight/document/group_component_spec.rb
|
|
725
738
|
- spec/components/blacklight/document_component_spec.rb
|
|
726
739
|
- spec/components/blacklight/document_metadata_component_spec.rb
|
|
740
|
+
- spec/components/blacklight/facet_field_checkboxes_component_spec.rb
|
|
727
741
|
- spec/components/blacklight/facet_field_list_component_spec.rb
|
|
728
742
|
- spec/components/blacklight/facet_item_component_spec.rb
|
|
729
743
|
- spec/components/blacklight/facet_item_pivot_component_spec.rb
|
|
@@ -739,6 +753,7 @@ files:
|
|
|
739
753
|
- spec/controllers/bookmarks_controller_spec.rb
|
|
740
754
|
- spec/controllers/catalog_controller_spec.rb
|
|
741
755
|
- spec/controllers/search_history_controller_spec.rb
|
|
756
|
+
- spec/features/advanced_search_spec.rb
|
|
742
757
|
- spec/features/alternate_controller_spec.rb
|
|
743
758
|
- spec/features/autocomplete_spec.rb
|
|
744
759
|
- spec/features/bookmarks_spec.rb
|
|
@@ -808,8 +823,10 @@ files:
|
|
|
808
823
|
- spec/models/record_mailer_spec.rb
|
|
809
824
|
- spec/models/search_spec.rb
|
|
810
825
|
- spec/models/solr_document_spec.rb
|
|
826
|
+
- spec/presenters/blacklight/clause_presenter_spec.rb
|
|
811
827
|
- spec/presenters/blacklight/document_presenter_spec.rb
|
|
812
828
|
- spec/presenters/blacklight/facet_field_presenter_spec.rb
|
|
829
|
+
- spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
|
|
813
830
|
- spec/presenters/blacklight/facet_item_presenter_spec.rb
|
|
814
831
|
- spec/presenters/blacklight/field_presenter_spec.rb
|
|
815
832
|
- spec/presenters/blacklight/index_presenter_spec.rb
|
|
@@ -872,7 +889,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
872
889
|
requirements:
|
|
873
890
|
- - ">="
|
|
874
891
|
- !ruby/object:Gem::Version
|
|
875
|
-
version: '2.
|
|
892
|
+
version: '2.5'
|
|
876
893
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
877
894
|
requirements:
|
|
878
895
|
- - ">="
|
|
@@ -885,11 +902,13 @@ specification_version: 4
|
|
|
885
902
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
|
886
903
|
index.
|
|
887
904
|
test_files:
|
|
905
|
+
- spec/components/blacklight/advanced_search_form_component_spec.rb
|
|
888
906
|
- spec/components/blacklight/constraint_layout_component_spec.rb
|
|
889
907
|
- spec/components/blacklight/document/action_component_spec.rb
|
|
890
908
|
- spec/components/blacklight/document/group_component_spec.rb
|
|
891
909
|
- spec/components/blacklight/document_component_spec.rb
|
|
892
910
|
- spec/components/blacklight/document_metadata_component_spec.rb
|
|
911
|
+
- spec/components/blacklight/facet_field_checkboxes_component_spec.rb
|
|
893
912
|
- spec/components/blacklight/facet_field_list_component_spec.rb
|
|
894
913
|
- spec/components/blacklight/facet_item_component_spec.rb
|
|
895
914
|
- spec/components/blacklight/facet_item_pivot_component_spec.rb
|
|
@@ -905,6 +924,7 @@ test_files:
|
|
|
905
924
|
- spec/controllers/bookmarks_controller_spec.rb
|
|
906
925
|
- spec/controllers/catalog_controller_spec.rb
|
|
907
926
|
- spec/controllers/search_history_controller_spec.rb
|
|
927
|
+
- spec/features/advanced_search_spec.rb
|
|
908
928
|
- spec/features/alternate_controller_spec.rb
|
|
909
929
|
- spec/features/autocomplete_spec.rb
|
|
910
930
|
- spec/features/bookmarks_spec.rb
|
|
@@ -974,8 +994,10 @@ test_files:
|
|
|
974
994
|
- spec/models/record_mailer_spec.rb
|
|
975
995
|
- spec/models/search_spec.rb
|
|
976
996
|
- spec/models/solr_document_spec.rb
|
|
997
|
+
- spec/presenters/blacklight/clause_presenter_spec.rb
|
|
977
998
|
- spec/presenters/blacklight/document_presenter_spec.rb
|
|
978
999
|
- spec/presenters/blacklight/facet_field_presenter_spec.rb
|
|
1000
|
+
- spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
|
|
979
1001
|
- spec/presenters/blacklight/facet_item_presenter_spec.rb
|
|
980
1002
|
- spec/presenters/blacklight/field_presenter_spec.rb
|
|
981
1003
|
- spec/presenters/blacklight/index_presenter_spec.rb
|