blacklight 7.1.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.jshintrc +3 -1
- data/.rubocop_todo.yml +8 -8
- data/.travis.yml +13 -13
- data/CONTRIBUTING.md +3 -1
- data/Gemfile +2 -0
- data/VERSION +1 -1
- data/app/assets/images/blacklight/list.svg +1 -1
- data/app/assets/images/blacklight/search.svg +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +82 -70
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +17 -13
- data/app/assets/stylesheets/blacklight/_facets.scss +3 -0
- data/app/assets/stylesheets/blacklight/_header.scss +26 -0
- data/app/assets/stylesheets/blacklight/_icons.scss +6 -6
- data/app/assets/stylesheets/blacklight/_mixins.scss +3 -3
- data/app/controllers/concerns/blacklight/facet.rb +1 -7
- data/app/helpers/blacklight/catalog_helper_behavior.rb +16 -17
- data/app/helpers/blacklight/layout_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/javascript/blacklight/button_focus.js +9 -0
- data/app/javascript/blacklight/facet_load.js +18 -19
- data/app/javascript/blacklight/search_context.js +67 -49
- data/app/models/blacklight/icon.rb +26 -5
- data/app/presenters/blacklight/search_bar_presenter.rb +3 -1
- data/app/views/catalog/_bookmark_control.html.erb +11 -13
- data/app/views/catalog/_facet_group.html.erb +1 -1
- data/app/views/catalog/_facet_layout.html.erb +9 -2
- data/app/views/catalog/_facets.html.erb +1 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +4 -0
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/layouts/blacklight.html.erb +2 -2
- data/app/views/layouts/blacklight/base.html.erb +14 -8
- data/config/locales/blacklight.de.yml +17 -2
- data/config/locales/blacklight.en.yml +17 -2
- data/config/locales/blacklight.es.yml +17 -2
- data/config/locales/blacklight.fr.yml +17 -2
- data/config/locales/blacklight.hu.yml +17 -3
- data/config/locales/blacklight.it.yml +17 -2
- data/config/locales/blacklight.nl.yml +17 -3
- data/config/locales/blacklight.pt-BR.yml +17 -2
- data/config/locales/blacklight.sq.yml +17 -2
- data/config/locales/blacklight.zh.yml +17 -3
- data/lib/blacklight/configuration.rb +6 -0
- data/lib/blacklight/engine.rb +5 -4
- data/lib/blacklight/solr.rb +2 -0
- data/{app/models/concerns → lib}/blacklight/solr/document.rb +0 -0
- data/{app/models → lib}/blacklight/solr/facet_paginator.rb +0 -0
- data/lib/blacklight/solr/response/group_response.rb +10 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +12 -0
- data/lib/generators/blacklight/assets_generator.rb +4 -1
- data/package-lock.json +1 -1
- data/package.json +2 -2
- data/spec/features/facets_spec.rb +22 -1
- data/spec/features/search_filters_spec.rb +25 -5
- data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +4 -4
- data/spec/helpers/catalog_helper_spec.rb +0 -9
- data/spec/models/blacklight/icon_spec.rb +25 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +13 -0
- data/spec/models/blacklight/solr/response_spec.rb +3 -0
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +15 -0
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +82 -0
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +5 -66
- metadata +7 -5
- data/app/javascript/blacklight/collapsable.js +0 -9
@@ -63,6 +63,19 @@ RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
|
|
63
63
|
expect(group.empty?).to be false
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
describe "entry_name" do
|
68
|
+
it "accesses a custom field grouped i18n key" do
|
69
|
+
allow(I18n).to receive(:t).with(
|
70
|
+
'blacklight.entry_name.grouped.result_group_ssi',
|
71
|
+
default: :'blacklight.entry_name.grouped.default'
|
72
|
+
).and_return('cool group')
|
73
|
+
expect(group.entry_name(count: 2)).to eq 'cool groups'
|
74
|
+
end
|
75
|
+
it "falls back to default group key" do
|
76
|
+
expect(group.entry_name(count: 2)).to eq 'grouped results'
|
77
|
+
end
|
78
|
+
end
|
66
79
|
end
|
67
80
|
|
68
81
|
def create_response(response, params = {})
|
@@ -66,6 +66,9 @@ RSpec.describe Blacklight::Solr::Response, api: true do
|
|
66
66
|
expect(r.total_count).to eq(r.total)
|
67
67
|
expect(r.next_page).to eq(r.current_page + 1)
|
68
68
|
expect(r.prev_page).to eq(nil)
|
69
|
+
expect(r.entry_name(count: 1)).to eq 'entry'
|
70
|
+
expect(r.entry_name(count: 2)).to eq 'entries'
|
71
|
+
expect(r.size).to eq 26
|
69
72
|
if Kaminari.config.respond_to? :max_pages
|
70
73
|
expect(r.max_pages).to be_nil
|
71
74
|
end
|
@@ -46,6 +46,12 @@ RSpec.describe Blacklight::SearchBarPresenter do
|
|
46
46
|
subject { presenter.autofocus? }
|
47
47
|
|
48
48
|
context "on a catalog-like index page without query or facet parameters" do
|
49
|
+
let(:blacklight_config) do
|
50
|
+
Blacklight::Configuration.new.configure do |config|
|
51
|
+
config.enable_search_bar_autofocus = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
49
55
|
before do
|
50
56
|
allow(controller).to receive(:action_name).and_return('index')
|
51
57
|
allow(controller).to receive(:has_search_parameters?).and_return(false)
|
@@ -54,6 +60,15 @@ RSpec.describe Blacklight::SearchBarPresenter do
|
|
54
60
|
it { is_expected.to be true }
|
55
61
|
end
|
56
62
|
|
63
|
+
context "when disabled in config" do
|
64
|
+
before do
|
65
|
+
allow(controller).to receive(:action_name).and_return('index')
|
66
|
+
allow(controller).to receive(:has_search_parameters?).and_return(false)
|
67
|
+
end
|
68
|
+
|
69
|
+
it { is_expected.to be false }
|
70
|
+
end
|
71
|
+
|
57
72
|
context "when not the catalog controller" do
|
58
73
|
let(:controller) { ApplicationController.new }
|
59
74
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe "catalog/_facet_group" do
|
4
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(view).to receive_messages(blacklight_config: blacklight_config)
|
8
|
+
allow(view).to receive(:search_action_path).and_return('/catalog')
|
9
|
+
end
|
10
|
+
|
11
|
+
context "without any facet fields" do
|
12
|
+
before do
|
13
|
+
allow(view).to receive_messages(groupname: nil, render_facet_partials: '')
|
14
|
+
render
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not have a header if no facets are displayed" do
|
18
|
+
expect(rendered).not_to have_selector('h4')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with facet groups" do
|
23
|
+
let :facet_field do
|
24
|
+
Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: nil).normalize!
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:mock_display_facet1) do
|
28
|
+
double(name: 'facet_field_1', sort: nil, offset: nil, prefix: nil, items: [Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Value', hits: 1234)])
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:response) do
|
32
|
+
instance_double(Blacklight::Solr::Response, aggregations: { "facet_field_1" => mock_display_facet1 })
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
blacklight_config.facet_fields['facet_field_1'] = facet_field
|
37
|
+
allow(view).to receive_messages(groupname: nil, facet_field_names: [:facet_field_1], facet_limit_for: 10)
|
38
|
+
@response = response
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with the default facet group" do
|
42
|
+
it "has a header" do
|
43
|
+
allow(view).to receive_messages(render_facet_partials: '')
|
44
|
+
render
|
45
|
+
expect(rendered).to have_selector('.facets-heading')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with a named facet group" do
|
50
|
+
let :facet_field do
|
51
|
+
Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: 'group_1').normalize!
|
52
|
+
end
|
53
|
+
|
54
|
+
before do
|
55
|
+
blacklight_config.facet_fields['facet_field_1'] = facet_field
|
56
|
+
allow(view).to receive_messages(groupname: 'group_1', facet_field_names: [:facet_field_1], facet_limit_for: 10)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a header" do
|
60
|
+
allow(view).to receive_messages(render_facet_partials: '')
|
61
|
+
render
|
62
|
+
expect(rendered).to have_selector('.facets-heading')
|
63
|
+
expect(rendered).to have_selector('#facets-group_1')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "facet display" do
|
68
|
+
it "has a(n accessible) header" do
|
69
|
+
render
|
70
|
+
expect(rendered).to have_selector('.facet-field-heading')
|
71
|
+
end
|
72
|
+
it "lists values" do
|
73
|
+
render
|
74
|
+
# The .facet-content class is used by blacklight_range_limit js, and
|
75
|
+
# should be applied to the .panel-collapse div that contains the collapsible
|
76
|
+
# facet content. Please make sure it remains if possible.
|
77
|
+
expect(rendered).to have_selector('.facet-content a.facet-select')
|
78
|
+
expect(rendered).to have_selector('.facet-content .facet-count')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -27,7 +27,7 @@ RSpec.describe "catalog/facet_layout" do
|
|
27
27
|
|
28
28
|
it "is collapsable" do
|
29
29
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
30
|
-
expect(rendered).to have_selector '.
|
30
|
+
expect(rendered).to have_selector 'button.collapsed'
|
31
31
|
expect(rendered).to have_selector '.collapse .card-body'
|
32
32
|
end
|
33
33
|
|
@@ -1,76 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe "catalog/_facets" do
|
4
|
-
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
|
-
|
6
|
-
before do
|
7
|
-
allow(view).to receive_messages(blacklight_config: blacklight_config)
|
8
|
-
allow(view).to receive(:search_action_path).and_return('/catalog')
|
9
|
-
end
|
10
|
-
|
11
|
-
context "without any facet fields" do
|
12
|
-
it "does not have a header if no facets are displayed" do
|
13
|
-
allow(view).to receive_messages(render_facet_partials: '')
|
14
|
-
render
|
15
|
-
expect(rendered).not_to have_selector('h4')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
4
|
context "with facet groups" do
|
20
|
-
let :facet_field do
|
21
|
-
Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: nil).normalize!
|
22
|
-
end
|
23
|
-
|
24
5
|
before do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@response = double
|
29
|
-
allow(@response).to receive(:aggregations).and_return("facet_field_1" => @mock_display_facet_1)
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with the default facet group" do
|
33
|
-
it "has a header" do
|
34
|
-
allow(view).to receive_messages(render_facet_partials: '')
|
35
|
-
render
|
36
|
-
expect(rendered).to have_selector('.facets-heading')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with a named facet group" do
|
41
|
-
let :facet_field do
|
42
|
-
Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: 'group_1').normalize!
|
43
|
-
end
|
44
|
-
|
45
|
-
before do
|
46
|
-
blacklight_config.facet_fields['facet_field_1'] = facet_field
|
47
|
-
@mock_display_facet_1 = double(name: 'facet_field_1', sort: nil, offset: nil, prefix: nil, items: [Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Value', hits: 1234)])
|
48
|
-
allow(view).to receive_messages(facet_group_names: [nil, 'group_1'], facet_field_names: [:facet_field_1], facet_limit_for: 10)
|
49
|
-
@response = double
|
50
|
-
allow(@response).to receive(:aggregations).and_return("facet_field_1" => @mock_display_facet_1)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "has a header" do
|
54
|
-
allow(view).to receive_messages(render_facet_partials: '')
|
55
|
-
render
|
56
|
-
expect(rendered).to have_selector('.facets-heading')
|
57
|
-
expect(rendered).to have_selector('#facets-group_1')
|
58
|
-
end
|
6
|
+
stub_template('catalog/_facet_group.html.erb' => 'text')
|
7
|
+
allow(view).to receive_messages(facet_group_names: [nil, nil])
|
8
|
+
render
|
59
9
|
end
|
60
10
|
|
61
|
-
|
62
|
-
|
63
|
-
render
|
64
|
-
expect(rendered).to have_selector('.facet-field-heading')
|
65
|
-
end
|
66
|
-
it "lists values" do
|
67
|
-
render
|
68
|
-
# The .facet-content class is used by blacklight_range_limit js, and
|
69
|
-
# should be applied to the .panel-collapse div that contains the collapsible
|
70
|
-
# facet content. Please make sure it remains if possible.
|
71
|
-
expect(rendered).to have_selector('.facet-content a.facet-select')
|
72
|
-
expect(rendered).to have_selector('.facet-content .facet-count')
|
73
|
-
end
|
11
|
+
it "Calls facet_group for each name" do
|
12
|
+
expect(rendered).to match(/^ text\n text\n$/)
|
74
13
|
end
|
75
14
|
end
|
76
15
|
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.2.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: 2019-
|
20
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -376,15 +376,14 @@ files:
|
|
376
376
|
- app/helpers/catalog_helper.rb
|
377
377
|
- app/javascript/blacklight/autocomplete.js
|
378
378
|
- app/javascript/blacklight/bookmark_toggle.js
|
379
|
+
- app/javascript/blacklight/button_focus.js
|
379
380
|
- app/javascript/blacklight/checkbox_submit.js
|
380
|
-
- app/javascript/blacklight/collapsable.js
|
381
381
|
- app/javascript/blacklight/core.js
|
382
382
|
- app/javascript/blacklight/facet_load.js
|
383
383
|
- app/javascript/blacklight/modal.js
|
384
384
|
- app/javascript/blacklight/search_context.js
|
385
385
|
- app/models/blacklight/facet_paginator.rb
|
386
386
|
- app/models/blacklight/icon.rb
|
387
|
-
- app/models/blacklight/solr/facet_paginator.rb
|
388
387
|
- app/models/blacklight/suggest_search.rb
|
389
388
|
- app/models/bookmark.rb
|
390
389
|
- app/models/concerns/blacklight/configurable.rb
|
@@ -398,7 +397,6 @@ files:
|
|
398
397
|
- app/models/concerns/blacklight/document/schema_org.rb
|
399
398
|
- app/models/concerns/blacklight/document/semantic_fields.rb
|
400
399
|
- app/models/concerns/blacklight/document/sms.rb
|
401
|
-
- app/models/concerns/blacklight/solr/document.rb
|
402
400
|
- app/models/concerns/blacklight/suggest/response.rb
|
403
401
|
- app/models/concerns/blacklight/user.rb
|
404
402
|
- app/models/record_mailer.rb
|
@@ -552,6 +550,8 @@ files:
|
|
552
550
|
- lib/blacklight/search_builder.rb
|
553
551
|
- lib/blacklight/search_state.rb
|
554
552
|
- lib/blacklight/solr.rb
|
553
|
+
- lib/blacklight/solr/document.rb
|
554
|
+
- lib/blacklight/solr/facet_paginator.rb
|
555
555
|
- lib/blacklight/solr/repository.rb
|
556
556
|
- lib/blacklight/solr/request.rb
|
557
557
|
- lib/blacklight/solr/response.rb
|
@@ -698,6 +698,7 @@ files:
|
|
698
698
|
- spec/views/catalog/_constraints_element.html.erb_spec.rb
|
699
699
|
- spec/views/catalog/_document.html.erb_spec.rb
|
700
700
|
- spec/views/catalog/_document_list.html.erb_spec.rb
|
701
|
+
- spec/views/catalog/_facet_group.html.erb_spec.rb
|
701
702
|
- spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
|
702
703
|
- spec/views/catalog/_facet_layout.html.erb_spec.rb
|
703
704
|
- spec/views/catalog/_facets.html.erb_spec.rb
|
@@ -846,6 +847,7 @@ test_files:
|
|
846
847
|
- spec/views/catalog/_constraints_element.html.erb_spec.rb
|
847
848
|
- spec/views/catalog/_document.html.erb_spec.rb
|
848
849
|
- spec/views/catalog/_document_list.html.erb_spec.rb
|
850
|
+
- spec/views/catalog/_facet_group.html.erb_spec.rb
|
849
851
|
- spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
|
850
852
|
- spec/views/catalog/_facet_layout.html.erb_spec.rb
|
851
853
|
- spec/views/catalog/_facets.html.erb_spec.rb
|
@@ -1,9 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
Blacklight.onLoad(function() {
|
3
|
-
// when clicking on a link that toggles the collapsing behavior, don't do anything
|
4
|
-
// with the hash or the page could jump around.
|
5
|
-
$(document).on('click', 'a[data-toggle=collapse][href="#"], [data-toggle=collapse] a[href="#"]', function(event) {
|
6
|
-
event.preventDefault();
|
7
|
-
});
|
8
|
-
});
|
9
|
-
})(jQuery);
|