<!--!  Copyright (C) 2010-2021 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 https://trac.edgewall.org/wiki/TracLicense.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at https://trac.edgewall.org/.

Display groups of tickets in a progress bar.

Arguments:
 - stats: an instance of trac.ticket.roadmap.TicketGroupStats
 - interval_hrefs: link associated to each interval in stats.intervals
 - percent=None: show that value as percentage, instead of stats.done_percent
 - legend=True: show a legend of label and count for each interval
 - style=None: explicit styling for the table.progress
 - stats_href=None: link associated to the total
-->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      py:with="percent = value_of('percent', None);
               legend = value_of('legend', True);
               style = value_of('style', None);
               stats_href = value_of('stats_href', None)" py:strip="">

  <table class="progress" style="$style">
    <tr>
      <td py:for="idx, interval in enumerate(stats.intervals)"
          class="$interval.css_class"
          style="${'width: %d%%' % interval.percent if interval.percent > 0 else 'display: none'}">
        <a href="${interval_hrefs[idx] if interval_hrefs else None}"
           title="${_('%(count)s/%(total)s %(title)s',
                      count=interval.count, total=stats.count, title=interval.title)}"></a>
      </td>
    </tr>
  </table>

  <p class="percent">${'%d%%' % stats.done_percent if percent is None else percent}</p>

  <p py:if="legend" class="legend">
    <span class="first interval">
      <a href="${stats_href}"
         i18n:msg="unit, count">Total number of ${stats.unit}: ${stats.count}</a>
    </span>
    <span py:for="idx, interval in enumerate(stats.intervals)" class="interval">
      - <a href="${interval_hrefs[idx] if interval_hrefs else None}"
           i18n:msg="title, count">${interval.title}: ${interval.count}</a>
    </span>
  </p>
</html>
