Sha256: 50eaabdcad2b996ea70dc99b892b8af68cd3dc508cc154bc75f44f423cb92a49

Contents?: true

Size: 721 Bytes

Versions: 9

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true
module ActiveAdmin
  module Views

    class Panel < ActiveAdmin::Component
      builder_method :panel

      def build(title, attributes = {})
        super(attributes)
        add_class "panel"
        @title = h3(title.to_s, class: "panel-title")
        @contents = div(class: "panel-body")
      end

      def add_child(child)
        if @contents
          @contents << child
        else
          super
        end
      end

      # Override children? to only report children when the panel's
      # contents have been added to. This ensures that the panel
      # correctly appends string values, etc.
      def children?
        @contents.children?
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activeadmin-4.0.0.beta14 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta13 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta12 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta11 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta10 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta9 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta8 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta7 lib/active_admin/views/components/panel.rb
activeadmin-4.0.0.beta6 lib/active_admin/views/components/panel.rb