{% extends "administration/base.html" %}

{% load i18n %}
{% load passbook_utils %}
{% load admin_reflection %}

{% block content %}
<section class="pf-c-page__main-section pf-m-light">
    <div class="pf-c-content">
        <h1>
            <i class="pf-icon pf-icon-plugged"></i>
            {% trans 'Prompts' %}
        </h1>
        <p>{% trans "Single Prompts that can be used for Prompt Stages." %}</p>
    </div>
</section>
<section class="pf-c-page__main-section pf-m-no-padding-mobile">
    <div class="pf-c-card">
        {% if object_list %}
        <div class="pf-c-toolbar">
            <div class="pf-c-toolbar__content">
                <div class="pf-c-toolbar__bulk-select">
                    <a href="{% url 'passbook_admin:stage-prompt-create' %}?back={{ request.get_full_path }}" class="pf-c-button pf-m-primary" type="button">{% trans 'Create' %}</a>
                </div>
                {% include 'partials/pagination.html' %}
            </div>
        </div>
        <table class="pf-c-table pf-m-compact pf-m-grid-xl" role="grid">
            <thead>
                <tr role="row">
                    <th role="columnheader" scope="col">{% trans 'Field' %}</th>
                    <th role="columnheader" scope="col">{% trans 'Label' %}</th>
                    <th role="columnheader" scope="col">{% trans 'Type' %}</th>
                    <th role="columnheader" scope="col">{% trans 'Order' %}</th>
                    <th role="columnheader" scope="col">{% trans 'Flows' %}</th>
                    <th role="cell"></th>
                </tr>
            </thead>
            <tbody role="rowgroup">
                {% for prompt in object_list %}
                <tr role="row">
                    <th role="columnheader">
                        <div>
                            <div>{{ prompt.field_key }}</div>
                        </div>
                    </th>
                    <td role="cell">
                        <div>
                            {{ prompt.label }}
                        </div>
                    </td>
                    <td role="cell">
                        <div>
                            {{ prompt.type }}
                        </div>
                    </td>
                    <td role="cell">
                        <div>
                            {{ prompt.order }}
                        </div>
                    </td>
                    <td role="cell">
                        <ul>
                            {% for flow in prompt.flow_set.all %}
                            <li><a href="{% url 'passbook_admin:flow-update' pk=flow.pk %}">{{ flow.slug }}</a></li>
                            {% empty %}
                            <li>-</li>
                            {% endfor %}
                        </ul>
                    </td>
                    <td>
                        <a class="pf-c-button pf-m-secondary" href="{% url 'passbook_admin:stage-prompt-update' pk=prompt.pk %}?back={{ request.get_full_path }}">{% trans 'Edit' %}</a>
                        <a class="pf-c-button pf-m-danger" href="{% url 'passbook_admin:stage-prompt-delete' pk=prompt.pk %}?back={{ request.get_full_path }}">{% trans 'Delete' %}</a>
                        {% get_links prompt as links %}
                        {% for name, href in links.items %}
                        <a class="pf-c-button pf-m-tertiary" href="{{ href }}?back={{ request.get_full_path }}">{% trans name %}</a>
                        {% endfor %}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <div class="pf-c-toolbar" id="page-layout-table-simple-toolbar-bottom">
            {% include 'partials/pagination.html' %}
        </div>
        {% else %}
        <div class="pf-c-empty-state">
            <div class="pf-c-empty-state__content">
                <i class="fas fa-cubes pf-c-empty-state__icon" aria-hidden="true"></i>
                <h1 class="pf-c-title pf-m-lg">
                    {% trans 'No Stage Prompts.' %}
                </h1>
                <div class="pf-c-empty-state__body">
                    {% trans 'Currently no stage prompts exist. Click the button below to create one.' %}
                </div>
                <a href="{% url 'passbook_admin:stage-prompt-create' %}?back={{ request.get_full_path }}" class="pf-c-button pf-m-primary" type="button">{% trans 'Create' %}</a>
            </div>
        </div>
        {% endif %}
    </div>
</section>
{% endblock %}
