<!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" />
  <xi:include href="macros.html" />
  <head>
    <title>Milestone ${milestone.name}</title>
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#content").find("h1,h2,h3,h4,h5,h6").addAnchor("Link to this section");
      });
    </script>
    <link rel="stylesheet" type="text/css"
          href="${chrome.htdocs_location}css/roadmap.css" />
  </head>

  <body>
    <div id="content" class="milestone">
      <h1>Milestone ${milestone.name}</h1>
      <div class="info">
        <py:choose>
          <p py:when="milestone.completed" class="date">
            Completed ${dateinfo(milestone.completed)} ago
            (${format_datetime(milestone.completed)})
          </p>
          <p py:when="milestone.is_late" class="date">
            <strong>${dateinfo(milestone.due)} late</strong>
            (${format_date(milestone.due)})
          </p>
          <p py:when="milestone.due" class="date">
            Due in ${dateinfo(milestone.due)}
            (${format_date(milestone.due)})
          </p>
          <p py:otherwise="" class="date">
            No date set
          </p>
        </py:choose>
        <py:if test="stats.count">${progress_bar(stats, interval_hrefs, stats_href=stats_href)}</py:if>
      </div>

      <form py:if="available_groups and stats.count" id="stats" action="">
        <fieldset>
          <legend>
            <label for="by">${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>
                ${progress_bar(group.stats, (group.interval_hrefs, None)
                               [grouped_by in ['owner', 'reporter'] 
                                  and group.name != format_author(group.name)],
                               '%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>

      ${list_of_attachments(attachments, compact=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>
        ${attach_file_form(attachments)}
      </div>

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

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