<!--!  Copyright (C) 2006-2014 Edgewall Software

  This software is licensed as described in the file COPYING, which
  you should have received as part of this distribution. The terms
  are also available at http://trac.edgewall.com/license.html.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at http://trac.edgewall.org/.
-->
<!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" i18n:msg="name">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());
          $("#retarget-comment").enable(checked && retarget.checked());
        }
        $("#completed").click(updateCompletedDate);
        updateCompletedDate();
        $("#retarget").click(function(){
          $("#target").enable(this.checked);
          $("#retarget-comment").enable(this.checked);
        });
        $("#duedate").datetimepicker();
        $("#completeddate").datetimepicker();
      });
    /*]]>*/</script>
  </head>

  <body>
    <div id="content" class="milestone">
      <py:choose test="milestone.exists">
        <h1 py:when="True" i18n:msg="name">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" class="trac-autofocus" 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>
              <br/>
              <label for="retarget-comment">Comment:</label>
              <!--! Don't translate ticket comment (comment:40:ticket:5658) -->
              <input type="text" id="retarget-comment" name="comment" size="40"
                     value="Ticket retargeted after milestone closed" />
            </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-fullwidth 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" name="save"
                 value="${_('Submit changes')}" class="trac-disable-on-submit" />
          <input py:otherwise="" type="submit" name="add"
                 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>
