{#
/*
 * Spring Signage Ltd - http://www.springsignage.com
 * Copyright (C) 2015 Spring Signage Ltd
 * (${FILE_NAME})
 */
#}

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}
{% import "inline.twig" as inline %}

{% set randomId = random() %}

{% block formTitle %}
    {% trans "Permissions" %}
{% endblock %}

{% block formButtons %}
    {% trans "Help" %}, XiboHelpRender("{{ help.permissions }}")
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, permissionsFormSubmit("{{ randomId }}")
{% endblock %}

{% block callBack %}permissionsFormOpen{% endblock %}

{% block formHtml %}
    <div class="permissions-form">
        <div class="row">
            <div class="col-md-12">
                <div class="XiboGrid permissionsGrid" id="{{ randomId }}"
                     data-url="{{ urlFor("user.permissions", {entity: entity, id: objectId}) }}"
                     data-permissions="{{ permissions|json_encode }}">
                    <div class="permissionsTableFilter">
                        <form onsubmit="false">
                            {% set title %}{% trans "Name" %}{% endset %}
                            {{ inline.input("name", title) }}
                        </form>
                    </div>
                    <div class="XiboData">
                        <table id="permissionsTable" class="table table-striped">
                            <thead>
                            <tr>
                                <th>{% trans "Name" %}</th>
                                <th>{% trans "View" %}</th>
                                <th>{% trans "Edit" %}</th>
                                <th>{% trans "Delete" %}</th>
                            </tr>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        {% if entity == "Campaign" %}
        <div class="row">
            <div class="col-md-12">
                {% set title %}{% trans %}Cascade permissions to all items underneath this one.{% endtrans %}{% endset %}
                {% set helpText %}{% trans %}For example, if this is a Layout then update the permissions on all Regions, Playlists and Widgets.{% endtrans %}{% endset %}
                {{ forms.checkbox("cascade", title, 0, helpText) }}
            </div>
        </div>
        {% endif %}
        {% if canSetOwner %}
        <div class="row">
            <div class="col-md-12">
                {% set title %}{% trans %}Owner{% endtrans %}{% endset %}
                {% set helpText %}{% trans %}Change the Owner of this item. Leave empty to keep the current owner.{% endtrans %}{% endset %}
                {{ forms.dropdown("ownerId", "single", title, "", [{"userId": null, "userName": ""}]|merge(owners), "userId", "userName", helpText) }}
            </div>
        </div>
        {% endif %}
    </div>
{% endblock %}