{% 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">
{%  include "reviews/trophy_box.html" %}
{%  include "reviews/review_header.html" %}

{%  box "review-request" %}
 <div class="actions-container">
{%   star review_request %}
  <ul class="actions">
{%   review_request_action_hooks %}
{%   review_request_dropdown_action_hooks %}
{%   include "reviews/review_request_actions_secondary.html" %}
{%   if has_diffs %}
   <li class="primary"><a href="diff/raw/">{% trans "Download Diff" %}</a></li>
{%   endif %}
{%   include "reviews/review_request_actions_primary.html" %}
{%   if has_diffs %}
   <li class="primary"><a href="{% url 'view-diff' review_request.display_id %}#index_header">{% trans "View Diff" %}</a></li>
{%   endif %}
  </ul>
 </div>

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

  <ul class="controls">
{%   if entries %}
   <li>
    <a href="#" id="expand-all">
     <div class="rb-icon rb-icon-expand"></div>
     <span>{% trans "Expand All" %}</span>
    </a>
   </li>
   <li>
    <a href="#" id="collapse-all">
     <div class="rb-icon rb-icon-collapse"></div>
     <span>{% trans "Collapse All" %}</span>
    </a>
   </li>
{%   endif %}
  </ul>
 </div>
{%  endbox "review-request" %}
</div>

{%  for entry in entries %}
{%   if entry.review %}
{%    include "reviews/boxes/review.html" %}
{%   elif entry.changedesc %}
{%    include "reviews/boxes/change.html" %}
{%   endif %}
{%  endfor %}
{% 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}}",
                               {{request.GET.reply_id}});
    });
{%  endif %}
</script>
{% endblock scripts-post %}
