{% load i18n l10n fontawesome_5 %}
<div id="deadlines" class="card">
    <div class="card-header rlp-r">
        <div class="row">
            <div class="col-sm-6">
                <h5>
                    <span class="badge badge-light">{{obj.deadlines.count}}</span>
                    {% trans 'Deadlines' %}
                </h5>
            </div>
            <div class="col-sm-6">
                <div class="d-flex justify-content-end">
                    {% if is_default_member and has_access  %}
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'ema:new-deadline' obj.id %}" title="{% trans 'Add new deadline' %}">
                        {% fa5_icon 'plus' %}
                        {% fa5_icon 'calendar-check' %}
                    </button>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    {% if not has_finished_deadlines %}
    <div class="alert alert-danger mb-0">
        {% trans 'Missing finished deadline ' %}
    </div>
    {% endif %}
    <div class="card-body {% if tables_scrollable %}scroll-300{% endif %} p-2">
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col">
                    {% trans 'Type' %}
                </th>
                <th scope="col">
                    {% trans 'Date' %}
                </th>
                <th scope="col">
                    {% trans 'Comment' %}
                </th>
                <th class="w-10" scope="col">
                    <span class="float-right">
                        {% trans 'Action' %}
                    </span>
                </th>
            </tr>
            </thead>
            <tbody>
            {% for deadline in obj.deadlines.all %}
            <tr>
                <td class="align-middle">
                    {% trans deadline.type_humanized %}
                </td>
                <td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
                <td class="align-middle">
                    <div class="scroll-150">
                        {{ deadline.comment }}
                    </div>
                </td>
                <td class="align-middle float-right">
                    {% if is_default_member and has_access  %}
                    <button data-form-url="{% url 'ema:deadline-edit' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit deadline' %}">
                        {% fa5_icon 'edit' %}
                    </button>
                    <button data-form-url="{% url 'ema:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">
                        {% fa5_icon 'trash' %}
                    </button>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>