{% from 'forms/_form.html' import form_header, form_footer, form_rows, form_row %}
{% from 'message_box.html' import message_box %}

{%- block content %}
    {% call message_box('warning', fixed_width=true) %}
        {% trans %}
            Please be aware that only the URL will be stored and no copy of the referenced file
            or website will be made. In case of a file, it is recommended to upload it to Indico instead.
        {% endtrans %}
    {% endcall %}
    {{ form_header(form, id='attachment-link-form')}}
    {{ form_row(form.link_url, widget_attrs={'placeholder': 'Example: https://www.google.com'}) }}
    {{ form_rows(form, fields=('title',)) }}
    {{ form_rows(form, skip=('link_url', 'title', 'description', 'folder', 'protected', 'acl')) }}
    {{ form_rows(form, fields=('description', 'folder', 'protected', 'acl')) }}
    {{ protection_message | safe }}
    {% call form_footer(attach_form) %}
        <input class="i-button big highlight" type="submit" value="{% trans %}Submit{% endtrans %}">
        <button class="i-button big" data-button-back>{% trans %}Cancel{% endtrans %}</button>
    {% endcall %}
    <script>
        (function() {
            'use strict';

            $('#{{ form.folder.id }}').nullableselector();
            var form = $('#attachment-link-form');
            aclIfProtected(
                $('#{{ form.protected.id }}'),
                {% if form.acl %}$('#{{ form.acl.id }}'){% else %}null{% endif %},
                form.find('.protected-protection-message'),
                form.find('.inheriting-protection-message'),
                $('#{{ form.folder.id }}')
            );
            messageIfFolderProtected(
                $('#{{ form.protected.id }}'), $('#{{ form.folder.id }}'),
                {{ folders_protection_info | tojson }},
                form.find('.protected-protection-message'),
                form.find('.inheriting-protection-message'),
                form.find('.folder-protection-message')
            );
        })();
    </script>
{%- endblock %}
