Skip to content

Commit

Permalink
fix: belongs to field target inside tab -> panel -> row (#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Jul 12, 2023
1 parent 9fccabf commit 9a58ac0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/avo/concerns/has_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ def get_items
panelfull_items.grep(Avo::TabGroup).each do |tab_group|
tab_group.items.grep(Avo::Tab).each do |tab|
tab.items.grep(Avo::Panel).each do |panel|
panel.items.grep(Avo::Fields::BelongsToField).each do |field|
field.target = :_top
set_target_to_top panel.items.grep(Avo::Fields::BelongsToField)

panel.items.grep(Avo::Row).each do |row|
set_target_to_top row.items.grep(Avo::Fields::BelongsToField)
end
end
end
Expand All @@ -315,6 +317,12 @@ def get_items

private

def set_target_to_top(fields)
fields.each do |field|
field.target = :_top
end
end

def check_license
if !Rails.env.production? && App.license.present? && App.license.lacks(:resource_tools)
# Add error message to let the developer know the resource tool will not be available in a production environment.
Expand Down

0 comments on commit 9a58ac0

Please sign in to comment.