Skip to content

Commit

Permalink
Refactored History Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bbenezech committed Nov 26, 2012
1 parent b3e25ac commit 4b06b94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/views/rails_admin/main/_dashboard_history.html.haml
Expand Up @@ -2,9 +2,19 @@
%thead
%tr
%th.shrink.user= t("admin.table_headers.username")
%th.shrink.items= t("admin.table_headers.items")
%th.changes= t("admin.table_headers.changes")
%tbody
- @history.each do |t|
- abstract_model = RailsAdmin.config(t.table).try(:abstract_model)
%tr
%td= t.try :username
%td= "#{m = t.message.try(:downcase)} #{m.to_s.rindex("changed") ? "for #{t.table.capitalize} ##{t.item}" : ''}"
- if o = abstract_model.try(:get, t.item)
- label = o.send(abstract_model.config.object_label_method)
- if show_action = action(:show, abstract_model, o)
%td= link_to(label, url_for(:action => show_action.action_name, :model_name => abstract_model.to_param, :id => o.id), :class => 'pjax')
- else
%td= label
- else
%td= "#{t.table} ##{t.item}"
%td= t.message.in?('delete', 'new') ? t("admin.actions.#{t.message}.done").capitalize : t.message
2 changes: 1 addition & 1 deletion lib/rails_admin/extensions/history/history.rb
Expand Up @@ -15,7 +15,7 @@ def self.create_history_item(message, object, abstract_model, user)
create(
:message => [message].flatten.join(', '),
:item => object.id,
:table => abstract_model.pretty_name,
:table => abstract_model.model.to_s,
:username => user.try(:email)
)
end
Expand Down

0 comments on commit 4b06b94

Please sign in to comment.