
{% load i18n %}
{% load common_filters %}

{% comment %}
<!--
  Copyright (C) 2011 University of Dundee & Open Microscopy Environment.
  All rights reserved.

  This program 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 (at your option) any later version.

  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
-->
{% endcomment %}

{% comment %}
<!--
  This is the content of a form for choosing existing file-annotations.
  Loaded by AJAX into a form dialog.
-->
{% endcomment %}
<script type="text/javascript">
    $(document).ready(function(){
        $(":button:contains('Accept')",
            $("#choose_attachments_form").parent()).prop("disabled", true).addClass(
                'ui-state-disabled');
        
        $('#id_annotation_file, #id_files').change(
            function(){
                if ($(this).val()){
                    $(":button:contains('Accept')",
                        $("#choose_attachments_form").parent()
                            ).prop("disabled", false).removeClass('ui-state-disabled');
                }
                else {
                    $(":button:contains('Accept')",
                        $("#choose_attachments_form").parent()).prop("disabled", true).addClass(
                            'ui-state-disabled');
            }
        });
        
    });
</script>

<div>

    <h1>{% trans "Upload a new file" %}:</h1>
    <span>Choose a local file to upload and attach</span>
    {{ form_file.annotation_file }}
</div>

<p>
    <h1>And/or attach an existing File:</h1>
    <span>Select the attachments to add</span>
    
    <div>{{ form_file.files }}</div>
    <!-- hidden fields used to specify the objects we're tagging -->
    <div class="hiddenField">{{ form_file.image }}</div>
    <div class="hiddenField">{{ form_file.dataset }}</div>
    <div class="hiddenField">{{ form_file.project }}</div>
    <div class="hiddenField">{{ form_file.screen }}</div>
    <div class="hiddenField">{{ form_file.plate }}</div>
    <div class="hiddenField">{{ form_file.acquisition }}</div>
    <div class="hiddenField">{{ form_file.well }}</div>
    <div class="hiddenField"><input type="text" name="index" value="{{ index }}"/></div>

</p>