blacklight 7.15.2 → 7.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/components/blacklight/document/action_component.html.erb +1 -1
- data/app/components/blacklight/document/action_component.rb +2 -1
- data/app/components/blacklight/document/actions_component.html.erb +1 -1
- data/app/components/blacklight/document/actions_component.rb +2 -1
- data/app/components/blacklight/search_bar_component.rb +5 -1
- data/app/controllers/concerns/blacklight/catalog.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/presenters/blacklight/document_presenter.rb +8 -4
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +2 -2
- data/lib/blacklight/configuration.rb +50 -5
- data/lib/blacklight/configuration/view_config.rb +16 -5
- data/lib/blacklight/open_struct_with_hash_access.rb +4 -0
- data/lib/blacklight/search_state.rb +2 -2
- data/lib/blacklight/solr/search_builder_behavior.rb +11 -1
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +12 -0
- data/spec/models/blacklight/configuration_spec.rb +64 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +32 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ceacfa202c3acda3cb375ea3f76dd2e854f786aaba9e5a83a40cce15a1a77f5
|
4
|
+
data.tar.gz: b09a2d694145f7b8da82ecb99314632c1e521d63748ea0854a8d7dd131710633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fd109f991c7cf33507b73fa8e40bd67c90601751abca9374da323d0e907f8117ab676406f2edba878e1aba39f2bfd477fe4892e1dd015b11a30ef9311d95d6f
|
7
|
+
data.tar.gz: a10adadf6affff113b5ee41dd10c469ace59eda64afb560052fb8cdd94a1188ee11b1dc7c7cafe92ff229a43504a8590c8508c407f64c6fdfadb9dfbc70a7ccd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.16.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= link_to label,
|
3
3
|
url,
|
4
4
|
id: @id,
|
5
|
-
class:
|
5
|
+
class: @link_classes,
|
6
6
|
data: {}.merge(({ blacklight_modal: "trigger" } if @action.modal != false) || {}) %>
|
7
7
|
<% else %>
|
8
8
|
<%= @view_context.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options)) %>
|
@@ -7,12 +7,13 @@ module Blacklight
|
|
7
7
|
with_collection_parameter :action
|
8
8
|
|
9
9
|
# @param [Blacklight::Document] document
|
10
|
-
def initialize(document:, action:, options: {}, url_opts: {}, id: nil)
|
10
|
+
def initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link')
|
11
11
|
@document = document
|
12
12
|
@action = action
|
13
13
|
@options = options
|
14
14
|
@url_opts = url_opts
|
15
15
|
@id = id || @action.fetch(:id, "#{@action.name}Link")
|
16
|
+
@link_classes = link_classes
|
16
17
|
end
|
17
18
|
|
18
19
|
def using_default_document_action?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= content_tag @tag, class: @classes do %>
|
2
2
|
<% @actions.each do |action| %>
|
3
|
-
<% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts)) } %>
|
3
|
+
<% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes)) } %>
|
4
4
|
|
5
5
|
<% if @wrapping_tag %>
|
6
6
|
<%= content_tag(@wrapping_tag, class: Array(@wrapping_classes) + [action.key]) do %>
|
@@ -6,7 +6,7 @@ module Blacklight
|
|
6
6
|
class ActionsComponent < ::ViewComponent::Base
|
7
7
|
# @param [Blacklight::Document] document
|
8
8
|
# rubocop:disable Metrics/ParameterLists
|
9
|
-
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil)
|
9
|
+
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil, link_classes: 'nav-link')
|
10
10
|
@document = document
|
11
11
|
@actions = actions
|
12
12
|
@tag = tag
|
@@ -15,6 +15,7 @@ module Blacklight
|
|
15
15
|
@url_opts = url_opts
|
16
16
|
@wrapping_tag = wrapping_tag
|
17
17
|
@wrapping_classes = wrapping_classes
|
18
|
+
@link_classes = link_classes
|
18
19
|
end
|
19
20
|
# rubocop:enable Metrics/ParameterLists
|
20
21
|
|
@@ -46,7 +46,11 @@ module Blacklight
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def presenter
|
49
|
-
@presenter ||=
|
49
|
+
@presenter ||= presenter_class.new(controller, blacklight_config)
|
50
|
+
end
|
51
|
+
|
52
|
+
def presenter_class
|
53
|
+
blacklight_config.view_config(action_name: :index).search_bar_presenter_class
|
50
54
|
end
|
51
55
|
|
52
56
|
def blacklight_config
|
@@ -198,7 +198,7 @@ module Blacklight::Catalog
|
|
198
198
|
# @example
|
199
199
|
# config.index.respond_to.txt = Proc.new { render plain: "A list of docs." }
|
200
200
|
def additional_response_formats(format)
|
201
|
-
blacklight_config.index.respond_to.each do |key, config|
|
201
|
+
blacklight_config.view_config(action_name: :index).respond_to.each do |key, config|
|
202
202
|
format.send key do
|
203
203
|
case config
|
204
204
|
when false
|
@@ -380,7 +380,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
380
380
|
def show_presenter_class(_document)
|
381
381
|
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter_class is deprecated; use #document_presenter_class instead')
|
382
382
|
|
383
|
-
blacklight_config.show.document_presenter_class
|
383
|
+
blacklight_config.view_config(:show, action_name: action_name).document_presenter_class
|
384
384
|
end
|
385
385
|
|
386
386
|
# @deprecated
|
@@ -388,13 +388,12 @@ module Blacklight::BlacklightHelperBehavior
|
|
388
388
|
def index_presenter_class(_document)
|
389
389
|
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter_class is deprecated; use #document_presenter_class instead')
|
390
390
|
|
391
|
-
|
392
|
-
blacklight_config.index.document_presenter_class
|
391
|
+
blacklight_config.view_config(document_index_view_type, action_name: action_name).document_presenter_class
|
393
392
|
end
|
394
393
|
|
395
394
|
# @return [Class]
|
396
395
|
def search_bar_presenter_class
|
397
|
-
blacklight_config.index.search_bar_presenter_class
|
396
|
+
blacklight_config.view_config(action_name: :index).search_bar_presenter_class
|
398
397
|
end
|
399
398
|
|
400
399
|
# @!group Layout helpers
|
@@ -94,11 +94,11 @@ module Blacklight
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def show_doc_actions?(document = @document, options = {})
|
97
|
-
filter_partials(blacklight_config.show.document_actions, { document: document }.merge(options)).any?
|
97
|
+
filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge(options)).any?
|
98
98
|
end
|
99
99
|
|
100
100
|
def document_actions(document, options: {})
|
101
|
-
filter_partials(blacklight_config.show.document_actions, { document: document }.merge(options)).map { |_k, v| v }
|
101
|
+
filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge(options)).map { |_k, v| v }
|
102
102
|
end
|
103
103
|
|
104
104
|
private
|
@@ -101,9 +101,9 @@ module Blacklight::ConfigurationHelperBehavior
|
|
101
101
|
|
102
102
|
# Return the label for a search view
|
103
103
|
# @return [String]
|
104
|
-
def view_label
|
104
|
+
def view_label(view)
|
105
105
|
view_config = blacklight_config.view[view]
|
106
|
-
view_config.display_label
|
106
|
+
view_config.display_label
|
107
107
|
end
|
108
108
|
deprecation_deprecate view_label: 'Moving to ViewConfig#display_label and Blacklight::Response::ViewTypeComponent'
|
109
109
|
|
@@ -72,9 +72,9 @@ module Blacklight
|
|
72
72
|
fields += Array.wrap(view_config[:"#{base_name}_display_type_field"]) if base_name && view_config.key?(:"#{base_name}_display_type_field")
|
73
73
|
fields += Array.wrap(view_config.display_type_field)
|
74
74
|
|
75
|
-
if fields.empty?
|
76
|
-
fields += Array.wrap(
|
77
|
-
fields += Array.wrap(
|
75
|
+
if fields.empty? && show_view_config != view_config
|
76
|
+
fields += Array.wrap(show_view_config[:"#{base_name}_display_type_field"]) if base_name && show_view_config.key?(:"#{base_name}_display_type_field")
|
77
|
+
fields += Array.wrap(show_view_config.display_type_field)
|
78
78
|
end
|
79
79
|
|
80
80
|
fields += ['format'] if fields.empty? # backwards compatibility with the old default value for display_type_field
|
@@ -118,7 +118,11 @@ module Blacklight
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def view_config
|
121
|
-
@view_config ||=
|
121
|
+
@view_config ||= show_view_config
|
122
|
+
end
|
123
|
+
|
124
|
+
def show_view_config
|
125
|
+
configuration.view_config(:show)
|
122
126
|
end
|
123
127
|
|
124
128
|
private
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if render_show_doc_actions_method_from_blacklight? %>
|
2
|
-
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: '
|
2
|
+
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: 'div', classes: "#{controller_name}Tools", wrapping_tag: 'span', wrapping_classes: 'btn btn-outline-primary', link_classes: '', actions: document_actions(document_list, options: { document: nil }), options: { document_list: @response.documents }, url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h))) %>
|
3
3
|
<% else %>
|
4
4
|
<% Deprecation.warn(self, '#render_show_doc_actions is deprecated; use ActionComponents instead') %>
|
5
5
|
<ul class="<%= controller_name %>Tools nav nav-pills">
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<% @page_title = t('blacklight.search.show.title', document_title: Deprecation.silence(Blacklight::BlacklightHelperBehavior) { document_show_html_title }, application_name: application_name).html_safe %>
|
4
4
|
<% content_for(:head) { render_link_rel_alternates } %>
|
5
5
|
|
6
|
-
<%= render (blacklight_config.show.document_component || Blacklight::DocumentComponent).new(document: @document, component: :div, title_component: :h1, show: true) do |component| %>
|
6
|
+
<%= render (blacklight_config.view_config(:show).document_component || Blacklight::DocumentComponent).new(document: @document, component: :div, title_component: :h1, show: true) do |component| %>
|
7
7
|
<% component.with(:footer) do %>
|
8
8
|
<% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
|
9
9
|
<!--
|
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
<%# Use :body for complete backwards compatibility (overriding the component body markup),
|
19
19
|
but if the app explicitly opted-in to components, make the partials data available as :partials to ease migrations pain %>
|
20
|
-
<% component.with(blacklight_config.show.document_component.blank? && blacklight_config.view_config(:show).partials.any? ? :body : :partials) do %>
|
20
|
+
<% component.with(blacklight_config.view_config(:show).document_component.blank? && blacklight_config.view_config(:show).partials.any? ? :body : :partials) do %>
|
21
21
|
<div id="doc_<%= @document.id.to_s.parameterize %>">
|
22
22
|
<%= render_document_partials @document, blacklight_config.view_config(:show).partials, component: component %>
|
23
23
|
</div>
|
@@ -95,6 +95,12 @@ module Blacklight
|
|
95
95
|
partials: [:show_header, :show],
|
96
96
|
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
97
97
|
),
|
98
|
+
action_mapping: NestedOpenStructWithHashAccess.new(
|
99
|
+
ViewConfig,
|
100
|
+
default: { top_level_config: :index },
|
101
|
+
show: { top_level_config: :show },
|
102
|
+
citation: { parent_config: :show }
|
103
|
+
),
|
98
104
|
# Configurations for specific types of index views
|
99
105
|
view: NestedOpenStructWithHashAccess.new(ViewConfig,
|
100
106
|
list: {},
|
@@ -307,13 +313,35 @@ module Blacklight
|
|
307
313
|
end
|
308
314
|
alias_method :inheritable_copy, :build
|
309
315
|
|
310
|
-
# Get a view configuration for the given view type
|
311
|
-
#
|
316
|
+
# Get a view configuration for the given view type + action. The effective
|
317
|
+
# view configuration is inherited from:
|
318
|
+
# - the configuration from blacklight_config.view with the key `view_type`
|
319
|
+
# - the configuration from blacklight_config.action_mapping with the key `action_name`
|
320
|
+
# - any parent config for the action map result above
|
321
|
+
# - the action_mapping default configuration
|
322
|
+
# - the top-level index/show view configuration
|
323
|
+
#
|
312
324
|
# @param [Symbol,#to_sym] view_type
|
313
325
|
# @return [Blacklight::Configuration::ViewConfig]
|
314
|
-
def view_config(view_type)
|
315
|
-
view_type
|
316
|
-
|
326
|
+
def view_config(view_type = nil, action_name: :index)
|
327
|
+
view_type &&= view_type.to_sym
|
328
|
+
action_name &&= action_name.to_sym
|
329
|
+
action_name ||= :index
|
330
|
+
|
331
|
+
if view_type == :show
|
332
|
+
action_name = view_type
|
333
|
+
view_type = nil
|
334
|
+
end
|
335
|
+
|
336
|
+
@view_config ||= {}
|
337
|
+
@view_config[[view_type, action_name]] ||= begin
|
338
|
+
if view_type.nil?
|
339
|
+
action_config(action_name)
|
340
|
+
else
|
341
|
+
base_config = action_config(action_name)
|
342
|
+
base_config.merge(view.fetch(view_type, {}))
|
343
|
+
end
|
344
|
+
end
|
317
345
|
end
|
318
346
|
|
319
347
|
# YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
|
@@ -441,5 +469,22 @@ module Blacklight
|
|
441
469
|
yield(object)
|
442
470
|
end
|
443
471
|
end
|
472
|
+
|
473
|
+
def action_config(action, default: :index)
|
474
|
+
action_config = action_mapping[action]
|
475
|
+
action_config ||= action_mapping[:default]
|
476
|
+
|
477
|
+
if action_config.parent_config && action_config.parent_config != :default
|
478
|
+
parent_config = action_mapping[action_config.parent_config]
|
479
|
+
raise "View configuration error: the parent configuration of #{action_config.key}, #{parent_config.key}, must not specific its own parent configuration" if parent_config.parent_config
|
480
|
+
|
481
|
+
action_config = action_config.reverse_merge(parent_config)
|
482
|
+
end
|
483
|
+
action_config = action_config.reverse_merge(action_mapping[:default]) if action_config != action_mapping[:default]
|
484
|
+
|
485
|
+
action_config = action_config.reverse_merge(self[action_config.top_level_config]) if action_config.top_level_config
|
486
|
+
action_config = action_config.reverse_merge(show) if default == :show && action_config.top_level_config != :show
|
487
|
+
action_config.reverse_merge(index)
|
488
|
+
end
|
444
489
|
end
|
445
490
|
end
|
@@ -17,15 +17,18 @@ class Blacklight::Configuration
|
|
17
17
|
super || Blacklight::SearchBarPresenter
|
18
18
|
end
|
19
19
|
|
20
|
-
def display_label(
|
20
|
+
def display_label(deprecated_key = nil, **options)
|
21
|
+
Deprecation.warn('Passing the key argument to ViewConfig#display_label is deprecated') if deprecated_key.present?
|
22
|
+
|
21
23
|
I18n.t(
|
22
|
-
:"blacklight.search.view_title.#{key}",
|
24
|
+
:"blacklight.search.view_title.#{deprecated_key || key}",
|
23
25
|
default: [
|
24
|
-
:"blacklight.search.view.#{key}",
|
26
|
+
:"blacklight.search.view.#{deprecated_key || key}",
|
25
27
|
label,
|
26
28
|
title,
|
27
|
-
key.to_s.humanize
|
28
|
-
]
|
29
|
+
(deprecated_key || key).to_s.humanize
|
30
|
+
],
|
31
|
+
**options
|
29
32
|
)
|
30
33
|
end
|
31
34
|
|
@@ -38,6 +41,10 @@ class Blacklight::Configuration
|
|
38
41
|
def document_presenter_class
|
39
42
|
super || Blacklight::ShowPresenter
|
40
43
|
end
|
44
|
+
|
45
|
+
def to_h
|
46
|
+
super.merge(document_presenter_class: document_presenter_class)
|
47
|
+
end
|
41
48
|
end
|
42
49
|
|
43
50
|
class Index < ViewConfig
|
@@ -52,6 +59,10 @@ class Blacklight::Configuration
|
|
52
59
|
def document_presenter_class
|
53
60
|
super || Blacklight::IndexPresenter
|
54
61
|
end
|
62
|
+
|
63
|
+
def to_h
|
64
|
+
super.merge(document_presenter_class: document_presenter_class)
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
@@ -44,6 +44,10 @@ module Blacklight
|
|
44
44
|
@table.merge!((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
45
45
|
end
|
46
46
|
|
47
|
+
def reverse_merge(other_hash)
|
48
|
+
self.class.new to_h.reverse_merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
49
|
+
end
|
50
|
+
|
47
51
|
def deep_dup
|
48
52
|
self.class.new @table.deep_dup
|
49
53
|
end
|
@@ -115,9 +115,9 @@ module Blacklight
|
|
115
115
|
# documents
|
116
116
|
def url_for_document(doc, options = {})
|
117
117
|
if respond_to?(:blacklight_config) &&
|
118
|
-
blacklight_config.show.route &&
|
118
|
+
blacklight_config.view_config(:show).route &&
|
119
119
|
(!doc.respond_to?(:to_model) || doc.to_model.is_a?(SolrDocument))
|
120
|
-
route = blacklight_config.show.route.merge(action: :show, id: doc).merge(options)
|
120
|
+
route = blacklight_config.view_config(:show).route.merge(action: :show, id: doc).merge(options)
|
121
121
|
route[:controller] = params[:controller] if route[:controller] == :current
|
122
122
|
route
|
123
123
|
else
|
@@ -59,6 +59,8 @@ module Blacklight::Solr
|
|
59
59
|
##
|
60
60
|
if search_field&.query_builder.present?
|
61
61
|
add_search_field_query_builder_params(solr_parameters)
|
62
|
+
elsif search_field&.clause_params.present?
|
63
|
+
add_search_field_with_json_query_parameters(solr_parameters)
|
62
64
|
elsif search_field&.solr_local_parameters.present?
|
63
65
|
add_search_field_with_local_parameters(solr_parameters)
|
64
66
|
elsif search_state.query_param.is_a? Hash
|
@@ -86,6 +88,14 @@ module Blacklight::Solr
|
|
86
88
|
solr_parameters[:spellcheck] = 'false'
|
87
89
|
end
|
88
90
|
|
91
|
+
def add_search_field_with_json_query_parameters(solr_parameters)
|
92
|
+
bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
|
93
|
+
|
94
|
+
solr_parameters[:json] ||= { query: { bool: { must: [] } } }
|
95
|
+
solr_parameters[:json][:query] ||= { bool: { must: [] } }
|
96
|
+
solr_parameters[:json][:query][:bool][:must] << bool_query
|
97
|
+
end
|
98
|
+
|
89
99
|
# Transform "clause" parameters into the Solr JSON Query DSL
|
90
100
|
def add_adv_search_clauses(solr_parameters)
|
91
101
|
return if search_state.clause_params.blank?
|
@@ -367,7 +377,7 @@ module Blacklight::Solr
|
|
367
377
|
##
|
368
378
|
# The key to use to retrieve the grouped field to display
|
369
379
|
def grouped_key_for_results
|
370
|
-
blacklight_config.index.group
|
380
|
+
blacklight_config.view_config(action_name: :index).group
|
371
381
|
end
|
372
382
|
|
373
383
|
def facet_fields_to_include_in_request
|
@@ -9,7 +9,7 @@ RSpec.describe Blacklight::Configuration::ViewConfig do
|
|
9
9
|
describe '#display_label' do
|
10
10
|
it "looks up the label to display for the given document and field" do
|
11
11
|
allow(I18n).to receive(:t).with(:"blacklight.search.view_title.my_view", default: [:"blacklight.search.view.my_view", label, nil, "My view"]).and_return('x')
|
12
|
-
expect(subject.display_label
|
12
|
+
expect(subject.display_label).to eq 'x'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -123,6 +123,18 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
describe '#reverse_merge' do
|
127
|
+
before do
|
128
|
+
@h = described_class.new
|
129
|
+
@h[:a] = 1
|
130
|
+
@h[:b] = 2
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'reverse merges the object with the hash, preserving the object class' do
|
134
|
+
expect(@h.reverse_merge(b: 3, c: 4)).to have_attributes a: 1, b: 2, c: 4
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
126
138
|
describe "#to_json" do
|
127
139
|
subject { described_class.new a: 1, b: 2 }
|
128
140
|
|
@@ -557,4 +557,68 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
557
557
|
expect(config.facet_paginator_class).to eq Blacklight::Solr::FacetPaginator
|
558
558
|
end
|
559
559
|
end
|
560
|
+
|
561
|
+
describe '#view_config' do
|
562
|
+
before do
|
563
|
+
config.index.title_field = 'title_tsim'
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'with a view that does not exist' do
|
567
|
+
it 'defaults to the index config' do
|
568
|
+
expect(config.view_config('this-doesnt-exist')).to have_attributes config.index.to_h
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
context 'with the :show view' do
|
573
|
+
it 'includes the show config' do
|
574
|
+
expect(config.view_config(:show)).to have_attributes config.show.to_h
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'uses the show document presenter' do
|
578
|
+
expect(config.view_config(:show)).to have_attributes document_presenter_class: Blacklight::ShowPresenter
|
579
|
+
end
|
580
|
+
|
581
|
+
it 'includes index config defaults' do
|
582
|
+
expect(config.view_config(:show)).to have_attributes title_field: 'title_tsim'
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
context 'with just an action name' do
|
587
|
+
it 'includes the action config' do
|
588
|
+
expect(config.view_config(action_name: :show)).to have_attributes config.show.to_h
|
589
|
+
end
|
590
|
+
|
591
|
+
it 'includes the default action mapping configuration' do
|
592
|
+
config.action_mapping.default.whatever = :some_value
|
593
|
+
|
594
|
+
expect(config.view_config(action_name: :show)).to have_attributes whatever: :some_value
|
595
|
+
end
|
596
|
+
|
597
|
+
it 'includes the action-specific mappings' do
|
598
|
+
config.action_mapping.foo.document_presenter_class = Blacklight::DocumentPresenter
|
599
|
+
|
600
|
+
expect(config.view_config(action_name: :foo)).to have_attributes config.action_mapping.foo.to_h
|
601
|
+
end
|
602
|
+
|
603
|
+
it 'allows the action mapping to specific a parent configuration with some more defaults' do
|
604
|
+
config.action_mapping.foo.parent_config = :bar
|
605
|
+
config.action_mapping.bar.whatever = :bar_value
|
606
|
+
|
607
|
+
expect(config.view_config(action_name: :foo)).to have_attributes whatever: :bar_value
|
608
|
+
end
|
609
|
+
|
610
|
+
context 'with the :citation action' do
|
611
|
+
it 'also includes the show config' do
|
612
|
+
expect(config.view_config(action_name: :citation)).to have_attributes config.show.to_h
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
context 'with a view' do
|
618
|
+
it 'includes the configuration-level view parameters' do
|
619
|
+
expect(config.view_config(:atom)).to have_attributes config.index.to_h.except(:partials)
|
620
|
+
expect(config.view_config(:atom)).to have_attributes partials: [:document]
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
560
624
|
end
|
@@ -321,6 +321,38 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
|
+
describe "solr json query parameters from the fielded search" do
|
325
|
+
let(:user_params) { subject_search_params }
|
326
|
+
|
327
|
+
before do
|
328
|
+
blacklight_config.search_fields['subject'].solr_parameters = {
|
329
|
+
some: :parameter
|
330
|
+
}
|
331
|
+
|
332
|
+
blacklight_config.search_fields['subject'].clause_params = {
|
333
|
+
edismax: {
|
334
|
+
another: :parameter
|
335
|
+
}
|
336
|
+
}
|
337
|
+
end
|
338
|
+
|
339
|
+
it 'sets solr parameters from the field' do
|
340
|
+
expect(subject[:some]).to eq :parameter
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'does not set a q parameter' do
|
344
|
+
expect(subject).not_to have_key :q
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'includes the user query in the JSON query DSL request' do
|
348
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include query: 'wome'
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'includes addtional clause parameters for the field' do
|
352
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include another: :parameter
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
324
356
|
describe "overriding of qt parameter" do
|
325
357
|
let(:user_params) do
|
326
358
|
{ qt: 'overridden' }
|
@@ -12,7 +12,7 @@ RSpec.describe "catalog/index" do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
let(:blacklight_config) { CatalogController.blacklight_config }
|
15
|
+
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
16
16
|
|
17
17
|
before do
|
18
18
|
@response = Blacklight::Solr::Response.new({ response: { numFound: 30 } }, start: 10, rows: 10)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -14,10 +14,10 @@ authors:
|
|
14
14
|
- Dan Funk
|
15
15
|
- Naomi Dushay
|
16
16
|
- Justin Coyne
|
17
|
-
autorequire:
|
17
|
+
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2021-03-
|
20
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -881,7 +881,7 @@ homepage: http://projectblacklight.org/
|
|
881
881
|
licenses:
|
882
882
|
- Apache 2.0
|
883
883
|
metadata: {}
|
884
|
-
post_install_message:
|
884
|
+
post_install_message:
|
885
885
|
rdoc_options: []
|
886
886
|
require_paths:
|
887
887
|
- lib
|
@@ -896,8 +896,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
896
896
|
- !ruby/object:Gem::Version
|
897
897
|
version: '0'
|
898
898
|
requirements: []
|
899
|
-
rubygems_version: 3.
|
900
|
-
signing_key:
|
899
|
+
rubygems_version: 3.1.4
|
900
|
+
signing_key:
|
901
901
|
specification_version: 4
|
902
902
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
903
903
|
index.
|