-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistent custom dashboards #2184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ class CustomDashboard | |
|
||
class << self | ||
def resource_name(_opts) | ||
named_resource.pluralize.titleize | ||
@named_resource.pluralize.titleize | ||
end | ||
|
||
def resource(resource_name) | ||
define_singleton_method(:named_resource) { resource_name } | ||
@named_resource = resource_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is not strictly necessary, but I felt that the current code was needlessly complicated and could be simplified like this. |
||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require "administrate/custom_dashboard" | ||
|
||
class StatDashboard < Administrate::CustomDashboard | ||
resource "Stats" | ||
resource "Stat" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class StatPolicy < ApplicationPolicy | ||
end |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<div style="padding: 20px"> | ||
<h1>Stats</h1> | ||
<br> | ||
<p><b>Total Customers:</b> <%= @stats[:customer_count] %></h1> | ||
<br> | ||
<p><b>Total Orders:</b> <%= @stats[:order_count] %></h1> | ||
<p><b>Total Customers:</b> <%= @stats[:customer_count] %></p> | ||
<p><b>Total Orders:</b> <%= @stats[:order_count] %></p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed markup. |
||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is copied straight from
spec/example_app/app/views/admin/stats/index.html.erb
. I have removed the padding because it's not relevant here.