{% extends "base.html" %}

{% block content %}
<section class="grid">
    <article class="panel">
        <h1>Rubros y alias</h1>
        <p class="muted">Cada alias ayuda a agrupar keywords y negocios en una familia comercial consistente.</p>
        <form action="/taxonomy" method="post" class="form">
            <label>Alias
                <input type="text" name="alias" placeholder="centro odontologico" required>
            </label>
            <label>Grupo
                <input type="text" name="category_group" list="group-options" placeholder="odontologia" required>
                <datalist id="group-options">
                    {% for group in groups %}
                        <option value="{{ group }}"></option>
                    {% endfor %}
                </datalist>
            </label>
            <button type="submit">Agregar alias</button>
        </form>
    </article>

    <article class="panel">
        <h2>Alias cargados</h2>
        {% if aliases %}
            <table class="table">
                <thead>
                    <tr>
                        <th>Alias</th>
                        <th>Grupo</th>
                        <th>Accion</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in aliases %}
                        <tr>
                            <td>{{ item.alias }}</td>
                            <td>{{ item.category_group }}</td>
                            <td>
                                <form action="/taxonomy/{{ item.id }}/delete" method="post">
                                    <button type="submit" class="mini-button danger">Eliminar</button>
                                </form>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% else %}
            <p class="muted">Todavia no hay alias cargados.</p>
        {% endif %}
    </article>
</section>
{% endblock %}
