@@ -211,14 +211,14 @@ def initialized_default_configuration?
211211
212212 # @!attribute action_mapping
213213 # @since v7.16.0
214- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig }]
214+ # @return [Hash{Symbol => Blacklight::Configuration::ActionConfigMapEntry }]
215215 property :action_mapping , default : NestedOpenStructWithHashAccess . new (
216- ViewConfig ,
217- default : { top_level_config : :index } ,
218- show : { top_level_config : :show } ,
219- citation : { parent_config : :show } ,
220- email_record : { top_level_config : :email } ,
221- sms_record : { top_level_config : :sms }
216+ ActionConfigMapEntry ,
217+ default : { blacklight_config_property : :index , default : [ :index ] } ,
218+ show : { blacklight_config_property : :show , default : [ :index ] } ,
219+ citation : { parent_action_key : :show } ,
220+ email_record : { blacklight_config_property : :email } ,
221+ sms_record : { blacklight_config_property : :sms }
222222 )
223223
224224 # @!attribute sms
@@ -528,12 +528,7 @@ def view_config(view_type = nil, action_name: :index)
528528 view_type = nil
529529 end
530530
531- @view_config [ [ view_type , action_name ] ] ||= if view_type . nil?
532- action_config ( action_name )
533- else
534- base_config = action_config ( action_name )
535- base_config . merge ( view . fetch ( view_type , { } ) )
536- end
531+ @view_config [ [ view_type , action_name ] ] ||= action_config ( action_name , ( view . fetch ( view_type , nil ) if view_type ) )
537532 end
538533
539534 # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
@@ -646,8 +641,8 @@ def _deep_copy(value)
646641 end
647642 end
648643
649- def action_config ( action , default : :index )
650- action_config = action_mapping [ action ]
644+ def action_config ( action_name , view_type_specific_config , default : :index )
645+ action_config = action_mapping [ action_name ]
651646 action_config ||= action_mapping [ :default ]
652647
653648 if action_config . parent_config && action_config . parent_config != :default
@@ -658,9 +653,19 @@ def action_config(action, default: :index)
658653 end
659654 action_config = action_config . reverse_merge ( action_mapping [ :default ] ) if action_config != action_mapping [ :default ]
660655
661- action_config = action_config . reverse_merge ( self [ action_config . top_level_config ] ) if action_config . top_level_config
662- action_config = action_config . reverse_merge ( show ) if default == :show && action_config . top_level_config != :show
663- action_config . reverse_merge ( index )
656+ view_config = if action_config . blacklight_config_property
657+ self [ action_config . blacklight_config_property ]
658+ else
659+ self [ default ]
660+ end
661+
662+ view_config = Array ( action_config . default - [ action_config . blacklight_config_property || default ] ) . inject ( view_config ) do |config , top_level_config |
663+ config . reverse_merge ( self [ top_level_config ] )
664+ end
665+
666+ view_config = view_config . merge ( view_type_specific_config ) if view_type_specific_config
667+
668+ view_config
664669 end
665670 end
666671end
0 commit comments