{% extends 'babybuddy/page.html' %}
{% load datetime duration i18n widget_tweaks %}

{% block title %}{% trans "Tummy Time" %}{% endblock %}

{% block breadcrumbs %}
    <li class="breadcrumb-item active" aria-current="page">{% trans "Tummy Time" %}</li>
{% endblock %}

{% block content %}
    <h1>
        {% trans "Tummy Time" %}
        {% if perms.core.add_tummytime %}
            <a href="{% url 'core:tummytime-add' %}" class="btn btn-sm btn-success">
                <i class="icon-tummytime" aria-hidden="true"></i> {% trans "Add Tummy Time" %}</a>
        {% endif %}
    </h1>
    {% include 'babybuddy/filter.html' %}
    <div class="table-responsive">
        <table class="table table-instances table-borderless table-striped table-hover align-middle">
            <thead>
                <tr>
                    <th>{% trans "Actions" %}</th>
                    <th>{% trans "Start" %}</th>
                    <th>{% trans "End" %}</th>
                    {% if not unique_child %}
                        <th>{% trans "Child" %}</th>
                    {% endif %}
                    <th>{% trans "Duration" %}</th>
                    <th>{% trans "Milestone" %}</th>
                    <th>{% trans "Tags" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for tummytime in object_list %}
                    <tr>
                        <td>
                            <div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">

                                {% if perms.core.change_tummytime %}
                                    <a href="{% url 'core:tummytime-update' tummytime.id %}" class="btn btn-primary">
                                        <i class="icon-update" aria-hidden="true"></i>
                                    </a>
                                {% endif %}

                                {% if perms.core.delete_tummytime %}
                                    <a href="{% url 'core:tummytime-delete' tummytime.id %}" class="btn btn-danger">
                                        <i class="icon-delete" aria-hidden="true"></i>
                                    </a>
                                {% endif %}

                            </div>
                        </td>
                        <th scope="row">{{ tummytime.start|datetime_short }}</th>
                        <td>{{ tummytime.end|datetime_short }}</td>
                        {% if not unique_child %}
                            <td><a href="{% url 'core:child' tummytime.child.slug %}">{{ tummytime.child }}</a></td>
                        {% endif %}
                        <td>{{ tummytime.duration|duration_string }}</td>
                        <td>{{ tummytime.milestone }}</td>
                        <td>
                            {% include "core/render_tag_list.html" with tags=tummytime.tags.all %}
                        </td>
                    </tr>
                {% empty %}
                    <tr>
                        <th colspan="7">{% trans "No tummy time entries found." %}</th>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% include 'babybuddy/paginator.html' %}
{% endblock %}