<!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:i18n="http://genshi.edgewall.org/i18n"
      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">/*<![CDATA[*/
      jQuery(document).ready(function($) {
        function updateDueDate() {
          $("#duedate").enable($("#due").checked());
        }        
        $("#due").click(updateDueDate);        
        updateDueDate();
        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()
        $("#duedate").datetimepicker();
        $("#completeddate").datetimepicker();
      });
    /*]]>*/</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>
          <div class="field">
            <label>
              <input type="checkbox" id="due" name="due" checked="${milestone.due or None}" />
              Due:<br />
            </label>
            <label>
              <input type="text" id="duedate" name="duedate" size="${len(datetime_hint)}"
                     value="${format_datetime(milestone.due or default_due)}" 
                     title="${_('Format: %(datehint)s', datehint=datetime_hint)}" />
              <em i18n:msg="datehint">Format: ${datetime_hint}</em>        
            </label>
          </div>          
          <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)}"
                     value="${format_datetime(milestone.completed)}"
                     title="${_('Format: %(datehint)s', datehint=datetime_hint)}" />
              <em i18n:msg="datehint">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"
                          value="${milestone.name}" py:content="milestone.name"></option>
                </optgroup>
              </select>
            </py:if>
          </div>
        </fieldset>
        <div class="field">
          <fieldset>
            <label for="description" i18n:msg="">Description (you may use <a tabindex="42"
                   href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):</label>
            <p><textarea id="description" name="description" class="wikitext trac-resizable" 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" i18n:msg=""><strong>Note:</strong> See
        <a href="${href.wiki('TracRoadmap')}">TracRoadmap</a> for help on using
        the roadmap.
      </div>

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