Sha256: f029404fc18fec982b5a33a59c49b72fbe0feaba9449147956eb6f4044ab742a

Contents?: true

Size: 1.63 KB

Versions: 38

Compression:

Stored size: 1.63 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)
          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
          title = display_name(resource)

          if title.blank?
            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
            active_admin_config.resource_columns
          end
        end

        include DefaultMainContent
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 4 rubygems

Version Path
activeadmin-rb-1.6.0 lib/active_admin/views/pages/show.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/views/pages/show.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/views/pages/show.rb
activeadmin-rb-1.5.2 lib/active_admin/views/pages/show.rb
activeadmin-2.9.0 lib/active_admin/views/pages/show.rb
activeadmin-2.8.1 lib/active_admin/views/pages/show.rb
activeadmin-2.8.0 lib/active_admin/views/pages/show.rb
activeadmin-rb-1.5.1 lib/active_admin/views/pages/show.rb
activeadmin-2.7.0 lib/active_admin/views/pages/show.rb
activeadmin-2.6.1 lib/active_admin/views/pages/show.rb
activeadmin-2.6.0 lib/active_admin/views/pages/show.rb
activeadmin-2.5.0 lib/active_admin/views/pages/show.rb
activeadmin-2.4.0 lib/active_admin/views/pages/show.rb
activeadmin-2.3.1 lib/active_admin/views/pages/show.rb
activeadmin-2.3.0 lib/active_admin/views/pages/show.rb
activeadmin-2.2.0 lib/active_admin/views/pages/show.rb
activeadmin-2.1.0 lib/active_admin/views/pages/show.rb
activeadmin-2.0.0 lib/active_admin/views/pages/show.rb
activeadmin-rb-1.5.0 lib/active_admin/views/pages/show.rb
activeadmin-2.0.0.rc2 lib/active_admin/views/pages/show.rb