<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

  <xi:include href="master.html" />

  <?python from allura.lib.security import has_artifact_access ?>

  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>$c.project.name / $app.config.options.mount_label /  Admin Fields</title>
  </head>

  <body>
    <h1 class="title">$app.config.options.mount_point Admin Fields</h1>
    <div class="content">
      <div class="row">
        <div class="column grid_12">
          <form>
            <ol>
              <li>
       				  <label>Milestone Names:</label>
       				  <input type="text" name="milestone_names" id="milestone_names" value="${globals.milestone_names}"
                       py:if="allow_config"/>
                <span py:if="not allow_config">${globals.milestone_names}</span>
              </li>
              <hr/>
              <li>
       				  <label>Status Names:</label>
       				  <input type="text" name="status_names" id="status_names" value="${globals.status_names}"
                       py:if="allow_config"/>
                <span py:if="not allow_config">${globals.status_names}</span>
              </li>
              <hr/>
              <li>
       				  <label>Custom Fields:</label>
                  <p id="has_fields_message" py:if="allow_config">Drag and drop the fields to re-order.</p>
                  <p id="no_fields_message" py:if="allow_config">No custom fields have been created.</p>
                  <p py:if="not allow_config">&nbsp;</p>
              </li>
              <li>
                  <div id="custom-field-list">
                    <py:for each="field in globals.custom_fields">
                      <?python show_in_search = 'true' if field.show_in_search else 'false' ?>
                      <div style="display:none" class="custom-field-stub"
                          data-label="${field.label}" data-type="${field.type}" data-options="${getattr(field, 'options', '')}"
                          data-show-in-search="${show_in_search}"
                          py:if="allow_config"/>
                      <py:if test="not allow_config">
                        <div class="span-3"><label>Label: </label></div><div class="span-15 last">${field.label}</div>
                        <div class="span-3"><label>Type: </label></div><div class="span-15 last">${field.type}</div>
                        <span class="options-wrapper" py:if="field.options"><div class="span-3"><label>Options: </label></div><div class="span-15 last">${getattr(field, 'options', '')}</div></span>
                      </py:if>
                    </py:for>
                  </div>
              </li>
              <hr/>
              <li>
       				  <label>&nbsp;</label>
       				  <input type="button" onclick="add_field()"
                        py:if="allow_config" value="Add Field"/>
                <input type="button" onclick="save_fields()"
                        py:if="allow_config" value="Save"/>
              </li>
            </ol>
          </form>
        </div>
      </div>
    </div>
  </body>
  <style type="text/css">
    div.custom-field {
      cursor: move;
      border:1px solid #ccc;
      margin:2px;
      padding:2px;
    }
  </style>
  <script type="text/javascript" src="${g.app_static('js/custom-fields.js', app=app)}"
          py:if="allow_config"/>
</html>
