{% extends "base.html" %}

{% block content %}
<div class="content-card">
    <div class="page-header">
        <h1>Themen</h1>
        <a class="btn" href="{{ url_for('admin_thema_new') }}">Neues Thema erstellen</a>
    </div>

    {% if themen %}
        <table class="admin-table">
            <thead>
                <tr>
                    <th>Rfg</th>
                    <th>Kurztitel</th>
                    <th>Titel</th>
                    <th>Bild</th>
                    <th>Fragen</th>
                    <th>Aktionen</th>
                </tr>
            </thead>
            <tbody>
                {% for thema in themen %}
                <tr>
                    <td>{{ thema.reihenfolge }}</td>
                    <td>{{ thema.kurztitel }}</td>
                    <td>{{ thema.titel }}</td>
                    <td>{{ thema.pic }}</td>
                    <td>
                        {{ thema.fragen_anzahl }}
                        {% if thema.fragen_anzahl < 8 %}
                            <span class="muted">/ 8</span>
                        {% endif %}
                    </td>
                    <td class="actions">
                        <a class="btn btn-small" href="{{ url_for('admin_thema_edit', thema_id=thema.id) }}">Bearbeiten</a>
                        <a class="btn btn-small btn-secondary" href="{{ url_for('admin_question_new_for_thema', thema_id=thema.id) }}">Fragen pflegen</a>

                        <form method="post"
                              action="{{ url_for('admin_thema_delete', thema_id=thema.id) }}"
                              style="display:inline;"
                              onsubmit="return confirm('Thema wirklich löschen?');">
                            <button type="submit" class="btn btn-small btn-danger">Löschen</button>
                        </form>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>Keine Themen vorhanden.</p>
    {% endif %}
</div>
{% endblock %}