<!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>
    <title>Milestone ${milestone.name}</title>
    <link py:if="'MILESTONE_MODIFY' in perm(milestone.resource)" rel="alternate" type="application/x-wiki"
          title="Edit this milestone" href="${href.milestone(milestone.name, action='edit')}" />
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#content").find("h1,h2,h3,h4,h5,h6").addAnchor("Link to this section");
        $(".foldable").enableFolding(true, true);
      });
    </script>
  </head>

  <body>
    <div id="content" class="milestone">
      <h1>Milestone ${milestone.name}</h1>
      <div class="info">
        <py:choose>
          <p py:when="milestone.completed" class="date">
            <i18n:msg params="duration, date">
              Completed ${dateinfo(milestone.completed)} ago (${format_datetime(milestone.completed)})
            </i18n:msg>
          </p>
          <p py:when="milestone.is_late" class="date">
            <i18n:msg params="duration, date">
              <strong>${dateinfo(milestone.due)} late</strong> (${format_datetime(milestone.due)})
            </i18n:msg>
          </p>
          <p py:when="milestone.due" class="date">
            <i18n:msg params="duration, date">
              Due in ${dateinfo(milestone.due)} (${format_datetime(milestone.due)})
            </i18n:msg>
          </p>
          <p py:otherwise="" class="date">
            No date set
          </p>
        </py:choose>
        <xi:include href="progress_bar.html" py:if="stats.count"/>
      </div>

      <form py:if="available_groups and stats.count" id="stats" action="">
        <fieldset>
          <legend>
            <label for="by" i18n:msg="stat_title">${stats.title.capitalize()} by</label>
            <select id="by" name="by" onchange="this.form.submit()">
              <option py:for="group in available_groups"
                      value="${group.name}" py:content="group.label"
                      selected="${grouped_by == group.name or None}" />
            </select>
            <input type="submit" value="${_('Update')}" class="noscript" />
            <script type="text/javascript">
              jQuery(document).ready(function ($) { $(".noscript").attr("style", "display: none"); });
            </script>
          </legend>
          <table py:if="groups" summary="Shows the milestone completion status grouped by ${grouped_by}">
            <tr py:for="group in groups">
              <th scope="row" py:choose="">
                <i py:when="not group.name"><a href="${group.stats_href}">(none)</a></i>
                <a py:when="grouped_by in ['owner', 'reporter']"
                   py:with="obfus_name = format_author(group.name)"
                   py:strip="obfus_name != group.name"
                   href="${group.stats_href}">${obfus_name}</a>
                <a py:otherwise="" href="${group.stats_href}">${group.name}</a>
              </th>
              <td>
                <xi:include href="progress_bar.html"
                            py:with="stats = group.stats;
                                     interval_hrefs = (group.interval_hrefs, None)
                                                      [bool(grouped_by in ['owner', 'reporter']
                                                            and group.name and group.name != format_author(group.name))];
                                     percent = '%d / %d' % (group.stats.done_count, group.stats.count);
                                     legend=False;
                                     style='width: %d%%' % (group.percent_of_max_total * 0.8)"/>
              </td>
            </tr>
          </table>
        </fieldset>
      </form>

      <div class="description" xml:space="preserve">
        ${wiki_to_html(context, milestone.description)}
      </div>

      <xi:include href="list_of_attachments.html"
                  py:with="alist = attachments; compact = True; foldable = True"/>

      <div py:if="'MILESTONE_MODIFY' in perm(milestone.resource) or
                  'MILESTONE_DELETE' in perm(milestone.resource) or
                  attachments.can_create"
           class="buttons">
        <form py:if="'MILESTONE_MODIFY' in perm(milestone.resource)" method="get" action="" id="editmilestone">
          <div>
            <input type="hidden" name="action" value="edit" />
            <input type="submit" value="${_('Edit milestone')}" />
          </div>
        </form>
        <form py:if="'MILESTONE_DELETE' in perm(milestone.resource)" method="get" action="" id="deletemilestone">
          <div>
            <input type="hidden" name="action" value="delete" />
            <input type="submit" value="${_('Delete milestone')}" />
          </div>
        </form>
        <xi:include href="attach_file_form.html" py:with="alist = attachments"/>
      </div>

      <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>
