{#-
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<form id="update-values" method="post" action="../update_tickets">
    {% for field in globals.custom_fields %}
      {% if field.name == '_milestone' %}
      <div class="grid-6">{{milestones}}
        <label for="{{field.name}}" class="cr">{{field.label}}:</label>
        <select name="{{field.name}}" id="{{field.name}}" class="wide">
          <option value="" selected="selected">no change</option>
          {% for m in field.milestones %}
            {% if not m.complete %}
              <option value="{{m.name}}">{{m.name}}</option>
            {% endif %}
          {% endfor %}
        </select>
      </div>
      {% endif %}
    {% endfor %}
    <div class="grid-6">
      <label for="status" class="cr">Status:</label>
      <select name="status" id="status" class="wide">
        <option value="" selected="selected">no change</option>
        {% for option in globals.all_status_names.split() %}
          <option value="{{option}}">{{option}}</option>
        {% endfor %}
      </select>
    </div>
    <div class="grid-6">
      <label for="private" class="cr">Private:</label>
      <select name="private" id="private">
        <option value="" selected="selected">Don't change</option>
        <option value="True">True</option>
        <option value="False">False</option>
      </select>
    </div>
    <div class="grid-6">
      <label for="deleted" class="cr">Delete:</label>
      <select name="deleted" id="deleted">
        <option value="" selected="selected">Don't change</option>
        <option value="True">True</option>
      </select>
    </div>
    <div class="grid-6">
      <label for="assigned_to" class="cr">Owner:</label>
      {{c.user_select.display(name='assigned_to', id='assigned_to', value='', className='wide')}}
    </div>
    <div style="clear: both"></div>
    <div class="grid-18">
        <label class="cr">Labels:</label>
        {{c.label_edit.display(name='labels', className='wide')}}
    </div>
    {% set cf_count = 0 %}
    {% for field in globals.custom_fields %}
      {% if field.name != '_milestone' %}
        {% if cf_count%3 == 0 %}
          <div style="clear: both"></div>
        {% endif %}
        <div class="grid-6">
          <label for="{{field.id}}" class="cr">{{field.label}}:</label>
          {% if field.type == 'boolean' %}
            <select name="{{field.name}}" id="{{field.name}}">
                <option value="" selected="selected">Don't change</option>
                <option value="True">True</option>
                <option value="False">False</option>
            </select>
          {% elif field.type == 'select' %}
            <select name="{{field.name}}" class="wide">
              <option value="" selected="selected">no change</option>
              {% for option in h.split_select_field_options(h.really_unicode(field.options)) %}
                {% if option.startswith('*') %}
                  <option value="{{option[1:]}}">{{option[1:]}}</option>
                {% else %}
                  <option value="{{option}}">{{option}}</option>
                {% endif %}
              {% endfor %}
            </select>
          {% elif field.type == 'milestone' %}
            <select name="{{field.name}}">
              <option value="" selected="selected">no change</option>
              {% for m in field.milestones %}
                {% if not m.complete %}
                  <option value="{{m.name}}">{{m.name}}</option>
                {% endif %}
              {% endfor %}
            </select>
          {% elif field.type == 'user' %}
            {{c.user_select.display(name=field.name, id=field.name, value='', className='wide')}}
          {% else %}
            <input name="{{field.name}}" type="text" value="" class="wide"/>
          {% endif %}
        </div>
        {% set cf_count=cf_count+1 %}
      {% endif %}
    {% endfor %}
    <div class="grid-18">
      <input type="submit" class="update_tickets" value="Save"/>
      <a href="{{cancel_href}}" class="btn link">Cancel</a>
      <!-- tg.url(c.app.url+'search/', dict(q=query, limit=limit, sort=sort))}}" class="btn link">Cancel</a>-->
    </div>
    <div class="grid-12" id="result"></div>
    <input name="__search" type="hidden" value="" id="id_search" />
    {{lib.csrf_token()}}
</form>
