Sha256: 771ee05e7babb9c3b299acbc2cf519ff4f8524db6dfd66e20dab5fcf65713824

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
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

17 entries across 17 versions & 1 rubygems

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