Sha256: 98802dfe0060a4f7da7e0b5666c2a8f4a3382da54d3d706a1aa8b03ce674f918

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  module Views
    module Pages
      class Show < Base

        def config
          active_admin_config.get_page_presenter(:show) || super
        end

        def title
          if config[:title]
            render_or_call_method_or_proc_on(resource, config[:title])
          else
            assigns[:page_title] || default_title
          end
        end

        def main_content
          if config.block
            # Eval the show config from the controller
            instance_exec resource, &config.block
          else
            default_main_content
          end
        end

        def attributes_table(*args, &block)
          opts = args.extract_options!
          table_title = if opts.has_key?(:title)
                          render_or_call_method_or_proc_on(resource, opts[:title])
                        else
                          ActiveAdmin::Localizers.resource(active_admin_config).t(:details)
                        end
          panel(table_title) do
            attributes_table_for resource, *args, &block
          end
        end

        protected

        def default_title
          display_name(resource)
        end

        module DefaultMainContent
          def default_main_content(&block)
            attributes_table(*default_attribute_table_rows, &block)
          end

          def default_attribute_table_rows
            active_admin_config.resource_columns
          end
        end

        include DefaultMainContent
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/views/pages/show.rb
activeadmin-3.2.4 lib/active_admin/views/pages/show.rb
activeadmin-3.2.3 lib/active_admin/views/pages/show.rb
activeadmin-3.2.2 lib/active_admin/views/pages/show.rb
activeadmin-3.2.1 lib/active_admin/views/pages/show.rb
activeadmin-3.2.0 lib/active_admin/views/pages/show.rb
activeadmin-3.1.0 lib/active_admin/views/pages/show.rb
activeadmin-3.0.0 lib/active_admin/views/pages/show.rb