blacklight 7.7.0 → 7.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docker/app/Dockerfile +26 -0
- data/.docker/app/entrypoint.sh +6 -0
- data/.env +5 -0
- data/.rubocop_todo.yml +13 -13
- data/.travis.yml +15 -23
- data/Gemfile +4 -1
- data/README.md +4 -0
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_pagination.scss +4 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +21 -0
- data/app/components/blacklight/constraint_layout_component.rb +16 -0
- data/app/components/blacklight/facet_field_component.html.erb +25 -0
- data/app/components/blacklight/facet_field_component.rb +11 -0
- data/app/components/blacklight/facet_field_list_component.html.erb +18 -0
- data/app/components/blacklight/facet_field_list_component.rb +22 -0
- data/app/components/blacklight/facet_field_no_layout_component.rb +13 -0
- data/app/components/blacklight/facet_item_component.rb +120 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +84 -48
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +64 -33
- data/app/javascript/blacklight/modal.js +1 -1
- data/app/models/concerns/blacklight/document/extensions.rb +3 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +0 -4
- data/app/presenters/blacklight/facet_field_presenter.rb +57 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +81 -0
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -1
- data/app/views/catalog/_constraints_element.html.erb +5 -24
- data/app/views/catalog/_email_form.html.erb +1 -1
- data/app/views/catalog/_facet_layout.html.erb +8 -17
- data/app/views/catalog/_facet_limit.html.erb +3 -12
- data/app/views/catalog/_facet_pagination.html.erb +2 -2
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/blacklight.gemspec +1 -0
- data/config/locales/blacklight.ar.yml +29 -25
- data/docker-compose.yml +35 -0
- data/lib/blacklight/engine.rb +2 -6
- data/lib/blacklight/search_state.rb +32 -0
- data/lib/blacklight/solr/response/facets.rb +2 -0
- data/lib/generators/blacklight/assets_generator.rb +10 -0
- data/spec/{views/catalog/_constraints_element.html.erb_spec.rb → components/blacklight/constraint_layout_component_spec.rb} +21 -11
- data/spec/components/blacklight/facet_field_list_component_spec.rb +108 -0
- data/spec/components/blacklight/facet_item_component_spec.rb +50 -0
- data/spec/features/facets_spec.rb +1 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +24 -12
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +4 -23
- data/spec/lib/blacklight/search_state_spec.rb +38 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +30 -1
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +109 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +92 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/presenter_test_helpers.rb +11 -0
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
- data/tasks/blacklight.rake +30 -23
- metadata +43 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 103d3b133711969469b938bec955df2f26e460762dd4734574bd1aecc4fb6451
|
4
|
+
data.tar.gz: b483715ad76633f2cccdca1292a035a7f8714d00acd8b1f6f1a14b6f63e7cfe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1216b0bc9e7824cd19ac8503932f28de07a7fa9c058b762d90cf479c9c792070ccea3b48c38676d4da54b95681ff52c848a886011a86c6743bf526f74dcb4ba8
|
7
|
+
data.tar.gz: 92ed30878b6bd680f5ea8c8ea8e49f170aace6615f56645feae0ab383a7334d6b0a8a5a539634547f9e967b90007e28e7dbdde5712b64006e06e4ca5f64de776
|
@@ -0,0 +1,26 @@
|
|
1
|
+
ARG ALPINE_RUBY_VERSION
|
2
|
+
|
3
|
+
FROM ruby:${ALPINE_RUBY_VERSION}-alpine
|
4
|
+
|
5
|
+
RUN apk add --update --no-cache \
|
6
|
+
bash \
|
7
|
+
build-base \
|
8
|
+
git \
|
9
|
+
libxml2-dev \
|
10
|
+
libxslt-dev \
|
11
|
+
nodejs \
|
12
|
+
sqlite-dev \
|
13
|
+
tzdata
|
14
|
+
|
15
|
+
RUN mkdir /app
|
16
|
+
WORKDIR /app
|
17
|
+
|
18
|
+
RUN gem update --system && \
|
19
|
+
gem install bundler && \
|
20
|
+
bundle config build.nokogiri --use-system-libraries
|
21
|
+
|
22
|
+
COPY . .
|
23
|
+
|
24
|
+
EXPOSE 3000
|
25
|
+
|
26
|
+
CMD [".docker/app/entrypoint.sh"]
|
data/.env
ADDED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2020-
|
3
|
+
# on 2020-03-30 10:03:33 -0700 using RuboCop version 0.63.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -177,7 +177,7 @@ Lint/UselessComparison:
|
|
177
177
|
Exclude:
|
178
178
|
- 'spec/models/blacklight/document/active_model_shim_spec.rb'
|
179
179
|
|
180
|
-
# Offense count:
|
180
|
+
# Offense count: 60
|
181
181
|
Metrics/AbcSize:
|
182
182
|
Max: 49
|
183
183
|
|
@@ -201,20 +201,20 @@ Metrics/ClassLength:
|
|
201
201
|
Metrics/CyclomaticComplexity:
|
202
202
|
Max: 11
|
203
203
|
|
204
|
-
# Offense count:
|
204
|
+
# Offense count: 56
|
205
205
|
# Configuration parameters: CountComments, ExcludedMethods.
|
206
206
|
Metrics/MethodLength:
|
207
|
-
Max:
|
207
|
+
Max: 30
|
208
208
|
|
209
209
|
# Offense count: 8
|
210
210
|
# Configuration parameters: CountComments.
|
211
211
|
Metrics/ModuleLength:
|
212
212
|
Max: 212
|
213
213
|
|
214
|
-
# Offense count:
|
214
|
+
# Offense count: 5
|
215
215
|
# Configuration parameters: CountKeywordArgs.
|
216
216
|
Metrics/ParameterLists:
|
217
|
-
Max:
|
217
|
+
Max: 7
|
218
218
|
|
219
219
|
# Offense count: 16
|
220
220
|
Metrics/PerceivedComplexity:
|
@@ -287,7 +287,7 @@ RSpec/BeforeAfterAll:
|
|
287
287
|
RSpec/ContextWording:
|
288
288
|
Enabled: false
|
289
289
|
|
290
|
-
# Offense count:
|
290
|
+
# Offense count: 56
|
291
291
|
RSpec/DescribeClass:
|
292
292
|
Enabled: false
|
293
293
|
|
@@ -297,7 +297,7 @@ RSpec/EmptyExampleGroup:
|
|
297
297
|
Exclude:
|
298
298
|
- 'spec/models/blacklight/solr/search_builder_spec.rb'
|
299
299
|
|
300
|
-
# Offense count:
|
300
|
+
# Offense count: 130
|
301
301
|
# Configuration parameters: Max.
|
302
302
|
RSpec/ExampleLength:
|
303
303
|
Enabled: false
|
@@ -321,7 +321,7 @@ RSpec/FilePath:
|
|
321
321
|
- 'spec/presenters/pipeline_spec.rb'
|
322
322
|
- 'spec/presenters/thumbnail_presenter_spec.rb'
|
323
323
|
|
324
|
-
# Offense count:
|
324
|
+
# Offense count: 191
|
325
325
|
# Configuration parameters: AssignmentOnly.
|
326
326
|
RSpec/InstanceVariable:
|
327
327
|
Enabled: false
|
@@ -371,12 +371,12 @@ RSpec/MessageSpies:
|
|
371
371
|
- 'spec/presenters/blacklight/field_presenter_spec.rb'
|
372
372
|
- 'spec/presenters/thumbnail_presenter_spec.rb'
|
373
373
|
|
374
|
-
# Offense count:
|
374
|
+
# Offense count: 343
|
375
375
|
# Configuration parameters: AggregateFailuresByDefault.
|
376
376
|
RSpec/MultipleExpectations:
|
377
377
|
Max: 16
|
378
378
|
|
379
|
-
# Offense count:
|
379
|
+
# Offense count: 341
|
380
380
|
# Configuration parameters: IgnoreSharedExamples.
|
381
381
|
RSpec/NamedSubject:
|
382
382
|
Enabled: false
|
@@ -412,7 +412,7 @@ RSpec/SubjectStub:
|
|
412
412
|
- 'spec/models/blacklight/search_builder_spec.rb'
|
413
413
|
- 'spec/services/blacklight/search_service_spec.rb'
|
414
414
|
|
415
|
-
# Offense count:
|
415
|
+
# Offense count: 118
|
416
416
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
417
417
|
RSpec/VerifiedDoubles:
|
418
418
|
Enabled: false
|
@@ -497,7 +497,7 @@ Style/ConditionalAssignment:
|
|
497
497
|
Exclude:
|
498
498
|
- 'lib/blacklight/solr/response/spelling.rb'
|
499
499
|
|
500
|
-
# Offense count:
|
500
|
+
# Offense count: 99
|
501
501
|
Style/Documentation:
|
502
502
|
Enabled: false
|
503
503
|
|
data/.travis.yml
CHANGED
@@ -1,50 +1,42 @@
|
|
1
1
|
dist: bionic
|
2
|
+
|
2
3
|
addons:
|
3
4
|
chrome: stable
|
4
|
-
language: ruby
|
5
5
|
|
6
|
-
|
7
|
-
email: false
|
6
|
+
language: ruby
|
8
7
|
|
9
8
|
matrix:
|
10
9
|
include:
|
11
10
|
- rvm: 2.7.0
|
12
|
-
env: "RAILS_VERSION=6.0.2.
|
11
|
+
env: "RAILS_VERSION=6.0.2.2"
|
13
12
|
- rvm: 2.6.5
|
14
|
-
env: "RAILS_VERSION=6.0.2.
|
13
|
+
env: "RAILS_VERSION=6.0.2.2"
|
15
14
|
- rvm: 2.6.5
|
16
|
-
env: "RAILS_VERSION=5.2.4.
|
15
|
+
env: "RAILS_VERSION=5.2.4.2"
|
17
16
|
- rvm: 2.5.7
|
18
|
-
env: "RAILS_VERSION=5.2.4.
|
17
|
+
env: "RAILS_VERSION=5.2.4.2 BLACKLIGHT_API_TEST=true ENGINE_CART_RAILS_OPTIONS=\"--api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test\""
|
19
18
|
- rvm: 2.4.9
|
20
|
-
env: "RAILS_VERSION=5.2.4.
|
19
|
+
env: "RAILS_VERSION=5.2.4.2"
|
21
20
|
- rvm: jruby-9.2.8.0
|
22
|
-
env: "RAILS_VERSION=5.2.4.
|
21
|
+
env: "RAILS_VERSION=5.2.4.2 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
|
23
22
|
allow_failures:
|
24
23
|
- rvm: jruby-9.2.8.0
|
25
24
|
fast_finish: true
|
26
25
|
|
27
26
|
before_install:
|
28
|
-
- docker pull solr:7
|
29
|
-
- docker run -d -p 8983:8983 -v $PWD/lib/generators/blacklight/templates/solr/conf:/myconfig solr:7 solr-create -c blacklight-core -d /myconfig
|
30
|
-
- docker ps -a
|
31
27
|
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
global_env:
|
39
|
-
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
40
|
-
- ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
41
|
-
- CC_TEST_REPORTER_ID=5042c7358c96b0b926088a4cda3e132fffe7a66ce8047cdb1dc6f0b4b6676b79
|
42
|
-
|
43
|
-
jdk: openjdk11
|
29
|
+
env:
|
30
|
+
global:
|
31
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
32
|
+
- ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
33
|
+
- CC_TEST_REPORTER_ID=5042c7358c96b0b926088a4cda3e132fffe7a66ce8047cdb1dc6f0b4b6676b79
|
44
34
|
|
45
35
|
before_script:
|
46
36
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
47
37
|
- chmod +x ./cc-test-reporter
|
48
38
|
- ./cc-test-reporter before-build
|
39
|
+
|
49
40
|
after_script:
|
50
41
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
42
|
+
- docker-compose build app || travis_terminate 1 # validates application Dockerfile
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -38,6 +38,10 @@ rails generate blacklight:install
|
|
38
38
|
* Bundler
|
39
39
|
* Rails 5.1+
|
40
40
|
|
41
|
+
## Contributing Code
|
42
|
+
|
43
|
+
Code contributions are always welcome, instructions for contributing can be found at [CONTRIBUTING.md](https://github.com/projectblacklight/blacklight/blob/master/CONTRIBUTING.md).
|
44
|
+
|
41
45
|
## Configuring Apache Solr
|
42
46
|
You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR)
|
43
47
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.8.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<span class="btn-group applied-filter constraint <%= @classes %>">
|
2
|
+
<span class="constraint-value btn btn-outline-secondary">
|
3
|
+
<% if @label.present? %>
|
4
|
+
<span class="filter-name"><%= @label %></span>
|
5
|
+
<% end %>
|
6
|
+
<% if @value.present? %>
|
7
|
+
<%= content_tag :span, @value, class: 'filter-value', title: strip_tags(@value) %>
|
8
|
+
<% end %>
|
9
|
+
</span>
|
10
|
+
<% if @remove_path.present? %>
|
11
|
+
<%= link_to(@remove_path, class: 'btn btn-outline-secondary remove') do %>
|
12
|
+
<span class="remove-icon">✖</span>
|
13
|
+
<%= if @label.blank?
|
14
|
+
t('blacklight.search.filters.remove.value', value: @value)
|
15
|
+
else
|
16
|
+
t('blacklight.search.filters.remove.label_value', label: @label, value: @value)
|
17
|
+
end
|
18
|
+
%>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
</span>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
class ConstraintLayoutComponent < ::ViewComponent::Base
|
5
|
+
def initialize(value:, label: nil, remove_path: nil, classes: nil)
|
6
|
+
@value = value
|
7
|
+
@label = label
|
8
|
+
@remove_path = remove_path
|
9
|
+
@classes = Array(classes).join(' ')
|
10
|
+
end
|
11
|
+
|
12
|
+
def render?
|
13
|
+
@value.present?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<div class="card facet-limit blacklight-<%= @facet_field.key %> <%= 'facet-limit-active' if @facet_field.active? %>">
|
2
|
+
<h3 class="card-header p-0 facet-field-heading" id="<%= @facet_field.html_id %>-header">
|
3
|
+
<button
|
4
|
+
class="btn btn-block p-2 text-left collapse-toggle <%= "collapsed" if @facet_field.collapsed? %>"
|
5
|
+
data-toggle="collapse"
|
6
|
+
data-target="#<%= @facet_field.html_id %>"
|
7
|
+
aria-expanded="<%= @facet_field.collapsed? ? 'false' : 'true' %>"
|
8
|
+
>
|
9
|
+
<%= label %>
|
10
|
+
</button>
|
11
|
+
</h3>
|
12
|
+
<div id="<%= @facet_field.html_id %>" aria-labelledby="<%= @facet_field.html_id %>-header" class="panel-collapse facet-content collapse <%= "show" unless @facet_field.collapsed? %>">
|
13
|
+
<div class="card-body">
|
14
|
+
<%= body %>
|
15
|
+
|
16
|
+
<% if @facet_field.modal_path %>
|
17
|
+
<div class="more_facets">
|
18
|
+
<%= link_to t("more_#{@facet_field.key}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: @facet_field.label),
|
19
|
+
@facet_field.modal_path,
|
20
|
+
data: { blacklight_modal: 'trigger' } %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= render(@layout.new(facet_field: @facet_field)) do |component| %>
|
2
|
+
<% component.with(:label) do %>
|
3
|
+
<%= @facet_field.label %>
|
4
|
+
<% end %>
|
5
|
+
<% component.with(:body) do %>
|
6
|
+
<ul class="facet-values list-unstyled">
|
7
|
+
<%= render_facet_limit_list @facet_field.paginator, @facet_field.key %>
|
8
|
+
</ul>
|
9
|
+
<%# backwards compatibility, ugh %>
|
10
|
+
<% if @layout == Blacklight::FacetFieldNoLayoutComponent && !@facet_field.in_modal? && @facet_field.modal_path %>
|
11
|
+
<div class="more_facets">
|
12
|
+
<%= link_to t("more_#{@facet_field.key}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: @facet_field.label),
|
13
|
+
@facet_field.modal_path,
|
14
|
+
data: { blacklight_modal: 'trigger' } %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
class FacetFieldListComponent < ::ViewComponent::Base
|
5
|
+
def initialize(facet_field:, layout: nil)
|
6
|
+
@facet_field = facet_field
|
7
|
+
@layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
|
8
|
+
end
|
9
|
+
|
10
|
+
# Here for backwards compatibility only.
|
11
|
+
# @private
|
12
|
+
def render_facet_limit_list(*args)
|
13
|
+
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
14
|
+
@view_context.render_facet_limit_list(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def render?
|
19
|
+
@facet_field.paginator.items.any?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
class FacetItemComponent < ::ViewComponent::Base
|
5
|
+
with_collection_parameter :facet_item
|
6
|
+
|
7
|
+
def initialize(facet_item:, wrapping_element: 'li', suppress_link: false)
|
8
|
+
@facet_item = facet_item
|
9
|
+
@label = facet_item.label
|
10
|
+
@hits = facet_item.hits
|
11
|
+
@href = facet_item.href
|
12
|
+
@selected = facet_item.selected?
|
13
|
+
@wrapping_element = wrapping_element
|
14
|
+
@suppress_link = suppress_link
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
# if the downstream app has overridden the helper methods we'd usually call,
|
19
|
+
# use the helpers to preserve compatibility
|
20
|
+
content = if overridden_helper_methods?
|
21
|
+
content_from_legacy_view_helper
|
22
|
+
elsif @selected
|
23
|
+
render_selected_facet_value
|
24
|
+
else
|
25
|
+
render_facet_value
|
26
|
+
end
|
27
|
+
|
28
|
+
return if content.blank?
|
29
|
+
return content unless @wrapping_element
|
30
|
+
|
31
|
+
content_tag @wrapping_element, content
|
32
|
+
end
|
33
|
+
|
34
|
+
# This is a little shim to let us call the render methods below outside the
|
35
|
+
# usual component rendering cycle (for backward compatibility)
|
36
|
+
# @private
|
37
|
+
# @deprecated
|
38
|
+
def with_view_context(view_context)
|
39
|
+
@view_context = view_context
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
# Check if the downstream application has overridden these methods
|
44
|
+
# @deprecated
|
45
|
+
# @private
|
46
|
+
def overridden_helper_methods?
|
47
|
+
return false if explicit_component_configuration?
|
48
|
+
|
49
|
+
@view_context.method(:render_facet_item).owner != Blacklight::FacetsHelperBehavior ||
|
50
|
+
@view_context.method(:render_facet_value).owner != Blacklight::FacetsHelperBehavior ||
|
51
|
+
@view_context.method(:render_selected_facet_value).owner != Blacklight::FacetsHelperBehavior
|
52
|
+
end
|
53
|
+
|
54
|
+
# Call out to the helper method equivalent of this component
|
55
|
+
# @deprecated
|
56
|
+
# @private
|
57
|
+
def content_from_legacy_view_helper
|
58
|
+
Deprecation.warn('Calling out to the #render_facet_item helper for backwards compatibility.')
|
59
|
+
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
60
|
+
@view_context.render_facet_item(@facet_item.facet_field, @facet_item.facet_item)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Standard display of a facet value in a list. Used in both _facets sidebar
|
66
|
+
# partial and catalog/facet expanded list. Will output facet value name as
|
67
|
+
# a link to add that to your restrictions, with count in parens.
|
68
|
+
#
|
69
|
+
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
70
|
+
# @param [Blacklight::Solr::Response::Facets::FacetItem] item
|
71
|
+
# @param [Hash] options
|
72
|
+
# @option options [Boolean] :suppress_link display the facet, but don't link to it
|
73
|
+
# @return [String]
|
74
|
+
# @private
|
75
|
+
def render_facet_value
|
76
|
+
content_tag(:span, class: "facet-label") do
|
77
|
+
link_to_unless(@suppress_link, @label, @href, class: "facet-select")
|
78
|
+
end + render_facet_count
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
|
83
|
+
# @see #render_facet_value
|
84
|
+
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
85
|
+
# @param [String] item
|
86
|
+
# @private
|
87
|
+
def render_selected_facet_value
|
88
|
+
content_tag(:span, class: "facet-label") do
|
89
|
+
content_tag(:span, @label, class: "selected") +
|
90
|
+
# remove link
|
91
|
+
link_to(@href, class: "remove") do
|
92
|
+
content_tag(:span, '✖', class: "remove-icon") +
|
93
|
+
content_tag(:span, '[remove]', class: 'sr-only')
|
94
|
+
end
|
95
|
+
end + render_facet_count(classes: ["selected"])
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Renders a count value for facet limits. Can be over-ridden locally
|
100
|
+
# to change style. And can be called by plugins to get consistent display.
|
101
|
+
#
|
102
|
+
# @param [Integer] num number of facet results
|
103
|
+
# @param [Hash] options
|
104
|
+
# @option options [Array<String>] an array of classes to add to count span.
|
105
|
+
# @return [String]
|
106
|
+
# @private
|
107
|
+
def render_facet_count(options = {})
|
108
|
+
return @view_context.render_facet_count(@hits, options) unless @view_context.method(:render_facet_count).owner == Blacklight::FacetsHelperBehavior || explicit_component_configuration?
|
109
|
+
|
110
|
+
classes = (options[:classes] || []) << "facet-count"
|
111
|
+
content_tag("span", t('blacklight.search.facets.count', number: number_with_delimiter(@hits)), class: classes)
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def explicit_component_configuration?
|
117
|
+
@facet_item.facet_config.item_component.present?
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|