blacklight 7.11.1 → 7.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.solr_wrapper.yml +5 -0
- data/VERSION +1 -1
- data/app/builders/blacklight/action_builder.rb +6 -0
- data/app/components/blacklight/constraint_component.html.erb +5 -0
- data/app/components/blacklight/constraint_component.rb +13 -0
- data/app/components/blacklight/constraint_layout_component.rb +2 -1
- data/app/components/blacklight/constraints_component.html.erb +10 -0
- data/app/components/blacklight/constraints_component.rb +65 -0
- data/app/components/blacklight/document/action_component.html.erb +9 -0
- data/app/components/blacklight/document/action_component.rb +38 -0
- data/app/components/blacklight/document/actions_component.html.erb +13 -0
- data/app/components/blacklight/document/actions_component.rb +26 -0
- data/app/components/blacklight/document/bookmark_component.html.erb +1 -1
- data/app/components/blacklight/document/bookmark_component.rb +8 -0
- data/app/components/blacklight/document/citation_component.html.erb +4 -2
- data/app/components/blacklight/document/citation_component.rb +8 -1
- data/app/components/blacklight/document/group_component.html.erb +9 -0
- data/app/components/blacklight/document/group_component.rb +26 -0
- data/app/components/blacklight/document/more_like_this_component.rb +2 -0
- data/app/components/blacklight/document/thumbnail_component.html.erb +12 -0
- data/app/components/blacklight/document/thumbnail_component.rb +25 -0
- data/app/components/blacklight/document_component.rb +27 -26
- data/app/components/blacklight/facet_field_filter_component.html.erb +12 -0
- data/app/components/blacklight/facet_field_filter_component.rb +25 -0
- data/app/components/blacklight/facet_field_pagination_component.html.erb +19 -0
- data/app/components/blacklight/facet_field_pagination_component.rb +21 -0
- data/app/components/blacklight/facet_item_component.rb +4 -8
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -1
- data/app/components/blacklight/response/facet_group_component.rb +8 -1
- data/app/components/blacklight/response/pagination_component.rb +3 -0
- data/app/components/blacklight/response/sort_component.html.erb +1 -1
- data/app/components/blacklight/response/spellcheck_component.rb +9 -2
- data/app/components/blacklight/response/view_type_component.html.erb +11 -0
- data/app/components/blacklight/response/view_type_component.rb +36 -0
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/components/blacklight/search_bar_component.rb +6 -0
- data/app/components/blacklight/search_context_component.rb +6 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.html.erb +4 -0
- data/app/components/blacklight/system/flash_message_component.rb +24 -0
- data/app/controllers/concerns/blacklight/catalog.rb +7 -1
- data/app/controllers/concerns/blacklight/controller.rb +12 -3
- data/app/controllers/concerns/blacklight/facet.rb +19 -5
- data/app/controllers/concerns/blacklight/search_fields.rb +7 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +127 -17
- data/app/helpers/blacklight/catalog_helper_behavior.rb +36 -5
- data/app/helpers/blacklight/component_helper_behavior.rb +36 -6
- data/app/helpers/blacklight/configuration_helper_behavior.rb +32 -4
- data/app/helpers/blacklight/facets_helper_behavior.rb +31 -8
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +5 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +28 -11
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +8 -3
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +4 -2
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +23 -3
- data/app/models/blacklight/icon.rb +0 -1
- data/app/models/concerns/blacklight/document.rb +1 -1
- data/app/models/concerns/blacklight/suggest/response.rb +1 -1
- data/app/models/record_mailer.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +42 -1
- data/app/presenters/blacklight/facet_field_presenter.rb +3 -1
- data/app/presenters/blacklight/facet_item_presenter.rb +8 -0
- data/app/presenters/blacklight/field_presenter.rb +9 -6
- data/app/presenters/blacklight/json_presenter.rb +3 -1
- data/app/presenters/blacklight/show_presenter.rb +4 -30
- data/app/presenters/blacklight/thumbnail_presenter.rb +5 -1
- data/app/services/blacklight/document_factory.rb +3 -0
- data/app/services/blacklight/field_retriever.rb +18 -4
- data/app/services/blacklight/search_service.rb +0 -1
- data/app/views/bookmarks/_tools.html.erb +12 -7
- data/app/views/catalog/_bookmark_control.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +12 -7
- data/app/views/catalog/_document.atom.builder +9 -6
- data/app/views/catalog/_document.rss.builder +4 -2
- data/app/views/catalog/_facet_index_navigation.html.erb +1 -10
- data/app/views/catalog/_facet_pagination.html.erb +1 -19
- data/app/views/catalog/_facets.html.erb +1 -1
- data/app/views/catalog/_group.html.erb +1 -9
- data/app/views/catalog/_index.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +1 -1
- data/app/views/catalog/_show.html.erb +1 -1
- data/app/views/catalog/_show_header.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +12 -8
- data/app/views/catalog/_start_over.html.erb +1 -1
- data/app/views/catalog/_thumbnail.html.erb +1 -5
- data/app/views/catalog/_view_type_group.html.erb +5 -13
- data/app/views/catalog/index.json.jbuilder +8 -6
- data/app/views/catalog/show.json.jbuilder +1 -1
- data/app/views/shared/_flash_msg.html.erb +1 -15
- data/blacklight.gemspec +1 -0
- data/config/locales/blacklight.ca.yml +241 -0
- data/lib/blacklight/abstract_repository.rb +13 -4
- data/lib/blacklight/configuration.rb +11 -5
- data/lib/blacklight/configuration/display_field.rb +50 -0
- data/lib/blacklight/configuration/facet_field.rb +58 -1
- data/lib/blacklight/configuration/field.rb +13 -0
- data/lib/blacklight/configuration/index_field.rb +5 -0
- data/lib/blacklight/configuration/search_field.rb +3 -0
- data/lib/blacklight/configuration/show_field.rb +5 -0
- data/lib/blacklight/configuration/sort_field.rb +3 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +25 -0
- data/lib/blacklight/search_state.rb +4 -2
- data/lib/blacklight/solr/repository.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +8 -7
- data/spec/components/blacklight/document/action_component_spec.rb +43 -0
- data/spec/components/blacklight/document/group_component_spec.rb +45 -0
- data/spec/components/blacklight/document_component_spec.rb +8 -0
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +0 -1
- data/spec/components/blacklight/system/flash_message_component_spec.rb +54 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +2 -0
- data/spec/controllers/catalog_controller_spec.rb +2 -0
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +6 -1
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +3 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight_helper_spec.rb +10 -0
- data/spec/helpers/catalog_helper_spec.rb +4 -4
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +17 -0
- data/spec/models/blacklight/search_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/search_builder_spec.rb +8 -0
- data/spec/presenters/blacklight/field_presenter_spec.rb +30 -5
- data/spec/services/blacklight/search_service_spec.rb +1 -5
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -1
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -2
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
- data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -0
- data/tasks/blacklight.rake +27 -12
- metadata +47 -2
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight
|
3
3
|
module ComponentHelperBehavior
|
4
|
+
extend Deprecation
|
5
|
+
|
6
|
+
# @deprecated
|
4
7
|
def document_action_label action, opts
|
5
8
|
t("blacklight.tools.#{action}", default: opts.label || action.to_s.humanize)
|
6
9
|
end
|
10
|
+
deprecation_deprecate :document_action_label
|
7
11
|
|
12
|
+
# @deprecated
|
8
13
|
def document_action_path action_opts, url_opts = nil
|
9
14
|
if action_opts.path
|
10
15
|
send(action_opts.path, url_opts)
|
@@ -14,6 +19,7 @@ module Blacklight
|
|
14
19
|
send("#{action_opts.key}_#{controller_name}_path", url_opts)
|
15
20
|
end
|
16
21
|
end
|
22
|
+
deprecation_deprecate :document_action_path
|
17
23
|
|
18
24
|
##
|
19
25
|
# Render "document actions" area for navigation header
|
@@ -36,9 +42,10 @@ module Blacklight
|
|
36
42
|
# @option options [String] :wrapping_class
|
37
43
|
# @return [String]
|
38
44
|
def render_index_doc_actions(document, options = {})
|
45
|
+
actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options)).map { |_k, v| v }
|
39
46
|
wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
|
40
|
-
|
41
|
-
|
47
|
+
|
48
|
+
render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: options, classes: wrapping_class))
|
42
49
|
end
|
43
50
|
|
44
51
|
##
|
@@ -49,9 +56,10 @@ module Blacklight
|
|
49
56
|
# @option options [String] :wrapping_class
|
50
57
|
# @return [String]
|
51
58
|
def render_results_collection_tools(options = {})
|
59
|
+
actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options).map { |_k, v| v }
|
52
60
|
wrapping_class = options.delete(:wrapping_class) || "search-widgets"
|
53
|
-
|
54
|
-
|
61
|
+
|
62
|
+
render(Blacklight::Document::ActionsComponent.new(actions: actions, options: options, classes: wrapping_class))
|
55
63
|
end
|
56
64
|
|
57
65
|
##
|
@@ -63,14 +71,36 @@ module Blacklight
|
|
63
71
|
# @param [SolrDocument] document
|
64
72
|
# @param [Hash] options
|
65
73
|
# @return [String]
|
66
|
-
def render_show_doc_actions(document = @document,
|
67
|
-
|
74
|
+
def render_show_doc_actions(document = @document, url_opts: {}, **options)
|
75
|
+
document = options[:document] if options.key? :document
|
76
|
+
|
77
|
+
actions = document_actions(document, options: options)
|
78
|
+
|
79
|
+
if block_given?
|
80
|
+
# TODO: Deprecate this behavior and replace it with a separate component?
|
81
|
+
# Deprecation.warn(Blacklight::ComponentHelperBehavior, 'Pass a block to #render_show_doc_actions is deprecated')
|
82
|
+
actions.each do |action|
|
83
|
+
yield action, render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: document, options: options, url_opts: url_opts))
|
84
|
+
end
|
85
|
+
|
86
|
+
nil
|
87
|
+
else
|
88
|
+
render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: options, url_opts: url_opts))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def render_show_doc_actions_method_from_blacklight?
|
93
|
+
method(:render_show_doc_actions).owner == Blacklight::ComponentHelperBehavior
|
68
94
|
end
|
69
95
|
|
70
96
|
def show_doc_actions?(document = @document, options = {})
|
71
97
|
filter_partials(blacklight_config.show.document_actions, { document: document }.merge(options)).any?
|
72
98
|
end
|
73
99
|
|
100
|
+
def document_actions(document, options: {})
|
101
|
+
filter_partials(blacklight_config.show.document_actions, { document: document }.merge(options)).map { |_k, v| v }
|
102
|
+
end
|
103
|
+
|
74
104
|
private
|
75
105
|
|
76
106
|
def render_filtered_partials(partials, options = {})
|
@@ -5,32 +5,40 @@ module Blacklight::ConfigurationHelperBehavior
|
|
5
5
|
##
|
6
6
|
# Index fields to display for a type of document
|
7
7
|
#
|
8
|
-
# @param [SolrDocument]
|
8
|
+
# @param [SolrDocument] _document
|
9
9
|
# @return [Array<Blacklight::Configuration::Field>]
|
10
10
|
def index_fields _document = nil
|
11
11
|
Deprecation.warn(self, "index_fields is deprecated and will be removed in Blacklight 8. Use IndexPresenter#fields instead")
|
12
12
|
blacklight_config.index_fields
|
13
13
|
end
|
14
14
|
|
15
|
+
##
|
16
|
+
# Return the available sort fields
|
17
|
+
# @return [Array<Blacklight::Configuration::Field>]
|
15
18
|
def active_sort_fields
|
16
19
|
blacklight_config.sort_fields.select { |_sort_key, field_config| should_render_field?(field_config) }
|
17
20
|
end
|
18
21
|
|
19
22
|
# Used in the search form partial for building a select tag
|
23
|
+
# @see #search_field_options_for_select
|
20
24
|
def search_fields
|
21
25
|
search_field_options_for_select
|
22
26
|
end
|
27
|
+
deprecation_deprecate search_fields: 'removed without replacement'
|
23
28
|
|
24
29
|
# Returns suitable argument to options_for_select method, to create
|
25
30
|
# an html select based on #search_field_list. Skips search_fields
|
26
31
|
# marked :include_in_simple_select => false
|
32
|
+
# @return [Array<Array>] the first element of the array is the label, the second is the sort field key
|
27
33
|
def search_field_options_for_select
|
28
34
|
blacklight_config.search_fields.collect do |_key, field_def|
|
29
35
|
[label_for_search_field(field_def.key), field_def.key] if should_render_field?(field_def)
|
30
36
|
end.compact
|
31
37
|
end
|
38
|
+
deprecation_deprecate search_field_options_for_select: 'removed without replacement'
|
32
39
|
|
33
40
|
# used in the catalog/_show partial
|
41
|
+
# @return [Array<Blacklight::Configuration::Field>]
|
34
42
|
def document_show_fields _document = nil
|
35
43
|
Deprecation.warn(self, "document_show_fields is deprecated and will be removed in Blacklight 8. Use ShowPresenter#fields instead")
|
36
44
|
blacklight_config.show_fields
|
@@ -45,19 +53,24 @@ module Blacklight::ConfigurationHelperBehavior
|
|
45
53
|
def constraint_query_label(localized_params = params)
|
46
54
|
label_for_search_field(localized_params[:search_field]) unless default_search_field?(localized_params[:search_field])
|
47
55
|
end
|
56
|
+
deprecation_deprecate constraint_query_label: 'Moving to Blacklight::ConstraintsComponent'
|
48
57
|
|
49
58
|
##
|
50
59
|
# Is the search form using the default search field ("all_fields" by default)?
|
51
60
|
# @param [String] selected_search_field the currently selected search_field
|
52
61
|
# @return [Boolean]
|
53
62
|
def default_search_field?(selected_search_field)
|
54
|
-
|
63
|
+
Deprecation.silence(Blacklight::SearchFields) do
|
64
|
+
selected_search_field.blank? || (default_search_field && selected_search_field == default_search_field[:key])
|
65
|
+
end
|
55
66
|
end
|
56
67
|
|
57
68
|
##
|
58
69
|
# Look up the label for the index field
|
70
|
+
# @deprecated
|
71
|
+
# @return [String]
|
59
72
|
def index_field_label document, field
|
60
|
-
field_config = blacklight_config.index_fields_for(
|
73
|
+
field_config = blacklight_config.index_fields_for(document_presenter(document).display_type)[field]
|
61
74
|
field_config ||= Blacklight::Configuration::NullField.new(key: field)
|
62
75
|
|
63
76
|
field_config.display_label('index')
|
@@ -66,8 +79,10 @@ module Blacklight::ConfigurationHelperBehavior
|
|
66
79
|
|
67
80
|
##
|
68
81
|
# Look up the label for the show field
|
82
|
+
# @deprecated
|
83
|
+
# @return [String]
|
69
84
|
def document_show_field_label document, field
|
70
|
-
field_config = blacklight_config.show_fields_for(
|
85
|
+
field_config = blacklight_config.show_fields_for(document_presenter(document).display_type)[field]
|
71
86
|
field_config ||= Blacklight::Configuration::NullField.new(key: field)
|
72
87
|
|
73
88
|
field_config.display_label('show')
|
@@ -76,6 +91,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
76
91
|
|
77
92
|
##
|
78
93
|
# Look up the label for the facet field
|
94
|
+
# @return [String]
|
79
95
|
def facet_field_label field
|
80
96
|
field_config = blacklight_config.facet_fields[field]
|
81
97
|
field_config ||= Blacklight::Configuration::NullField.new(key: field)
|
@@ -83,6 +99,8 @@ module Blacklight::ConfigurationHelperBehavior
|
|
83
99
|
field_config.display_label('facet')
|
84
100
|
end
|
85
101
|
|
102
|
+
# Return the label for a search view
|
103
|
+
# @return [String]
|
86
104
|
def view_label view
|
87
105
|
view_config = blacklight_config.view[view]
|
88
106
|
field_label(
|
@@ -93,9 +111,11 @@ module Blacklight::ConfigurationHelperBehavior
|
|
93
111
|
view.to_s.humanize
|
94
112
|
)
|
95
113
|
end
|
114
|
+
deprecation_deprecate view_label: 'Moving to Blacklight::Response::ViewTypeComponent'
|
96
115
|
|
97
116
|
# Shortcut for commonly needed operation, look up display
|
98
117
|
# label for the key specified.
|
118
|
+
# @return [String]
|
99
119
|
def label_for_search_field(key)
|
100
120
|
field_config = blacklight_config.search_fields[key]
|
101
121
|
return if key.nil? && field_config.nil?
|
@@ -105,6 +125,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
105
125
|
field_config.display_label('search')
|
106
126
|
end
|
107
127
|
|
128
|
+
# @return [String]
|
108
129
|
def sort_field_label(key)
|
109
130
|
field_config = blacklight_config.sort_fields[key]
|
110
131
|
field_config ||= Blacklight::Configuration::NullField.new(key: key)
|
@@ -124,12 +145,14 @@ module Blacklight::ConfigurationHelperBehavior
|
|
124
145
|
# before falling back to the label
|
125
146
|
# @param [Symbol] any number of additional keys
|
126
147
|
# @param [Symbol] ...
|
148
|
+
# @return [String]
|
127
149
|
def field_label *i18n_keys
|
128
150
|
first, *rest = i18n_keys.compact
|
129
151
|
|
130
152
|
t(first, default: rest)
|
131
153
|
end
|
132
154
|
|
155
|
+
# @return [Hash<Symbol => Blacklight::Configuration::ViewConfig>]
|
133
156
|
def document_index_views
|
134
157
|
blacklight_config.view.select do |_k, config|
|
135
158
|
should_render_field? config
|
@@ -151,17 +174,22 @@ module Blacklight::ConfigurationHelperBehavior
|
|
151
174
|
|
152
175
|
##
|
153
176
|
# Check if there are alternative views configuration
|
177
|
+
# @return [Boolean]
|
154
178
|
def has_alternative_views?
|
155
179
|
document_index_views.keys.length > 1
|
156
180
|
end
|
181
|
+
deprecation_deprecate has_alternative_views?: 'Moving to Blacklight::Response::ViewTypeComponent'
|
157
182
|
|
158
183
|
##
|
159
184
|
# Maximum number of results for spell checking
|
185
|
+
# @return [Number]
|
160
186
|
def spell_check_max
|
161
187
|
blacklight_config.spell_max
|
162
188
|
end
|
189
|
+
deprecation_deprecate spell_check_max: 'Use blacklight_config.spell_max directly'
|
163
190
|
|
164
191
|
# Used in the document list partial (search view) for creating a link to the document show action
|
192
|
+
# @deprecated
|
165
193
|
def document_show_link_field document = nil
|
166
194
|
fields = Array(blacklight_config.view_config(document_index_view_type).title_field)
|
167
195
|
|
@@ -8,9 +8,11 @@ module Blacklight::FacetsHelperBehavior
|
|
8
8
|
##
|
9
9
|
# Check if any of the given fields have values
|
10
10
|
#
|
11
|
+
# @deprecated
|
11
12
|
# @param [Array<String>] fields
|
12
13
|
# @return [Boolean]
|
13
14
|
def has_facet_values? fields = facet_field_names, response = nil
|
15
|
+
deprecated_method(:has_facet_values?)
|
14
16
|
unless response
|
15
17
|
Deprecation.warn(self, 'Calling has_facet_values? without passing the ' \
|
16
18
|
'second argument (response) is deprecated and will be removed in Blacklight ' \
|
@@ -18,7 +20,9 @@ module Blacklight::FacetsHelperBehavior
|
|
18
20
|
response = @response
|
19
21
|
end
|
20
22
|
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
21
|
-
|
23
|
+
Deprecation.silence(Blacklight::Facet) do
|
24
|
+
facets_from_request(fields, response).any? { |display_facet| should_render_facet?(display_facet) }
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -26,13 +30,16 @@ module Blacklight::FacetsHelperBehavior
|
|
26
30
|
# Render a collection of facet fields.
|
27
31
|
# @see #render_facet_limit
|
28
32
|
#
|
33
|
+
# @deprecated
|
29
34
|
# @param [Array<String>] fields
|
30
35
|
# @param [Hash] options
|
31
|
-
# @
|
36
|
+
# @option options [Blacklight::Solr::Response] :response the Solr response object
|
32
37
|
# @return String
|
33
38
|
def render_facet_partials fields = nil, options = {}
|
39
|
+
deprecated_method(:render_facet_partials)
|
40
|
+
|
34
41
|
unless fields
|
35
|
-
Deprecation.warn(self, 'Calling render_facet_partials without passing the ' \
|
42
|
+
Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
|
36
43
|
'first argument (fields) is deprecated and will be removed in Blacklight ' \
|
37
44
|
'8.0.0')
|
38
45
|
fields = facet_field_names
|
@@ -40,14 +47,18 @@ module Blacklight::FacetsHelperBehavior
|
|
40
47
|
|
41
48
|
response = options.delete(:response)
|
42
49
|
unless response
|
43
|
-
Deprecation.warn(self, 'Calling render_facet_partials without passing the ' \
|
50
|
+
Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
|
44
51
|
'response keyword is deprecated and will be removed in Blacklight ' \
|
45
52
|
'8.0.0')
|
46
53
|
response = @response
|
47
54
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
56
|
+
Deprecation.silence(Blacklight::Facet) do
|
57
|
+
safe_join(facets_from_request(fields, response).map do |display_facet|
|
58
|
+
render_facet_limit(display_facet, options)
|
59
|
+
end.compact, "\n")
|
60
|
+
end
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
64
|
##
|
@@ -102,6 +113,7 @@ module Blacklight::FacetsHelperBehavior
|
|
102
113
|
# Renders the list of values
|
103
114
|
# removes any elements where render_facet_item returns a nil value. This enables an application
|
104
115
|
# to filter undesireable facet items so they don't appear in the UI
|
116
|
+
# @deprecated
|
105
117
|
def render_facet_limit_list(paginator, facet_field, wrapping_element = :li)
|
106
118
|
facet_config ||= facet_configuration_for_field(facet_field)
|
107
119
|
|
@@ -115,6 +127,7 @@ module Blacklight::FacetsHelperBehavior
|
|
115
127
|
|
116
128
|
##
|
117
129
|
# Renders a single facet item
|
130
|
+
# @deprecated
|
118
131
|
def render_facet_item(facet_field, item)
|
119
132
|
deprecated_method(:render_facet_item)
|
120
133
|
if facet_in_params?(facet_field, item.value)
|
@@ -129,6 +142,7 @@ module Blacklight::FacetsHelperBehavior
|
|
129
142
|
#
|
130
143
|
# By default, only render facets with items.
|
131
144
|
#
|
145
|
+
# @deprecated
|
132
146
|
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
133
147
|
# @param [Blacklight::Configuration::FacetField] facet_config
|
134
148
|
# @return [Boolean]
|
@@ -147,6 +161,7 @@ module Blacklight::FacetsHelperBehavior
|
|
147
161
|
# - if the facet is configured to collapse (the default), collapse
|
148
162
|
# - if the facet is configured not to collapse, don't collapse
|
149
163
|
#
|
164
|
+
# @deprecated
|
150
165
|
# @param [Blacklight::Configuration::FacetField] facet_field
|
151
166
|
# @return [Boolean]
|
152
167
|
def should_collapse_facet? facet_field
|
@@ -172,7 +187,7 @@ module Blacklight::FacetsHelperBehavior
|
|
172
187
|
deprecation_deprecate :facet_partial_name
|
173
188
|
|
174
189
|
def facet_field_presenter(facet_config, display_facet)
|
175
|
-
facet_config.presenter.new(facet_config, display_facet, self)
|
190
|
+
(facet_config.presenter || Blacklight::FacetFieldPresenter).new(facet_config, display_facet, self)
|
176
191
|
end
|
177
192
|
|
178
193
|
##
|
@@ -193,6 +208,8 @@ module Blacklight::FacetsHelperBehavior
|
|
193
208
|
|
194
209
|
##
|
195
210
|
# Where should this facet link to?
|
211
|
+
#
|
212
|
+
# @deprecated
|
196
213
|
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
197
214
|
# @param [String] item
|
198
215
|
# @return [String]
|
@@ -204,6 +221,8 @@ module Blacklight::FacetsHelperBehavior
|
|
204
221
|
|
205
222
|
##
|
206
223
|
# Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
|
224
|
+
#
|
225
|
+
# @deprecated
|
207
226
|
# @see #render_facet_value
|
208
227
|
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
209
228
|
# @param [String] item
|
@@ -217,6 +236,7 @@ module Blacklight::FacetsHelperBehavior
|
|
217
236
|
# Renders a count value for facet limits. Can be over-ridden locally
|
218
237
|
# to change style. And can be called by plugins to get consistent display.
|
219
238
|
#
|
239
|
+
# @deprecated
|
220
240
|
# @param [Integer] num number of facet results
|
221
241
|
# @param [Hash] options
|
222
242
|
# @option options [Array<String>] an array of classes to add to count span.
|
@@ -243,6 +263,7 @@ module Blacklight::FacetsHelperBehavior
|
|
243
263
|
# Check if the query parameters have the given facet field with the
|
244
264
|
# given value.
|
245
265
|
#
|
266
|
+
# @deprecated
|
246
267
|
# @param [String] field
|
247
268
|
# @param [String] item facet value
|
248
269
|
# @return [Boolean]
|
@@ -254,6 +275,7 @@ module Blacklight::FacetsHelperBehavior
|
|
254
275
|
|
255
276
|
##
|
256
277
|
# Get the values of the facet set in the blacklight query string
|
278
|
+
# @deprecated
|
257
279
|
def facet_params field
|
258
280
|
config = facet_configuration_for_field(field)
|
259
281
|
|
@@ -274,6 +296,7 @@ module Blacklight::FacetsHelperBehavior
|
|
274
296
|
facet_item_presenter(facet_config, item, field).label
|
275
297
|
end
|
276
298
|
|
299
|
+
# @deprecated
|
277
300
|
def facet_field_id facet_field
|
278
301
|
"facet-#{facet_field.key.parameterize}"
|
279
302
|
end
|
@@ -10,10 +10,14 @@
|
|
10
10
|
# This is used to serialize a complete current query from current params
|
11
11
|
# to form fields used for sort and change per-page
|
12
12
|
module Blacklight::HashAsHiddenFieldsHelperBehavior
|
13
|
+
extend Deprecation
|
14
|
+
|
13
15
|
##
|
14
16
|
# Writes out zero or more <input type="hidden"> elements, completely
|
15
17
|
# representing a hash passed in using Rails-style request parameters
|
16
18
|
# for hashes nested with arrays and other hashes.
|
19
|
+
#
|
20
|
+
# @deprecated
|
17
21
|
# @param [Hash] hash
|
18
22
|
# @return [String]
|
19
23
|
def render_hash_as_hidden_fields(hash)
|
@@ -27,6 +31,7 @@ module Blacklight::HashAsHiddenFieldsHelperBehavior
|
|
27
31
|
|
28
32
|
safe_join(hidden_fields, "\n")
|
29
33
|
end
|
34
|
+
deprecation_deprecate render_hash_as_hidden_fields: 'Moving to a private method of Blacklight::SearchBarComponent'
|
30
35
|
|
31
36
|
private
|
32
37
|
|
@@ -12,7 +12,8 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
12
12
|
##
|
13
13
|
# Check if the query has any constraints defined (a query, facet, etc)
|
14
14
|
#
|
15
|
-
# @
|
15
|
+
# @deprecated
|
16
|
+
# @param [Blacklight::SearchState,Hash] params_or_search_state query parameters
|
16
17
|
# @return [Boolean]
|
17
18
|
def query_has_constraints?(params_or_search_state = search_state)
|
18
19
|
search_state = convert_to_search_state(params_or_search_state)
|
@@ -41,9 +42,11 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
41
42
|
##
|
42
43
|
# Render the query constraints
|
43
44
|
#
|
44
|
-
# @
|
45
|
+
# @deprecated
|
46
|
+
# @param [Blacklight::SearchState,ActionController::Parameters] params_or_search_state query parameters
|
45
47
|
# @return [String]
|
46
48
|
def render_constraints_query(params_or_search_state = search_state)
|
49
|
+
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_constraints_query is deprecated')
|
47
50
|
search_state = convert_to_search_state(params_or_search_state)
|
48
51
|
|
49
52
|
# So simple don't need a view template, we can just do it here.
|
@@ -56,27 +59,29 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
56
59
|
remove: remove_constraint_url(search_state))
|
57
60
|
end
|
58
61
|
end
|
59
|
-
deprecation_deprecate :render_constraints_query
|
60
62
|
|
61
63
|
##
|
62
64
|
# Provide a url for removing a particular constraint. This can be overriden
|
63
65
|
# in the case that you want parameters other than the defaults to be removed
|
64
66
|
# (e.g. :search_field)
|
65
67
|
#
|
66
|
-
# @
|
68
|
+
# @deprecated
|
69
|
+
# @param [Blacklight::SearchState,ActionController::Parameters] params_or_search_state query parameters
|
67
70
|
# @return [String]
|
68
71
|
def remove_constraint_url(params_or_search_state = search_state)
|
72
|
+
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'remove_constraint_url is deprecated')
|
69
73
|
search_state = convert_to_search_state(params_or_search_state)
|
70
74
|
|
71
75
|
search_action_path(search_state.remove_query_params)
|
72
76
|
end
|
73
|
-
deprecation_deprecate :remove_constraint_url
|
74
77
|
|
75
78
|
##
|
76
79
|
# Render the facet constraints
|
77
|
-
# @
|
80
|
+
# @deprecated
|
81
|
+
# @param [Blacklight::SearchState,Hash] params_or_search_state query parameters
|
78
82
|
# @return [String]
|
79
83
|
def render_constraints_filters(params_or_search_state = search_state)
|
84
|
+
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_constraints_filters is deprecated')
|
80
85
|
search_state = convert_to_search_state(params_or_search_state)
|
81
86
|
|
82
87
|
return "".html_safe if search_state.filter_params.blank?
|
@@ -87,15 +92,16 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
87
92
|
end, "\n")
|
88
93
|
end
|
89
94
|
end
|
90
|
-
deprecation_deprecate :render_constraints_filters
|
91
95
|
|
92
96
|
##
|
93
97
|
# Render a single facet's constraint
|
98
|
+
# @deprecated
|
94
99
|
# @param [String] facet field
|
95
100
|
# @param [Array<String>] values selected facet values
|
96
|
-
# @param [Blacklight::SearchState] path query parameters
|
101
|
+
# @param [Blacklight::SearchState] search_state path query parameters
|
97
102
|
# @return [String]
|
98
103
|
def render_filter_element(facet, values, search_state)
|
104
|
+
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_filter_element is deprecated')
|
99
105
|
facet_config = facet_configuration_for_field(facet)
|
100
106
|
|
101
107
|
safe_join(Array(values).map do |val|
|
@@ -104,14 +110,13 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
104
110
|
presenter = facet_item_presenter(facet_config, val, facet)
|
105
111
|
|
106
112
|
Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
|
107
|
-
render_constraint_element(
|
113
|
+
render_constraint_element(presenter.field_label,
|
108
114
|
presenter.label,
|
109
115
|
remove: presenter.remove_href(search_state),
|
110
116
|
classes: ["filter", "filter-" + facet.parameterize])
|
111
117
|
end
|
112
118
|
end, "\n")
|
113
119
|
end
|
114
|
-
deprecation_deprecate :render_filter_element
|
115
120
|
|
116
121
|
# Render a label/value constraint on the screen. Can be called
|
117
122
|
# by plugins and such to get application-defined rendering.
|
@@ -121,6 +126,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
121
126
|
#
|
122
127
|
# Can pass in nil label if desired.
|
123
128
|
#
|
129
|
+
# @deprecated
|
124
130
|
# @param [String] label to display
|
125
131
|
# @param [String] value to display
|
126
132
|
# @param [Hash] options
|
@@ -128,9 +134,20 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
128
134
|
# @option options [Array<String>] :classes an array of classes to add to container span for constraint.
|
129
135
|
# @return [String]
|
130
136
|
def render_constraint_element(label, value, options = {})
|
137
|
+
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_constraints_element is deprecated')
|
131
138
|
render(partial: "catalog/constraints_element", locals: { label: label, value: value, options: options })
|
132
139
|
end
|
133
|
-
|
140
|
+
|
141
|
+
# @private
|
142
|
+
def constraints_helpers_and_partials_from_blacklight?
|
143
|
+
method(:render_constraints).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
144
|
+
method(:render_constraints_query).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
145
|
+
method(:remove_constraint_url).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
146
|
+
method(:render_constraints_filters).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
147
|
+
method(:render_filter_element).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
148
|
+
method(:render_constraint_element).owner == Blacklight::RenderConstraintsHelperBehavior &&
|
149
|
+
partial_from_blacklight?('catalog/constraints_element')
|
150
|
+
end
|
134
151
|
|
135
152
|
private
|
136
153
|
|