Sha256: a87493f259367e08c31e775e31ce612a5c763435b737898711dca245a7e67086

Contents?: true

Size: 1.41 KB

Versions: 26

Compression:

Stored size: 1.41 KB

Contents

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

  include Avo::Concerns::HasItems
  include Avo::Concerns::HasItemType
  include Avo::Concerns::IsVisible
  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 = view
    @args = args

    post_initialize if respond_to?(:post_initialize)
  end

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

  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
    class << self
      def parse_block(**args, &block)
        Docile.dsl_eval(new(**args), &block).build
      end
    end

    attr_reader :items_holder

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

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

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
avo-3.0.1.beta6 lib/avo/resources/items/tab.rb
avo-3.0.1.beta7 lib/avo/resources/items/tab.rb
avo-3.0.1.beta5 lib/avo/resources/items/tab.rb
avo-3.0.1.beta2 lib/avo/resources/items/tab.rb
avo-3.0.1.beta4 lib/avo/resources/items/tab.rb
avo-3.0.1.beta3 lib/avo/resources/items/tab.rb
avo-3.0.0.beta1 lib/avo/resources/items/tab.rb
avo-3.0.1.beta1 lib/avo/resources/items/tab.rb
avo-3.0.0.pre17 lib/avo/resources/items/tab.rb
avo-3.0.0.pre18 lib/avo/resources/items/tab.rb
avo-3.0.0.pre14 lib/avo/resources/items/tab.rb
avo-3.0.0.pre16 lib/avo/resources/items/tab.rb
avo-3.0.0.pre15 lib/avo/resources/items/tab.rb
avo-3.0.0.pre13 lib/avo/resources/items/tab.rb
avo-3.0.0.pre12 lib/avo/resources/items/tab.rb
avo-3.0.0.pre10 lib/avo/resources/items/tab.rb
avo-3.0.0.pre11 lib/avo/resources/items/tab.rb
avo-3.0.0.pre8 lib/avo/resources/items/tab.rb
avo-3.0.0.pre9 lib/avo/resources/items/tab.rb
avo-3.0.0.pre7 lib/avo/resources/items/tab.rb