{# highlight_edit_select.html #}

{% extends "base.html" %}

{% block content %}

    {% include "query_nav.html" %}

    <h1>Current highlighting</h1>
    <ul>
        {% for h in highlight_descriptions %}
            <li>{{ h|safe }}</li>
        {% endfor %}
    </ul>

    <h1>Add a new highlight</h1>

    <form action="{% url 'highlight' %}" method="post">
        {% csrf_token %}
        <table class="formtable">
            {{ form.as_table }}
        </table>
        <input type="submit" value="Add" />
    </form>

    <h1>Existing highlights</h1>

    {% if highlights %}
        <table>
            <tr>
                <th>Text</th>
                <th>Colour number (0-{{ N_CSS_HIGHLIGHT_CLASSES|add:"-1" }})</th>
                <th>Delete highlight</th>
                <th>Active?</th>
                <th>Activate this one</th>
                <th>Deactivate this one</th>
            </tr>
            {% for highlight in highlights %}
                <tr>
                    <td>{{ highlight.text }}</td>
                    <td>{{ highlight.colour }}</td>
                    <td>
                        <form action="{% url 'delete_highlight' highlight.id %}" method="post">
                            {% csrf_token %}
                            <input type="submit" value="Delete" />
                        </form>
                    </td>
                    <td>
                        {% if highlight.active %}<b>{% endif %}
                        {{ highlight.active|yesno }}
                        {% if highlight.active %}</b>{% endif %}
                    </td>
                    <td>
                        {% if highlight.active %}
                            (activated)
                        {% else %}
                            <form action="{% url 'activate_highlight' highlight.id %}" method="post">
                                {% csrf_token %}
                                <input type="submit" value="Activate" />
                            </form>
                        {% endif %}
                    </td>
                    <td>
                        {% if highlight.active %}
                            <form action="{% url 'deactivate_highlight' highlight.id %}" method="post">
                                {% csrf_token %}
                                <input type="submit" value="Deactivate" />
                            </form>
                        {% else %}
                            (deactivated)
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </table>

        {% include "page_nav.html" with page=highlights %}

    {% else %}
        <div>None.</div>
    {% endif %}

    <h1>Colour examples</h1>
    {% for colour in colourlist %}
        <div class="highlight{{ colour }}">Colour {{ colour }}</div>
    {% endfor %}

{% endblock %}
