Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Jul 4, 2023
1 parent e9ffc58 commit 68516c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/components/avo/tab_switcher_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ def visible_items
tabs.select do |tab|
next false if tab.items.blank?
next false if tab.is_field? && !tab.authorized?

if tab.items.count == 1
next false if !single_item_visible?(tab.items.first)
end

next false if !tab.visible? || !tab.visible_on?(view)
next false if tab.has_a_single_item? && !single_item_visible?(tab.items.first)
next false if !tab.visible?
next false if !tab.visible_on?(view)

true
end
Expand All @@ -81,7 +78,8 @@ def visible_items

def single_item_visible?(item)
# Item is visible if is not a field or don't have its own panel
return true if !item.is_field? || !item.has_own_panel?
return true if !item.is_field?
return true if !item.has_own_panel?

return false unless item.visible_on?(view)

Expand Down
4 changes: 4 additions & 0 deletions lib/avo/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ def visible_on?(view)
super(view)
end
end

def has_a_single_item?
items.count == 1
end
end

0 comments on commit 68516c9

Please sign in to comment.