{% extends "isearch/sidebar.html" %}
{% import "isearch/include/macros.html" as macros %}

{% block title %}Список ревизий{% endblock %}


{% block sidebar %}
    <ul class="nav nav-list">
        <li class="nav-header">Статусы ревизий</li>
        {% for status in revisions %}
        <li><a href="{{ url("isearch-sources-revision-list", search_id, index) }}#{{ status }}">{{ status }}</a></li>
        {% endfor %}
    </ul>
{% endblock %}

{% block content %}
    <h2>Ревизии {{ search_id }} ({{ index or 'default'}}) {% if organization %}({{ organization.label }}){% endif %}</h2>
    <p><a href="{{ url('isearch-sources-indexation-list', search_id, index or 'default' ) }}">Список индексаций {% if organization %}{{ organization.label }}{% endif %}</a></p>
    {% for status, revs in revisions.items() %}
    <h3 id={{status}}>{{ status }}</h3>
    {% if revs %}
    <table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th>id</th>
                <th>создана</th>
                <th>переиндексирована</th>
                <th>сервис</th>
                {% if not organization %}
                <th>огр-ция</th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for rev in revs %}
            <tr>
                <td>
                    {{ macros.render_revision(rev)}}
                    <span class="muted pull-right"><a href="#revision_{{rev.id}}" data-toggle="modal"><i class="icon-wrench"></i></a></span>
                    <div id="revision_{{rev.id}}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="revision_{{rev.id}}" aria-hidden="true">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h3>Управление ревизией {{ rev.id }}</h3>
                        </div>
                        <div class="modal-body">
                            {{ macros.manage_revision(rev) }}
                        </div>
                    </div>
                </td>
                <td>{{ rev.date }}</td>
                <td>{{ rev.latest_indexation_time }}</td>
                <td>{{ rev.service }}</td>
                {% if not organization %}
                <td>{{ macros.admin_org_link(rev.organization) }}</td>
                {% endif %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
    <h5>(Empty)</h5>
    {% endif %}
    <br>
    {% endfor %}

{% endblock %}
