Sha256: 8764303ad3ae026e87f059f622a788a7011914dc99d48b3eee148a88baab7b94

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

module ActiveAdmin
  module Views
    class TitleBar < Component

      def build(title, action_items)
        super(id: "title_bar")
        @title = title
        @action_items = action_items
        build_titlebar_left
        build_titlebar_right
      end

      private

      def build_titlebar_left
        div id: "titlebar_left" do
          build_breadcrumb
          build_title_tag
        end
      end

      def build_titlebar_right
        div id: "titlebar_right" do
          build_action_items
        end
      end

      def build_breadcrumb(separator = "/")
        breadcrumb_config = active_admin_config && active_admin_config.breadcrumb

        links = if breadcrumb_config.is_a?(Proc)
          instance_exec(controller, &active_admin_config.breadcrumb)
        elsif breadcrumb_config.present?
          breadcrumb_links
        end
        return unless links.present? && links.is_a?(::Array)
        span class: "breadcrumb" do
          links.each do |link|
            text_node link
            span(separator, class: "breadcrumb_sep")
          end
        end
      end

      def build_title_tag
        h2(@title, id: 'page_title')
      end

      def build_action_items
        insert_tag(view_factory.action_items, @action_items)
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeadmin-1.0.0 lib/active_admin/views/title_bar.rb
activeadmin-1.0.0.pre5 lib/active_admin/views/title_bar.rb
activeadmin-orac-1.0.0.pre4 lib/active_admin/views/title_bar.rb
activeadmin-orac-1.0.0 lib/active_admin/views/title_bar.rb
activeadmin-orac-1.0.0.pre.orac lib/active_admin/views/title_bar.rb
activeadmin-1.0.0.pre4 lib/active_admin/views/title_bar.rb
activeadmin-1.0.0.pre3 lib/active_admin/views/title_bar.rb