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

<% 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-secondary" 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="card">
	    <div class="card-body">
	      <div class="self-service-card-icon">
		<span class="fa fa-<%= model.icon %>" aria-hidden="true"></span>
	      </div>
	      <div><%= name.capitalize %></div>
	    </div>
	  </div>
        </a>
      </div>
    <% end %>
  </div>

<% end %>
