blacklight 7.5.0 → 7.8.1
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/.gitignore +0 -1
- data/.rubocop_todo.yml +26 -37
- data/.travis.yml +16 -24
- 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 +23 -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/controllers/concerns/blacklight/catalog.rb +4 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +4 -2
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -4
- data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -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/blacklight/icon.rb +11 -5
- 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/document_presenter.rb +27 -36
- data/app/presenters/blacklight/facet_field_presenter.rb +57 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +81 -0
- data/app/presenters/blacklight/field_presenter.rb +31 -6
- data/app/presenters/blacklight/index_presenter.rb +2 -2
- data/app/presenters/blacklight/show_presenter.rb +3 -3
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +2 -2
- 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/_field.json.jbuilder +2 -2
- data/app/views/catalog/_index.html.erb +3 -3
- data/app/views/catalog/_previous_next_doc.html.erb +5 -5
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_show.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/_start_over.html.erb +1 -0
- data/app/views/catalog/_thumbnail.html.erb +1 -1
- data/app/views/catalog/index.json.jbuilder +2 -1
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/catalog/show.json.jbuilder +2 -1
- data/app/views/layouts/blacklight/base.html.erb +2 -2
- data/blacklight.gemspec +1 -0
- data/config/locales/blacklight.ar.yml +30 -24
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.hu.yml +2 -0
- data/config/locales/blacklight.it.yml +2 -0
- data/config/locales/blacklight.nl.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/config/locales/blacklight.sq.yml +2 -0
- data/config/locales/blacklight.zh.yml +2 -0
- data/docker-compose.yml +35 -0
- data/lib/blacklight/configuration/field.rb +5 -4
- data/lib/blacklight/engine.rb +2 -6
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/search_state.rb +52 -0
- data/lib/blacklight/solr/response/facets.rb +2 -0
- data/lib/generators/blacklight/assets_generator.rb +10 -0
- data/package.json +1 -1
- data/spec/{views/catalog/_constraints_element.html.erb_spec.rb → components/blacklight/constraint_layout_component_spec.rb} +22 -12
- 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/controllers/catalog_controller_spec.rb +13 -1
- data/spec/features/facets_spec.rb +1 -1
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
- 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/helpers/blacklight_helper_spec.rb +17 -0
- data/spec/helpers/catalog_helper_spec.rb +0 -7
- data/spec/lib/blacklight/search_state_spec.rb +50 -0
- data/spec/models/blacklight/icon_spec.rb +15 -6
- data/spec/models/blacklight/solr/response/facets_spec.rb +30 -1
- data/spec/presenters/blacklight/document_presenter_spec.rb +22 -62
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +109 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +92 -0
- data/spec/presenters/blacklight/field_presenter_spec.rb +268 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +0 -142
- data/spec/presenters/blacklight/show_presenter_spec.rb +0 -177
- 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/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +18 -0
- data/tasks/blacklight.rake +30 -23
- metadata +48 -7
- data/Vagrantfile +0 -79
- data/provision.sh +0 -30
@@ -22,6 +22,7 @@ de:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'Links überspringen'
|
25
26
|
main_content: 'Zum Hauptinhalt gehen'
|
26
27
|
search_field: 'Gehen Sie zur Suchleiste'
|
27
28
|
first_result: 'Gehe zum ersten Suchergebnis'
|
@@ -151,6 +152,7 @@ de:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> pro Seite</span>'
|
152
153
|
title: 'Anzahl der Ergebnisse, die pro Seite angezeigt werden'
|
153
154
|
submit: 'Aktualisieren'
|
155
|
+
aria_label: 'Ergebnisnavigation'
|
154
156
|
sort:
|
155
157
|
label: 'Ordnen nach %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Ordnen<span class="d-none d-sm-inline"> nach %{field}</span>'
|
@@ -22,6 +22,7 @@ en:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'Skip links'
|
25
26
|
main_content: 'Skip to main content'
|
26
27
|
search_field: 'Skip to search'
|
27
28
|
first_result: 'Skip to first result'
|
@@ -151,6 +152,7 @@ en:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> per page</span>'
|
152
153
|
title: 'Number of results to display per page'
|
153
154
|
submit: 'Update'
|
155
|
+
aria_label: 'Results navigation'
|
154
156
|
sort:
|
155
157
|
label: 'Sort by %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Sort<span class="d-none d-sm-inline"> by %{field}</span>'
|
@@ -22,6 +22,7 @@ es:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'Saltar enlaces'
|
25
26
|
main_content: 'Saltar al contenido principal'
|
26
27
|
search_field: 'Salta a la búsqueda'
|
27
28
|
first_result: 'Salta al primer resultado de búsqueda'
|
@@ -151,6 +152,7 @@ es:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> por página</span>'
|
152
153
|
title: 'El número de resultados a mostrar por página'
|
153
154
|
submit: 'Actualización'
|
155
|
+
aria_label: 'Navegación de resultados'
|
154
156
|
sort:
|
155
157
|
label: 'Ordenar por %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Ordenar<span class="d-none d-sm-inline"> por %{field}</span>'
|
@@ -22,6 +22,7 @@ fr:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'Sauter les liens'
|
25
26
|
main_content: 'Aller au contenu principal'
|
26
27
|
search_field: 'Aller à la recherche'
|
27
28
|
first_result: 'Aller au premier résultat de recherche'
|
@@ -154,6 +155,7 @@ fr:
|
|
154
155
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> par page</span>'
|
155
156
|
title: 'Nombre de résultats à afficher par page'
|
156
157
|
submit: 'mettre à jour'
|
158
|
+
aria_label: 'Navigation dans les résultats'
|
157
159
|
sort:
|
158
160
|
label: 'Trier par %{field}' # TODO: Remove during major release
|
159
161
|
label_html: 'Trier<span class="d-none d-sm-inline"> par %{field}</span>'
|
@@ -22,6 +22,7 @@ hu:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'átugrani a linkeket'
|
25
26
|
main_content: 'Ugrás a tartalomra'
|
26
27
|
search_field: 'Ugrás a keresésre'
|
27
28
|
first_result: 'Ugrás az első keresési eredményre'
|
@@ -151,6 +152,7 @@ hu:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> oldalanként</span>'
|
152
153
|
title: 'Az eredmények száma oldalanként'
|
153
154
|
submit: 'Frissítés'
|
155
|
+
aria_label: 'Eredmények navigáció'
|
154
156
|
sort:
|
155
157
|
label: 'Rendezés %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Rendezés<span class="d-none d-sm-inline"> %{field}</span>'
|
@@ -22,6 +22,7 @@ it:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'Saltare i collegamenti'
|
25
26
|
main_content: 'Vai al contenuto principale'
|
26
27
|
search_field: 'Vai alla ricerca'
|
27
28
|
first_result: 'Vai al primo risultato di ricerca'
|
@@ -151,6 +152,7 @@ it:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> per pagina</span>'
|
152
153
|
title: 'Risultati per pagina'
|
153
154
|
submit: 'Aggiorna'
|
155
|
+
aria_label: 'Navigazione dei risultati'
|
154
156
|
sort:
|
155
157
|
label: 'Ordina per %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Ordina<span class="d-none d-sm-inline"> per %{field}</span>'
|
@@ -22,6 +22,7 @@ nl:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'links overslaan'
|
25
26
|
main_content: 'Ga naar de hoofdinhoud'
|
26
27
|
search_field: 'Ga naar de zoekopdracht'
|
27
28
|
first_result: 'Ga naar het eerste zoekresultaat'
|
@@ -151,6 +152,7 @@ nl:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> per pagina</span>'
|
152
153
|
title: 'Toon aantal zoekresultaten per pagina'
|
153
154
|
submit: 'Update'
|
155
|
+
aria_label: 'Resultaten navigatie'
|
154
156
|
sort:
|
155
157
|
label: 'Sorteer op %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Sorteer<span class="d-none d-sm-inline"> op %{field}</span>'
|
@@ -23,6 +23,7 @@ pt-BR:
|
|
23
23
|
blacklight:
|
24
24
|
application_name: 'Blacklight'
|
25
25
|
skip_links:
|
26
|
+
label: 'pular links'
|
26
27
|
main_content: 'Ir para o conteúdo principal'
|
27
28
|
search_field: 'Ir para a pesquisa'
|
28
29
|
first_result: 'Ir para o primeiro resultado da pesquisa'
|
@@ -152,6 +153,7 @@ pt-BR:
|
|
152
153
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> por página</span>'
|
153
154
|
title: 'Número de resultados para mostrar por página'
|
154
155
|
submit: 'Atualizar'
|
156
|
+
aria_label: 'Navegação de resultados'
|
155
157
|
sort:
|
156
158
|
label: 'Ordenar por %{field}' # TODO: Remove during major release
|
157
159
|
label_html: 'Ordenar<span class="d-none d-sm-inline"> por %{field}</span>'
|
@@ -22,6 +22,7 @@ sq:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: 'lidhjet e kaloni'
|
25
26
|
main_content: 'Shkoni tek përmbajtja kryesore'
|
26
27
|
search_field: 'Shkoni në kërkim'
|
27
28
|
first_result: 'Shkoni te rezultati i parë i kërkimit'
|
@@ -151,6 +152,7 @@ sq:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> për faqe</span>'
|
152
153
|
title: 'Numri i rezultateve që do të shfaqen për faqe'
|
153
154
|
submit: 'Përditëso'
|
155
|
+
aria_label: 'Rezultatet e lundrimit'
|
154
156
|
sort:
|
155
157
|
label: 'Klasifikoj sipas %{field}' # TODO: Remove during major release
|
156
158
|
label_html: 'Klasifikoj<span class="d-none d-sm-inline"> sipas %{field}</span>'
|
@@ -22,6 +22,7 @@ zh:
|
|
22
22
|
blacklight:
|
23
23
|
application_name: 'Blacklight'
|
24
24
|
skip_links:
|
25
|
+
label: '跳过链接'
|
25
26
|
main_content: '转到主要内容'
|
26
27
|
search_field: '转到搜索'
|
27
28
|
first_result: '转到第一个搜索结果'
|
@@ -151,6 +152,7 @@ zh:
|
|
151
152
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> 每页</span>'
|
152
153
|
title: '每页显示结果数'
|
153
154
|
submit: '更新'
|
155
|
+
aria_label: '结果导航'
|
154
156
|
sort:
|
155
157
|
label: '按 %{field} 排序' # TODO: Remove during major release
|
156
158
|
label_html: '<span class="d-none d-sm-inline">按 %{field} </span>排序'
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
version: "3.7"
|
2
|
+
|
3
|
+
services:
|
4
|
+
app:
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
dockerfile: .docker/app/Dockerfile
|
8
|
+
args:
|
9
|
+
- ALPINE_RUBY_VERSION
|
10
|
+
volumes:
|
11
|
+
- .:/app
|
12
|
+
depends_on:
|
13
|
+
- solr
|
14
|
+
ports:
|
15
|
+
- "3000:3000"
|
16
|
+
environment:
|
17
|
+
- SOLR_URL # Set via environment variable or use default defined in .env file
|
18
|
+
- RAILS_VERSION # Set via environment variable or use default defined in .env file
|
19
|
+
|
20
|
+
solr:
|
21
|
+
environment:
|
22
|
+
- SOLR_PORT # Set via environment variable or use default defined in .env file
|
23
|
+
- SOLR_VERSION # Set via environment variable or use default defined in .env file
|
24
|
+
image: "solr:${SOLR_VERSION}"
|
25
|
+
volumes:
|
26
|
+
- $PWD/lib/generators/blacklight/templates/solr/conf:/opt/solr/conf
|
27
|
+
ports:
|
28
|
+
- "${SOLR_PORT}:8983"
|
29
|
+
entrypoint:
|
30
|
+
- docker-entrypoint.sh
|
31
|
+
- solr-precreate
|
32
|
+
- blacklight-core
|
33
|
+
- /opt/solr/conf
|
34
|
+
- "-Xms256m"
|
35
|
+
- "-Xmx512m"
|
@@ -19,12 +19,13 @@ module Blacklight
|
|
19
19
|
raise ArgumentError, "Must supply a field name" if self.field.nil?
|
20
20
|
end
|
21
21
|
|
22
|
-
def display_label(context = nil)
|
22
|
+
def display_label(context = nil, **options)
|
23
23
|
field_label(
|
24
24
|
(:"blacklight.search.fields.#{context}.#{key}" if context),
|
25
25
|
:"blacklight.search.fields.#{key}",
|
26
26
|
label,
|
27
|
-
default_label
|
27
|
+
default_label,
|
28
|
+
**options
|
28
29
|
)
|
29
30
|
end
|
30
31
|
|
@@ -50,10 +51,10 @@ module Blacklight
|
|
50
51
|
# before falling back to the label
|
51
52
|
# @param [Symbol] any number of additional keys
|
52
53
|
# @param [Symbol] ...
|
53
|
-
def field_label *i18n_keys
|
54
|
+
def field_label *i18n_keys, **options
|
54
55
|
first, *rest = i18n_keys.compact
|
55
56
|
|
56
|
-
I18n.t(first, default: rest)
|
57
|
+
I18n.t(first, default: rest, **options)
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
data/lib/blacklight/engine.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'view_component/engine'
|
3
|
+
|
2
4
|
module Blacklight
|
3
5
|
class Engine < Rails::Engine
|
4
6
|
engine_name "blacklight"
|
@@ -9,12 +11,6 @@ module Blacklight
|
|
9
11
|
ActionView::Base.send :include, BlacklightHelper
|
10
12
|
end
|
11
13
|
|
12
|
-
config.autoload_paths += %W(
|
13
|
-
#{config.root}/app/presenters
|
14
|
-
#{config.root}/app/controllers/concerns
|
15
|
-
#{config.root}/app/models/concerns
|
16
|
-
)
|
17
|
-
|
18
14
|
# This makes our rake tasks visible.
|
19
15
|
rake_tasks do
|
20
16
|
Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
|
@@ -37,6 +37,42 @@ module Blacklight
|
|
37
37
|
end
|
38
38
|
alias to_h to_hash
|
39
39
|
|
40
|
+
def to_unsafe_h
|
41
|
+
Deprecation.warn(self, 'Use SearchState#to_h instead of SearchState#to_unsafe_h')
|
42
|
+
to_hash
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(method_name, *arguments, &block)
|
46
|
+
if @params.respond_to?(method_name)
|
47
|
+
Deprecation.warn(self, "Calling `#{method_name}` on Blacklight::SearchState " \
|
48
|
+
'is deprecated and will be removed in Blacklight 8. Call #to_h first if you ' \
|
49
|
+
' need to use hash methods (or, preferably, use your own SearchState implementation)')
|
50
|
+
@params.public_send(method_name, *arguments, &block)
|
51
|
+
else
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def respond_to_missing?(method_name, include_private = false)
|
57
|
+
@params.respond_to?(method_name, include_private) || super
|
58
|
+
end
|
59
|
+
|
60
|
+
# Tiny shim to make it easier to migrate raw params access to using this class
|
61
|
+
delegate :[], to: :params
|
62
|
+
deprecation_deprecate :[]
|
63
|
+
|
64
|
+
def has_constraints?
|
65
|
+
!(query_param.blank? && filter_params.blank?)
|
66
|
+
end
|
67
|
+
|
68
|
+
def query_param
|
69
|
+
params[:q]
|
70
|
+
end
|
71
|
+
|
72
|
+
def filter_params
|
73
|
+
params[:f] || {}
|
74
|
+
end
|
75
|
+
|
40
76
|
def reset(params = nil)
|
41
77
|
self.class.new(params || ActionController::Parameters.new, blacklight_config, controller)
|
42
78
|
end
|
@@ -57,6 +93,12 @@ module Blacklight
|
|
57
93
|
end
|
58
94
|
end
|
59
95
|
|
96
|
+
def remove_query_params
|
97
|
+
p = reset_search_params
|
98
|
+
p.delete(:q)
|
99
|
+
p
|
100
|
+
end
|
101
|
+
|
60
102
|
# adds the value and/or field to params[:f]
|
61
103
|
# Does NOT remove request keys and otherwise ensure that the hash
|
62
104
|
# is suitable for a redirect. See
|
@@ -130,6 +172,16 @@ module Blacklight
|
|
130
172
|
p
|
131
173
|
end
|
132
174
|
|
175
|
+
def has_facet?(config, value: nil)
|
176
|
+
facet = params&.dig(:f, config.key)
|
177
|
+
|
178
|
+
if value
|
179
|
+
(facet || []).include? value
|
180
|
+
else
|
181
|
+
facet.present?
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
133
185
|
# Merge the source params with the params_to_merge hash
|
134
186
|
# @param [Hash] params_to_merge to merge into above
|
135
187
|
# @return [ActionController::Parameters] the current search parameters after being sanitized by Blacklight::Parameters.sanitize
|
@@ -210,6 +210,8 @@ module Blacklight::Solr::Response::Facets
|
|
210
210
|
Blacklight::Solr::Response::Facets::FacetItem.new(value: key, hits: hits, label: facet_field.query[key][:label])
|
211
211
|
end
|
212
212
|
|
213
|
+
items = items.sort_by(&:hits).reverse if facet_field.sort && facet_field.sort.to_sym == :count
|
214
|
+
|
213
215
|
hash[field_name] = Blacklight::Solr::Response::Facets::FacetField.new field_name, items
|
214
216
|
end
|
215
217
|
end
|
@@ -22,6 +22,16 @@ module Blacklight
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
##
|
26
|
+
# Remove the empty generated app/assets/images directory. Without doing this,
|
27
|
+
# the default Sprockets 4 manifest will raise an exception.
|
28
|
+
def appease_sprockets4
|
29
|
+
return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4'
|
30
|
+
|
31
|
+
append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
|
32
|
+
empty_directory 'app/assets/images'
|
33
|
+
end
|
34
|
+
|
25
35
|
def assets
|
26
36
|
copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss"
|
27
37
|
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "blacklight-frontend",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.7.0",
|
4
4
|
"description": "[![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=master)](https://coveralls.io/github/projectblacklight/blacklight?branch=master)",
|
5
5
|
"main": "app/assets/javascripts/blacklight",
|
6
6
|
"scripts": {
|
@@ -1,24 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
6
|
+
subject(:render) do
|
7
|
+
render_inline(described_class.new(params))
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:rendered) do
|
11
|
+
Capybara::Node::Simple.new(render)
|
12
|
+
end
|
13
|
+
|
4
14
|
describe "for simple display" do
|
5
|
-
|
6
|
-
|
15
|
+
let(:params) do
|
16
|
+
{ label: "my label", value: "my value" }
|
7
17
|
end
|
8
18
|
|
9
19
|
it "renders label and value" do
|
10
20
|
expect(rendered).to have_selector("span.applied-filter.constraint") do |s|
|
11
21
|
expect(s).to have_css("span.constraint-value")
|
12
22
|
expect(s).not_to have_css("a.constraint-value")
|
13
|
-
expect(s).to have_selector "span.filter-name",
|
14
|
-
expect(s).to have_selector "span.filter-value",
|
23
|
+
expect(s).to have_selector "span.filter-name", text: "my label"
|
24
|
+
expect(s).to have_selector "span.filter-value", text: "my value"
|
15
25
|
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
|
19
29
|
describe "with remove link" do
|
20
|
-
|
21
|
-
|
30
|
+
let(:params) do
|
31
|
+
{ label: "my label", value: "my value", remove_path: "http://remove" }
|
22
32
|
end
|
23
33
|
|
24
34
|
it "includes remove link" do
|
@@ -28,14 +38,14 @@ RSpec.describe "catalog/_constraints_element.html.erb" do
|
|
28
38
|
end
|
29
39
|
it "has an accessible remove label" do
|
30
40
|
expect(rendered).to have_selector(".remove") do |s|
|
31
|
-
expect(s).to
|
41
|
+
expect(s).to have_selector('.sr-only', text: 'Remove constraint my label: my value')
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
36
46
|
describe "with custom classes" do
|
37
|
-
|
38
|
-
|
47
|
+
let(:params) do
|
48
|
+
{ label: "my label", value: "my value", classes: %w[class1 class2] }
|
39
49
|
end
|
40
50
|
|
41
51
|
it "includes them" do
|
@@ -44,8 +54,8 @@ RSpec.describe "catalog/_constraints_element.html.erb" do
|
|
44
54
|
end
|
45
55
|
|
46
56
|
describe "with no escaping" do
|
47
|
-
|
48
|
-
|
57
|
+
let(:params) do
|
58
|
+
{ label: "<span class='custom_label'>my label</span>".html_safe, value: "<span class='custom_value'>my value</span>".html_safe }
|
49
59
|
end
|
50
60
|
|
51
61
|
it "does not escape key and value" do
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::FacetFieldListComponent, 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
|
+
paginator: paginator,
|
18
|
+
key: 'field',
|
19
|
+
label: 'Field',
|
20
|
+
active?: false,
|
21
|
+
collapsed?: false,
|
22
|
+
modal_path: nil,
|
23
|
+
html_id: 'facet-field'
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:paginator) do
|
28
|
+
instance_double(Blacklight::FacetPaginator, items: [
|
29
|
+
double(label: 'x', hits: 10),
|
30
|
+
double(label: 'y', hits: 33)
|
31
|
+
])
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'renders a collapsible card' do
|
35
|
+
expect(rendered).to have_selector '.card'
|
36
|
+
expect(rendered).to have_button 'Field'
|
37
|
+
expect(rendered).to have_selector 'button[data-target="#facet-field"]'
|
38
|
+
expect(rendered).to have_selector '#facet-field.collapse.show'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'renders the facet items' do
|
42
|
+
expect(rendered).to have_selector 'ul.facet-values'
|
43
|
+
expect(rendered).to have_selector 'li', count: 2
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with an active facet' do
|
47
|
+
let(:facet_field) do
|
48
|
+
instance_double(
|
49
|
+
Blacklight::FacetFieldPresenter,
|
50
|
+
paginator: paginator,
|
51
|
+
key: 'field',
|
52
|
+
label: 'Field',
|
53
|
+
active?: true,
|
54
|
+
collapsed?: false,
|
55
|
+
modal_path: nil,
|
56
|
+
html_id: 'facet-field'
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'adds the facet-limit-active class' do
|
61
|
+
expect(rendered).to have_selector 'div.facet-limit-active'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with a collapsed facet' do
|
66
|
+
let(:facet_field) do
|
67
|
+
instance_double(
|
68
|
+
Blacklight::FacetFieldPresenter,
|
69
|
+
paginator: paginator,
|
70
|
+
key: 'field',
|
71
|
+
label: 'Field',
|
72
|
+
active?: false,
|
73
|
+
collapsed?: true,
|
74
|
+
modal_path: nil,
|
75
|
+
html_id: 'facet-field'
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'renders a collapsed facet' do
|
80
|
+
expect(rendered).to have_selector '.facet-content.collapse'
|
81
|
+
expect(rendered).not_to have_selector '.facet-content.collapse.show'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'renders the toggle button in the collapsed state' do
|
85
|
+
expect(rendered).to have_selector '.btn.collapsed'
|
86
|
+
expect(rendered).to have_selector '.btn[aria-expanded="false"]'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'with a modal_path' do
|
91
|
+
let(:facet_field) do
|
92
|
+
instance_double(
|
93
|
+
Blacklight::FacetFieldPresenter,
|
94
|
+
paginator: paginator,
|
95
|
+
key: 'field',
|
96
|
+
label: 'Field',
|
97
|
+
active?: false,
|
98
|
+
collapsed?: false,
|
99
|
+
modal_path: '/catalog/facet/modal',
|
100
|
+
html_id: 'facet-field'
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'renders a link to the modal' do
|
105
|
+
expect(rendered).to have_link 'more Field', href: '/catalog/facet/modal'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|