{#
/**
 * Copyright (C) 2020 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}
{% import "forms.twig" as forms %}
{% block formHtml %}
    <div class="accordion" id="accordion" role="tablist" aria-multiselectable="true">
    {% for field in commands %}
        <div class="card">
            <div class="card-header" role="tab" id="heading{{ field.commandId }}">
                <h4 class="card-title">
                    <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ field.commandId }}"
                       aria-expanded="true" aria-controls="collapse{{ field.commandId }}">
                        {{ field.command }} | {{ field.code }}
                    </a>
                </h4>
            </div>
            <div id="collapse{{ field.commandId }}" class="collapse"
                 role="tabpanel" aria-labelledby="heading{{ field.commandId }}" aria-expanded="false">
                <div class="card-body">
                    {% set title %}{% trans "Name" %}{% endset %}
                    {{ forms.disabled("command", title, field.command, field.description) }}

                    {% if field.commandString != "" %}
                        {{ forms.disabled("", "", "This Command has a default Command String."|trans, field.commandString) }}
                    {% endif %}

                    {% set fieldId = "commandString_" ~ field.commandId %}
                    {% set title %}{% trans "Command" %}{% endset %}
                    {% set helpText %}{% trans "The Command String for this Command on this display" %}{% endset %}
                    {{ forms.input(fieldId, title, field.commandStringDisplayProfile, helpText, "XiboCommand") }}

                    {% if field.validationString != "" %}
                        {{ forms.disabled("", "", "This Command has a default Valildation String."|trans, field.validationString) }}
                    {% endif %}

                    {% set fieldId = "validationString_" ~ field.commandId %}
                    {% set title %}{% trans "Validation" %}{% endset %}
                    {% set helpText %}{% trans "The Validation String for this Command on this display" %}{% endset %}
                    {{ forms.input(fieldId, title, field.validationStringDisplayProfile, helpText) }}

                    {% if field.createAlertOn != "" %}
                        {{ forms.disabled("", "", "This Command has a default setting for creating alerts."|trans, field.createAlertOn) }}
                    {% endif %}

                    {% set fieldId = "createAlertOn_" ~ field.commandId %}
                    {% set options = [
                        { optionid: "", option: "" },
                        { optionid: "never", option: "Never" },
                        { optionid: "success", option: "Success" },
                        { optionid: "failure", option: "Failure" },
                        { optionid: "always", option: "Always" },
                    ] %}
                    {% set title %}{% trans "Create Alert On" %}{% endset %}
                    {% set helpText %}{% trans "On command execution, when should a Display alert be created?" %}{% endset %}

                    {{ forms.dropdown(fieldId, "single", title, field.createAlertOnDisplayProfile, options, "optionid", "option", helpText) }}
                </div>
            </div>
        </div>
    {% endfor %}
{% endblock %}