Sha256: a82ba276108f606db71548035e6a1416e63804a87e66a91fe313c78e09dfc889

Contents?: true

Size: 848 Bytes

Versions: 17

Compression:

Stored size: 848 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)
        @contents = div(class: "panel_contents")
      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
      # correcly appends string values, etc.
      def children?
        @contents.children?
      end

      def header_action(*args)
        action = args[0]

        @title << div(class: "header_action") do
          action
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/views/components/panel.rb
activeadmin-3.2.4 lib/active_admin/views/components/panel.rb
activeadmin-3.2.3 lib/active_admin/views/components/panel.rb
activeadmin-3.2.2 lib/active_admin/views/components/panel.rb
activeadmin-3.2.1 lib/active_admin/views/components/panel.rb
activeadmin-3.2.0 lib/active_admin/views/components/panel.rb
activeadmin-3.1.0 lib/active_admin/views/components/panel.rb
activeadmin-3.0.0 lib/active_admin/views/components/panel.rb
activeadmin-2.14.0 lib/active_admin/views/components/panel.rb
activeadmin-2.13.1 lib/active_admin/views/components/panel.rb
activeadmin-2.13.0 lib/active_admin/views/components/panel.rb
activeadmin-2.12.0 lib/active_admin/views/components/panel.rb
activeadmin-2.11.2 lib/active_admin/views/components/panel.rb
activeadmin-2.11.1 lib/active_admin/views/components/panel.rb
activeadmin-2.11.0 lib/active_admin/views/components/panel.rb
activeadmin-2.10.1 lib/active_admin/views/components/panel.rb
activeadmin-2.10.0 lib/active_admin/views/components/panel.rb