<!--!  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" py:strip="">
  <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());
        $("#retargeting").toggleClass("disabled", !checked);
      }
      $("#completed").click(updateCompletedDate);
      updateCompletedDate();
      $("#retarget").click(function() {
        $("#target").enable(this.checked);
        $("#retarget-comment").enable(this.checked);
      });
    });
  /*]]>*/</script>
  <form id="edit" class="mod" method="post" action=""
        py:with="disabled = 'disabled' if can_modify is False else None;
                 readonly = 'readonly' if can_modify is False else None">
    <fieldset>
      <legend py:choose="">
        <py:when test="readonly" i18n:msg="">View Milestone:</py:when>
        <py:when test="milestone.name" i18n:msg="">Modify Milestone:</py:when>
        <py:otherwise i18n:msg="">Create Milestone:</py:otherwise>
      </legend>
      <div class="field">
        <input type="hidden" name="action" value="edit" />
        <label>Name:<br />
          <input type="text" id="name" name="name" class="trac-autofocus" size="32"
                 value="${milestone.name or req.args.get('name')}" readonly="$readonly" />
        </label>
      </div>
      <div class="field">
        <label>
          <input type="checkbox" id="due" name="due"
                 checked="${milestone.due or None}" disabled="$disabled" />
          Due:<br />
        </label>
        <label class="${classes(readonly=readonly)}">
          <input type="text" id="duedate" name="duedate"
                 class="trac-datetimepicker" size="${len(datetime_hint) + 1}"
                 value="${format_datetime(milestone.due or default_due)}"
                 readonly="$readonly"
                 title="${_('Format: %(datehint)s', datehint=datetime_hint)}" />
          <span class="trac-datetimehint" i18n:msg="datehint">Format: $datetime_hint</span>
        </label>
      </div>
      <div class="field">
        <label>
          <input type="checkbox" id="completed" name="completed"
                 checked="${milestone.completed or None}" disabled="$disabled" />
          Completed:<br />
        </label>
        <label class="${classes(readonly=readonly)}">
          <input type="text" id="completeddate" name="completeddate"
                 class="trac-datetimepicker" size="${len(datetime_hint) + 1}"
                 value="${format_datetime(milestone.completed)}"
                 readonly="$readonly"
                 title="${_('Format: %(datehint)s', datehint=datetime_hint)}" />
          <span class="trac-datetimehint" i18n:msg="datehint">Format: $datetime_hint</span>
        </label>
      </div>
      <fieldset py:if="num_open_tickets or num_open_tickets == 0" id="retargeting" py:choose="">
        <legend>Retargeting</legend>
        <py:when test="num_open_tickets != 0">
          <label>
            <input type="checkbox" id="retarget" name="retarget"
                   checked="${not milestone.completed or None}" />
            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"
                      selected="${retarget_to == milestone.name or None}"
                      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:when>
        <p py:otherwise="" class="help">
          There are no open tickets associated with this milestone.
        </p>
      </fieldset>
      <div class="field description">
        <label for="description" i18n:msg="">
          Description: (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here)
        </label>
        <textarea id="description" name="description" readonly="$readonly"
                  class="wikitext trac-fullwidth trac-resizable" rows="8" cols="78">
$milestone.description</textarea>
      </div>
    </fieldset>
    <div class="buttons" py:choose="milestone.exists">
      <input py:when="True" type="submit" name="save" disabled="$disabled"
             class="trac-disable-on-submit" value="${_('Submit changes')}" />
      <input py:otherwise="" type="submit" name="add"
             value="${_('Add milestone')}" />
      <input type="submit" name="cancel" value="${_('Cancel')}" />
    </div>
  </form>
</html>
