blacklight 7.17.2 → 7.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/assets/javascripts/blacklight/blacklight.js +1 -2
  4. data/app/assets/stylesheets/blacklight/_balanced_list.scss +2 -2
  5. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +1 -1
  6. data/app/assets/stylesheets/blacklight/_constraints.scss +2 -2
  7. data/app/assets/stylesheets/blacklight/_controls.scss +2 -1
  8. data/app/assets/stylesheets/blacklight/_facets.scss +3 -1
  9. data/app/assets/stylesheets/blacklight/_header.scss +6 -1
  10. data/app/components/blacklight/constraint_layout_component.html.erb +1 -1
  11. data/app/components/blacklight/constraints_component.html.erb +2 -2
  12. data/app/components/blacklight/content_areas_shim.rb +2 -1
  13. data/app/components/blacklight/document/thumbnail_component.html.erb +3 -3
  14. data/app/components/blacklight/document/thumbnail_component.rb +11 -3
  15. data/app/components/blacklight/document_component.rb +7 -7
  16. data/app/components/blacklight/facet_field_component.html.erb +3 -1
  17. data/app/components/blacklight/facet_field_no_layout_component.rb +1 -1
  18. data/app/components/blacklight/facet_item_component.rb +2 -2
  19. data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
  20. data/app/components/blacklight/metadata_field_layout_component.rb +1 -1
  21. data/app/components/blacklight/response/facet_group_component.html.erb +2 -0
  22. data/app/components/blacklight/response/view_type_component.html.erb +1 -1
  23. data/app/components/blacklight/search_bar_component.html.erb +3 -3
  24. data/app/components/blacklight/system/dropdown_component.rb +1 -1
  25. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  26. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  27. data/app/helpers/blacklight/component_helper_behavior.rb +1 -1
  28. data/app/helpers/blacklight/render_partials_helper_behavior.rb +5 -1
  29. data/app/javascript/blacklight/modal.js +1 -1
  30. data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
  31. data/app/views/bookmarks/index.html.erb +1 -1
  32. data/app/views/catalog/_constraints.html.erb +2 -2
  33. data/app/views/catalog/_document.html.erb +4 -3
  34. data/app/views/catalog/_document_list.html.erb +3 -2
  35. data/app/views/catalog/_home_text.html.erb +1 -1
  36. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  37. data/app/views/catalog/_search_results.html.erb +2 -2
  38. data/app/views/search_history/index.html.erb +1 -1
  39. data/app/views/shared/_header_navbar.html.erb +1 -1
  40. data/config/locales/blacklight.ar.yml +2 -2
  41. data/config/locales/blacklight.ca.yml +2 -2
  42. data/config/locales/blacklight.de.yml +2 -2
  43. data/config/locales/blacklight.en.yml +2 -2
  44. data/config/locales/blacklight.es.yml +2 -2
  45. data/config/locales/blacklight.fr.yml +2 -2
  46. data/config/locales/blacklight.hu.yml +2 -2
  47. data/config/locales/blacklight.it.yml +2 -2
  48. data/config/locales/blacklight.nl.yml +2 -2
  49. data/config/locales/blacklight.pt-BR.yml +1 -1
  50. data/config/locales/blacklight.sq.yml +2 -2
  51. data/config/locales/blacklight.zh.yml +2 -2
  52. data/lib/blacklight/configuration.rb +7 -1
  53. data/lib/blacklight/configuration/view_config.rb +3 -1
  54. data/lib/blacklight/nested_open_struct_with_hash_access.rb +33 -14
  55. data/lib/blacklight/open_struct_with_hash_access.rb +1 -1
  56. data/lib/blacklight/search_builder.rb +1 -0
  57. data/lib/blacklight/solr/request.rb +10 -7
  58. data/lib/blacklight/solr/search_builder_behavior.rb +28 -16
  59. data/lib/generators/blacklight/install_generator.rb +5 -5
  60. data/lib/generators/blacklight/solr_generator.rb +4 -2
  61. data/lib/generators/blacklight/user_generator.rb +4 -2
  62. data/spec/components/blacklight/constraint_layout_component_spec.rb +3 -7
  63. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +3 -7
  64. data/spec/components/blacklight/facet_field_list_component_spec.rb +3 -7
  65. data/spec/components/blacklight/facet_item_component_spec.rb +2 -6
  66. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +3 -7
  67. data/spec/components/blacklight/hidden_search_state_component_spec.rb +7 -8
  68. data/spec/components/blacklight/metadata_field_component_spec.rb +4 -8
  69. data/spec/features/facets_spec.rb +2 -2
  70. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +9 -10
  71. data/spec/helpers/blacklight_helper_spec.rb +20 -2
  72. data/spec/helpers/catalog_helper_spec.rb +1 -1
  73. data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +36 -0
  74. data/spec/models/blacklight/configuration_spec.rb +10 -0
  75. data/spec/models/blacklight/solr/request_spec.rb +0 -1
  76. data/spec/models/blacklight/solr/search_builder_spec.rb +23 -1
  77. data/spec/services/blacklight/search_service_spec.rb +1 -1
  78. data/spec/spec_helper.rb +1 -0
  79. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  80. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
  81. data/spec/views/catalog/_document.html.erb_spec.rb +9 -0
  82. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  83. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
  84. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +5 -5
  85. metadata +4 -2
@@ -1,6 +1,7 @@
1
1
  <% # container for a single doc -%>
2
- <%= render (blacklight_config.view_config(document_index_view_type).document_component || Blacklight::DocumentComponent).new(presenter: document_presenter(document), counter: document_counter_with_offset(document_counter)) do |component| %>
3
- <% component.public_send(blacklight_config.view_config(document_index_view_type).document_component.blank? && blacklight_config.view_config(document_index_view_type).partials.any? ? :body : :partial) do %>
4
- <%= render_document_partials document, blacklight_config.view_config(document_index_view_type).partials, component: component, document_counter: document_counter %>
2
+ <% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type) %>
3
+ <%= render (view_config.document_component || Blacklight::DocumentComponent).new(presenter: document_presenter(document), counter: document_counter_with_offset(document_counter)) do |component| %>
4
+ <% component.public_send(view_config.document_component.blank? && view_config.partials.any? ? :body : :partial) do %>
5
+ <%= render_document_partials document, view_config.partials, component: component, document_counter: document_counter %>
5
6
  <% end %>
6
7
  <% end %>
@@ -1,4 +1,5 @@
1
1
  <% # container for all documents in index list view -%>
2
- <div id="documents" class="documents-<%= document_index_view_type %>">
3
- <%= render documents, :as => :document %>
2
+ <% view_config = local_assigns[:view_config] || blacklight_config&.view_config(document_index_view_type) %>
3
+ <div id="documents" class="documents-<%= view_config&.key || document_index_view_type %>">
4
+ <%= render documents, as: :document, view_config: view_config %>
4
5
  </div>
@@ -31,7 +31,7 @@
31
31
 
32
32
  <%# This is the same panel shown in the Rails welcome template %>
33
33
  <div id="about" class="card">
34
- <h2 class='card-header collapsed collapse-toggle' data-toggle="collapse" data-target="#about-content"><a href="/rails/info/properties">About your application&rsquo;s environment</a></h2>
34
+ <h2 class='card-header collapsed collapse-toggle' data-toggle="collapse" data-bs-toggle="collapse" data-bs-target="#about-content" data-target="#about-content"><a href="/rails/info/properties">About your application&rsquo;s environment</a></h2>
35
35
  <div id="about-content" class="card-body collapse"></div>
36
36
  </div>
37
37
 
@@ -1,5 +1,5 @@
1
1
  <% if show_sort_and_per_page? %>
2
- <span class="sr-only"><%= t('blacklight.search.per_page.title') %></span>
2
+ <span class="sr-only visually-hidden"><%= t('blacklight.search.per_page.title') %></span>
3
3
  <%= render(Blacklight::System::DropdownComponent.new(
4
4
  param: :per_page,
5
5
  choices: per_page_options_for_select,
@@ -12,14 +12,14 @@
12
12
  <% end %>
13
13
 
14
14
  <% content_for(:container_header) do -%>
15
- <h1 class="sr-only top-content-title"><%= t('blacklight.search.header') %></h1>
15
+ <h1 class="sr-only visually-hidden top-content-title"><%= t('blacklight.search.header') %></h1>
16
16
 
17
17
  <%= render 'constraints' %>
18
18
  <% end %>
19
19
 
20
20
  <%= render 'search_header' %>
21
21
 
22
- <h2 class="sr-only"><%= t('blacklight.search.search_results') %></h2>
22
+ <h2 class="sr-only visually-hidden"><%= t('blacklight.search.search_results') %></h2>
23
23
 
24
24
  <%- if @response.empty? %>
25
25
  <%= render "zero_results" %>
@@ -9,7 +9,7 @@
9
9
  blacklight.clear_search_history_path,
10
10
  method: :delete,
11
11
  data: { confirm: t('blacklight.search_history.clear.action_confirm') },
12
- class: 'btn btn-danger float-md-right' %>
12
+ class: 'btn btn-danger float-md-right float-md-end' %>
13
13
  <h2 class='section-heading'><%= t('blacklight.search_history.recent') %></h2>
14
14
  <table class="table table-striped search-history">
15
15
  <% @searches.each_with_index do |search,index| %>
@@ -1,7 +1,7 @@
1
1
  <nav class="navbar navbar-expand-md navbar-dark bg-dark topbar" role="navigation">
2
2
  <div class="<%= container_classes %>">
3
3
  <%= link_to application_name, root_path, class: 'mb-0 navbar-brand navbar-logo' %>
4
- <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#user-util-collapse" aria-controls="user-util-collapse" aria-expanded="false" aria-label="Toggle navigation">
4
+ <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-bs-toggle="collapse" data-target="#user-util-collapse" data-bs-target="#user-util-collapse" aria-controls="user-util-collapse" aria-expanded="false" aria-label="Toggle navigation">
5
5
  <span class="navbar-toggler-icon"></span>
6
6
  </button>
7
7
 
@@ -157,7 +157,7 @@ ar:
157
157
  request_error: "معذرة، لم أفهم ما تبحث عنه."
158
158
  invalid_solr_id: "معذرة! لقد طلبت سجلًا غير موجود."
159
159
  per_page:
160
- label: '%{count}<span class="sr-only"> لكل صفحة</span>'
160
+ label: '%{count}<span class="sr-only visually-hidden"> لكل صفحة</span>'
161
161
  button_label: '%{count} لكل صفحة' # TODO: Remove during major release
162
162
  button_label_html: '%{count}<span class="d-none d-sm-inline"> لكل صفحة</span>'
163
163
  title: 'عدد النتائج المعروضة في الصفحة'
@@ -209,7 +209,7 @@ ar:
209
209
  count: 'ترتيب رقمي'
210
210
  index: 'ترتيب أبجدي'
211
211
  count: '%{number}'
212
- more_html: 'المزيد <span class="sr-only">%{field_name}</span> »'
212
+ more_html: 'المزيد <span class="sr-only visually-hidden">%{field_name}</span> »'
213
213
  selected:
214
214
  remove: '[إزالة]'
215
215
  missing: "[غير موجود]"
@@ -147,7 +147,7 @@ ca:
147
147
  request_error: "No ha estat possible entendre la cerca"
148
148
  invalid_solr_id: "El registre que heu sol·licitat no existeix."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> per pàgina</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> per pàgina</span>'
151
151
  button_label: '%{count} per pàgina' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> per pàgina</span>'
153
153
  title: 'Nombre de resultats a mostrar per pàgina'
@@ -189,7 +189,7 @@ ca:
189
189
  count: 'Numèricament'
190
190
  index: 'Alfabèticament'
191
191
  count: '%{number}'
192
- more_html: 'més <span class="sr-only">%{field_name}</span> »'
192
+ more_html: 'més <span class="sr-only visually-hidden">%{field_name}</span> »'
193
193
  selected:
194
194
  remove: '[eliminar]'
195
195
  missing: "[Desaparegut]"
@@ -147,7 +147,7 @@ de:
147
147
  request_error: "Entschuldigung, ich habe Ihre Suche nicht verstanden."
148
148
  invalid_solr_id: "Entschuldigung, Sie haben einen nicht vorhandenen Datensatz angefordert."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> pro Seite</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> pro Seite</span>'
151
151
  button_label: '%{count} pro Seite' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> pro Seite</span>'
153
153
  title: 'Anzahl der Ergebnisse, die pro Seite angezeigt werden'
@@ -190,7 +190,7 @@ de:
190
190
  count: 'Numerisch ordnen'
191
191
  index: 'A-Z Ordnen'
192
192
  count: '%{number}'
193
- more_html: 'mehr <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'mehr <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[entfernen]'
196
196
  missing: [fehlt]
@@ -147,7 +147,7 @@ en:
147
147
  request_error: "Sorry, I don't understand your search."
148
148
  invalid_solr_id: "Sorry, you have requested a record that doesn't exist."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> per page</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> per page</span>'
151
151
  button_label: '%{count} per page' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> per page</span>'
153
153
  title: 'Number of results to display per page'
@@ -189,7 +189,7 @@ en:
189
189
  count: 'Numerical Sort'
190
190
  index: 'A-Z Sort'
191
191
  count: '%{number}'
192
- more_html: 'more <span class="sr-only">%{field_name}</span> »'
192
+ more_html: 'more <span class="sr-only visually-hidden">%{field_name}</span> »'
193
193
  selected:
194
194
  remove: '[remove]'
195
195
  missing: "[Missing]"
@@ -147,7 +147,7 @@ es:
147
147
  request_error: "Lo siento, no entiendo esta búsqueda"
148
148
  invalid_solr_id: "Lo sentimos, usted ha solicitado un registro que no existe."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> por página</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> por página</span>'
151
151
  button_label: '%{count} por página' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> por página</span>'
153
153
  title: 'El número de resultados a mostrar por página'
@@ -190,7 +190,7 @@ es:
190
190
  count: 'Ordenación numérica'
191
191
  index: 'Ordenación A-Z'
192
192
  count: '%{number}'
193
- more_html: 'más <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'más <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[borrar]'
196
196
  missing: '[Falta]'
@@ -150,7 +150,7 @@ fr:
150
150
  request_error: "Pardon, nous n'avons pas compris votre recherche."
151
151
  invalid_solr_id: "Vous avez demandé une notice qui n'existe pas."
152
152
  per_page:
153
- label: '%{count}<span class="sr-only"> par page</span>'
153
+ label: '%{count}<span class="sr-only visually-hidden"> par page</span>'
154
154
  button_label: '%{count} par page' # TODO: Remove during major release
155
155
  button_label_html: '%{count}<span class="d-none d-sm-inline"> par page</span>'
156
156
  title: 'Nombre de résultats à afficher par page'
@@ -193,7 +193,7 @@ fr:
193
193
  count: 'Du + au - fréquent'
194
194
  index: 'Tri de A à Z'
195
195
  count: '%{number}'
196
- more_html: 'plus <span class="sr-only">%{field_name}</span> »'
196
+ more_html: 'plus <span class="sr-only visually-hidden">%{field_name}</span> »'
197
197
  selected:
198
198
  remove: '[ X ]'
199
199
  missing: '[manquante]'
@@ -147,7 +147,7 @@ hu:
147
147
  request_error: "Elnézést, nem tudom értelmezni a keresést."
148
148
  invalid_solr_id: "Elnézést, de az Ön által kért rekord nem létezik."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> oldalanként</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> oldalanként</span>'
151
151
  button_label: '%{count} oldalanként' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> oldalanként</span>'
153
153
  title: 'Az eredmények száma oldalanként'
@@ -190,7 +190,7 @@ hu:
190
190
  count: 'Numerikus rendezés'
191
191
  index: 'A-Z rendezés'
192
192
  count: '%{number}'
193
- more_html: 'több <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'több <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[eltávolítás]'
196
196
  missing: "[Hiányzó]"
@@ -147,7 +147,7 @@ it:
147
147
  request_error: "La richiesta non è comprensibile."
148
148
  invalid_solr_id: "Il numero di scheda richiesto non esiste."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> per pagina</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> per pagina</span>'
151
151
  button_label: '%{count} per pagina' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> per pagina</span>'
153
153
  title: 'Risultati per pagina'
@@ -190,7 +190,7 @@ it:
190
190
  count: 'Ordina per numero'
191
191
  index: 'Ordina A-Z'
192
192
  count: '%{number}'
193
- more_html: 'altri <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'altri <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[cancella]'
196
196
  missing: [Mancante]
@@ -147,7 +147,7 @@ nl:
147
147
  request_error: "Sorry, ik kon uw zoekopdracht niet begrijpen."
148
148
  invalid_solr_id: "Sorry, u vroeg een onbestaande record op."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> per pagina</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> per pagina</span>'
151
151
  button_label: '%{count} per pagina' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> per pagina</span>'
153
153
  title: 'Toon aantal zoekresultaten per pagina'
@@ -190,7 +190,7 @@ nl:
190
190
  count: 'Numeriek sorteren'
191
191
  index: 'A-Z Sorteren'
192
192
  count: '%{number}'
193
- more_html: 'Meer <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'Meer <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[verwijder]'
196
196
  missing: "[Ontbrekend]"
@@ -191,7 +191,7 @@ pt-BR:
191
191
  count: 'Ordenar por Número'
192
192
  index: 'Ordem Alfabética A-Z'
193
193
  count: '%{number}'
194
- more_html: 'mais <span class="sr-only">%{field_name}</span> »'
194
+ more_html: 'mais <span class="sr-only visually-hidden">%{field_name}</span> »'
195
195
  selected:
196
196
  remove: '[remover]'
197
197
  missing: [Ausência]
@@ -147,7 +147,7 @@ sq:
147
147
  request_error: "Na vjen keq, unë nuk e kuptoj kërkimin tuaj."
148
148
  invalid_solr_id: "Na vjen keq, ju keni kërkuar një të dhënë që nuk ekziston."
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> për faqe</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> për faqe</span>'
151
151
  button_label: '%{count} për faqe' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> për faqe</span>'
153
153
  title: 'Numri i rezultateve që do të shfaqen për faqe'
@@ -190,7 +190,7 @@ sq:
190
190
  count: 'Renditja numerike'
191
191
  index: 'A-Z Renditja'
192
192
  count: '%{number}'
193
- more_html: 'Më shumë <span class="sr-only">%{field_name}</span> »'
193
+ more_html: 'Më shumë <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[fshije]'
196
196
  missing: "[Mungon]"
@@ -147,7 +147,7 @@ zh:
147
147
  request_error: "抱歉,我不明白你要找什么。"
148
148
  invalid_solr_id: "抱歉,你要找的结果不存在。"
149
149
  per_page:
150
- label: '%{count}<span class="sr-only"> 每页</span>'
150
+ label: '%{count}<span class="sr-only visually-hidden"> 每页</span>'
151
151
  button_label: '%{count} 每页' # TODO: Remove during major release
152
152
  button_label_html: '%{count}<span class="d-none d-sm-inline"> 每页</span>'
153
153
  title: '每页显示结果数'
@@ -190,7 +190,7 @@ zh:
190
190
  count: '按数量排序'
191
191
  index: '按字母排序'
192
192
  count: '%{number}'
193
- more_html: '更多 <span class="sr-only">%{field_name}</span> »'
193
+ more_html: '更多 <span class="sr-only visually-hidden">%{field_name}</span> »'
194
194
  selected:
195
195
  remove: '[删除]'
196
196
  missing: "[未找到]"
@@ -170,6 +170,8 @@ module Blacklight
170
170
  def initialize(hash = {})
171
171
  super(self.class.default_values.deep_dup.merge(hash))
172
172
  yield(self) if block_given?
173
+
174
+ @view_config ||= {}
173
175
  end
174
176
 
175
177
  def document_model
@@ -333,7 +335,6 @@ module Blacklight
333
335
  view_type = nil
334
336
  end
335
337
 
336
- @view_config ||= {}
337
338
  @view_config[[view_type, action_name]] ||= begin
338
339
  if view_type.nil?
339
340
  action_config(action_name)
@@ -428,6 +429,11 @@ module Blacklight
428
429
  fields.merge(show_fields)
429
430
  end
430
431
 
432
+ def freeze
433
+ each { |_k, v| v.is_a?(OpenStruct) && v.freeze }
434
+ super
435
+ end
436
+
431
437
  private
432
438
 
433
439
  def add_action(config_hash, name, opts)
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  class Blacklight::Configuration
3
3
  class ViewConfig < Blacklight::OpenStructWithHashAccess
4
+ # @!attribute template
5
+ # @return [String] partial to render around the documents
4
6
  # @!attribute partials
5
7
  # @return [Array<String>] partials to render for each document(see #render_document_partials)
6
8
  # @!attribute document_presenter_class
@@ -20,7 +22,7 @@ class Blacklight::Configuration
20
22
  end
21
23
 
22
24
  def display_label(deprecated_key = nil, **options)
23
- Deprecation.warn('Passing the key argument to ViewConfig#display_label is deprecated') if deprecated_key.present?
25
+ Deprecation.warn(Blacklight::Configuration::ViewConfig, 'Passing the key argument to ViewConfig#display_label is deprecated') if deprecated_key.present?
24
26
 
25
27
  I18n.t(
26
28
  :"blacklight.search.view_title.#{deprecated_key || key}",
@@ -5,18 +5,21 @@ module Blacklight
5
5
  # An OpenStruct refinement that converts any hash-keys into
6
6
  # additional instances of NestedOpenStructWithHashAccess
7
7
  class NestedOpenStructWithHashAccess < OpenStructWithHashAccess
8
+ extend Deprecation
9
+ self.deprecation_horizon = 'blacklight 8.0'
10
+
8
11
  attr_reader :nested_class
9
12
 
10
13
  delegate :default_proc=, to: :to_h
11
14
 
12
15
  def initialize(klass, hash = {})
13
16
  @nested_class = klass
14
- value = hash.transform_values do |v|
15
- if v.is_a? Hash
16
- nested_class.new(v)
17
- else
18
- v
19
- end
17
+ value = hash.each_with_object({}) do |(k, v), h|
18
+ h[k] = if v.is_a? Hash
19
+ nested_class.new({ key: k.to_sym }.merge(v))
20
+ else
21
+ v
22
+ end
20
23
  end
21
24
 
22
25
  super value
@@ -34,7 +37,7 @@ module Blacklight
34
37
  # into another NestedOpenStructWithHashAccess
35
38
  def []=(key, value)
36
39
  if value.is_a? Hash
37
- send "#{key}=", nested_class.new(value)
40
+ send "#{key}=", nested_class.new({ key: key.to_sym }.merge(value))
38
41
  else
39
42
  super
40
43
  end
@@ -86,15 +89,31 @@ module Blacklight
86
89
  ##
87
90
  # Override #method_missing from OpenStruct to ensure the default_proc logic
88
91
  # gets triggered.
89
- def method_missing(mid, *args)
92
+ def method_missing(mid, *args, **kwargs, &block)
90
93
  len = args.length
91
94
 
92
- if len.zero?
93
- new_ostruct_member!(mid)
94
- @table[mid]
95
- else
96
- super
97
- end
95
+ res = if mid.to_s.end_with?('!')
96
+ m = mid[0...-1].to_sym
97
+ new_ostruct_member!(m)
98
+ @table[m]
99
+ elsif mid.to_s.end_with?('=')
100
+ m = mid[0...-1].to_sym
101
+ new_ostruct_member!(m)
102
+ @table[m] = args.first
103
+ elsif len.zero? && kwargs.blank? && !block
104
+ Deprecation.warn(Blacklight::NestedOpenStructWithHashAccess,
105
+ "Initializing a #{nested_class} implicitly (by calling #{mid}) is deprecated. Call it as #{mid}! or pass initialize arguments")
106
+
107
+ new_ostruct_member!(mid)
108
+ @table[mid]
109
+ else
110
+ new_ostruct_member!(mid)
111
+ @table[mid] = nested_class.new(key: mid, **(args.first || {}), **kwargs)
112
+ end
113
+
114
+ block&.call(res)
115
+
116
+ res
98
117
  end
99
118
 
100
119
  private
@@ -6,7 +6,7 @@ module Blacklight
6
6
  class OpenStructWithHashAccess < OpenStruct
7
7
  delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?,
8
8
  :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!,
9
- :replace, :fetch, :to_json, :as_json, :any?, to: :to_h
9
+ :replace, :fetch, :to_json, :as_json, :any?, :freeze, :unfreeze, :frozen?, to: :to_h
10
10
 
11
11
  ##
12
12
  # Expose the internal hash
@@ -45,6 +45,7 @@ module Blacklight
45
45
  ##
46
46
  # Update the :q (query) parameter
47
47
  def where(conditions)
48
+ Deprecation.warn(Blacklight::SearchBuilder, "SearchBuilder#where must be called with a hash, received #{conditions.inspect}.") unless conditions.is_a? Hash
48
49
  params_will_change!
49
50
  @search_state = @search_state.reset(@search_state.params.merge(q: conditions))
50
51
  @blacklight_params = @search_state.params.dup
@@ -2,7 +2,10 @@
2
2
  class Blacklight::Solr::InvalidParameter < ArgumentError; end
3
3
 
4
4
  class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
5
+ # @deprecated
5
6
  SINGULAR_KEYS = %w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
7
+
8
+ # @deprecated
6
9
  ARRAY_KEYS = %w(facet.field facet.query facet.pivot fq hl.fl)
7
10
 
8
11
  def initialize(constructor = {})
@@ -12,9 +15,6 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
12
15
  else
13
16
  super(constructor)
14
17
  end
15
- ARRAY_KEYS.each do |key|
16
- self[key] ||= []
17
- end
18
18
  end
19
19
 
20
20
  def append_query(query)
@@ -49,26 +49,29 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
49
49
  end
50
50
 
51
51
  def append_filter_query(query)
52
+ self['fq'] ||= []
53
+ self['fq'] = Array(self['fq']) if self['fq'].is_a? String
54
+
52
55
  self['fq'] << query
53
56
  end
54
57
 
55
58
  def append_facet_fields(values)
59
+ self['facet.field'] ||= []
56
60
  self['facet.field'] += Array(values)
57
61
  end
58
62
 
59
63
  def append_facet_query(values)
64
+ self['facet.query'] ||= []
60
65
  self['facet.query'] += Array(values)
61
66
  end
62
67
 
63
68
  def append_facet_pivot(query)
69
+ self['facet.pivot'] ||= []
64
70
  self['facet.pivot'] << query
65
71
  end
66
72
 
67
73
  def append_highlight_field(query)
74
+ self['hl.fl'] ||= []
68
75
  self['hl.fl'] << query
69
76
  end
70
-
71
- def to_hash
72
- reject { |key, value| ARRAY_KEYS.include?(key) && value.blank? }
73
- end
74
77
  end