-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate dashbaord for
PaperTrail::Version
``` rails generate administrate:dashboard PaperTrail::Version ```
- Loading branch information
1 parent
b546a2b
commit 2f1d6ce
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Admin | ||
class PaperTrail::VersionsController < Admin::ApplicationController | ||
# To customize the behavior of this controller, | ||
# you can overwrite any of the RESTful actions. For example: | ||
# | ||
# def index | ||
# super | ||
# @resources = PaperTrail::Version. | ||
# page(params[:page]). | ||
# per(10) | ||
# end | ||
|
||
# Define a custom finder by overriding the `find_resource` method: | ||
# def find_resource(param) | ||
# PaperTrail::Version.find_by!(slug: param) | ||
# end | ||
|
||
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions | ||
# for more information | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require "administrate/base_dashboard" | ||
|
||
class PaperTrail::VersionDashboard < Administrate::BaseDashboard | ||
# ATTRIBUTE_TYPES | ||
# a hash that describes the type of each of the model's fields. | ||
# | ||
# Each different type represents an Administrate::Field object, | ||
# which determines how the attribute is displayed | ||
# on pages throughout the dashboard. | ||
ATTRIBUTE_TYPES = { | ||
item: Field::Polymorphic, | ||
id: Field::Number, | ||
event: Field::String, | ||
whodunnit: Field::String, | ||
object: Field::Text, | ||
created_at: Field::DateTime, | ||
}.freeze | ||
|
||
# COLLECTION_ATTRIBUTES | ||
# an array of attributes that will be displayed on the model's index page. | ||
# | ||
# By default, it's limited to four items to reduce clutter on index pages. | ||
# Feel free to add, remove, or rearrange items. | ||
COLLECTION_ATTRIBUTES = [ | ||
:item, | ||
:id, | ||
:event, | ||
:whodunnit, | ||
].freeze | ||
|
||
# SHOW_PAGE_ATTRIBUTES | ||
# an array of attributes that will be displayed on the model's show page. | ||
SHOW_PAGE_ATTRIBUTES = [ | ||
:item, | ||
:id, | ||
:event, | ||
:whodunnit, | ||
:object, | ||
:created_at, | ||
].freeze | ||
|
||
# FORM_ATTRIBUTES | ||
# an array of attributes that will be displayed | ||
# on the model's form (`new` and `edit`) pages. | ||
FORM_ATTRIBUTES = [ | ||
:item, | ||
:event, | ||
:whodunnit, | ||
:object, | ||
].freeze | ||
|
||
# Overwrite this method to customize how versions are displayed | ||
# across all pages of the admin dashboard. | ||
# | ||
# def display_resource(version) | ||
# "PaperTrail::Version ##{version.id}" | ||
# end | ||
end |