{#
/*
 * 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 "Delete Widget" %}
{% endblock %}

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

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <form id="widgetDeleteForm" class="XiboForm form-horizontal" method="delete" action="{{ urlFor("module.widget.delete", {id: module.widget.widgetId}) }}">
                {% set message %}{% trans "Are you sure you want to remove this widget?" %}{% endset %}
                {{ forms.message(message) }}

                {% set message %}{% trans "This action cannot be undone." %}{% endset %}
                {{ forms.message(message) }}

                {% if module.getModule().regionSpecific == 0 and module.widget.mediaIds|length > 0 %}
                    {% if module.getMedia().isUsed(1) %}
                        {% set message %}{% trans "This widget is linked to Media in the Library which is also in use elsewhere. If this should be deleted then please do so from the Library page." %}{% endset %}
                        {{ forms.message(message) }}
                    {% else %}
                        {% set title %}{% trans "Also delete from the Library?" %}{% endset %}
                        {% set helpText %}{% trans "This widget is linked to Media in the Library. Check this option to also delete that Media." %}{% endset %}
                        {{ forms.checkbox("deleteMedia", title, 0, helpText) }}
                    {% endif %}
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}