Sha256: a46886623ccfb84c14ce4f424329f61b4e02df78e5a0e65cfc24dfb50093dcda

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

module ActiveAdminVersioning
  module Extension
    module DSL
      def versioning
        return unless config.resource_class.try(:paper_trail_enabled_for_model?)

        controller { include ActiveAdminVersioning::Extension::ResourceController }

        member_action(:versions) do
          @versions   = resource.versions.reorder(id: :desc, created_at: :desc).page(params[:page])
          @page_title = ::PaperTrail::Version.model_name.human
          render "versions"
        end

        action_item(:version, only: :show) do
          link_to send("versions_admin_#{resource_instance_name}_path") do
            ::PaperTrail::Version.model_name.human
          end
        end

        sidebar(::PaperTrail::Version.model_name.human, only: :show) do
          if versions.present?
            attributes_table_for versions[0] do
              row(::PaperTrail::Version.model_name.human) { |_| version_number }
              row(:event, &:event_i18n)
              row(:whodunnit) do |record|
                record.whodunnit.presence || span(t("views.version.unknown_user"), class: "empty")
              end
              row(:created_at)
            end
            paginate(versions, theme: :version)
          else
            I18n.t("views.version.empty", model_name: ::PaperTrail::Version.model_name.human)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_admin_versioning-0.1.0 lib/active_admin_versioning/extension/dsl.rb