railsadminteam/rails_admin

View on GitHub
app/views/rails_admin/main/_dashboard_history.html.erb

Summary

Maintainability
Test Coverage
<table class="table table-condensed table-striped table-hover">
  <thead>
    <tr>
      <th class="shrink user">
        <%= t("admin.table_headers.username") %>
      </th>
      <th class="shrink items">
        <%= t("admin.table_headers.item") %>
      </th>
      <th class="changes">
        <%= t("admin.table_headers.changes") %>
      </th>
    </tr>
  </thead>
  <tbody class="table-group-divider">
    <% @history.each do |t| %>
      <% abstract_model = RailsAdmin.config(t.table).abstract_model %>
      <tr>
        <td>
          <%= t.try :username %>
        </td>
        <% 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)) %>
            </td>
          <% else %>
            <td>
              <%= label %>
            </td>
          <% end %>
        <% else %>
          <% label = Object.const_defined?(t.table) ? t.table.constantize.model_name.human : t.table %>
          <td>
            <%= "#{label} ##{t.item}" %>
          </td>
        <% end %>
        <td>
          <%= t.message %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>