Sha256: 3ee6e4df78330bec9ea9d16c35b862532adddf5ccec628dd49e03fc1de2d60a4

Contents?: true

Size: 926 Bytes

Versions: 14

Compression:

Stored size: 926 Bytes

Contents

module ActiveAdmin
  module Views

    class Panel < ActiveAdmin::Component
      builder_method :panel

      def build(title, attributes = {})
        icon_name = attributes.delete(:icon)
        icn = icon_name ? icon(icon_name) : "".html_safe
        super(attributes)
        add_class "panel"
        @title = h3(icn + 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

14 entries across 14 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.17.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.12.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.11.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.10.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.9.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.8.pre lib/active_admin/views/components/panel.rb
activeadmin-1.0.0.pre1 lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.7.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.6.pre lib/active_admin/views/components/panel.rb
yousty-activeadmin-1.0.5.pre lib/active_admin/views/components/panel.rb