blacklight 9.0.0.beta6 → 9.0.0.beta8
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/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +21 -3
- data/.solr_wrapper.yml +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +9 -5
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +9 -5
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +2 -1
- data/app/components/blacklight/constraints_component.html.erb +3 -8
- data/app/components/blacklight/constraints_component.rb +57 -14
- 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 +20 -24
- data/app/components/blacklight/facet_item_pivot_component.rb +4 -0
- data/app/components/blacklight/facets/filters_component.rb +1 -1
- data/app/components/blacklight/facets/item_component.rb +3 -0
- data/app/components/blacklight/facets/selected_value_component.rb +1 -1
- data/app/components/blacklight/facets/suggest_component.rb +2 -3
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +8 -4
- data/app/javascript/blacklight-frontend/facet_suggest.js +2 -1
- data/app/javascript/blacklight-frontend/modal.js +7 -4
- data/app/presenters/blacklight/constraint_presenter.rb +22 -0
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_presenter.rb +0 -18
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/join.rb +9 -5
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- 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 +9 -5
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/show.html.erb +2 -2
- 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 +2 -3
- 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 +7 -1
- data/lib/blacklight/configuration/facet_field.rb +4 -0
- data/lib/blacklight/configuration/view_config.rb +30 -16
- data/lib/blacklight/configuration.rb +58 -5
- data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
- data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +5 -5
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -2
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +26 -4
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
- data/package.json +1 -1
- data/spec/components/blacklight/constraints_component_spec.rb +2 -2
- data/spec/components/blacklight/document_component_spec.rb +8 -15
- data/spec/components/blacklight/facets/filters_component_spec.rb +2 -2
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +2 -1
- data/spec/components/blacklight/facets/suggest_component_spec.rb +15 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/features/advanced_search_spec.rb +39 -20
- data/spec/features/search_filters_spec.rb +3 -3
- data/spec/features/search_spec.rb +3 -3
- data/spec/models/blacklight/configuration_spec.rb +126 -0
- data/spec/models/blacklight/solr/repository_spec.rb +6 -0
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +52 -6
- data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -0
- metadata +18 -10
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
|
@@ -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,14 +117,40 @@ module Blacklight
|
|
|
100
117
|
end
|
|
101
118
|
end
|
|
102
119
|
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
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)
|
|
107
128
|
end
|
|
108
129
|
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
)
|
|
111
154
|
end
|
|
112
155
|
end
|
|
113
156
|
end
|
|
@@ -33,40 +33,36 @@ 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
|
|
37
|
-
component ||= view_config.
|
|
36
|
+
renders_one :title, (lambda do |component: nil, **kwargs|
|
|
37
|
+
component ||= view_config.document_title_component
|
|
38
38
|
|
|
39
|
-
component
|
|
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
|
-
component ||= view_config.
|
|
46
|
-
|
|
47
|
-
next unless component
|
|
48
|
-
|
|
49
|
-
component.new(*args, presenter: @presenter, document_counter: @document_counter, **kwargs)
|
|
45
|
+
component ||= view_config.document_embed_component
|
|
46
|
+
component&.new(presenter: @presenter, document_counter: @document_counter, **kwargs)
|
|
50
47
|
end)
|
|
51
48
|
|
|
52
49
|
# The primary metadata section
|
|
53
|
-
renders_one :metadata, (lambda do |static_content = nil,
|
|
50
|
+
renders_one :metadata, (lambda do |static_content = nil, component: nil, fields: nil, **kwargs|
|
|
54
51
|
next static_content if static_content.present?
|
|
55
52
|
|
|
56
|
-
component ||= view_config.
|
|
57
|
-
|
|
58
|
-
component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
|
|
53
|
+
component ||= view_config.document_metadata_component
|
|
54
|
+
component&.new(fields: fields || @presenter&.field_presenters || [], **kwargs)
|
|
59
55
|
end)
|
|
60
56
|
|
|
61
57
|
# Additional metadata sections
|
|
62
58
|
renders_many :metadata_sections
|
|
63
59
|
|
|
64
|
-
renders_one :thumbnail, (lambda do |image_options_or_static_content = {},
|
|
60
|
+
renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, component: nil, **kwargs|
|
|
65
61
|
next image_options_or_static_content if image_options_or_static_content.is_a? String
|
|
66
62
|
|
|
67
|
-
component ||= view_config.
|
|
63
|
+
component ||= view_config.document_thumbnail_component
|
|
68
64
|
|
|
69
|
-
component
|
|
65
|
+
component&.new(presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
|
|
70
66
|
end)
|
|
71
67
|
|
|
72
68
|
# A container for partials rendered using the view config partials configuration. Its use is discouraged, but necessary until
|
|
@@ -90,18 +86,18 @@ module Blacklight
|
|
|
90
86
|
def initialize(document: nil, partials: nil,
|
|
91
87
|
id: nil, classes: [], component: :article, title_component: nil,
|
|
92
88
|
counter: nil, document_counter: nil, counter_offset: 0,
|
|
93
|
-
show: false
|
|
94
|
-
@presenter = document
|
|
89
|
+
show: false)
|
|
90
|
+
@presenter = document
|
|
95
91
|
@document = @presenter.document
|
|
96
92
|
@view_partials = partials || []
|
|
97
93
|
|
|
98
94
|
@component = component
|
|
99
95
|
@title_component = title_component
|
|
100
|
-
@id = id
|
|
96
|
+
@id = id
|
|
101
97
|
@classes = classes
|
|
102
98
|
|
|
103
99
|
@counter = counter
|
|
104
|
-
@document_counter = document_counter
|
|
100
|
+
@document_counter = document_counter
|
|
105
101
|
@counter ||= 1 + @document_counter + counter_offset if @document_counter.present?
|
|
106
102
|
|
|
107
103
|
@show = show
|
|
@@ -119,10 +115,10 @@ module Blacklight
|
|
|
119
115
|
end
|
|
120
116
|
|
|
121
117
|
def before_render
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
with_title unless title
|
|
119
|
+
with_thumbnail unless thumbnail
|
|
120
|
+
with_metadata(fields: presenter.field_presenters, show: @show) unless metadata
|
|
121
|
+
with_embed unless embed
|
|
126
122
|
|
|
127
123
|
view_partials.each do |view_partial|
|
|
128
124
|
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
|
|
@@ -11,11 +11,10 @@ module Blacklight
|
|
|
11
11
|
|
|
12
12
|
attr_accessor :presenter
|
|
13
13
|
|
|
14
|
-
delegate :
|
|
14
|
+
delegate :key, :label, to: :presenter
|
|
15
15
|
|
|
16
16
|
def render?
|
|
17
|
-
|
|
18
|
-
suggest != false
|
|
17
|
+
presenter.suggest?
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
end
|
|
@@ -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
|
|
@@ -4,23 +4,28 @@ module Blacklight
|
|
|
4
4
|
class MetadataFieldLayoutComponent < Blacklight::Component
|
|
5
5
|
with_collection_parameter :field
|
|
6
6
|
renders_one :label
|
|
7
|
-
renders_many :values, (lambda do |value: nil, &block|
|
|
7
|
+
renders_many :values, (lambda do |index:, value: nil, &block|
|
|
8
|
+
classes = [@value_class, "blacklight-#{@key}"]
|
|
9
|
+
classes.unshift @offset_class unless index.zero?
|
|
10
|
+
classes.join(' ')
|
|
11
|
+
|
|
8
12
|
if @value_tag.nil?
|
|
9
13
|
block&.call || value
|
|
10
14
|
elsif block
|
|
11
|
-
content_tag @value_tag, class:
|
|
15
|
+
content_tag @value_tag, class: classes, &block
|
|
12
16
|
else
|
|
13
|
-
content_tag @value_tag, value, class:
|
|
17
|
+
content_tag @value_tag, value, class: classes
|
|
14
18
|
end
|
|
15
19
|
end)
|
|
16
20
|
|
|
17
21
|
# @param field [Blacklight::FieldPresenter]
|
|
18
|
-
def initialize(field:, value_tag: 'dd', label_class: 'col-md-3', value_class: 'col-md-9')
|
|
22
|
+
def initialize(field:, value_tag: 'dd', label_class: 'col-md-3', value_class: 'col-md-9', offset_class: 'offset-md-3')
|
|
19
23
|
@field = field
|
|
20
24
|
@key = @field.key.parameterize
|
|
21
25
|
@label_class = label_class
|
|
22
26
|
@value_tag = value_tag
|
|
23
27
|
@value_class = value_class
|
|
28
|
+
@offset_class = offset_class
|
|
24
29
|
end
|
|
25
30
|
end
|
|
26
31
|
end
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
<% end %>
|
|
37
37
|
|
|
38
38
|
<% if advanced_search_enabled? %>
|
|
39
|
-
<%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-
|
|
39
|
+
<%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-link text-body' %>
|
|
40
40
|
<% end %>
|
|
41
41
|
</search>
|
|
@@ -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
|
|
@@ -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) {
|
|
@@ -160,11 +160,14 @@ const Modal = (() => {
|
|
|
160
160
|
|
|
161
161
|
// Make sure user-agent dismissal of html 'dialog', etc `esc` key, triggers
|
|
162
162
|
// our hide logic, including events and scroll restoration.
|
|
163
|
-
modal.target()
|
|
164
|
-
|
|
163
|
+
const modalDom = modal.target();
|
|
164
|
+
if (modalDom) {
|
|
165
|
+
modal.target().addEventListener('cancel', (e) => {
|
|
166
|
+
e.preventDefault(); // 'hide' will close the modal unless cancelled
|
|
165
167
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
modal.hide();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
168
171
|
};
|
|
169
172
|
|
|
170
173
|
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
|
|
@@ -44,11 +44,11 @@ module Blacklight
|
|
|
44
44
|
#
|
|
45
45
|
# @return [String]
|
|
46
46
|
def heading
|
|
47
|
-
return field_value(view_config.title_field) if view_config.title_field.is_a? Blacklight::Configuration::Field
|
|
47
|
+
return field_value(view_config.title_field, join: true).first if view_config.title_field.is_a? Blacklight::Configuration::Field
|
|
48
48
|
|
|
49
49
|
fields = Array.wrap(view_config.title_field) + [configuration.document_model.unique_key]
|
|
50
50
|
f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
|
|
51
|
-
f ? field_value(f, except_operations: [Rendering::HelperMethod]) : ""
|
|
51
|
+
f ? field_value(f, except_operations: [Rendering::HelperMethod], join: true).first : ""
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
##
|
|
@@ -58,12 +58,12 @@ module Blacklight
|
|
|
58
58
|
# @see #document_heading
|
|
59
59
|
# @return [String]
|
|
60
60
|
def html_title
|
|
61
|
-
return field_value(view_config.html_title_field) if view_config.html_title_field.is_a? Blacklight::Configuration::Field
|
|
61
|
+
return field_value(view_config.html_title_field, join: true).first if view_config.html_title_field.is_a? Blacklight::Configuration::Field
|
|
62
62
|
|
|
63
63
|
if view_config.html_title_field
|
|
64
64
|
fields = Array.wrap(view_config.html_title_field) + [configuration.document_model.unique_key]
|
|
65
65
|
f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
|
|
66
|
-
field_value(f)
|
|
66
|
+
field_value(f, join: true).first
|
|
67
67
|
else
|
|
68
68
|
heading
|
|
69
69
|
end
|
|
@@ -93,8 +93,9 @@ module Blacklight
|
|
|
93
93
|
# @param [Configuration::Field] field_config
|
|
94
94
|
# @param [Hash] options
|
|
95
95
|
# @option options [String] :value
|
|
96
|
+
# @return [Array]
|
|
96
97
|
def field_value field_config, options = {}
|
|
97
|
-
field_presenter(field_config, options).render
|
|
98
|
+
Array.wrap(field_presenter(field_config, options).render)
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
def thumbnail_presenter_class
|
|
@@ -4,18 +4,18 @@ module Blacklight
|
|
|
4
4
|
class FacetFieldPresenter
|
|
5
5
|
attr_reader :facet_field, :display_facet, :view_context, :search_state
|
|
6
6
|
|
|
7
|
-
delegate :key,
|
|
7
|
+
delegate :key, to: :facet_field
|
|
8
8
|
delegate :field_name, to: :display_facet
|
|
9
9
|
|
|
10
10
|
# @param [Blacklight::Configuration::FacetField] facet_field
|
|
11
11
|
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
|
12
12
|
# @param [#search_action_path,#facet_field_presenter] view_context
|
|
13
13
|
# @param [Blacklight::SearchState] search_state
|
|
14
|
-
def initialize(facet_field, display_facet, view_context, search_state =
|
|
14
|
+
def initialize(facet_field, display_facet, view_context, search_state = nil)
|
|
15
15
|
@facet_field = facet_field
|
|
16
16
|
@display_facet = display_facet
|
|
17
17
|
@view_context = view_context
|
|
18
|
-
@search_state = search_state
|
|
18
|
+
@search_state = search_state || view_context&.search_state
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# @param [Blacklight::Solr::Response::Facets::FacetItem, String] facet_item
|
|
@@ -23,6 +23,13 @@ module Blacklight
|
|
|
23
23
|
facet_field.item_presenter.new(facet_item, facet_field, view_context, key, search_state)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
# Is facet suggest feature configured on for this facet, or by global default.
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean]
|
|
29
|
+
def suggest?
|
|
30
|
+
!!(facet_field.suggest.nil? ? blacklight_config.default_facet_suggest : facet_field.suggest)
|
|
31
|
+
end
|
|
32
|
+
|
|
26
33
|
def collapsed?
|
|
27
34
|
!active? && facet_field.collapse
|
|
28
35
|
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
|
|
@@ -33,9 +33,11 @@ module Blacklight
|
|
|
33
33
|
|
|
34
34
|
delegate :key, :component, to: :field_config
|
|
35
35
|
|
|
36
|
-
# @return [String]
|
|
36
|
+
# @return [Array<String>]
|
|
37
37
|
def render
|
|
38
|
-
|
|
38
|
+
Array.wrap(
|
|
39
|
+
Rendering::Pipeline.new(values, field_config, document, view_context, pipeline_steps, options).render
|
|
40
|
+
)
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
# @return [Enumerable]
|
|
@@ -22,7 +22,13 @@ module Blacklight
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def html?
|
|
25
|
-
|
|
25
|
+
format.nil? || format.to_s == 'html'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def format
|
|
29
|
+
return options[:format] unless context.respond_to?(:search_state)
|
|
30
|
+
|
|
31
|
+
options[:format] || context.search_state&.params&.dig(:format)
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
end
|