Sha256: e3230dc3050b46578d245f1d49ee583cfa852cd22e86e0d1485cbdb3a2c545c2

Contents?: true

Size: 873 Bytes

Versions: 102

Compression:

Stored size: 873 Bytes

Contents

# This concern helps us figure out what kind of items (field, tool, tab_group, or panel) have been passed to the resource or action.
module Avo
  module Concerns
    module IsResourceItem
      include Avo::Concerns::Hydration

      # These attributes are required to be hydrated in order to properly find the visible_items
      attr_accessor :resource
      attr_accessor :view

      # Returns the final state of if an item is visible or not
      # For items that have children it checks to see if it contains any visible children.
      def visible?
        # For items that may contains other items like tabs and panels we should also check
        # if any on their children have visible items.
        if self.class.ancestors.include?(Avo::Concerns::HasItems)
          return false unless visible_items.any?
        end

        super
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
avo-3.16.4 lib/avo/concerns/is_resource_item.rb
avo-3.16.3 lib/avo/concerns/is_resource_item.rb
avo-3.16.2 lib/avo/concerns/is_resource_item.rb
avo-3.16.1 lib/avo/concerns/is_resource_item.rb
avo-3.16.0 lib/avo/concerns/is_resource_item.rb
avo-3.15.7 lib/avo/concerns/is_resource_item.rb
avo-3.15.6 lib/avo/concerns/is_resource_item.rb
avo-3.15.5 lib/avo/concerns/is_resource_item.rb
avo-3.15.4 lib/avo/concerns/is_resource_item.rb
avo-3.15.3 lib/avo/concerns/is_resource_item.rb
avo-3.15.2 lib/avo/concerns/is_resource_item.rb
avo-3.15.1 lib/avo/concerns/is_resource_item.rb
avo-3.15.0 lib/avo/concerns/is_resource_item.rb
avo-3.14.5 lib/avo/concerns/is_resource_item.rb
avo-3.14.4 lib/avo/concerns/is_resource_item.rb
avo-3.14.3 lib/avo/concerns/is_resource_item.rb
avo-3.14.2 lib/avo/concerns/is_resource_item.rb
avo-3.14.1 lib/avo/concerns/is_resource_item.rb
avo-3.14.0 lib/avo/concerns/is_resource_item.rb
avo-3.13.7 lib/avo/concerns/is_resource_item.rb