Sha256: 731a306f210aca14a1d81b872bd1c4fe10d8bcbc0c432f670127b1d8a732cf35

Contents?: true

Size: 1.44 KB

Versions: 14

Compression:

Stored size: 1.44 KB

Contents

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)
          panel(I18n.t('active_admin.details', model: active_admin_config.resource_label)) do
            attributes_table_for resource, *args, &block
          end
        end

        protected

        def default_title
          title = display_name(resource)

          if title.nil? || title.empty? || title == resource.to_s
            title = "#{active_admin_config.resource_label} ##{resource.id}"
          end

          title
        end

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

          def default_attribute_table_rows
            resource.class.columns.collect{|column| column.name.to_sym }
          end
        end

        include DefaultMainContent
      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/pages/show.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.12.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.11.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.10.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.9.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.8.pre lib/active_admin/views/pages/show.rb
activeadmin-1.0.0.pre1 lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.7.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.6.pre lib/active_admin/views/pages/show.rb
yousty-activeadmin-1.0.5.pre lib/active_admin/views/pages/show.rb