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

{% block title %}{% trans "Notes" %}{% endblock %}

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

{% block content %}
    <h1>
        {% trans "Notes" %}
        {% if perms.core.add_note %}
            <a href="{% url 'core:note-add' %}" class="btn btn-sm btn-success">
                <i class="icon-note" aria-hidden="true"></i> {% trans "Add Note" %}
            </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 "Time" %}</th>
                    {% if not unique_child %}
                        <th>{% trans "Child" %}</th>
                    {% endif %}
                    <th>{% trans "Image" %}</th>
                    <th>{% trans "Note" %}</th>
                    <th>{% trans "Tags" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for note in object_list %}
                    <tr>
                        <td>
                            <div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">

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

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

                            </div>
                        </td>
                        <th scope="row">{{ note.time|datetime_short }}</th>
                        {% if not unique_child %}
                            <td><a href="{% url 'core:child' note.child.slug %}">{{ note.child }}</a></td>
                        {% endif %}
                        <td>
                            {% if note.image %}
                                {% thumbnail '40x40' note.image as thumb %}
                                <a href="{{ note.image.url }}" target="_blank"><img src="{{ thumb.url }}" class="img-fluid" /></a>
                            {% endif %}
                        </td>
                        <td>{{ note.note }}</td>
                        <td>
                            {% include "core/render_tag_list.html" with tags=note.tags.all %}
                        </td>
                    </tr>
                {% empty %}
                    <tr>
                        <th colspan="5">{% trans "No notes found." %}</th>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% include 'babybuddy/paginator.html' %}
{% endblock %}