{% extends "page.html" %}
{% block breadcrumb %}<a href="/service/documents/">Документация</a> / Управление доступами{% endblock %}
{% block page_actions %}<a href="/service/documents/" class="btn btn-secondary btn-sm">← Назад</a>{% endblock %}
{% block page_content %}
<div class="card">
    <form method="post" action="/service/documents/admin/permissions">
        <table class="permissions-table">
            <thead>
                <tr>
                    <th>Документ</th>
                    <th>Engineer: Просмотр</th>
                    <th>Engineer: Редактирование</th>
                    <th>Technician: Просмотр</th>
                </tr>
            </thead>
            <tbody>
                {% for slug, doc in perms.items()|sort(attribute='value.sort_order') %}
                <tr>
                    <td>{{ doc.title }}</td>
                    <td>
                        <input type="checkbox" name="{{ slug }}_engineer_view" {% if doc.permissions.engineer.view %}checked{% endif %}>
                    </td>
                    <td>
                        <input type="checkbox" name="{{ slug }}_engineer_edit" {% if doc.permissions.engineer.edit %}checked{% endif %}>
                    </td>
                    <td>
                        <input type="checkbox" name="{{ slug }}_technician_view" {% if doc.permissions.technician and doc.permissions.technician.view %}checked{% endif %}>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary">Сохранить</button>
            <a href="/service/documents/" class="btn btn-secondary">Отмена</a>
        </div>
    </form>
</div>
{% endblock %}
