-
-
Save kivanio/6bbfbbe699d136999161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if defined?(ActiveAdmin) | |
require 'active_admin/views' | |
require 'active_admin/views/components/panel' | |
module ActiveAdmin | |
module PaperTrail | |
module Views | |
class Versions < ActiveAdmin::Views::Panel | |
builder_method :active_admin_paper_trail_versions_for | |
attr_accessor :resource | |
def build(resource) | |
@resource = resource | |
super(title, for: resource) | |
build_versions | |
end | |
protected | |
def title | |
I18n.t 'admin.version.title' | |
end | |
def build_versions | |
table_for resource.versions do | |
%i{id created_at event whodunnit ip}.each do|c| | |
t = I18n.t("admin.version.#{c}", default: c) | |
if c == :whodunnit | |
column(t, c) {|v| | |
u = AdminUser.find v.whodunnit | |
link_to u.email, u | |
} | |
else | |
column t, c | |
end | |
end | |
end | |
end | |
end | |
end | |
module VersionsHelper | |
def active_admin_paper_trail_versions(*args, &block) | |
active_admin_paper_trail_versions_for(resource, *args, &block) | |
end | |
end | |
end | |
end | |
ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::PaperTrail::VersionsHelper | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment