Blob Blame Raw
{% extends "master.html" %}

{% block title %}Issues for {{ username }}{% endblock %}


{% block content %}
<div class="p-t-2">
  <div class="container">
    <h3 class="p-b-2">
        Issues for {{ username | avatar(20) | safe }} {{ username }}
    </h3>
    <div>
      <span class="btn-group btn-group-sm issues-tagbar" role="group">
          <a data-togglebutton="issue-status-open" id="toggle-open" class="btn btn-primary btn-sm" href="#">Open</a>
          <a data-togglebutton="issue-status-closed" id="toggle-closed" class="btn btn-secondary btn-sm" href="#">Closed</a>
          <a data-togglebutton="issue-status-all" class="btn btn-secondary btn-sm" href="#">All</a>
      </span>
    </div>
    <hr>

    {% for issues in (user.assigned_issues, user.issues) %}
      {% set outer_loop = loop %}
      {% if outer_loop.index == 1 %}
        <b>Assigned Issues <span id="assigned_issue_count"></span></b>
      {% else %}
        <b>Opened Issues <span id="opened_issue_count"></span></b>
      {% endif %}
      <table class="table table-hover table-striped m-b-0 m-t-1">
        <thead class="thead-default">
            <tr>
                <th class="nowrap">#</th>
                <th>Status</th>
                <th>Title</th>
                <th class="open_date nowrap">Opened</th>
                <th class="open_date nowrap">Modified</th>
                <th class="nowrap">Priority</th>
                <th class="nowrap">Project</th>
                <th class="assigned nowrap">Created by</th>
                <th class="assigned nowrap">Assigned to</th>
            </tr>
        </thead>
        <tfoot>
        </tfoot>
        <tbody>
        {% for issue in issues if issue.project.settings.get('issue_tracker', True) %}
          <tr class="issue-status issue-status-{{issue.status|lower}} loop-index-{{outer_loop.index}}"
              {%- if issue.status|lower != "open" %} style="display:none;"{% endif %}>
                <td class="nowrap"><span class="label label-default">#{{ issue.id }}</span></td>
                <td><span class="label {%
                    if issue.status|lower == 'closed' %}label-danger{%
                    elif issue.status|lower == 'open'%}label-primary{%
                    else %}label-default{%
                    endif%}">{{issue.status}}</span></td>
                <td class="stretch-table-column">
                  <a href="{{ url_for(
                      'ui_ns.view_issue',
                      repo=issue.project.name,
                      username=issue.project.user.username if issue.project.is_fork else None,
                      namespace=issue.project.namespace,
                      issueid=issue.id) }}">
                    {% if issue.private %}
                        Private Issue
                    {% else %}
                        {{ issue.title | noJS("img") | safe }}
                    {% endif %}
                  </a>
                </td>
                <td class="nowrap">
                    <span title="{{issue.date_created | format_datetime}}">{{
                        issue.date_created | humanize}}</span>
                </td>
                <td class="nowrap">
                    <span title="{{issue.last_updated | format_datetime}}">{{
                        issue.last_updated | humanize}}</span>
                </td>
                <td>
                    {{ issue.project.priorities[issue.priority | string] or '' }}
                </td>
                <td class="nowrap">
                  <a href="{{ url_for(
                    'ui_ns.view_repo',
                    repo=issue.project.name,
                    username=issue.project.user.username if issue.project.is_fork else None,
                    namespace=issue.project.namespace) }}">
                    {{ issue.project.user.username + '/' if issue.project.is_fork }}
                    {{ issue.project.namespace + '/' if issue.project.namespace }}
                    {{ issue.project.name }}
                  </a>
                </td>
                <td class="nowrap">
                  {{ issue.user.default_email | avatar(16) | safe }}
                  {{ issue.user.user }}
                </td>
                <td class="nowrap">
                  {% if issue.assignee %}
                  {{ issue.assignee.default_email | avatar(16) | safe }}
                  {{ issue.assignee.user }}
                  {% else %}
                  <span class="text-muted">unassigned</span>
                  {% endif %}
                </td>
            </tr>
        {% else %}
            <tr>
                <td colspan="9" class="noresult">No issues found</td>
            </tr>
        {% endfor %}
        </tbody>
      </table>
      <br>
    {% endfor %}
  </div>
</div>

{% endblock %}

{% block jscripts %}
    {{ super() }}
    <script type="text/javascript">
      count_issues(status='.issue-status-open');
      $(function(){
        $('.issues-tagbar .btn').click(function(){
          var current_btn = $(this).attr("data-togglebutton");
          count_issues(status='.'+current_btn);
          $('.issues-tagbar .btn-primary').addClass("btn-secondary");
          $('.issues-tagbar .btn-primary').removeClass("btn-primary");
          $(this).removeClass("btn-secondary");
          $(this).addClass("btn-primary");
          if (current_btn == "issue-status-all"){
            count_issues(status='');
            $(".issue-status").show();
          } else {
            $(".issue-status").hide();
            $("."+$(this).attr("data-togglebutton")).show();
          }
        });
      });
      function count_issues(status='.issue-status-open') {
        var assigned_issue_count = $(status + '.loop-index-1').length;
        var opened_issue_count = $(status + '.loop-index-2').length;
        $('#assigned_issue_count').text(assigned_issue_count);
        $('#opened_issue_count').text(opened_issue_count);
      }
    </script>
{% endblock %}