{% extends "admin/base_main.html" %}
{% load activity_tags %}

{% block subtitle %}Emoji{% endblock %}

{% block settings_content %}
    <form action="." class="search">
        <input type="search" name="query" value="{{ query }}" placeholder="Search by shortcode or domain">
        {% if local_only %}
            <input type="hidden" name="local_only" value="true">
        {% endif %}
        <button><i class="fa-solid fa-search"></i></button>
    </form>
    <div class="view-options">
        {% if local_only %}
            <a href=".?{% urlparams local_only=False %}" class="selected"><i class="fa-solid fa-check"></i> Local Only</a>
        {% else %}
            <a href=".?{% urlparams local_only=True %}"><i class="fa-solid fa-xmark"></i> Local Only</a>
        {% endif %}
        <a href="{% url "admin_emoji_create" %}" class="button">Add Emoji</a>
    </div>
    <table class="items">
        {% for emoji in page_obj %}
            <tr>
                <td class="icon">
                    <img src="{{ emoji.full_url_admin.relative }}" class="icon">
                </td>
                <td class="name">
                    {{ emoji.shortcode }}
                    {% if emoji.domain %}<small>{{ emoji.domain }}</small>{% endif %}
                </td>
                <td>
                </td>
                <td class="actions">
                    {% if emoji.can_copy_local %}
                        <a hx-post="{{ emoji.urls.admin_copy }}" title="Copy to Local"><i class="fa-solid fa-copy"></i></a>
                    {% endif %}
                    {% if not emoji.is_usable %}
                        <span class="bad">Disabled</span>
                        <a hx-post="{{ emoji.urls.admin_enable }}" title="Enable"><i class="fa-solid fa-circle-check"></i></a>
                    {% else %}
                        <a hx-post="{{ emoji.urls.admin_disable }}" class="danger" title="Disable"><i class="fa-solid fa-circle-xmark"></i></a>
                    {% endif %}
                    <a hx-post="{{ emoji.urls.admin_delete }}" hx-confirm="Are you sure you want to delete :{{ emoji.shortcode }}:?" class="danger" title="Delete"><i class="fa-solid fa-trash"></i></a>
                </td>
            </tr>
        {% empty %}
            <tr class="empty">
                <td>
                    {% if query %}
                        No emoji match your query.
                    {% else %}
                        There are no emoji yet.
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
    </table>
    {% include "admin/_pagination.html" with nouns="emoji,emoji" %}
{% endblock %}
