<ol class="breadcrumb">
  <li class="<%= 'active' unless current_model %>"><a href="/admin">Admin</a></li>
  <% if current_model %>
    <li class="active">
      <i class="fa fa-<%= current_model_info.icon %>"></i>
      <%= current_model_name.capitalize %>
    </li>
  <% end %>
</ol>

<% if current_model %>

  <p>
  <form class="form-inline" method="GET">
    <% if current_model_info.search_fields %>
      <input type="text" name="q" value="<%= params[:q] %>">
    <% end %>
    <% if current_model_info.new %>
      <a class="btn btn-sm btn-default" href="/admin/<%= current_model_name %>/new/"><i class="fa fa-plus"></i> Add <%= current_model_name.singularize %></a>
    <% end %>
  </form>
  <p>

  <table class="table table-striped">
    <tr>
      <% fields.each do |f| %>
	<th><%= f.to_s.humanize %></th>
      <% end %>
    </tr>
    <% results.records.each do |object| %>
      <tr>
	<% fields.each do |f| %>
	  <td>
	    <a href="/admin/<%= current_model_name %>/<%= object.id %>/"><%= format(f, object.send(f)) %></a>
	  </td>
	<% end %>
      </tr>
    <% end %>
  </table>

  <%== erb(:pagination, locals: {query: params.reject { |k,_| k.to_sym == :model}, results: results}) %>

<% else %>

  <div class="row">
    <% models.each do |name, model| %>
      <div class="col-md-3">
        <a class="well self-service-card text-center" href="/admin/<%= name %>/">
          <div class="self-service-card-icon">
	    <span class="fa fa-<%= model.icon %>" aria-hidden="true"></span>
          </div>
	  <div><%= name.capitalize %></div>
        </a>
      </div>
    <% end %>
  </div>

<% end %>
