blacklight 7.13.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/.github/workflows/ruby.yml +109 -0
- data/README.md +0 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +4 -2
- 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 +42 -17
- data/app/components/blacklight/document/thumbnail_component.html.erb +2 -2
- data/app/components/blacklight/document/thumbnail_component.rb +5 -2
- 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_field_pagination_component.html.erb +4 -4
- data/app/components/blacklight/facet_field_pagination_component.rb +0 -4
- data/app/components/blacklight/facet_item_component.rb +2 -0
- data/app/components/blacklight/hidden_search_state_component.rb +54 -0
- data/app/components/blacklight/search_bar_component.html.erb +14 -8
- data/app/components/blacklight/search_bar_component.rb +16 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +9 -3
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -38
- data/app/helpers/blacklight/icon_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +2 -2
- data/app/javascript/blacklight/button_focus.js +1 -0
- data/app/javascript/blacklight/modal.js +10 -4
- 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/values/blacklight/types.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- 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 +5 -4
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/blacklight.en.yml +17 -0
- data/lib/blacklight/configuration.rb +2 -1
- data/lib/blacklight/configuration/field.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +1 -1
- data/lib/blacklight/configuration/sort_field.rb +1 -1
- data/lib/blacklight/routes/searchable.rb +1 -0
- data/lib/blacklight/search_builder.rb +2 -0
- data/lib/blacklight/search_state.rb +5 -1
- data/lib/blacklight/search_state/filter_field.rb +17 -7
- data/lib/blacklight/solr/repository.rb +14 -5
- data/lib/blacklight/solr/response.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +87 -23
- data/package.json +1 -1
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +51 -0
- data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +17 -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/components/blacklight/hidden_search_state_component_spec.rb +24 -0
- 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/features/facets_spec.rb +2 -17
- data/spec/features/search_filters_spec.rb +0 -20
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -0
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -0
- 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/response/facets_spec.rb +1 -1
- 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
- data/spec/spec_helper.rb +8 -3
- data/spec/test_app_templates/Gemfile.extra +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +2 -0
- data/tasks/blacklight.rake +3 -3
- metadata +67 -28
- data/.travis.yml +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cb69c90e780b277faa807c99cf35b99d2ad0e04b68fd3c56f36a6c170eb8112
|
|
4
|
+
data.tar.gz: d5d7f85ff7af44d193e93a041a658a332a2d0ae31d9dd362f2000135e97ad54d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e8369e2769bb01b1388da32990b3a4868a14a9214ac070a6827871f5aa8a3659804cf0c11eb53b5f3d49a8f5925fafbd063be53977d1159cfa6f24954762771
|
|
7
|
+
data.tar.gz: 91046b20b9d00fc7cbe8a2f65f888e6a3e891fbf33230b203d0f4f7dc8d1a6d8317acdeec6d067f284bd47ecc51e469c0b6999a053816eec75fde5b7328b526a
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: CI
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [ master ]
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [ master ]
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
lint:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: 2.7
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: bundle install
|
|
27
|
+
- name: Run linter
|
|
28
|
+
run: bundle exec rake rubocop
|
|
29
|
+
test:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
strategy:
|
|
32
|
+
matrix:
|
|
33
|
+
ruby: [2.7, 3.0]
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v2
|
|
36
|
+
- name: Set up Ruby
|
|
37
|
+
uses: ruby/setup-ruby@v1
|
|
38
|
+
with:
|
|
39
|
+
ruby-version: ${{ matrix.ruby }}
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: bundle install
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: bundle exec rake ci
|
|
44
|
+
env:
|
|
45
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
|
46
|
+
test_rails6_0:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
strategy:
|
|
49
|
+
matrix:
|
|
50
|
+
ruby: [2.6]
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v2
|
|
53
|
+
- name: Set up Ruby
|
|
54
|
+
uses: ruby/setup-ruby@v1
|
|
55
|
+
with:
|
|
56
|
+
ruby-version: ${{ matrix.ruby }}
|
|
57
|
+
- name: Install dependencies
|
|
58
|
+
run: bundle install
|
|
59
|
+
env:
|
|
60
|
+
RAILS_VERSION: 6.0.3.4
|
|
61
|
+
- name: Run tests
|
|
62
|
+
run: bundle exec rake ci
|
|
63
|
+
env:
|
|
64
|
+
RAILS_VERSION: 6.0.3.4
|
|
65
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
|
66
|
+
test_rails5_2:
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
strategy:
|
|
69
|
+
matrix:
|
|
70
|
+
ruby: [2.5]
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v2
|
|
73
|
+
- name: Set up Ruby
|
|
74
|
+
uses: ruby/setup-ruby@v1
|
|
75
|
+
with:
|
|
76
|
+
ruby-version: ${{ matrix.ruby }}
|
|
77
|
+
- name: Install dependencies
|
|
78
|
+
run: bundle install
|
|
79
|
+
env:
|
|
80
|
+
RAILS_VERSION: 5.2.4.2
|
|
81
|
+
- name: Run tests
|
|
82
|
+
run: bundle exec rake ci
|
|
83
|
+
env:
|
|
84
|
+
RAILS_VERSION: 5.2.4.2
|
|
85
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
|
86
|
+
api_test:
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
strategy:
|
|
89
|
+
matrix:
|
|
90
|
+
ruby: [2.7]
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/checkout@v2
|
|
93
|
+
- name: Set up Ruby
|
|
94
|
+
uses: ruby/setup-ruby@v1
|
|
95
|
+
with:
|
|
96
|
+
ruby-version: ${{ matrix.ruby }}
|
|
97
|
+
- name: Install dependencies
|
|
98
|
+
run: bundle install
|
|
99
|
+
- name: Run tests
|
|
100
|
+
run: bundle exec rake ci
|
|
101
|
+
env:
|
|
102
|
+
BLACKLIGHT_API_TEST: true
|
|
103
|
+
ENGINE_CART_RAILS_OPTIONS: '--api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
|
104
|
+
docker_build:
|
|
105
|
+
runs-on: ubuntu-latest
|
|
106
|
+
steps:
|
|
107
|
+
- uses: actions/checkout@v2
|
|
108
|
+
- name: Build docker image
|
|
109
|
+
run: docker-compose build app
|
data/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Blacklight
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/projectblacklight/blacklight) [](http://badge.fury.io/rb/blacklight) [](https://codeclimate.com/github/projectblacklight/blacklight/test_coverage)
|
|
4
|
-
|
|
5
3
|
Blacklight is an open source Solr user interface discovery platform.
|
|
6
4
|
You can use Blacklight to enable searching and browsing of your collections.
|
|
7
5
|
Blacklight uses the [Apache Solr](http://lucene.apache.org/solr) search engine
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.
|
|
1
|
+
7.15.0
|
|
@@ -99,6 +99,7 @@ Blacklight.onLoad(function () {
|
|
|
99
99
|
Blacklight.onLoad(function () {
|
|
100
100
|
// Button clicks should change focus. As of 10/3/19, Firefox for Mac and
|
|
101
101
|
// Safari both do not set focus to a button on button click.
|
|
102
|
+
// See https://zellwk.com/blog/inconsistent-button-behavior/ for background information
|
|
102
103
|
document.querySelectorAll('button.collapse-toggle').forEach(button => {
|
|
103
104
|
button.addEventListener('click', () => {
|
|
104
105
|
event.target.focus();
|
|
@@ -349,8 +350,9 @@ Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]'; // Calle
|
|
|
349
350
|
// to show to user in modal. Right now called only for extreme
|
|
350
351
|
// network errors.
|
|
351
352
|
|
|
352
|
-
Blacklight.modal.onFailure = function (
|
|
353
|
-
|
|
353
|
+
Blacklight.modal.onFailure = function (jqXHR, textStatus, errorThrown) {
|
|
354
|
+
console.error('Server error:', this.url, jqXHR.status, errorThrown);
|
|
355
|
+
var contents = '<div class="modal-header">' + '<div class="modal-title">There was a problem with your request.</div>' + '<button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">×</span>' + '</button></div>' + ' <div class="modal-body"><p>Expected a successful response from the server, but got an error</p>' + '<pre>' + this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown + '</pre></div>';
|
|
354
356
|
$(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
|
|
355
357
|
$(Blacklight.modal.modalSelector).modal('show');
|
|
356
358
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Warning! If you want to change these, just copy them into your own theme css. But you want to remove the !default, which only will set them if not already set. */
|
|
2
2
|
|
|
3
3
|
$logo-image: image_url('blacklight/logo.png') !default;
|
|
4
|
-
$logo_image: false !default; // deprecated
|
|
5
4
|
|
|
6
5
|
/* label (field names) */
|
|
7
6
|
$field_name_color: $text-muted !default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<% if constraints.present? %>
|
|
2
|
+
<div class="constraints well search_history">
|
|
3
|
+
<h4><%= t 'blacklight.advanced_search.form.search_context' %></h4>
|
|
4
|
+
<%= constraints %>
|
|
5
|
+
</div>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %>
|
|
9
|
+
<%= render_hash_as_hidden_fields(@params) %>
|
|
10
|
+
|
|
11
|
+
<div class="input-criteria">
|
|
12
|
+
<div class="query-criteria">
|
|
13
|
+
<h2 class="query-criteria-heading">
|
|
14
|
+
<%= t('blacklight.advanced_search.form.query_criteria_heading_html', select_menu: default_operator_menu) %>
|
|
15
|
+
</h2>
|
|
16
|
+
|
|
17
|
+
<div id="advanced_search">
|
|
18
|
+
<%= search_field_controls %>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="limit-criteria">
|
|
23
|
+
<h2 class="limit-criteria-heading"><%= t('blacklight.advanced_search.form.limit_criteria_heading_html')%></h2>
|
|
24
|
+
|
|
25
|
+
<div id="advanced_search_facets" class="limit_input">
|
|
26
|
+
<div class="advanced-facet-limits panel-group">
|
|
27
|
+
<%= search_filter_controls %>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<%= content_tag :h2, t('blacklight.advanced_search.form.sort_label') %>
|
|
34
|
+
<div class="form-group row">
|
|
35
|
+
<div class="col-sm-offset-3 col-sm-4">
|
|
36
|
+
<%= sort_fields_select %>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div class="form-group row">
|
|
41
|
+
<div class="submit-buttons col-sm-offset-3 col-sm-9">
|
|
42
|
+
<%= submit_tag t('blacklight.advanced_search.form.search_btn_html'), class: 'btn btn-primary advanced-search-submit', id: "advanced-search-submit" %>
|
|
43
|
+
<%= button_tag t('blacklight.advanced_search.form.start_over_html'), type: 'reset', class: 'btn btn-link advanced-search-start-over' %>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class AdvancedSearchFormComponent < SearchBarComponent
|
|
5
|
+
with_content_areas :constraints, :search_field_controls, :search_filter_controls
|
|
6
|
+
|
|
7
|
+
def initialize(response:, **options)
|
|
8
|
+
super(**options)
|
|
9
|
+
@response = response
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def default_operator_menu
|
|
13
|
+
options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
|
|
14
|
+
select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Rubocop is just wrong here, so...:
|
|
18
|
+
# rubocop:disable Rails/ContentTag
|
|
19
|
+
def search_field_controls
|
|
20
|
+
@search_field_controls || safe_join(search_fields.values.map.with_index do |field, i|
|
|
21
|
+
fields_for('clause[]', i, include_id: false) do |f|
|
|
22
|
+
content_tag(:div, class: 'form-group advanced-search-field row') do
|
|
23
|
+
f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label") +
|
|
24
|
+
content_tag(:div, class: 'col-sm-9') do
|
|
25
|
+
f.hidden_field(:field, value: field.key) +
|
|
26
|
+
f.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end, "\n")
|
|
31
|
+
end
|
|
32
|
+
# rubocop:enable Rails/ContentTag
|
|
33
|
+
|
|
34
|
+
def query_for_search_clause(key)
|
|
35
|
+
field = (@params[:clause] || {}).values.find { |value| value['field'].to_s == key.to_s }
|
|
36
|
+
|
|
37
|
+
field&.dig('query')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def search_filter_controls
|
|
41
|
+
return @search_filter_controls if @search_filter_controls
|
|
42
|
+
|
|
43
|
+
fields = blacklight_config.facet_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
|
|
44
|
+
|
|
45
|
+
safe_join(fields.map do |_k, config|
|
|
46
|
+
display_facet = @response.aggregations[config.field]
|
|
47
|
+
|
|
48
|
+
presenter = (config.presenter || Blacklight::FacetFieldPresenter).new(config, display_facet, @view_context)
|
|
49
|
+
component = config.advanced_search_component || Blacklight::FacetFieldCheckboxesComponent
|
|
50
|
+
@view_context.render(component.new(facet_field: presenter))
|
|
51
|
+
end, "\n")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def constraints
|
|
55
|
+
params = @view_context.search_state.params_for_search.except :page, :f_inclusive, :q, :search_field, :op, :index, :sort
|
|
56
|
+
|
|
57
|
+
params.except!(*search_fields.map { |_key, field_def| field_def[:key] })
|
|
58
|
+
|
|
59
|
+
@view_context.render_search_to_s(params)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def sort_fields_select
|
|
63
|
+
options = sort_fields.values.map { |field_config| [@view_context.sort_field_label(field_config.key), field_config.key] }
|
|
64
|
+
select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def search_fields
|
|
68
|
+
blacklight_config.search_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def sort_fields
|
|
72
|
+
blacklight_config.sort_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%= render(@layout.new(
|
|
2
|
-
classes: (Array(@classes) + ["filter-#{@facet_item_presenter.
|
|
2
|
+
classes: (Array(@classes) + ["filter-#{@facet_item_presenter.key.parameterize}"]).join(' '),
|
|
3
3
|
label: @facet_item_presenter.field_label,
|
|
4
4
|
value: @facet_item_presenter.label,
|
|
5
5
|
remove_path: @facet_item_presenter.remove_href)) %>
|
|
@@ -15,23 +15,25 @@ module Blacklight
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def query_constraints
|
|
18
|
-
return if @search_state.query_param.blank?
|
|
19
|
-
|
|
20
18
|
Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
if @search_state.query_param.present?
|
|
20
|
+
@view_context.render(
|
|
21
|
+
@query_constraint_component.new(
|
|
22
|
+
search_state: @search_state,
|
|
23
|
+
value: @search_state.query_param,
|
|
24
|
+
label: label,
|
|
25
|
+
remove_path: @view_context.remove_constraint_url(@search_state),
|
|
26
|
+
classes: 'query'
|
|
27
|
+
)
|
|
28
28
|
)
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
else
|
|
30
|
+
''.html_safe
|
|
31
|
+
end
|
|
32
|
+
end + @view_context.render(@facet_constraint_component.with_collection(clause_presenters.to_a))
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def facet_constraints
|
|
34
|
-
@view_context.render(@facet_constraint_component.with_collection(facet_item_presenters))
|
|
36
|
+
@view_context.render(@facet_constraint_component.with_collection(facet_item_presenters.to_a))
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def start_over_path
|
|
@@ -46,22 +48,45 @@ module Blacklight
|
|
|
46
48
|
|
|
47
49
|
private
|
|
48
50
|
|
|
51
|
+
def label
|
|
52
|
+
Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
53
|
+
@view_context.constraint_query_label(@search_state.params)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
49
57
|
def facet_item_presenters
|
|
50
|
-
|
|
51
|
-
@search_state.filter_params.each_pair.flat_map do |facet, values|
|
|
52
|
-
facet_config = @view_context.facet_configuration_for_field(facet)
|
|
58
|
+
return to_enum(:facet_item_presenters) unless block_given?
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
Deprecation.silence(Blacklight::SearchState) do
|
|
61
|
+
@search_state.filters.map do |facet|
|
|
62
|
+
facet.values.map do |val|
|
|
55
63
|
next if val.blank? # skip empty string
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
if val.is_a?(Array)
|
|
66
|
+
yield inclusive_facet_item_presenter(facet.config, val, facet.key) if val.any?(&:present?)
|
|
67
|
+
else
|
|
68
|
+
yield facet_item_presenter(facet.config, val, facet.key)
|
|
69
|
+
end
|
|
58
70
|
end
|
|
59
71
|
end
|
|
60
72
|
end
|
|
61
73
|
end
|
|
62
74
|
|
|
75
|
+
def clause_presenters
|
|
76
|
+
return to_enum(:clause_presenters) unless block_given?
|
|
77
|
+
|
|
78
|
+
@search_state.clause_params.each do |key, clause|
|
|
79
|
+
field_config = @view_context.blacklight_config.search_fields[clause[:field]]
|
|
80
|
+
yield Blacklight::ClausePresenter.new(key, clause, field_config, @view_context)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
63
84
|
def facet_item_presenter(facet_config, facet_item, facet_field)
|
|
64
85
|
Blacklight::FacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
|
|
65
86
|
end
|
|
87
|
+
|
|
88
|
+
def inclusive_facet_item_presenter(facet_config, facet_item, facet_field)
|
|
89
|
+
Blacklight::InclusiveFacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
|
|
90
|
+
end
|
|
66
91
|
end
|
|
67
92
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% value = @use_thumbnail_tag ? @presenter.thumbnail.thumbnail_tag(
|
|
1
|
+
<% value = @use_thumbnail_tag ? @presenter.thumbnail.thumbnail_tag(@image_options, 'aria-hidden': true, tabindex: -1, counter: @counter) : @presenter.thumbnail.render(@image_options) %>
|
|
2
2
|
|
|
3
3
|
<% if value %>
|
|
4
4
|
<div class="document-thumbnail">
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<% warn_about_deprecated_behavior %>
|
|
7
7
|
<%= value %>
|
|
8
8
|
<% else %>
|
|
9
|
-
<%=
|
|
9
|
+
<%= helpers.link_to_document(@presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
|
|
10
10
|
<% end %>
|
|
11
11
|
</div>
|
|
12
12
|
<% end %>
|
|
@@ -7,10 +7,13 @@ module Blacklight
|
|
|
7
7
|
with_collection_parameter :presenter
|
|
8
8
|
|
|
9
9
|
# @param [Blacklight::DocumentPresenter] presenter
|
|
10
|
-
|
|
10
|
+
# @param [Integer] counter
|
|
11
|
+
# @param [Hash] image_options options for the thumbnail presenter's image tag
|
|
12
|
+
def initialize(presenter:, counter:, image_options: {})
|
|
11
13
|
@presenter = presenter
|
|
12
14
|
@counter = counter
|
|
13
|
-
@
|
|
15
|
+
@image_options = { alt: '' }.merge(image_options)
|
|
16
|
+
@use_thumbnail_tag = !@presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def render?
|
|
@@ -26,6 +26,7 @@ module Blacklight
|
|
|
26
26
|
id: nil, classes: [], component: :article, title_component: :h4,
|
|
27
27
|
metadata_component: Blacklight::DocumentMetadataComponent,
|
|
28
28
|
embed_component: nil,
|
|
29
|
+
thumbnail_component: Blacklight::Document::ThumbnailComponent,
|
|
29
30
|
counter: nil, document_counter: nil, counter_offset: 0,
|
|
30
31
|
show: false)
|
|
31
32
|
if presenter.nil? && document.nil?
|
|
@@ -42,6 +43,7 @@ module Blacklight
|
|
|
42
43
|
|
|
43
44
|
@embed_component = embed_component
|
|
44
45
|
@metadata_component = metadata_component
|
|
46
|
+
@thumbnail_component = thumbnail_component
|
|
45
47
|
|
|
46
48
|
@document_counter = document_counter
|
|
47
49
|
@counter = counter
|
|
@@ -83,11 +85,14 @@ module Blacklight
|
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
# Content for the document thumbnail area
|
|
86
|
-
def thumbnail
|
|
88
|
+
def thumbnail(image_options = {})
|
|
87
89
|
return super if block_given?
|
|
90
|
+
return @thumbnail if @thumbnail
|
|
91
|
+
|
|
88
92
|
return if @show
|
|
89
93
|
|
|
90
|
-
@
|
|
94
|
+
component = @thumbnail_component || presenter.view_config.thumbnail_component
|
|
95
|
+
render(component.new(presenter: presenter, counter: @counter, image_options: image_options))
|
|
91
96
|
end
|
|
92
97
|
|
|
93
98
|
# Content for the document metadata area
|