{% extends "p4l/p4l_base.html" %}
{% load static %}
{% load i18n %}
{% load p4lstringfilters %}

{% block page_title %}{% trans 'Record List' %} - {% trans 'Page' %} {{ page_obj.number }}{% endblock %}

{% block content %}
<div class="row">
	<h3 class="col-md-6">{% trans 'Record List' %}</h3>
	<div class="col-md-6 text-right">
	  <form method="GET" class="form-inline" role="form">
	    <div class="form-group">
	      <input id="id_title" class="form-control" type="text" placeholder="{% trans 'Title' %}" name="title" required="required"/>
	    </div>
	    <div class="form-group">
	      <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
	    </div>
      - <a class="btn btn-default" href="{% url 'p4l_record_new' %}">{% trans 'New record' %} <i class="glyphicon glyphicon-plus-sign"></i></a>
	  </form>
	</div>
</div>
{% if is_paginated %}
<div class="pagination pull-right">
    <span class="page-links">
        {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}{% for k,v in filter_params.items %}&{{k}}={{v}}{% endfor %}">{% trans 'Previous' %}</a>
        {% endif %}
        <span class="page-current">
            {% trans 'Page' %} {{ page_obj.number }} {% trans 'on' %} {{ page_obj.paginator.num_pages }}
        </span>
        {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}{% for k,v in filter_params.items %}&{{k}}={{v}}{% endfor %}">{% trans 'Next' %}</a>
        {% endif %}
    </span>
</div>
{% endif %}
<table class="table">
  <thead>
    <tr><td>{% trans 'identifier' %}</td><td>{% trans 'titles' %}</td><td>{% trans 'dates' %}</td><td class="two_buttons">{% trans 'actions' %}</td></tr>
  </thead>
  <tbody>
  {% for record in object_list %}
    <tr>
      <td>{{ record.identifier }}</td>
      <td><ul>{% for t in record.titles.all %}
          <li>{{ t.title }}</li>
          {% endfor %}</ul></td>
      <td>{{ record.get_imprints_years|join:", "}}</td>
      <td>
        <a class="btn btn-default" href="{% url 'p4l_record_view' slug=record.identifier %}"><i class="glyphicon glyphicon-eye-open"></i></a>
        <a class="btn btn-default" href="{% url 'p4l_record_edit' slug=record.identifier %}?previous={{request.get_full_path|urlencode}}"><i class="glyphicon glyphicon-pencil"></i></a>
      </td>
    </tr>
  {% empty %}
    <tr><td>{% trans 'No record' %}</td></tr>
  {% endfor %}
  </tbody>
</table>
{% if is_paginated %}
<div class="pagination pull-right">
    <span class="page-links">
        {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}{% for k,v in filter_params.items %}&{{k}}={{v}}{% endfor %}">{% trans 'Previous' %}</a>
        {% endif %}
        <span class="page-current">
            {% trans 'Page' %} {{ page_obj.number }} {% trans 'on' %} {{ page_obj.paginator.num_pages }}
        </span>
        {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}{% for k,v in filter_params.items %}&{{k}}={{v}}{% endfor %}">{% trans 'Next' %}</a>
        {% endif %}
    </span>
</div>
{% endif %}
{% endblock %}