<commit_before>{#
/**
 * 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/>.
 */
#}
{% extends "authed.twig" %}
{% import "inline.twig" as inline %}

{% block title %}{{ "Display Groups"|trans }} | {% endblock %}

{% block actionMenu %}
    {% if currentUser.featureEnabled("displaygroup.add") %}
    <div class="widget-action-menu pull-right">
        <button class="btn btn-success XiboFormButton" title="{% trans "Add a new Display Group" %}" href="{{ url_for("displayGroup.add.form") }}"> <i class="fa fa-desktop" aria-hidden="true"></i> {% trans "Add Display Group" %}</button>
        <button class="btn btn-primary" id="refreshGrid" title="{% trans "Refresh the Table" %}" href="#"><i class="fa fa-refresh" aria-hidden="true"></i> {% trans "Refresh" %}</button>
    </div>
    {% endif %}
{% endblock %}

{% block pageContent %}
    <div class="widget">
        <div class="widget-title">{% trans "Display Groups" %}</div>
        <div class="widget-body">
            <div class="XiboGrid" id="{{ random() }}">
                <div class="XiboFilter card mb-3 bg-light">
                    <div class="FilterDiv card-body" id="Filter">
                        <form class="form-inline">
                            {% set title %}{% trans "ID" %}{% endset %}
                            {{ inline.input("displayGroupId", title) }}

                            {% set title %}{% trans "Name" %}{% endset %}
                            {{ inline.inputNameGrid('displayGroup', title) }}

                            {% set title %}{% trans "Display" %}{% endset %}
                            {% set attributes = [
                                { name: "data-width", value: "200px" },
                                { name: "data-allow-clear", value: "true" },
                                { name: "data-placeholder--id", value: null },
                                { name: "data-placeholder--value", value: "" },
                                { name: "data-search-url", value: url_for("display.search") },
                                { name: "data-search-term", value: "display" },
                                { name: "data-search-term-tags", value: "tags" },
                                { name: "data-id-property", value: "displayId" },
                                { name: "data-text-property", value: "display" }
                            ] %}
                            {% set helpText %}{% trans "Return Display Groups that directly contain the selected Display." %}{% endset %}
                            {{ inline.dropdown("displayId", "single", title, "", null, "displayId", "display", helpText, "pagedSelect", "", "", "", attributes) }}

                            {% set title %}{% trans "Nested Display" %}{% endset %}
                            {% set helpText %}{% trans "Return Display Groups that contain the selected Display somewhere in the nested Display Group relationship tree." %}{% endset %}
                            {{ inline.dropdown("nestedDisplayId", "single", title, "", null, "displayId", "display", helpText, "pagedSelect", "", "", "", attributes) }}

                            {% set title %}{% trans "Dynamic Criteria" %}{% endset %}
                            {{ inline.input("dynamicCriteria", title) }}

                            {% if currentUser.featureEnabled("tag.tagging") %}
                                {% set title %}{% trans "Tags" %}{% endset %}
                                {% set exactTagTitle %}{% trans "Exact match?" %}{% endset %}
                                {% set logicalOperatorTitle %}{% trans "When filtering by multiple Tags, which logical operator should be used?" %}{% endset %}
                                {% set helpText %}{% trans "A comma separated list of tags to filter by. Enter a Tag value preceded with | to filter by Tag values. Enter --no-tag to see items without tags." %}{% endset %}
                                {{ inline.inputWithTags("tags", title, null, helpText, null, null, null, "exactTags", exactTagTitle, logicalOperatorTitle) }}
                            {% endif %}

                            {{ inline.hidden("folderId") }}
                        </form>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
                        <div class="form-check">
                            <input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
                            <label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
                        </div>
                        <div id="container-folder-tree"></div>
                    </div>
                    <div class="folder-controller d-none">
                        <button type="button" id="folder-tree-select-folder-button" class="btn btn-outline-secondary" title="{% trans "Open / Close Folder Search options" %}"><i class="fas fa-folder fa-1x"></i></button>
                        <div id="breadcrumbs" class="mt-2 pl-2"></div>
                    </div>
                    <div id="datatable-container" class="card col-sm-10 pt-4 px-2">
                        <div class="XiboData">
                            <table id="displaygroups" class="table table-striped" data-content-type="displayGroup" data-content-id-name="displayGroupId" data-state-preference-name="displayGroupGrid" style="width: 100%;">
                                <thead>
                                    <tr>
                                        <th>{% trans "ID" %}</th>
                                        <th>{% trans "Name" %}</th>
                                        <th>{% trans "Description" %}</th>
                                        <th>{% trans "Is Dynamic?" %}</th>
                                        <th>{% trans "Criteria" %}</th>
                                        {% if currentUser.featureEnabled("tag.tagging") %}
                                            <th>{% trans "Criteria Tags" %}</th>
                                            <th>{% trans "Tags" %}</th>
                                        {% endif %}
                                        <th>{% trans "Sharing" %}</th>
                                        <th>{% trans "Created Date" %}</th>
                                        <th>{% trans "Modified Date" %}</th>
                                        <th class="rowMenu"></th>
                                    </tr>
                                </thead>
                                <tbody>

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

{% block javaScript %}
    <script type="text/javascript">
        {% if not currentUser.featureEnabled("folder.view") %}
        disableFolders();
        {% endif %}

        var table = $("#displaygroups").DataTable({
            "language": dataTablesLanguage,
            dom: dataTablesTemplate,
            serverSide: true,
            stateSave: true,
            stateDuration: 0,
            responsive: true,
            stateLoadCallback: dataTableStateLoadCallback,
            stateSaveCallback: dataTableStateSaveCallback,
            "filter": false,
            searchDelay: 3000,
            "order": [[ 1, "asc"]],
            ajax: {
                "url": "{{ url_for("displayGroup.search") }}",
                "data": function(d) {
                    $.extend(d, $("#displaygroups").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
                }
            },
            "columns": [
                { "data": "displayGroupId", responsivePriority: 2},
                { "data": "displayGroup", "render": dataTableSpacingPreformatted, responsivePriority: 2 },
                { "data": "description", responsivePriority: 3 },
                { "data": "isDynamic", "render": dataTableTickCrossColumn, responsivePriority: 3 },
                { "data": "dynamicCriteria", responsivePriority: 4 },
                {% if currentUser.featureEnabled("tag.tagging") %}
                { "data": "dynamicCriteriaTags", responsivePriority: 4},
                {
                    "name": "tags",
                    "sortable": false,
                    responsivePriority: 3,
                    "data": dataTableCreateTags
                },
                {% endif %}
                {
                    "data": "groupsWithPermissions",
                    visible: false,
                    responsivePriority: 10,
                    "render": dataTableCreatePermissions
                },
                { "data": "createdDt", "visible": false, responsivePriority: 5 },
                { "data": "modifiedDt", "visible": false, responsivePriority: 5 },
                {
                    "orderable": false,
                    responsivePriority: 1,
                    "data": dataTableButtonsColumn
                }
            ]
        });

        $("#refreshGrid").click(function () {
          table.ajax.reload();
        });

        table.on('draw', dataTableDraw);
        table.on('draw', { form: $("#displaygroups").closest(".XiboGrid").find(".FilterDiv form") }, dataTableCreateTagEvents);
        table.on('processing.dt', dataTableProcessing);
        dataTableAddButtons(table, $('#displaygroups_wrapper').find('.dataTables_buttons'));

        var displayTable;
        var criteria;
        var criteriaTag;
        var useRegexForName;
        var exactTags;
        var logicalOperator;
        var logicalOperatorName;

        function setDeleteMultiSelectFormOpen(dialog) {
            $(dialog).find('.save-button').prop('disabled', false);
            var template = Handlebars.compile($('#template-display-group-multi-delete-checkbox').html());
            var $input = $(template());
            $input.find('input').on('change', function() {
                $(dialog).find('.save-button').prop('disabled', !$(this).is(':checked'));
            });
            $(dialog).find('.modal-body').append($input);
        }

        function displayGroupAddFormNext() {<commit_msg>DisplayGroup page : add data-grid-name, fix page load<commit_after>{#
/**
 * 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/>.
 */
#}
{% extends "authed.twig" %}
{% import "inline.twig" as inline %}

{% block title %}{{ "Display Groups"|trans }} | {% endblock %}

{% block actionMenu %}
    {% if currentUser.featureEnabled("displaygroup.add") %}
    <div class="widget-action-menu pull-right">
        <button class="btn btn-success XiboFormButton" title="{% trans "Add a new Display Group" %}" href="{{ url_for("displayGroup.add.form") }}"> <i class="fa fa-desktop" aria-hidden="true"></i> {% trans "Add Display Group" %}</button>
        <button class="btn btn-primary" id="refreshGrid" title="{% trans "Refresh the Table" %}" href="#"><i class="fa fa-refresh" aria-hidden="true"></i> {% trans "Refresh" %}</button>
    </div>
    {% endif %}
{% endblock %}

{% block pageContent %}
    <div class="widget">
        <div class="widget-title">{% trans "Display Groups" %}</div>
        <div class="widget-body">
            <div class="XiboGrid" id="{{ random() }}" data-grid-name="displayGroupGridView">
                <div class="XiboFilter card mb-3 bg-light">
                    <div class="FilterDiv card-body" id="Filter">
                        <form class="form-inline">
                            {% set title %}{% trans "ID" %}{% endset %}
                            {{ inline.input("displayGroupId", title) }}

                            {% set title %}{% trans "Name" %}{% endset %}
                            {{ inline.inputNameGrid('displayGroup', title) }}

                            {% set title %}{% trans "Display" %}{% endset %}
                            {% set attributes = [
                                { name: "data-width", value: "200px" },
                                { name: "data-allow-clear", value: "true" },
                                { name: "data-placeholder--id", value: null },
                                { name: "data-placeholder--value", value: "" },
                                { name: "data-search-url", value: url_for("display.search") },
                                { name: "data-search-term", value: "display" },
                                { name: "data-search-term-tags", value: "tags" },
                                { name: "data-id-property", value: "displayId" },
                                { name: "data-text-property", value: "display" }
                            ] %}
                            {% set helpText %}{% trans "Return Display Groups that directly contain the selected Display." %}{% endset %}
                            {{ inline.dropdown("displayId", "single", title, "", null, "displayId", "display", helpText, "pagedSelect", "", "", "", attributes) }}

                            {% set title %}{% trans "Nested Display" %}{% endset %}
                            {% set helpText %}{% trans "Return Display Groups that contain the selected Display somewhere in the nested Display Group relationship tree." %}{% endset %}
                            {{ inline.dropdown("nestedDisplayId", "single", title, "", null, "displayId", "display", helpText, "pagedSelect", "", "", "", attributes) }}

                            {% set title %}{% trans "Dynamic Criteria" %}{% endset %}
                            {{ inline.input("dynamicCriteria", title) }}

                            {% if currentUser.featureEnabled("tag.tagging") %}
                                {% set title %}{% trans "Tags" %}{% endset %}
                                {% set exactTagTitle %}{% trans "Exact match?" %}{% endset %}
                                {% set logicalOperatorTitle %}{% trans "When filtering by multiple Tags, which logical operator should be used?" %}{% endset %}
                                {% set helpText %}{% trans "A comma separated list of tags to filter by. Enter a Tag value preceded with | to filter by Tag values. Enter --no-tag to see items without tags." %}{% endset %}
                                {{ inline.inputWithTags("tags", title, null, helpText, null, null, null, "exactTags", exactTagTitle, logicalOperatorTitle) }}
                            {% endif %}

                            {{ inline.hidden("folderId") }}
                        </form>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
                        <div class="form-check">
                            <input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
                            <label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
                        </div>
                        <div id="container-folder-tree"></div>
                    </div>
                    <div class="folder-controller d-none">
                        <button type="button" id="folder-tree-select-folder-button" class="btn btn-outline-secondary" title="{% trans "Open / Close Folder Search options" %}"><i class="fas fa-folder fa-1x"></i></button>
                        <div id="breadcrumbs" class="mt-2 pl-2"></div>
                    </div>
                    <div id="datatable-container" class="card col-sm-10 pt-4 px-2">
                        <div class="XiboData">
                            <table id="displaygroups" class="table table-striped" data-content-type="displayGroup" data-content-id-name="displayGroupId" data-state-preference-name="displayGroupGrid" style="width: 100%;">
                                <thead>
                                    <tr>
                                        <th>{% trans "ID" %}</th>
                                        <th>{% trans "Name" %}</th>
                                        <th>{% trans "Description" %}</th>
                                        <th>{% trans "Is Dynamic?" %}</th>
                                        <th>{% trans "Criteria" %}</th>
                                        {% if currentUser.featureEnabled("tag.tagging") %}
                                            <th>{% trans "Criteria Tags" %}</th>
                                            <th>{% trans "Tags" %}</th>
                                        {% endif %}
                                        <th>{% trans "Sharing" %}</th>
                                        <th>{% trans "Created Date" %}</th>
                                        <th>{% trans "Modified Date" %}</th>
                                        <th class="rowMenu"></th>
                                    </tr>
                                </thead>
                                <tbody>

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

{% block javaScript %}
    <script type="text/javascript">
      var displayGroupTable;
      var displayTable;
      var criteria;
      var criteriaTag;
      var useRegexForName;
      var exactTags;
      var logicalOperator;
      var logicalOperatorName;

      $(document).ready(function() {
        {% if not currentUser.featureEnabled("folder.view") %}
        disableFolders();
        {% endif %}

        displayGroupTable = $("#displaygroups").DataTable({
            "language": dataTablesLanguage,
            dom: dataTablesTemplate,
            serverSide: true,
            stateSave: true,
            stateDuration: 0,
            responsive: true,
            stateLoadCallback: dataTableStateLoadCallback,
            stateSaveCallback: dataTableStateSaveCallback,
            "filter": false,
            searchDelay: 3000,
            "order": [[ 1, "asc"]],
            ajax: {
                "url": "{{ url_for("displayGroup.search") }}",
                "data": function(d) {
                    $.extend(d, $("#displaygroups").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
                }
            },
            "columns": [
                { "data": "displayGroupId", responsivePriority: 2},
                { "data": "displayGroup", "render": dataTableSpacingPreformatted, responsivePriority: 2 },
                { "data": "description", responsivePriority: 3 },
                { "data": "isDynamic", "render": dataTableTickCrossColumn, responsivePriority: 3 },
                { "data": "dynamicCriteria", responsivePriority: 4 },
                {% if currentUser.featureEnabled("tag.tagging") %}
                { "data": "dynamicCriteriaTags", responsivePriority: 4},
                {
                    "name": "tags",
                    "sortable": false,
                    responsivePriority: 3,
                    "data": dataTableCreateTags
                },
                {% endif %}
                {
                    "data": "groupsWithPermissions",
                    visible: false,
                    responsivePriority: 10,
                    "render": dataTableCreatePermissions
                },
                { "data": "createdDt", "visible": false, responsivePriority: 5 },
                { "data": "modifiedDt", "visible": false, responsivePriority: 5 },
                {
                    "orderable": false,
                    responsivePriority: 1,
                    "data": dataTableButtonsColumn
                }
            ]
        });

        $("#refreshGrid").click(function () {
          displayGroupTable.ajax.reload();
        });

        displayGroupTable.on('draw', dataTableDraw);
        displayGroupTable.on('draw', { form: $("#displaygroups").closest(".XiboGrid").find(".FilterDiv form") }, dataTableCreateTagEvents);
        displayGroupTable.on('processing.dt', dataTableProcessing);
        dataTableAddButtons(displayGroupTable, $('#displaygroups_wrapper').find('.dataTables_buttons'));
      });

        function setDeleteMultiSelectFormOpen(dialog) {
            $(dialog).find('.save-button').prop('disabled', false);
            var template = Handlebars.compile($('#template-display-group-multi-delete-checkbox').html());
            var $input = $(template());
            $input.find('input').on('change', function() {
                $(dialog).find('.save-button').prop('disabled', !$(this).is(':checked'));
            });
            $(dialog).find('.modal-body').append($input);
        }

        function displayGroupAddFormNext() {
{'fraction_non_alphanumeric': 0.14241693461950697, 'fraction_numerical': 0.0034833869239013935, 'mean_word_length': 1.523439260761776, 'pattern_counts': {'":': 50, '<': 161, '<?xml version=': 0, '>': 161, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 84, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3802618', 'n_tokens_mistral': 5726, 'n_tokens_neox': 5274, 'n_words': 1371}