{% extends theme('base.html') %}
{% import 'macro/fomanticui.html' as sui %}

{% block title %}
    {% trans %}Edit a client{% endtrans %}
{% endblock %}

{% block script %}
    <script src="/static/js/admin/client_edit.js"></script>
{% endblock %}

{% block content %}
    <div class="ui basic modal">
        <div class="ui icon header">
            <i class="trash icon"></i>
            {% trans %}Client deletion{% endtrans %}
        </div>
        <div class="content">
            <p>{{ _("Are you sure you want to delete this client? This action is unrevokable and all the data about this client will be removed.") }}</p>
        </div>
        <div class="actions">
            <div class="ui inverted cancel button">{% trans %}Cancel{% endtrans %}</div>
            <div class="ui inverted red approve button">{% trans %}Delete{% endtrans %}</div>
        </div>
    </div>

    <div class="loginform">
        <h3 class="ui top attached header">
            {% trans %}Edit a client{% endtrans %}
        </h3>

        <div class="ui attached clearing segment">
            <div class="ui form">
                <form id="readonly">
                    <div class="field">
                        <label>{% trans %}ID{% endtrans %}</label>
                        <div class="ui cornor labeled input">
                            <input type="text" value="{{ client.client_id }}" readonly name="client_id">
                            <div class="ui corner label" title="{{ _("This field is not editable") }}">
                                <i class="lock icon"></i>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <label>{% trans %}Secret{% endtrans %}</label>
                        <div class="ui cornor labeled input">
                            <input type="text" value="{{ client.client_secret }}" readonly name="client_secret">
                            <div class="ui corner label" title="{{ _("This field is not editable") }}">
                                <i class="lock icon"></i>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <label>{% trans %}Issued at{% endtrans %}</label>
                        <div class="ui cornor labeled input">
                            <input type="text" value="{{ client.client_id_issued_at }}" readonly name="client_id_issued_at">
                            <div class="ui corner label" title="{{ _("This field is not editable") }}">
                                <i class="lock icon"></i>
                            </div>
                        </div>
                    </div>
                </form>
            </div>

            <form method="POST"
                id="{{ form.__class__.__name__|lower }}"
                action="{{ form.action }}"
                role="form"
                enctype="multipart/form-data"
                class="ui form"
            >

                {{ sui.render_fields(form) }}

                <div class="ui right aligned container">
                    <div class="ui stackable buttons">
                        <button type="submit" class="ui right floated negative basic button confirm" name="action" value="delete" id="delete">
                            {{ _("Delete the client") }}
                        </button>
                        <button type="submit" class="ui right floated primary button" name="action" value="edit" id="edit">
                            {{ _("Edit") }}
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}
