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

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

{% block callBack %}mediaEditFormOpen{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <form id="mediaEditForm" class="XiboForm form-horizontal" method="put" action="{{ urlFor("library.edit", {"id": media.mediaId}) }}" data-media-id="{{ media.mediaId }}" data-valid-extensions="{{ validExtensions }}" data-gettag="{{ urlFor("tag.getByName") }}">
                {% if media.mediaType != "font" %}

                    {% set title %}{% trans "Name" %}{% endset %}
                    {% set helpText %}{% trans "The Name of this item - Leave blank to use the file name" %}{% endset %}
                    {{ forms.input("name", title, media.name, helpText) }}

                    {% set title %}{% trans "Duration" %}{% endset %}
                    {% set helpText %}{% trans "The duration in seconds this item should be displayed" %}{% endset %}
                    {{ forms.number("duration", title, media.duration, helpText) }}

                    {% set title %}{% trans "Tags" %}{% endset %}
                    {% set helpText %}{% trans "Tags for this Media - Comma separated string of Tags or Tag|Value format. If you choose a Tag that has associated values, they will be shown for selection below." %}{% endset %}
                    {{ forms.inputWithTags("tags", title, tags, helpText, 'tags-with-value') }}

                    <p id="loadingValues" style="margin-left: 17%"></p>

                    {% set title %}{% trans "Tag value" %}{% endset %}
                    {{ forms.dropdown("tagValue", "single", title, "", options, "key", "value") }}

                    <div id="tagValueRequired" class="alert alert-info">
                        <p>{% trans "This tag requires a set value, please select one from the Tag value dropdown." %}</p>
                    </div>

                    {% set title %}{% trans "Expiry date" %}{% endset %}
                    {% set helpText %}{% trans "Select the date and time after which this media should be removed from the CMS - it will be removed from any existing widgets as well" %}{% endset %}
                    {{ forms.dateTime("expires", title, expiryDate, helpText) }}

                    {% set title %}{% trans "Retire this media?" %}{% endset %}
                    {% set helpText %}{% trans "Retired media remains on existing Layouts but is not available to assign to new Layouts." %}{% endset %}
                    {{ forms.checkbox("retired", title, media.retired, helpText) }}

                    {% set title %}{% trans "Enable Media Stats Collection?" %}{% endset %}
                    {% set helpText %}{% trans "Enable the collection of Proof of Play statistics for this Media Item. Ensure that ‘Enable Stats Collection’ is set to ‘On’ in the Display Settings." %}{% endset %}

                    {% set offOption %}{% trans "Off" %}{% endset %}
                    {% set onOption %}{% trans "On" %}{% endset %}
                    {% set inheritOption %}{% trans "Inherit" %}{% endset %}
                    {% set options = [
                        { id: "Off", value: offOption },
                        { id: "On", value: onOption },
                        { id: "Inherit", value: inheritOption }
                    ] %}
                    {{ forms.dropdown("enableStat", "single", title, media.enableStat, options, "id", "value", helpText) }}

                    {% set title %}{% trans "Update this media in all layouts it is assigned to?" %}{% endset %}
                    {% set helpText %}{% trans "Note: It will only be updated in layouts you have permission to edit." %}{% endset %}
                    {% if settings.LIBRARY_MEDIA_UPDATEINALL_CHECKB == 1 %}
                        {% set checked = 1 %}
                    {% endif %}
                    {{ forms.checkbox("updateInLayouts", title, checked, helpText) }}

                {% else %}
                    {% set message %}{% trans "Sorry, Fonts do not have any editable properties." %}{% endset %}
                    {{ forms.message(message) }}
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}