Sha256: ea8eab9f9057ab3d41192526492a3823824253568fcc1fad4788fbe17449bb72

Contents?: true

Size: 1.93 KB

Versions: 46

Compression:

Stored size: 1.93 KB

Contents

module ActiveAdmin
  # Page is the primary data storage for page configuration in Active Admin
  #
  # When you register a page (ActiveAdmin.page "Status") you are actually creating
  # a new Page instance within the given Namespace.
  #
  # The instance of the current page is available in PageController and views
  # by calling the #active_admin_config method.
  #
  class Page

    # The namespace this config belongs to
    attr_reader :namespace

    # The name of the page
    attr_reader :name

    # An array of custom actions defined for this page
    attr_reader :page_actions
    
    # Set breadcrumb builder
    attr_accessor :breadcrumb

    module Base
      def initialize(namespace, name, options)
        @namespace = namespace
        @name = name
        @options = options
        @page_actions = []
      end
    end

    include Base
    include Resource::Controllers
    include Resource::PagePresenters
    include Resource::Sidebars
    include Resource::ActionItems
    include Resource::Menu
    include Resource::Naming
    include Resource::Routes

    # label is singular
    def plural_resource_label
      name
    end

    def resource_name
      @resource_name ||= Resource::Name.new(nil, name)
    end

    def underscored_resource_name
      resource_name.parameterize.underscore
    end

    def camelized_resource_name
      underscored_resource_name.camelize
    end

    def default_menu_options
      super.merge(:id => resource_name)
    end

    def controller_name
      [namespace.module_name, camelized_resource_name + "Controller"].compact.join('::')
    end

    # Override from `ActiveAdmin::Resource::Controllers`
    def route_uncountable?
      false
    end

    def belongs_to?
      false
    end

    def add_default_action_items
    end

    def add_default_sidebar_sections
    end
    
    # Clears all the custom actions this page knows about
    def clear_page_actions!
      @page_actions = []
    end

  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/page.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/lib/active_admin/page.rb