{#
/**
 * Copyright (C) 2021 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 "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% set name = layout.layout %}
    {% trans %}Copy {{ name }}{% endtrans %}
{% endblock %}

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Copy" %}, $("#layoutCopyForm").submit()
{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs" role="tablist">
                <li class="nav-item"><a class="nav-link active" href="#general" role="tab" data-toggle="tab"><span>{% trans "General" %}</span></a></li>
                <li class="nav-item"><a class="nav-link" href="#description" role="tab" data-toggle="tab"><span>{% trans "Description" %}</span></a></li>
            </ul>
            <form id="layoutCopyForm" class="XiboForm form-horizontal" method="post" action="{{ url_for("layout.copy", {id: layout.layoutId}) }}")>
                <div class="tab-content">
                    <div class="tab-pane active" id="general">
                        {% if layout.publishedStatusId == 2 %}
                            {% set warning %} {% trans "Copying this Layout will create an exact copy of the last time this Layout was Published.
                             Any changes made to this Layout while it has been a Draft will not be copied. Publish the Layout before making a copy if the Draft changes should be included in the copy." %} {% endset %}
                            {{ forms.message(warning, 'alert alert-info') }}
                        {% endif %}

                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "The Name for the copy (1 - 50 characters)" %}{% endset %}
                        {% set layoutName %}{{ layout.layout }} 2{% endset %}
                        {{ forms.input("name", title, layoutName, helpText) }}

                        {% set title %}{% trans "Make new copies of all media?" %}{% endset %}
                        {% set helpText %}{% trans "This will duplicate all media that is currently assigned to the item being copied." %}{% endset %}
                        {% if settings.LAYOUT_COPY_MEDIA_CHECKB == 1 %}
                            {% set checked = 1 %}
                        {% else %}
                            {% set checked = 0 %}
                        {% endif %}
                        {{ forms.checkbox("copyMediaFiles", title, checked, helpText) }}
                    </div>
                    <div class="tab-pane" id="description">
                        {% set title %}{% trans "Description" %}{% endset %}
                        {% set helpText %}{% trans "An optional description (1 - 250 characters)" %}{% endset %}
                        {{ forms.textarea("description", title, layout.description, helpText) }}
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}