{% 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-8">{% trans 'Record List' %}</h3>
	<div class="col-md-4 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>
	  </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>URI</td><td>lang.</td><td>{% trans 'titles' %}</td><td class="two_buttons">{% trans 'actions' %}</td></tr>
  </thead>
  <tbody>
  {% for record in object_list %}
    <tr>
      <td title="{{ record.uri }}">{{ record.uri|reduce:"4,13" }}</td>
      <td title="{{ record.language.uri }}">{{ record.language.uri|reduce:"0,3" }}</td>
      <td><ul>{% for t in record.titles.all %}
          <li>{{ t.title }}</li>
          {% endfor %}</ul></td>
      <td>
        <a class="btn btn-default" href="{% url 'p4l_record_view' %}?uri={{ record.uri }}"><i class="glyphicon glyphicon-eye-open"></i></a>
        <a class="btn btn-default" href="{% url 'p4l_record_edit' id=record.identifier %}"><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 %}