@@ -211,14 +211,14 @@ def initialized_default_configuration?
211
211
212
212
# @!attribute action_mapping
213
213
# @since v7.16.0
214
- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig }]
214
+ # @return [Hash{Symbol => Blacklight::Configuration::ActionConfigMapEntry }]
215
215
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 }
222
222
)
223
223
224
224
# @!attribute sms
@@ -528,12 +528,7 @@ def view_config(view_type = nil, action_name: :index)
528
528
view_type = nil
529
529
end
530
530
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 ) )
537
532
end
538
533
539
534
# 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)
646
641
end
647
642
end
648
643
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 ]
651
646
action_config ||= action_mapping [ :default ]
652
647
653
648
if action_config . parent_config && action_config . parent_config != :default
@@ -658,9 +653,19 @@ def action_config(action, default: :index)
658
653
end
659
654
action_config = action_config . reverse_merge ( action_mapping [ :default ] ) if action_config != action_mapping [ :default ]
660
655
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
664
669
end
665
670
end
666
671
end
0 commit comments