{% load i18n l10n fontawesome_5 %}
<div id="revocation" class="card">
    <div class="card-header rlp-r">
        <div class="row">
            <div class="col-sm-6">
                <h5>
                    <span class="badge badge-light">{{obj.legal.revocations.count}}</span>
                    {% trans 'Revocations' %}
                </h5>
            </div>
            <div class="col-sm-6">
                <div class="d-flex justify-content-end">
                    {% comment %}
                        Only show add-button if no revocation exists, yet.
                    {% endcomment %}
                    {% if is_default_member and is_entry_shared and not obj.legal.revocation %}
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:new-revocation' obj.id %}" title="{% trans 'Add revocation' %}">
                        {% fa5_icon 'plus' %}
                        {% fa5_icon 'ban' %}
                    </button>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    <div class="card-body {% if tables_scrollable %}scroll-300{% endif %} p-2">
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col">
                    {% trans 'From' context 'Revocation' %}
                </th>
                <th scope="col">
                    {% trans 'Document' %}
                </th>
                <th scope="col">
                    {% trans 'Comment' %}
                </th>
                {% if is_default_member and is_entry_shared %}
                    <th class="w-10" scope="col">
                        <span class="float-right">
                            {% trans 'Action' %}
                        </span>
                    </th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for rev in obj.legal.revocations.all %}
                <tr>
                    <td class="align-middle">
                        {{ rev.date }}
                    </td>
                    <td class="align-middle">
                        {% if rev.document %}
                            <a href="{% url 'intervention:get-doc-revocation' rev.document.id %}">
                                {% trans 'Revocation' %}
                            </a>
                        {% endif %}
                    </td>
                    <td class="align-middle">
                        <div class="scroll-150">
                            {{ rev.comment }}
                        </div>
                    </td>
                    <td class="align-middle float-right">
                        {% if is_default_member and is_entry_shared  %}
                        <button data-form-url="{% url 'intervention:edit-revocation' obj.id rev.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit revocation' %}">
                            {% fa5_icon 'edit' %}
                        </button>
                        <button data-form-url="{% url 'intervention:remove-revocation' obj.id rev.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove revocation' %}">
                            {% fa5_icon 'trash' %}
                        </button>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
