@@ -142,29 +142,35 @@ def initialized_default_configuration?
142
142
# set to nil if a checkbox is prefered to the icon
143
143
property :bookmark_icon_component , default : Blacklight ::Icons ::BookmarkIconComponent
144
144
145
- # @!attribute index
146
- # General configuration for all views
145
+ # @!attribute defaults
146
+ # Default configuration for all views
147
147
# @return [Blacklight::Configuration::ViewConfig::Index]
148
- property :index , default : ViewConfig :: Index . new (
148
+ property :defaults , default : ViewConfig . new (
149
149
# document presenter class used by helpers and views
150
150
document_presenter_class : Blacklight ::IndexPresenter ,
151
- # document presenter used for json responses
152
- json_presenter_class : Blacklight ::JsonPresenter ,
153
151
# component class used to render a document
154
152
document_component : Blacklight ::DocumentComponent ,
155
153
document_embed_component : nil ,
156
154
document_metadata_component : Blacklight ::DocumentMetadataComponent ,
157
155
document_thumbnail_component : Blacklight ::Document ::ThumbnailComponent ,
158
156
document_title_component : Blacklight ::DocumentTitleComponent ,
159
- sidebar_component : Blacklight ::Search ::SidebarComponent ,
160
- dropdown_component : Blacklight ::System ::DropdownComponent ,
161
157
# solr field to use to render a document title
162
158
title_field : nil ,
163
159
# solr field to use to render format-specific partials
164
- display_type_field : nil ,
160
+ display_type_field : nil
161
+ )
162
+
163
+ # @!attribute index
164
+ # General configuration for search views
165
+ # @return [Blacklight::Configuration::ViewConfig::Index]
166
+ property :index , default : ViewConfig ::Index . new (
167
+ document_actions : NestedOpenStructWithHashAccess . new ( ToolConfig ) ,
168
+ # document presenter used for json responses
169
+ json_presenter_class : Blacklight ::JsonPresenter ,
170
+ sidebar_component : Blacklight ::Search ::SidebarComponent ,
171
+ dropdown_component : Blacklight ::System ::DropdownComponent ,
165
172
# the "field access" key to use to look up the document display fields
166
173
document_fields_key : :index_fields ,
167
- document_actions : NestedOpenStructWithHashAccess . new ( ToolConfig ) ,
168
174
collection_actions : NestedOpenStructWithHashAccess . new ( ToolConfig ) ,
169
175
# what field, if any, to use to render grouped results
170
176
group : false ,
@@ -192,20 +198,18 @@ def initialized_default_configuration?
192
198
property :show , default : ViewConfig ::Show . new (
193
199
# document presenter class used by helpers and views
194
200
document_presenter_class : Blacklight ::ShowPresenter ,
195
- document_component : Blacklight :: DocumentComponent ,
201
+ document_actions : NestedOpenStructWithHashAccess . new ( ToolConfig ) ,
196
202
document_thumbnail_component : nil ,
197
203
show_tools_component : Blacklight ::Document ::ShowToolsComponent ,
198
204
show_header_tools_component : nil ,
199
205
document_header_component : Blacklight ::Document ::PageHeaderComponent ,
200
206
sidebar_component : Blacklight ::Document ::SidebarComponent ,
201
- display_type_field : nil ,
202
207
# the "field access" key to use to look up the document display fields
203
208
document_fields_key : :show_fields ,
204
209
# Default route parameters for 'show' requests.
205
210
# Set this to a hash with additional arguments to merge into the route,
206
211
# or set `controller: :current` to route to the current controller.
207
212
route : nil ,
208
- document_actions : NestedOpenStructWithHashAccess . new ( ToolConfig ) ,
209
213
header_actions : NestedOpenStructWithHashAccess . new ( ToolConfig )
210
214
)
211
215
@@ -214,8 +218,8 @@ def initialized_default_configuration?
214
218
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
215
219
property :action_mapping , default : NestedOpenStructWithHashAccess . new (
216
220
ViewConfig ,
217
- default : { top_level_config : :index } ,
218
- show : { top_level_config : :show } ,
221
+ default : { top_level_config : :index , default_top_level_config : :defaults } ,
222
+ show : { top_level_config : :show , default_top_level_config : :index } ,
219
223
citation : { parent_config : :show } ,
220
224
email_record : { top_level_config : :email } ,
221
225
sms_record : { top_level_config : :sms }
@@ -660,7 +664,12 @@ def action_config(action, default: :index)
660
664
661
665
action_config = action_config . reverse_merge ( self [ action_config . top_level_config ] ) if action_config . top_level_config
662
666
action_config = action_config . reverse_merge ( show ) if default == :show && action_config . top_level_config != :show
663
- action_config . reverse_merge ( index )
667
+ action_config = action_config . reverse_merge ( self [ action_config . default_top_level_config ] )
668
+
669
+ # provide backwards compatibility for e.g. the show action falling back on the index defaults
670
+ action_config = action_config . reverse_merge ( defaults ) if action_config . default_top_level_config == :index
671
+
672
+ action_config
664
673
end
665
674
end
666
675
end
0 commit comments