Sha256: 3f2c9e0f04fbcbc2cf241c38c54c8f285cc5d948d79896291b6f0f4746e3e0b9

Contents?: true

Size: 1.42 KB

Versions: 48

Compression:

Stored size: 1.42 KB

Contents

class Avo::Resources::Items::Tab
  prepend Avo::Concerns::IsResourceItem

  include Avo::Concerns::HasItems
  include Avo::Concerns::HasItemType
  include Avo::Concerns::VisibleItems
  include Avo::Concerns::VisibleInDifferentViews

  delegate :items, :add_item, to: :items_holder

  attr_accessor :description

  def initialize(name: nil, description: nil, view: nil, **args)
    @name = name
    @description = description
    @items_holder = Avo::Resources::Items::Holder.new
    @view = Avo::ViewInquirer.new view
    @args = args

    post_initialize if respond_to?(:post_initialize)
  end

  def name
    Avo::ExecutionContext.new(target: @name).handle
  end

  def id
    name.to_s.parameterize
  end
  alias_method :to_param, :id

  def turbo_frame_id(parent: nil)
    id = "#{Avo::Resources::Items::Tab.to_s.parameterize} #{name}".parameterize

    return id if parent.nil?

    "#{parent.turbo_frame_id} #{id}".parameterize
  end

  class Builder
    include Avo::Concerns::BorrowItemsHolder

    delegate :field, to: :items_holder
    delegate :tool, to: :items_holder
    delegate :panel, to: :items_holder
    delegate :items, to: :items_holder

    def initialize(parent:, name: nil, **args)
      @tab = Avo::Resources::Items::Tab.new(name: name, **args)
      @items_holder = Avo::Resources::Items::Holder.new(parent: parent)
    end

    # Fetch the tab
    def build
      @tab.items_holder = @items_holder
      @tab
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
avo-3.10.6 lib/avo/resources/items/tab.rb
avo-3.10.5 lib/avo/resources/items/tab.rb
avo-3.10.4 lib/avo/resources/items/tab.rb
avo-3.10.3 lib/avo/resources/items/tab.rb
avo-3.10.2 lib/avo/resources/items/tab.rb
avo-3.10.1 lib/avo/resources/items/tab.rb
avo-3.10.0 lib/avo/resources/items/tab.rb
avo-3.9.2 lib/avo/resources/items/tab.rb
avo-3.9.1 lib/avo/resources/items/tab.rb
avo-3.8.2 lib/avo/resources/items/tab.rb
avo-3.9.0 lib/avo/resources/items/tab.rb
avo-3.8.1 lib/avo/resources/items/tab.rb
avo-3.8.0 lib/avo/resources/items/tab.rb
avo-3.6.4 lib/avo/resources/items/tab.rb
avo-3.6.3 lib/avo/resources/items/tab.rb
avo-3.6.2 lib/avo/resources/items/tab.rb
avo-3.6.1 lib/avo/resources/items/tab.rb
avo-3.6.0 lib/avo/resources/items/tab.rb
avo-3.5.8 lib/avo/resources/items/tab.rb
avo-3.5.7 lib/avo/resources/items/tab.rb