{% load djblets_extensions djblets_utils i18n reviewtags static %}

{% template_hook_point "before-review-request-summary" %}

<div class="rb-c-review-request__summary">
 <div class="rb-c-review-request-fieldset -has-inline-fields"
      aria-label="{% trans 'Review request summary' %}"
      role="group">
{% template_hook_point "review-request-summary-pre" %}

{% review_request_field review_request_details 'summary' %}
  {{field.as_html}}
{% end_review_request_field %}
 </div>
 <p>
{%  blocktrans with review_request.display_id as review_request_id and review_request.get_absolute_url as review_request_url %}
  Review Request #<a href="{{review_request_url}}">{{review_request_id}}</a>
  &mdash;
  {{review_request_status_html}}
{%  endblocktrans %}
 </p>
{% template_hook_point "review-request-summary-post" %}
</div>

{% template_hook_point "after-review-request-summary" %}

<div class="rb-c-review-request__warning" id="review-request-warning"></div>

{% template_hook_point "before-review-request-fields" %}

<div class="rb-c-review-request__details"
     id="review-request-details">
{% for_review_request_fieldset review_request_details %}
{%  if fieldset.fieldset_id != 'main' and fieldset.fieldset_id != 'extra' %}
 <div class="rb-c-review-request-fieldset -is-tabular -has-inline-fields"
      id="fieldset_{{fieldset.fieldset_id}}_head"
      aria-labelledby="fieldset_label_{{fieldset.fieldset_id}}"
      role="group">
  <h3 class="rb-c-review-request-fieldset__label"
      id="fieldset_label_{{fieldset.fieldset_id}}">
   {{fieldset.label}}
{%   if show_fieldset_required %}
    <span class="required-flag" aria-label="{% trans 'This field is required' %}" title="{% trans 'This field is required' %}">*</span>
{%   endif %}
  </h3>
{%   for_review_request_field review_request_details fieldset %}
{{field.as_html}}
{%   end_for_review_request_field %}
 </div>
{%  endif %}
{% end_for_review_request_fieldset %}
</div>

<div class="rb-c-review-request__main"
     id="review-request-main">
 <div class="rb-c-review-request-fieldset"
      aria-label="{% trans 'Main fields' %}"
      role="group">
{% for_review_request_field review_request_details 'main' %}
{%  if field.field_id != 'summary' %}
  {{field.as_html}}
{%  endif %}
{% end_for_review_request_field %}
 </div>
</div>

{% template_hook_point "after-review-request-fields" %}
{% template_hook_point "before-review-request-extra-panes" %}

<div class="rb-c-review-request__extra"
     id="review-request-extra">
 <div class="rb-c-review-request-fieldset"
      aria-label="{% trans 'Extra fields' %}"
      role="group">

{% definevar "extra_fields_html" strip %}
{%  for_review_request_field review_request_details 'extra' %}
 {{field.as_html}}
{%  end_for_review_request_field %}
{% enddefinevar %}

{% if extra_fields_html %}
  {{extra_fields_html}}
{% endif %}

{% template_hook_point "review-request-extra-panes-pre" %}

{% if screenshots %}
 <div class="rb-c-review-request-fieldset"
      aria-labelledby="screenshots_label"
      role="group">
  <h3 class="rb-c-review-request-fieldset__label"
      id="screenshots_label">{% trans "Screenshots" %}</h3>
  <div id="screenshot-thumbnails">
{%  for image in screenshots %}
   <div class="screenshot-container" data-screenshot-id="{{image.id}}">
    <div class="image" onclick="javascript:window.location='{{image.get_absolute_url}}'; return false;"><a href="{{image.get_absolute_url}}">{{image.thumb}}</a></div>
    <div class="screenshot-caption">
     <a href="{{image.get_absolute_url}}" class="edit">{% if draft %}{{image.draft_caption|default:image.caption}}{% else %}{{image.caption}}{% endif %}</a>
{%   if request.user.pk == review_request.submitter_id or perms.reviews.delete_screenshot %}
{%    if review_request.status == 'P' %}
     <a href="#" class="delete rb-icon rb-icon-delete" title="{% trans "Delete Screenshot" %}"></a>
{%    endif %}
{%   endif %}
    </div>
   </div>
{%  endfor %}
  </div>
 </div>
{% endif %}

 <div id="file-list-container"
      class="rb-c-review-request-field"
      {% if not file_attachments %} style="display: none;"{% endif %}
      aria-labelledby="file_list_container_label"
      aria-busy="true"
      aria-live="polite"
      role="group">
  <label class="rb-c-review-request-field__label"
      id="file_list_container_label">
   {% trans "Files" %}
   <span class="djblets-o-spinner"
         aria-label="{% trans "Loading file attachments" %}"></span>
  </label>
  <div class="rb-c-review-request__value" id="file-list">
{% for file_attachment in file_attachments %}
   <div class="file-container -is-loading">
    <div class="file">
     <div class="file-thumbnail-container"></div>
     <div class="file-caption-container">
     </div>
    </div>
   </div>
{% endfor %}
   <br clear="both" />
  </div>
 </div>

{% if show_issue_summary_table %}
{%  include "reviews/review_issue_summary_table.html" %}
{% endif %}

{% template_hook_point "review-request-extra-panes-post" %}
 </div>
</div>

{% template_hook_point "after-review-request-extra-panes" %}
