blacklight 9.0.0.beta6 → 9.0.0.beta7

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/matrix.json +8 -1
  3. data/.solr_wrapper.yml +1 -1
  4. data/VERSION +1 -1
  5. data/app/assets/javascripts/blacklight/blacklight.esm.js +2 -1
  6. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  7. data/app/assets/javascripts/blacklight/blacklight.js +2 -1
  8. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  9. data/app/components/blacklight/constraints_component.html.erb +3 -8
  10. data/app/components/blacklight/constraints_component.rb +57 -14
  11. data/app/components/blacklight/document/bookmark_component.rb +1 -1
  12. data/app/components/blacklight/document/page_header_component.rb +1 -1
  13. data/app/components/blacklight/document_component.rb +15 -16
  14. data/app/components/blacklight/facet_item_pivot_component.rb +4 -0
  15. data/app/components/blacklight/facets/item_component.rb +3 -0
  16. data/app/components/blacklight/facets/selected_value_component.rb +1 -1
  17. data/app/components/blacklight/header_component.rb +2 -2
  18. data/app/controllers/concerns/blacklight/catalog.rb +8 -4
  19. data/app/javascript/blacklight-frontend/facet_suggest.js +2 -1
  20. data/app/presenters/blacklight/constraint_presenter.rb +22 -0
  21. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
  22. data/app/presenters/blacklight/facet_item_presenter.rb +0 -18
  23. data/app/views/catalog/_document.atom.builder +1 -1
  24. data/app/views/catalog/_document.html.erb +1 -1
  25. data/app/views/catalog/_show_main_content.html.erb +1 -1
  26. data/blacklight.gemspec +1 -1
  27. data/config/locales/blacklight.ar.yml +1 -2
  28. data/config/locales/blacklight.ca.yml +1 -2
  29. data/config/locales/blacklight.de.yml +1 -2
  30. data/config/locales/blacklight.en.yml +1 -2
  31. data/config/locales/blacklight.es.yml +1 -2
  32. data/config/locales/blacklight.fr.yml +1 -2
  33. data/config/locales/blacklight.hu.yml +1 -2
  34. data/config/locales/blacklight.it.yml +1 -2
  35. data/config/locales/blacklight.nl.yml +1 -2
  36. data/config/locales/blacklight.pt-BR.yml +1 -2
  37. data/config/locales/blacklight.sq.yml +1 -2
  38. data/config/locales/blacklight.zh.yml +1 -2
  39. data/lib/blacklight/component.rb +5 -1
  40. data/lib/blacklight/configuration/facet_field.rb +2 -0
  41. data/lib/blacklight/configuration.rb +2 -0
  42. data/lib/generators/blacklight/templates/.solr_wrapper.yml +1 -1
  43. data/package.json +1 -1
  44. data/spec/components/blacklight/constraints_component_spec.rb +2 -2
  45. data/spec/components/blacklight/document_component_spec.rb +9 -9
  46. data/spec/components/blacklight/facets/index_navigation_component_spec.rb +2 -1
  47. data/spec/components/blacklight/facets/suggest_component_spec.rb +2 -1
  48. data/spec/features/search_filters_spec.rb +3 -3
  49. data/spec/features/search_spec.rb +3 -3
  50. data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
  51. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
  52. data/spec/support/presenter_test_helpers.rb +1 -1
  53. data/spec/views/catalog/index.atom.builder_spec.rb +2 -0
  54. metadata +16 -7
@@ -33,40 +33,39 @@ module Blacklight
33
33
  renders_one :body
34
34
 
35
35
  # The document title with some reasonable default behavior
36
- renders_one :title, (lambda do |*args, component: nil, **kwargs|
36
+ renders_one :title, (lambda do |component: nil, **kwargs|
37
37
  component ||= view_config.title_component || Blacklight::DocumentTitleComponent
38
38
 
39
- component.new(*args, counter: @counter, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
39
+ component.new(counter: @counter, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
40
40
  end)
41
41
 
42
- renders_one :embed, (lambda do |static_content = nil, *args, component: nil, **kwargs|
42
+ renders_one :embed, (lambda do |static_content = nil, component: nil, **kwargs|
43
43
  next static_content if static_content.present?
44
44
 
45
45
  component ||= view_config.embed_component
46
46
 
47
47
  next unless component
48
48
 
49
- component.new(*args, presenter: @presenter, document_counter: @document_counter, **kwargs)
49
+ component.new(presenter: @presenter, document_counter: @document_counter, **kwargs)
50
50
  end)
51
51
 
52
52
  # The primary metadata section
53
- renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
53
+ renders_one :metadata, (lambda do |static_content = nil, component: nil, fields: nil, **kwargs|
54
54
  next static_content if static_content.present?
55
55
 
56
56
  component ||= view_config.metadata_component || Blacklight::DocumentMetadataComponent
57
-
58
- component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
57
+ component.new(fields: fields || @presenter&.field_presenters || [], **kwargs)
59
58
  end)
60
59
 
61
60
  # Additional metadata sections
62
61
  renders_many :metadata_sections
63
62
 
64
- renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, *args, component: nil, **kwargs|
63
+ renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, component: nil, **kwargs|
65
64
  next image_options_or_static_content if image_options_or_static_content.is_a? String
66
65
 
67
66
  component ||= view_config.thumbnail_component || Blacklight::Document::ThumbnailComponent
68
67
 
69
- component.new(*args, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
68
+ component.new(presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
70
69
  end)
71
70
 
72
71
  # A container for partials rendered using the view config partials configuration. Its use is discouraged, but necessary until
@@ -90,8 +89,8 @@ module Blacklight
90
89
  def initialize(document: nil, partials: nil,
91
90
  id: nil, classes: [], component: :article, title_component: nil,
92
91
  counter: nil, document_counter: nil, counter_offset: 0,
93
- show: false, **args)
94
- @presenter = document || args[self.class.collection_parameter]
92
+ show: false)
93
+ @presenter = document
95
94
  @document = @presenter.document
96
95
  @view_partials = partials || []
97
96
 
@@ -101,7 +100,7 @@ module Blacklight
101
100
  @classes = classes
102
101
 
103
102
  @counter = counter
104
- @document_counter = document_counter || args.fetch(self.class.collection_counter_parameter, nil)
103
+ @document_counter = document_counter
105
104
  @counter ||= 1 + @document_counter + counter_offset if @document_counter.present?
106
105
 
107
106
  @show = show
@@ -119,10 +118,10 @@ module Blacklight
119
118
  end
120
119
 
121
120
  def before_render
122
- set_slot(:title, nil) unless title
123
- set_slot(:thumbnail, nil) unless thumbnail || show?
124
- set_slot(:metadata, nil, fields: presenter.field_presenters, show: @show) unless metadata
125
- set_slot(:embed, nil) unless embed
121
+ with_title unless title
122
+ with_thumbnail unless thumbnail || show?
123
+ with_metadata(fields: presenter.field_presenters, show: @show) unless metadata
124
+ with_embed unless embed
126
125
 
127
126
  view_partials.each do |view_partial|
128
127
  with_partial(view_partial) do
@@ -19,6 +19,10 @@ module Blacklight
19
19
 
20
20
  with_collection_parameter :facet_item
21
21
 
22
+ # @param [Blacklight::FacetItemPivotPresenter] facet_item
23
+ # @param [String] wrapping_element
24
+ # @param [Boolean] suppress_link
25
+ # @param [Boolean] collapsing
22
26
  def initialize(facet_item:, wrapping_element: 'li', suppress_link: false, collapsing: nil)
23
27
  @facet_item = facet_item
24
28
  @wrapping_element = wrapping_element
@@ -7,6 +7,9 @@ module Blacklight
7
7
 
8
8
  with_collection_parameter :facet_item
9
9
 
10
+ # @param [Blacklight::FacetItemPresenter] facet_item
11
+ # @param [String] wrapping_element
12
+ # @param [Boolean] suppress_link
10
13
  def initialize(facet_item:, wrapping_element: 'li', suppress_link: false)
11
14
  @facet_item = facet_item
12
15
  @label = facet_item.label
@@ -7,7 +7,7 @@ module Blacklight
7
7
  def initialize(label:, href:)
8
8
  @label = label
9
9
  @href = href
10
- super
10
+ super()
11
11
  end
12
12
 
13
13
  attr_reader :label, :href
@@ -19,8 +19,8 @@ module Blacklight
19
19
  # Hack so that the default lambdas are triggered
20
20
  # so that we don't have to do c.with_top_bar() in the call.
21
21
  def before_render
22
- set_slot(:top_bar, nil) unless top_bar
23
- set_slot(:search_bar, nil) unless search_bar
22
+ with_top_bar unless top_bar
23
+ with_search_bar unless search_bar
24
24
  end
25
25
  end
26
26
  end
@@ -29,10 +29,7 @@ module Blacklight::Catalog
29
29
  format.html { store_preferred_view }
30
30
  format.rss { render layout: false }
31
31
  format.atom { render layout: false }
32
- format.json do
33
- @presenter = Blacklight::JsonPresenter.new(@response,
34
- blacklight_config)
35
- end
32
+ format.json { @presenter = json_presenter(@response) }
36
33
  additional_response_formats(format)
37
34
  document_export_formats(format)
38
35
  end
@@ -143,7 +140,14 @@ module Blacklight::Catalog
143
140
 
144
141
  private
145
142
 
143
+ # @param [Blacklight::Solr::Response] repository_response
144
+ # @return [Blacklight::JsonPresenter]
145
+ def json_presenter(repository_response)
146
+ blacklight_config.index.json_presenter_class.new(repository_response, blacklight_config)
147
+ end
148
+
146
149
  # This method may be overridden to customize search behavior.
150
+ # @return [Blacklight::Solr::Response] the solr response object
147
151
  def retrieve_search_results
148
152
  search_service.search_results
149
153
  end
@@ -17,8 +17,9 @@ const FacetSuggest = async (e) => {
17
17
  // Drop facet.page so a filtered suggestion list will always start on page 1
18
18
  url.searchParams.delete('facet.page');
19
19
  const facetSearchParams = url.searchParams.toString();
20
+ const basePathComponent = url.pathname.split('/')[1];
20
21
 
21
- const urlToFetch = `/catalog/facet_suggest/${facetField}/${queryFragment}?${facetSearchParams}`;
22
+ const urlToFetch = `/${basePathComponent}/facet_suggest/${facetField}/${queryFragment}?${facetSearchParams}`;
22
23
 
23
24
  const response = await fetch(urlToFetch);
24
25
  if (response.ok) {
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class ConstraintPresenter
5
+ def initialize(facet_item_presenter:, field_label:)
6
+ @facet_item_presenter = facet_item_presenter
7
+ @field_label = field_label
8
+ end
9
+
10
+ attr_accessor :facet_item_presenter, :field_label
11
+
12
+ delegate :key, :remove_href, to: :facet_item_presenter
13
+
14
+ # Get the displayable version of the facet's value for use
15
+ # in e.g. the constraints widget
16
+ #
17
+ # @return [String]
18
+ def constraint_label
19
+ facet_item_presenter.label
20
+ end
21
+ end
22
+ end
@@ -13,10 +13,6 @@ module Blacklight
13
13
  selected? || facet_item_presenters.any? { |x| x.try(:shown?) }
14
14
  end
15
15
 
16
- def field_label
17
- facet_field_presenter.label
18
- end
19
-
20
16
  def facet_item_presenters
21
17
  return to_enum(:facet_item_presenters) unless block_given?
22
18
  return [] unless items
@@ -25,7 +21,7 @@ module Blacklight
25
21
  end
26
22
 
27
23
  def facet_item_presenter(facet_item)
28
- facet_field_presenter.item_presenter(facet_item)
24
+ view_context.facet_field_presenter(facet_config, {}).item_presenter(facet_item)
29
25
  end
30
26
 
31
27
  ##
@@ -38,10 +38,6 @@ module Blacklight
38
38
  search_state.filter(facet_config).include?(value)
39
39
  end
40
40
 
41
- def field_label
42
- facet_field_presenter.label
43
- end
44
-
45
41
  ##
46
42
  # Get the displayable version of a facet's value
47
43
  #
@@ -67,14 +63,6 @@ module Blacklight
67
63
  end
68
64
  end
69
65
 
70
- # Get the displayable version of the facet's value for use
71
- # in e.g. the constraints widget
72
- #
73
- # @return [String]
74
- def constraint_label
75
- label
76
- end
77
-
78
66
  def value
79
67
  if facet_item.respond_to? :value
80
68
  facet_item.value
@@ -104,11 +92,5 @@ module Blacklight
104
92
  view_context.search_action_path(search_state.add_facet_params_and_redirect(facet_config.key, facet_item).merge(path_options))
105
93
  end
106
94
  end
107
-
108
- private
109
-
110
- def facet_field_presenter
111
- @facet_field_presenter ||= view_context.facet_field_presenter(facet_config, {})
112
- end
113
95
  end
114
96
  end
@@ -21,7 +21,7 @@ xml.entry do
21
21
  with_format(:html) do
22
22
  xml.summary "type" => "html" do
23
23
  document_component = blacklight_config.view_config(:atom).summary_component
24
- xml.text! render document_component.new(document_component.collection_parameter => document_presenter(document), component: :div, show: true)
24
+ xml.text! render document_component.new(document: document_presenter(document), component: :div, show: true)
25
25
  end
26
26
  end
27
27
 
@@ -1,4 +1,4 @@
1
1
  <% # container for a single doc -%>
2
2
  <% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type, action_name: action_name) %>
3
3
  <% document_component = view_config.document_component -%>
4
- <%= render document_component.new(document_component.collection_parameter => document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
4
+ <%= render document_component.new(document: document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
@@ -3,7 +3,7 @@
3
3
  <% content_for(:head) { render_link_rel_alternates } %>
4
4
 
5
5
  <% document_component = blacklight_config.view_config(:show).document_component -%>
6
- <%= render (document_component).new(document_component.collection_parameter => document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %>
6
+ <%= render document_component.new(document: document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %>
7
7
  <% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %>
8
8
  <% component.with_footer do %>
9
9
  <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
data/blacklight.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
32
32
  s.add_dependency "i18n", '>= 1.7.0' # added named parameters
33
33
  s.add_dependency "ostruct", '>= 0.3.2'
34
- s.add_dependency "view_component", '~> 3.9'
34
+ s.add_dependency "view_component", '>= 3.0', '< 5.0'
35
35
  s.add_dependency "zeitwerk"
36
36
 
37
37
  s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
@@ -120,7 +120,7 @@ ar:
120
120
  remove:
121
121
  label_value: "إزالة القيد %{label}: %{value}"
122
122
  value: إزالة القيد %{value}
123
- title: "لقد بحثت عن:"
123
+ title: "اختياراتك:"
124
124
  form:
125
125
  search:
126
126
  label: ابحث عن
@@ -160,7 +160,6 @@ ar:
160
160
  submit: تحديث
161
161
  title: عدد النتائج المعروضة في الصفحة
162
162
  rss_feed: خلاصات RSS للنتائج
163
- search_constraints_header: قيود البحث
164
163
  search_results: نتائج البحث
165
164
  show:
166
165
  label: "%{label}:"
@@ -136,7 +136,6 @@ ca:
136
136
  many_constraint_values: "%{values} seleccionat"
137
137
  joiner: " / "
138
138
  header: "Cerca"
139
- search_constraints_header: "Filtres de la cerca"
140
139
  search_results: "Resultats de la cerca"
141
140
  errors:
142
141
  invalid_solr_id: "El registre que heu sol·licitat no existeix."
@@ -194,7 +193,7 @@ ca:
194
193
  group:
195
194
  more: "més »"
196
195
  filters:
197
- title: "Heu cercat per:"
196
+ title: "Les teves seleccions:"
198
197
  label: "%{label}:"
199
198
  remove:
200
199
  value: "Eliminar el filtre %{value}"
@@ -111,7 +111,7 @@ de:
111
111
  remove:
112
112
  label_value: "Filter %{label}: %{value} entfernen"
113
113
  value: Filter %{value} entfernen
114
- title: "Sie suchten nach:"
114
+ title: "Ihre Auswahl:"
115
115
  form:
116
116
  search:
117
117
  label: suchen nach
@@ -147,7 +147,6 @@ de:
147
147
  submit: Aktualisieren
148
148
  title: Anzahl der Ergebnisse, die pro Seite angezeigt werden
149
149
  rss_feed: RSS für Ergebnisse
150
- search_constraints_header: Suchen
151
150
  search_results: Suchergebnisse
152
151
  show:
153
152
  label: "%{label}:"
@@ -129,7 +129,7 @@ en:
129
129
  remove:
130
130
  label_value: "Remove constraint %{label}: %{value}"
131
131
  value: Remove constraint %{value}
132
- title: "You searched for:"
132
+ title: "Your selections:"
133
133
  form:
134
134
  search:
135
135
  label: search for
@@ -165,7 +165,6 @@ en:
165
165
  submit: Update
166
166
  title: Number of results to display per page
167
167
  rss_feed: RSS for results
168
- search_constraints_header: Search Constraints
169
168
  search_results: Search Results
170
169
  show:
171
170
  label: "%{label}:"
@@ -110,7 +110,7 @@ es:
110
110
  remove:
111
111
  label_value: "Eliminar la restricción%{label}: %{value}"
112
112
  value: Eliminar la restricción %{value}
113
- title: "Usted ha buscado:"
113
+ title: "Tus selecciones:"
114
114
  form:
115
115
  search:
116
116
  label: buscar
@@ -146,7 +146,6 @@ es:
146
146
  submit: Actualización
147
147
  title: El número de resultados a mostrar por página
148
148
  rss_feed: RSS de los resultados
149
- search_constraints_header: Buscar
150
149
  search_results: Resultados de la búsqueda
151
150
  show:
152
151
  label: "%{label}:"
@@ -110,7 +110,7 @@ fr:
110
110
  remove:
111
111
  label_value: "Supprimer la restriction %{label}: %{value}"
112
112
  value: Supprimer la restriction %{value}
113
- title: "Vous avez demandé :"
113
+ title: "Vos sélections:"
114
114
  form:
115
115
  search:
116
116
  label: Rechercher
@@ -146,7 +146,6 @@ fr:
146
146
  submit: mettre à jour
147
147
  title: Nombre de résultats à afficher par page
148
148
  rss_feed: RSS pour les résultats
149
- search_constraints_header: Recherche
150
149
  search_results: Résultats de recherche
151
150
  show:
152
151
  label: "%{label}:"
@@ -108,7 +108,7 @@ hu:
108
108
  remove:
109
109
  label_value: "Feltétel eltávolítása %{label}: %{value}"
110
110
  value: Feltételek eltávolítása %{value}
111
- title: "Ön ezt kereste:"
111
+ title: "Az Ön választása:"
112
112
  form:
113
113
  search:
114
114
  label: keresés
@@ -144,7 +144,6 @@ hu:
144
144
  submit: Frissítés
145
145
  title: Az eredmények száma oldalanként
146
146
  rss_feed: Eredmények RSS-ként
147
- search_constraints_header: Keresés feltételei
148
147
  search_results: Keresés eredményei
149
148
  show:
150
149
  label: "%{label}:"
@@ -111,7 +111,7 @@ it:
111
111
  remove:
112
112
  label_value: "Cancella il filtro %{label}: %{value}"
113
113
  value: Cancella il filtro %{value}
114
- title: "Hai cercato per:"
114
+ title: "Le tue selezioni:"
115
115
  form:
116
116
  search:
117
117
  label: cerca per
@@ -147,7 +147,6 @@ it:
147
147
  submit: Aggiorna
148
148
  title: Risultati per pagina
149
149
  rss_feed: RSS per i risultati
150
- search_constraints_header: Ricerca
151
150
  search_results: Risultati della ricerca
152
151
  show:
153
152
  label: "%{label}:"
@@ -108,7 +108,7 @@ nl:
108
108
  remove:
109
109
  label_value: "Verwijder zoekfilter %{label}: %{value}"
110
110
  value: Verwijder zoekfilter %{value}
111
- title: "U zocht op:"
111
+ title: "Uw selecties:"
112
112
  form:
113
113
  search:
114
114
  label: zoeken op
@@ -144,7 +144,6 @@ nl:
144
144
  submit: Update
145
145
  title: Toon aantal zoekresultaten per pagina
146
146
  rss_feed: RSS voor zoekresultaten
147
- search_constraints_header: Zoek filters
148
147
  search_results: Zoek resultaten
149
148
  show:
150
149
  label: "%{label}:"
@@ -109,7 +109,7 @@ pt-BR:
109
109
  remove:
110
110
  label_value: "Remover %{label}: %{value}"
111
111
  value: Remover filtro %{value}
112
- title: "Sua busca por:"
112
+ title: "Suas seleções:"
113
113
  form:
114
114
  search:
115
115
  label: busca
@@ -145,7 +145,6 @@ pt-BR:
145
145
  submit: Atualizar
146
146
  title: Número de resultados para mostrar por página
147
147
  rss_feed: RSS para resultadoss
148
- search_constraints_header: Busca
149
148
  search_results: Resultados da Busca
150
149
  show:
151
150
  label: "%{label}:"
@@ -108,7 +108,7 @@ sq:
108
108
  remove:
109
109
  label_value: "Fshij kufizimin %{label}: %{value}"
110
110
  value: Fshij kufizimin %{value}
111
- title: "Ju keni kërkuar për:"
111
+ title: "Zgjedhjet tuaja:"
112
112
  form:
113
113
  search:
114
114
  label: kërko për
@@ -144,7 +144,6 @@ sq:
144
144
  submit: Përditëso
145
145
  title: Numri i rezultateve që do të shfaqen për faqe
146
146
  rss_feed: RSS për rezultatet
147
- search_constraints_header: Kufizimet e kërkimit
148
147
  search_results: Rezultatet e kërkimit
149
148
  show:
150
149
  label: "%{label}:"
@@ -108,7 +108,7 @@ zh:
108
108
  remove:
109
109
  label_value: "删除限定条件 %{label}: %{value}"
110
110
  value: 删除限定条件 %{value}
111
- title: 你在搜索:
111
+ title: 您的选择:
112
112
  form:
113
113
  search:
114
114
  label: 搜索
@@ -144,7 +144,6 @@ zh:
144
144
  submit: 更新
145
145
  title: 每页显示结果数
146
146
  rss_feed: 搜索结果RSS
147
- search_constraints_header: 搜索条件
148
147
  search_results: 搜索结果
149
148
  show:
150
149
  label: "%{label}:"
@@ -9,9 +9,13 @@ module Blacklight
9
9
  @__vc_compiler = nil
10
10
  end
11
11
 
12
+ # This allows the host application to provide erb templates that override the templates
13
+ # provided by Blacklight.
12
14
  def sidecar_files(*args, **kwargs)
13
15
  upstream_sidecar_files(*args, **kwargs).map do |path|
14
- app_path = Rails.root.join(path.slice(path.index(view_component_path)..-1).to_s).to_s
16
+ components_path = ViewComponent::VERSION::MAJOR == 3 ? view_component_path : config.generate.path
17
+
18
+ app_path = Rails.root.join(path.slice(path.index(components_path)..-1).to_s).to_s
15
19
 
16
20
  if File.exist?(app_path)
17
21
  app_path
@@ -76,6 +76,8 @@ module Blacklight
76
76
  self.index_range = 'A'..'Z' if index_range == true
77
77
  self.presenter ||= Blacklight::FacetFieldPresenter
78
78
  self.item_presenter ||= Blacklight::FacetItemPresenter
79
+ self.constraint_presenter ||= Blacklight::ConstraintPresenter
80
+
79
81
  self.component = Blacklight::Facets::ListComponent if component.nil? || component == true
80
82
  self.advanced_search_component ||= Blacklight::Facets::CheckboxesComponent
81
83
  self.item_component ||= Blacklight::Facets::ItemComponent
@@ -148,6 +148,8 @@ module Blacklight
148
148
  property :index, default: ViewConfig::Index.new(
149
149
  # document presenter class used by helpers and views
150
150
  document_presenter_class: nil,
151
+ # document presenter used for json responses
152
+ json_presenter_class: Blacklight::JsonPresenter,
151
153
  # component class used to render a document
152
154
  document_component: Blacklight::DocumentComponent,
153
155
  sidebar_component: Blacklight::Search::SidebarComponent,
@@ -3,5 +3,5 @@
3
3
  env:
4
4
  SOLR_MODULES: analysis-extras
5
5
  collection:
6
- dir: solr/conf/
6
+ dir: solr/
7
7
  name: blacklight-core
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "9.0.0-beta5",
3
+ "version": "9.0.0-beta7",
4
4
  "description": "The frontend code and styles for Blacklight",
5
5
  "exports": {
6
6
  "./blacklight.esm.js": "./app/assets/javascripts/blacklight/blacklight.esm.js",
@@ -36,7 +36,7 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
36
36
  end
37
37
 
38
38
  it 'has a header' do
39
- expect(page).to have_css('h2', text: 'Search Constraints')
39
+ expect(page).to have_css('h2', text: 'Your selections:')
40
40
  end
41
41
 
42
42
  it 'wraps the output in a div' do
@@ -79,7 +79,7 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
79
79
  end
80
80
 
81
81
  it 'omits the headers' do
82
- expect(page).to have_no_css('h2', text: 'Search Constraints')
82
+ expect(page).to have_no_css('h2', text: 'Your selections:')
83
83
  end
84
84
  end
85
85
  end
@@ -34,11 +34,11 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
34
34
  end
35
35
 
36
36
  it 'has some defined content areas' do
37
- component.set_slot(:title) { 'Title' }
38
- component.set_slot(:embed, nil, 'Embed')
39
- component.set_slot(:metadata, nil, 'Metadata')
40
- component.set_slot(:thumbnail, nil, 'Thumbnail')
41
- component.set_slot(:actions) { 'Actions' }
37
+ component.with_title { 'Title' }
38
+ component.with_embed('Embed')
39
+ component.with_metadata('Metadata')
40
+ component.with_thumbnail('Thumbnail')
41
+ component.with_actions { 'Actions' }
42
42
  render_inline component
43
43
 
44
44
  expect(page).to have_content 'Title'
@@ -49,7 +49,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
49
49
  end
50
50
 
51
51
  it 'has schema.org properties' do
52
- component.set_slot(:body) { '-' }
52
+ component.with_body { '-' }
53
53
  render_inline component
54
54
 
55
55
  expect(page).to have_css 'article[@itemtype="http://schema.org/Thing"]'
@@ -58,7 +58,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
58
58
 
59
59
  context 'with a provided body' do
60
60
  it 'opts-out of normal component content' do
61
- component.set_slot(:body) { 'Body content' }
61
+ component.with_body { 'Body content' }
62
62
  render_inline component
63
63
 
64
64
  expect(page).to have_content 'Body content'
@@ -75,7 +75,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
75
75
  let(:attr) { { counter: 5 } }
76
76
 
77
77
  it 'has data properties' do
78
- component.set_slot(:body) { '-' }
78
+ component.with_body { '-' }
79
79
  render_inline component
80
80
 
81
81
  expect(page).to have_css 'article[@data-document-id="x"]'
@@ -137,7 +137,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
137
137
  end
138
138
 
139
139
  it 'renders with an id' do
140
- component.set_slot(:body) { '-' }
140
+ component.with_body { '-' }
141
141
  render_inline component
142
142
 
143
143
  expect(page).to have_css 'article#document'
@@ -16,7 +16,8 @@ RSpec.describe Blacklight::Facets::IndexNavigationComponent, type: :component do
16
16
 
17
17
  it 'renders the facet index navigation range' do
18
18
  expect(page).to have_css '.pagination'
19
- expect(page).to have_link '0', href: '/catalog/facet/language.html?facet.prefix=0&facet.sort=index'
19
+ facet_path = ViewComponent::VERSION::MAJOR == 3 ? '/catalog/facet/language.html' : '/catalog/facet/language'
20
+ expect(page).to have_link '0', href: "#{facet_path}?facet.prefix=0&facet.sort=index"
20
21
  expect(page).to have_link '1'
21
22
  expect(page).to have_link '8'
22
23
  expect(page).to have_link '9'
@@ -28,7 +28,8 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
28
28
  it 'has an input with the data-facet-search-context attribute, which the javascript needs to determine the current search context' do
29
29
  with_request_url "/catalog/facet/language_facet?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields" do
30
30
  rendered = render_inline component
31
- expect(rendered.css('input[data-facet-search-context="/catalog/facet/language_facet.html?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields"]').count).to eq 1
31
+ facet_path = ViewComponent::VERSION::MAJOR == 3 ? '/catalog/facet/language_facet.html' : '/catalog/facet/language_facet'
32
+ expect(rendered.css("input[data-facet-search-context=\"#{facet_path}?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields\"]").count).to eq 1
32
33
  end
33
34
  end
34
35