{% extends "reviews/reviewable_base.html" %}
{% load i18n djblets_deco djblets_js rb_extensions reviewtags staticfiles tz %}

{% block title %}{{review_request_details.summary}} | {% trans "Review Request" %}{% endblock %}

{% block css %}
{{block.super}}

{%  if siteconfig_settings.diffviewer_show_trailing_whitespace %}
<style type="text/css">
  .ew { background: #ee3434; }
</style>
{%  endif %}
{% endblock css %}

{% block content %}
<div id="review_request">
 <div id="review_request_banners"></div>
{% display_review_request_trophies review_request %}
{%  box "review-request" %}
 <div class="review-request-header">
  <ul class="actions page-tabs">
   <li class="active"><a href="{{review_request.get_absolute_url}}">{% trans "Reviews" %}</a></li>
{%   if has_diffs %}
   <li><a href="{% url 'view-diff' review_request.display_id %}#index_header">{% trans "Diff" %}</a></li>
{%   endif %}
  </ul>

  <div class="actions-container">
   <ul class="actions actions-left">
{%   if request.user.is_authenticated and review_request.status == 'P' %}
    <li>{% star review_request %}</li>
    <li class="has-menu">
     <a class="menu-title" id="hide-review-request-link" href="#"><span class="rb-icon rb-icon-archive-off"></span></a>
     <ul class="menu" id="hide-review-request-menu" style="display: none;"></ul>
    </li>
{%   endif %}
   </ul>
   <ul class="actions actions-right-container">
    <li class="has-menu">
     <a href="#" class="mobile-actions-menu-label"><span class="fa fa-ellipsis-h fa-lg"></span></a>
     <ul class="actions actions-right">
{%   review_request_action_hooks %}
{%   review_request_dropdown_action_hooks %}
{%   include "reviews/review_request_actions_secondary.html" %}
{%   if has_diffs %}
      <li><a href="diff/raw/">{% trans "Download Diff" %}</a></li>
{%   endif %}
{%   include "reviews/review_request_actions_primary.html" %}
     </ul>
    </li>
   </ul>
  </div>
 </div>

 <div class="main">
{%   include "reviews/review_request_box.html" %}
 </div>
{%  endbox "review-request" %}
</div>

<div id="reviews">
 <ul id="view_controls">
{%  if entries %}
  <li>
   <a href="#" id="expand-all">
    <span class="fa fa-plus"></span>
    <span>{% trans "Expand All" %}</span>
   </a>
  </li>
  <li>
   <a href="#" id="collapse-all">
    <span class="fa fa-minus"></span>
    <span>{% trans "Collapse All" %}</span>
   </a>
  </li>
{%  endif %}
 </ul>

{%  for entry in entries %}
{%   if entry.review %}
{%    include "reviews/boxes/review.html" %}
{%   elif entry.changedesc %}
{%    include "reviews/boxes/change.html" %}
{%   endif %}
{%  endfor %}
</div>
{% endblock content %}

{% block scripts-post %}
{{block.super}}

<script>
    RB.PageManager.setPage(new RB.ReviewRequestPageView({
{%  localtime off %}
        lastActivityTimestamp: {{last_activity_time|json_dumps}},
{%  endlocaltime %}
{%  include "reviews/reviewable_page_data.js" %}
    }));

    RB.PageManager.beforeRender(function(page) {
{%  for entry in entries %}
{%   if entry.review %}
{%    for comment in entry.comments.diff_comments %}
        page.queueLoadDiff(
            "{{comment.id}}",
{%     if comment.interfilediff %}
            "{{comment.filediff.id}}-{{comment.interfilediff.id}}"
{%     else %}
            "{{comment.filediff.id}}"
{%     endif %}
        );
{%    endfor %}
{%   endif %}
{%  endfor %}
    });

{%  if request.GET.reply_id and request.GET.reply_type %}
    RB.PageManager.ready(function(page) {
        page.openCommentEditor("{{request.GET.reply_type|escapejs}}",
                               parseInt("{{request.GET.reply_id|escapejs}}", 10));
    });
{%  endif %}
</script>
{% endblock scripts-post %}
