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

#}

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

{% block formTitle %}
    {% trans "Edit Display Group" %}
{% endblock %}

{% block formButtons %}
    {% trans "Help" %}, XiboHelpRender("{{ help }}")  
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#displayGroupEditForm").submit()
{% endblock %}

{% block formFieldActions %}
    [{
    "field": "isDynamic",
    "trigger": "init",
    "value": false,
    "operation": "is:checked",
    "actions": {
    ".dynamic-fields": { "display": "none" }
    }
    },{
    "field": "isDynamic",
    "trigger": "change",
    "value": false,
    "operation": "is:checked",
    "actions": {
    ".dynamic-fields": { "display": "none" }
    }
    },{
    "field": "isDynamic",
    "trigger": "init",
    "value": true,
    "operation": "is:checked",
    "actions": {
    ".dynamic-fields": { "display": "block" }
    }
    },{
    "field": "isDynamic",
    "trigger": "change",
    "value": true,
    "operation": "is:checked",
    "actions": {
    ".dynamic-fields": { "display": "block" }
    }
    }]
{% endblock %}

{% block callBack %}displayGroupFormOpen{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <form id="displayGroupEditForm" class="XiboForm form-horizontal" method="put" action="{{ urlFor("displayGroup.edit", {"id": displayGroup.displayGroupId}) }}">
                {% set title %}{% trans "Name" %}{% endset %}
                {% set helpText %}{% trans "The Name for this Display Group" %}{% endset %}
                {{ forms.input("displayGroup", title, displayGroup.displayGroup , helpText) }}

                {% set title %}{% trans "Description" %}{% endset %}
                {% set helpText %}{% trans "A short description of this Display Group" %}{% endset %}
                {{ forms.input("description", title, displayGroup.description, helpText) }}

                {% set title %}{% trans "Tags" %}{% endset %}
                {% set helpText %}{% trans "Tag this item. Comma Separated." %}{% endset %}
                {{ forms.inputWithTags("tags", title, displayGroup.tags, helpText) }}

                {% set title %}{% trans "Dynamic Group?" %}{% endset %}
                {% set helpText %}{% trans "Are the members of this group dynamic?" %}{% endset %}
                {{ forms.checkbox("isDynamic", title, displayGroup.isDynamic, helpText) }}

                {% set title %}{% trans "Criteria" %}{% endset %}
                {% set helpText %}{% trans "A comma separated set of regular expressions run against the Display name to determine membership." %}{% endset %}
                {{ forms.input("dynamicCriteria", title, displayGroup.dynamicCriteria, helpText, "dynamic-fields") }}
            </form>
        </div>
    </div>
    <div class="row dynamic-fields">
        <div class="col-md-12">
            <h4>Displays</h4>
            <div id="displayGroupDisplayList" class="well">
                <table id="displays" class="table table-striped">
                    <thead>
                    <tr>
                        <th>{% trans "ID" %}</th>
                        <th>{% trans "Display" %}</th>
                        <th>{% trans "Status" %}</th>
                        <th>{% trans "Licence" %}</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}