blacklight 9.0.0.beta5 → 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.
- checksums.yaml +4 -4
- data/.github/matrix.json +8 -1
- data/.solr_wrapper.yml +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +12 -3
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +12 -3
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/constraint_component.html.erb +1 -5
- data/app/components/blacklight/constraint_component.rb +11 -0
- data/app/components/blacklight/constraints_component.html.erb +3 -8
- data/app/components/blacklight/constraints_component.rb +57 -12
- data/app/components/blacklight/document/bookmark_component.rb +1 -1
- data/app/components/blacklight/document/page_header_component.rb +1 -1
- data/app/components/blacklight/document_component.rb +15 -16
- data/app/components/blacklight/facet_item_pivot_component.rb +4 -0
- data/app/components/blacklight/facets/item_component.rb +3 -0
- data/app/components/blacklight/facets/list_component.rb +2 -1
- data/app/components/blacklight/facets/selected_value_component.rb +1 -1
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/controllers/concerns/blacklight/catalog.rb +8 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +0 -14
- data/app/javascript/blacklight-frontend/checkbox_submit.js +2 -2
- data/app/javascript/blacklight-frontend/facet_suggest.js +2 -1
- data/app/javascript/blacklight-frontend/modal.js +8 -0
- data/app/presenters/blacklight/constraint_presenter.rb +22 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +9 -0
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +6 -0
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_presenter.rb +5 -18
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_document.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +1 -1
- data/app/views/catalog/index.json.jbuilder +5 -3
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.ar.yml +1 -2
- data/config/locales/blacklight.ca.yml +1 -2
- data/config/locales/blacklight.de.yml +1 -2
- data/config/locales/blacklight.en.yml +1 -2
- data/config/locales/blacklight.es.yml +1 -2
- data/config/locales/blacklight.fr.yml +1 -2
- data/config/locales/blacklight.hu.yml +1 -2
- data/config/locales/blacklight.it.yml +1 -2
- data/config/locales/blacklight.nl.yml +1 -2
- data/config/locales/blacklight.pt-BR.yml +1 -2
- data/config/locales/blacklight.sq.yml +1 -2
- data/config/locales/blacklight.zh.yml +1 -2
- data/lib/blacklight/component.rb +5 -1
- data/lib/blacklight/configuration/facet_field.rb +2 -0
- data/lib/blacklight/configuration.rb +2 -0
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +1 -1
- data/package.json +1 -1
- data/spec/components/blacklight/constraints_component_spec.rb +2 -2
- data/spec/components/blacklight/document_component_spec.rb +9 -9
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +2 -1
- data/spec/components/blacklight/facets/list_component_spec.rb +6 -0
- data/spec/components/blacklight/facets/pivot_list_component_spec.rb +6 -0
- data/spec/components/blacklight/facets/suggest_component_spec.rb +2 -1
- data/spec/features/search_filters_spec.rb +3 -3
- data/spec/features/search_spec.rb +3 -3
- data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -0
- metadata +14 -5
@@ -6,9 +6,10 @@ module Blacklight
|
|
6
6
|
renders_many :facet_constraints_area
|
7
7
|
renders_many :additional_constraints
|
8
8
|
|
9
|
+
# Constraints are stored and used to display search history - with this method, we initialize the ConstraintsComponent
|
10
|
+
# in a way that displays well in a table (and without a start-over button)
|
9
11
|
def self.for_search_history(**)
|
10
|
-
new(tag: :span,
|
11
|
-
render_headers: false,
|
12
|
+
new(tag: :span, render_headers: false,
|
12
13
|
id: nil,
|
13
14
|
query_constraint_component: Blacklight::SearchHistoryConstraintLayoutComponent,
|
14
15
|
facet_constraint_component_options: { layout: Blacklight::SearchHistoryConstraintLayoutComponent },
|
@@ -20,7 +21,8 @@ module Blacklight
|
|
20
21
|
def initialize(search_state:,
|
21
22
|
tag: :div,
|
22
23
|
render_headers: true,
|
23
|
-
|
24
|
+
heading_classes: 'constraints-label h6 mb-0',
|
25
|
+
id: 'appliedParams', classes: 'clearfix constraints-container mb-2 align-items-center',
|
24
26
|
query_constraint_component: Blacklight::ConstraintLayoutComponent,
|
25
27
|
query_constraint_component_options: {},
|
26
28
|
facet_constraint_component: Blacklight::ConstraintComponent,
|
@@ -33,12 +35,14 @@ module Blacklight
|
|
33
35
|
@facet_constraint_component_options = facet_constraint_component_options
|
34
36
|
@start_over_component = start_over_component
|
35
37
|
@render_headers = render_headers
|
38
|
+
@heading_classes = heading_classes
|
36
39
|
@tag = tag
|
37
40
|
@id = id
|
38
41
|
@classes = classes
|
39
42
|
end
|
40
43
|
# rubocop:enable Metrics/ParameterLists
|
41
44
|
|
45
|
+
# @return [String] HTML representation of query constraints
|
42
46
|
def query_constraints
|
43
47
|
if @search_state.query_param.present?
|
44
48
|
render(
|
@@ -56,41 +60,54 @@ module Blacklight
|
|
56
60
|
end + render(@facet_constraint_component.with_collection(clause_presenters.to_a, **@facet_constraint_component_options))
|
57
61
|
end
|
58
62
|
|
63
|
+
# @return [String] URL path to remove the current query
|
59
64
|
def remove_path
|
60
65
|
helpers.search_action_path(@search_state.remove_query_params)
|
61
66
|
end
|
62
67
|
|
68
|
+
# @return [String] HTML representation of facet constraints
|
63
69
|
def facet_constraints
|
64
|
-
render(@facet_constraint_component.with_collection(
|
70
|
+
render(@facet_constraint_component.with_collection(constraint_presenters.to_a, **@facet_constraint_component_options))
|
65
71
|
end
|
66
72
|
|
73
|
+
# @return [Boolean] true if search state has constraints
|
67
74
|
def render?
|
68
75
|
@search_state.has_constraints?
|
69
76
|
end
|
70
77
|
|
71
78
|
private
|
72
79
|
|
80
|
+
# @return [String, nil] label for the search field if not the default search field
|
73
81
|
def label
|
74
82
|
search_field = @search_state.params[:search_field]
|
75
83
|
helpers.label_for_search_field(search_field) unless helpers.default_search_field?(search_field)
|
76
84
|
end
|
77
85
|
|
78
|
-
|
79
|
-
|
86
|
+
# Yields constraint presenters for each facet value
|
87
|
+
#
|
88
|
+
# @yield [Blacklight::ConstraintPresenter] facet constraint presenter
|
89
|
+
# @return [Enumerator] if no block given
|
90
|
+
def constraint_presenters
|
91
|
+
return to_enum(:constraint_presenters) unless block_given?
|
80
92
|
|
81
93
|
@search_state.filters.map do |facet|
|
94
|
+
facet_field_presenter = helpers.facet_field_presenter(facet.config, {})
|
82
95
|
facet.each_value do |val|
|
83
96
|
next if val.blank?
|
84
97
|
|
85
98
|
if val.is_a?(Array)
|
86
|
-
yield
|
99
|
+
yield inclusive_facet_constraint_presenter(facet_field_presenter, facet.config, val, facet.key) if val.any?(&:present?)
|
87
100
|
else
|
88
|
-
yield
|
101
|
+
yield facet_constraint_presenter(facet_field_presenter, facet.config, val)
|
89
102
|
end
|
90
103
|
end
|
91
104
|
end
|
92
105
|
end
|
93
106
|
|
107
|
+
# Yields clause presenters for search clauses
|
108
|
+
#
|
109
|
+
# @yield [Blacklight::ClausePresenter] clause presenter
|
110
|
+
# @return [Enumerator] if no block given
|
94
111
|
def clause_presenters
|
95
112
|
return to_enum(:clause_presenters) unless block_given?
|
96
113
|
|
@@ -100,12 +117,40 @@ module Blacklight
|
|
100
117
|
end
|
101
118
|
end
|
102
119
|
|
103
|
-
|
104
|
-
|
120
|
+
# Creates a facet constraint presenter for a single facet item
|
121
|
+
#
|
122
|
+
# @param facet_field_presenter [Blacklight::FacetFieldPresenter] presenter for the facet field
|
123
|
+
# @param facet_config [Blacklight::Configuration::FacetField] configuration for the facet
|
124
|
+
# @param facet_item [String] the facet item
|
125
|
+
# @return [Blacklight::ConstraintPresenter] constraint presenter for the facet item
|
126
|
+
def facet_constraint_presenter(facet_field_presenter, facet_config, facet_item)
|
127
|
+
facet_config.constraint_presenter.new(facet_item_presenter: facet_field_presenter.item_presenter(facet_item), field_label: facet_field_presenter.label)
|
105
128
|
end
|
106
129
|
|
107
|
-
|
108
|
-
|
130
|
+
# Creates a constraint presenter for an inclusive facet (multiple values)
|
131
|
+
#
|
132
|
+
# @param facet_field_presenter [Blacklight::FacetFieldPresenter] presenter for the facet field
|
133
|
+
# @param facet_config [Blacklight::Configuration::FacetField] configuration for the facet
|
134
|
+
# @param facet_item [Array] array of facet items
|
135
|
+
# @param facet_field [Symbol, String] the facet field name
|
136
|
+
# @return [Blacklight::ConstraintPresenter] constraint presenter for the inclusive facet
|
137
|
+
def inclusive_facet_constraint_presenter(facet_field_presenter, facet_config, facet_item, facet_field)
|
138
|
+
facet_config.constraint_presenter.new(
|
139
|
+
facet_item_presenter: Blacklight::InclusiveFacetItemPresenter.new(facet_item, facet_config, helpers, facet_field),
|
140
|
+
field_label: facet_field_presenter.label
|
141
|
+
)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns a heading tag for the constraints section
|
145
|
+
#
|
146
|
+
# @return [ActiveSupport::SafeBuffer, nil] constraints heading html
|
147
|
+
def constraints_heading
|
148
|
+
return unless @render_headers
|
149
|
+
|
150
|
+
tag.h2(
|
151
|
+
t('blacklight.search.filters.title'),
|
152
|
+
class: @heading_classes
|
153
|
+
)
|
109
154
|
end
|
110
155
|
end
|
111
156
|
end
|
@@ -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
|
36
|
+
renders_one :title, (lambda do |component: nil, **kwargs|
|
37
37
|
component ||= view_config.title_component || Blacklight::DocumentTitleComponent
|
38
38
|
|
39
|
-
component.new(
|
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,
|
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(
|
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,
|
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 = {},
|
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(
|
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
|
94
|
-
@presenter = document
|
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
|
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
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Blacklight
|
4
4
|
module Facets
|
5
5
|
class ListComponent < Blacklight::Component
|
6
|
+
# @param [Blacklight::FacetFieldPresenter] facet_field
|
6
7
|
def initialize(facet_field:,
|
7
8
|
classes: %w[facet-values list-unstyled],
|
8
9
|
role: nil,
|
@@ -30,7 +31,7 @@ module Blacklight
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def facet_item_presenter(facet_item)
|
33
|
-
|
34
|
+
@facet_field.item_presenter(facet_item)
|
34
35
|
end
|
35
36
|
|
36
37
|
def facet_item_component_class
|
@@ -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
|
-
|
23
|
-
|
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
|
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
|
@@ -130,10 +130,12 @@ module Blacklight::CatalogHelperBehavior
|
|
130
130
|
# @return [String]
|
131
131
|
def render_search_to_page_title_filter(facet, values)
|
132
132
|
facet_config = facet_configuration_for_field(facet)
|
133
|
-
|
133
|
+
facet_presenter = facet_field_presenter(facet_config, {})
|
134
|
+
filter_label = facet_presenter.label
|
134
135
|
filter_value = if values.size < 3
|
135
136
|
values.map do |value|
|
136
|
-
|
137
|
+
item_presenter = facet_presenter.item_presenter(value)
|
138
|
+
label = item_presenter.label
|
137
139
|
label = strip_tags(label) if label.html_safe?
|
138
140
|
label
|
139
141
|
end.to_sentence
|
@@ -15,18 +15,4 @@ module Blacklight::FacetsHelperBehavior
|
|
15
15
|
.except(:page)
|
16
16
|
url_for opts
|
17
17
|
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def facet_value_for_facet_item item
|
22
|
-
if item.respond_to? :value
|
23
|
-
item.value
|
24
|
-
else
|
25
|
-
item
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def facet_item_presenter(facet_config, facet_item, facet_field)
|
30
|
-
facet_config.item_presenter.new(facet_item, facet_config, self, facet_field)
|
31
|
-
end
|
32
18
|
end
|
@@ -44,8 +44,8 @@ export default class CheckboxSubmit {
|
|
44
44
|
counter.innerHTML = json.bookmarks.count;
|
45
45
|
});
|
46
46
|
|
47
|
-
var e = new CustomEvent('bookmark.blacklight', { detail: { checked: this.checked } });
|
48
|
-
|
47
|
+
var e = new CustomEvent('bookmark.blacklight', { detail: { checked: this.checked }, bubbles: true });
|
48
|
+
this.formTarget.dispatchEvent(e)
|
49
49
|
}).catch((error) => {
|
50
50
|
this.handleError(error)
|
51
51
|
})
|
@@ -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 =
|
22
|
+
const urlToFetch = `/${basePathComponent}/facet_suggest/${facetField}/${queryFragment}?${facetSearchParams}`;
|
22
23
|
|
23
24
|
const response = await fetch(urlToFetch);
|
24
25
|
if (response.ok) {
|
@@ -157,6 +157,14 @@ const Modal = (() => {
|
|
157
157
|
else if (e.target.matches(`${modal.modalSelector}`) || e.target.closest('[data-bl-dismiss="modal"]'))
|
158
158
|
modal.hide()
|
159
159
|
})
|
160
|
+
|
161
|
+
// Make sure user-agent dismissal of html 'dialog', etc `esc` key, triggers
|
162
|
+
// our hide logic, including events and scroll restoration.
|
163
|
+
modal.target().addEventListener('cancel', (e) => {
|
164
|
+
e.preventDefault(); // 'hide' will close the modal unless cancelled
|
165
|
+
|
166
|
+
modal.hide();
|
167
|
+
});
|
160
168
|
};
|
161
169
|
|
162
170
|
modal.hide = function (el) {
|
@@ -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
|
@@ -7,6 +7,10 @@ module Blacklight
|
|
7
7
|
delegate :key, :suggest, to: :facet_field
|
8
8
|
delegate :field_name, to: :display_facet
|
9
9
|
|
10
|
+
# @param [Blacklight::Configuration::FacetField] facet_field
|
11
|
+
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
12
|
+
# @param [#search_action_path,#facet_field_presenter] view_context
|
13
|
+
# @param [Blacklight::SearchState] search_state
|
10
14
|
def initialize(facet_field, display_facet, view_context, search_state = view_context.search_state)
|
11
15
|
@facet_field = facet_field
|
12
16
|
@display_facet = display_facet
|
@@ -14,6 +18,11 @@ module Blacklight
|
|
14
18
|
@search_state = search_state
|
15
19
|
end
|
16
20
|
|
21
|
+
# @param [Blacklight::Solr::Response::Facets::FacetItem, String] facet_item
|
22
|
+
def item_presenter(facet_item)
|
23
|
+
facet_field.item_presenter.new(facet_item, facet_field, view_context, key, search_state)
|
24
|
+
end
|
25
|
+
|
17
26
|
def collapsed?
|
18
27
|
!active? && facet_field.collapse
|
19
28
|
end
|
@@ -6,6 +6,12 @@ module Blacklight
|
|
6
6
|
|
7
7
|
delegate :key, to: :facet_config
|
8
8
|
|
9
|
+
# @param [Array<String>] group
|
10
|
+
# @param [String] facet_item
|
11
|
+
# @param [Blacklight::Configuration::FacetField] facet_config
|
12
|
+
# @param [#search_action_path] view_context
|
13
|
+
# @param [String] facet_field
|
14
|
+
# @param [Blacklight::SearchState] search_state
|
9
15
|
def initialize(group, facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state)
|
10
16
|
super(facet_item, facet_config, view_context, facet_field, search_state)
|
11
17
|
@group = group
|
@@ -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
|
-
|
24
|
+
view_context.facet_field_presenter(facet_config, {}).item_presenter(facet_item)
|
29
25
|
end
|
30
26
|
|
31
27
|
##
|
@@ -6,6 +6,11 @@ module Blacklight
|
|
6
6
|
|
7
7
|
delegate :key, to: :facet_config
|
8
8
|
|
9
|
+
# @param [Blacklight::Solr::Response::Facets::FacetItem, String] facet_item
|
10
|
+
# @param [Blacklight::Configuration::FacetField] facet_config
|
11
|
+
# @param [#search_action_path,#facet_field_presenter] view_context
|
12
|
+
# @param [String] facet_field the name of the facet field. Same as facet_config.key
|
13
|
+
# @param [Blacklight::SearchState] search_state
|
9
14
|
def initialize(facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state)
|
10
15
|
@facet_item = facet_item
|
11
16
|
@facet_config = facet_config
|
@@ -33,10 +38,6 @@ module Blacklight
|
|
33
38
|
search_state.filter(facet_config).include?(value)
|
34
39
|
end
|
35
40
|
|
36
|
-
def field_label
|
37
|
-
facet_field_presenter.label
|
38
|
-
end
|
39
|
-
|
40
41
|
##
|
41
42
|
# Get the displayable version of a facet's value
|
42
43
|
#
|
@@ -62,14 +63,6 @@ module Blacklight
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
# Get the displayable version of the facet's value for use
|
66
|
-
# in e.g. the constraints widget
|
67
|
-
#
|
68
|
-
# @return [String]
|
69
|
-
def constraint_label
|
70
|
-
label
|
71
|
-
end
|
72
|
-
|
73
66
|
def value
|
74
67
|
if facet_item.respond_to? :value
|
75
68
|
facet_item.value
|
@@ -99,11 +92,5 @@ module Blacklight
|
|
99
92
|
view_context.search_action_path(search_state.add_facet_params_and_redirect(facet_config.key, facet_item).merge(path_options))
|
100
93
|
end
|
101
94
|
end
|
102
|
-
|
103
|
-
private
|
104
|
-
|
105
|
-
def facet_field_presenter
|
106
|
-
@facet_field_presenter ||= view_context.facet_field_presenter(facet_config, {})
|
107
|
-
end
|
108
95
|
end
|
109
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(
|
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(
|
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
|
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) %>
|
@@ -42,9 +42,11 @@ json.included do
|
|
42
42
|
json.id facet.name
|
43
43
|
json.attributes do
|
44
44
|
facet_config = facet_configuration_for_field(facet.name)
|
45
|
-
|
45
|
+
facet_presenter = facet_field_presenter(facet_config, facet)
|
46
|
+
json.label facet_presenter.label
|
46
47
|
json.items do
|
47
48
|
json.array! facet.items do |item|
|
49
|
+
item_presenter = facet_presenter.item_presenter(item)
|
48
50
|
json.id
|
49
51
|
json.attributes do
|
50
52
|
json.label item.label
|
@@ -52,10 +54,10 @@ json.included do
|
|
52
54
|
json.hits item.hits
|
53
55
|
end
|
54
56
|
json.links do
|
55
|
-
if search_state.filter(facet_config).include?(
|
57
|
+
if search_state.filter(facet_config).include?(item.value)
|
56
58
|
json.remove search_action_path(search_state.filter(facet.name).remove(item.value))
|
57
59
|
else
|
58
|
-
json.self
|
60
|
+
json.self item_presenter.href(only_path: false)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
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", '
|
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: "
|
196
|
+
title: "Les teves seleccions:"
|
198
197
|
label: "%{label}:"
|
199
198
|
remove:
|
200
199
|
value: "Eliminar el filtre %{value}"
|