{% load i18n %}


{% 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 'include' page is used by 'script_ui.html' at different points in the parameter hierarchy.
-->
{% endcomment %}

<div class="param" {% if i.description %}title="{{ i.description }}"{% endif %}>

<table border='0' cellpadding='0' cellspacing='1'><tr>
<td valign="top">
{{ i.name }}:

{% if i.required %}<span style='color:red'>*</span>{% endif %}
</td>
<td valign="top">
<!-- List - Users should enter comma-separated values into field -->
{% if i.list %}
    {% if i.options %}
    <!-- List has options -->
        <img src="{% static "webclient/image/info16.png" %}" title="Add items to list with [+]" />
        <select tabIndex="1" name="{{ i.key }}">
            {% for v in i.options %}
                <option value="{{ v }}" {% ifequal i.default v %} selected="True" {% endifequal %} >{{ v }}</option>
            {% endfor %}
        </select>
        <a href="#" class="removeListSelect">[-]</a> <a href="#" class="addListSelect">[+]</a>
    <!-- Otherwise, Use comma-separated list -->
    {% else %}
        <img src="{% static "webclient/image/info16.png" %}" title="Add items to list, separated by ','" />
        <input tabIndex="1" type="text" name="{{ i.key }}" {% ifnotequal i.default None %} value="{{ i.default }}" {% endifnotequal %} />
    {% endif %}
{% else %}
    {% if i.options %}
    <!-- drop-down list of enums -->
        <select tabIndex="1" name="{{ i.key }}">
            {% for v in i.options %}
                <option value="{{ v }}" {% ifequal i.default v %} selected="True" {% endifequal %} >{{ v }}</option>
            {% endfor %}
        </select>
    {% else %}

        {% if i.map %}
        <!-- inputs for key:value pairs - use javascript to add input rows -->
        <a href="#" class="addKeyValue" title="Add key:value fields">[+]</a>
        <a href="#" class="removeKeyValue" title="Remove key:value fields">[-]</a>
    </td>
    <td valign="top">
            <table class="map">
                <tr>
                    <td><input tabIndex="1" type="text" name="{{ i.key }}_key0"/></td>
                    <td><input tabIndex="1" type="text" name="{{ i.key }}_value0"/></td>
                </tr>
            </table>
        {% else %}
            {% if i.boolean %}
                <input tabIndex="1" type="checkbox" name="{{ i.key }}" {% if i.default %} checked="True" {% endif %} />
            {% else %}
                {% if i.number %}
                    <input tabIndex="1" type="text" name="{{ i.key }}" class="{{ i.number }}" {% ifnotequal i.default None %} value="{{ i.default }}" {% endifnotequal %} />
                {% else %}
                    <input tabIndex="1" type="text" name="{{ i.key }}" {% ifnotequal i.default None %} value="{{ i.default }}" {% endifnotequal %} />
                {% endif %}
            {% endif %}
        {% endif %}
    {% endif %}
{% endif %}

{% if i.min %}<span style="color: #666"> Min: {{ i.min }} </span>{% endif %}
{% if i.max %}<span style="color: #666"> Max: {{ i.max }} </span>{% endif %}

<!-- If "File Annotation", allow user to choose file to upload, to create a File-Annotation -->
{% ifequal i.name 'File Annotation' %}
    OR <input name='file_annotation' type='file'/>
{% endifequal %}

</td></tr>
</table>
</div>
