<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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="layout.html" />
  <head>
    <py:choose test="milestone.exists">
      <title py:when="True">Edit Milestone ${milestone.name}</title>
      <title py:otherwise="">New Milestone</title>
    </py:choose>
    <link rel="stylesheet" type="text/css"
          href="${chrome.htdocs_location}css/roadmap.css" />
    <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    <script type="text/javascript">/*<![CDATA[*/
      jQuery(document).ready(function($) {
        function updateCompletedDate() {
          var checked = $("#completed").checked();
          $("#completeddate").enable(checked);
          var retarget = $("#retarget");
          retarget.enable(checked);
          $("#target").enable(checked && retarget.checked());
        }
        $("#completed").click(updateCompletedDate);
        updateCompletedDate();
        $("#retarget").click(function(){ $("#target").enable(this.checked) });
        $("#name").get(0).focus()
      });
    /*]]>*/</script>
  </head>

  <body>
    <div id="content" class="milestone">
      <py:choose test="milestone.exists">
        <h1 py:when="True">Edit Milestone ${milestone.name}</h1>
        <h1 py:otherwise="">New Milestone</h1>
      </py:choose>

      <form id="edit" action="" method="post">
        <div class="field">
          <input type="hidden" name="id" value="${milestone.name}" />
          <input type="hidden" name="action" value="edit" />
          <label>Name of the milestone:<br />
            <input type="text" id="name" name="name" size="32" value="${milestone.name or req.args.get('name')}" />
          </label>
        </div>
        <fieldset>
          <legend>Schedule</legend>
          <label>Due:<br />
            <input type="text" id="duedate" name="duedate" size="${len(date_hint)}"
                   value="${milestone.due and format_date(milestone.due)}" title="Format: ${date_hint}" />
            <em>Format: ${date_hint}</em>
          </label>
          <div class="field">
            <label>
              <input type="checkbox" id="completed" name="completed"
                     checked="${milestone.completed or None}" />
              Completed:<br />
            </label>
            <label>
              <input type="text" id="completeddate" name="completeddate"
                     size="${len(datetime_hint)}" title="Format: ${datetime_hint}"
                     value="${format_datetime(milestone.completed)}" />
              <em>Format: ${datetime_hint}</em>
            </label>
            <py:if test="milestone_groups">
              <br/>
              <input type="checkbox" id="retarget" name="retarget" checked="${not milestone.completed or None}" />
              <label for="retarget">Retarget associated open tickets to milestone:</label>
              <select id="target" name="target">
                <option value="">None</option>
                <optgroup py:for="(label, milestones) in milestone_groups"
                          py:if="milestones" label="${label}">
                  <option py:for="milestone in milestones"
                          py:content="milestone.name"></option>
                </optgroup>
              </select>
            </py:if>
          </div>
        </fieldset>
        <div class="field">
          <fieldset class="iefix">
            <label for="description">Description (you may use <a tabindex="42"
                   href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):</label>
            <p><textarea id="description" name="description" class="wikitext" rows="10" cols="78">
${milestone.description}</textarea></p>
          </fieldset>
        </div>
        <div class="buttons" py:choose="milestone.exists">
          <input py:when="True" type="submit" value="Submit changes" />
          <input py:otherwise="" type="submit" value="Add milestone" />
          <input type="submit" name="cancel" value="Cancel" />
        </div>
      </form>

      <div id="help"><strong>Note:</strong> See
        <a href="${href.wiki('TracRoadmap')}">TracRoadmap</a> for help on using
        the roadmap.
      </div>

    </div>
  </body>
</html>
