{% extends "admin/base.html" %}

{% load i18n admin_tags static %}

{% block title %} Papermerge | Documents {% endblock %}

{% comment %}
  beautiful refresh feature BEGIN
{% endcomment %}
{% block animated_opacity_content_wrapper %}
  animated-opacity
{% endblock %}

{% block animated_opacity_main_header %}
  animated-opacity
{% endblock %}

{% block animated_opacity_main_sidebar %}
  animated-opacity
{% endblock %}
{% comment %}
  beautiful refresh feature END
{% endcomment %}

{% block widgetsbar %}
  <div id="info-widget-document" class="card">
    <div class="card-body">
      <div class="card-title">{% trans "Info" %}</div>
      <div class="card-text">
        <ul class="collection">
          <li class="collection-item">
            <label for="language">{% trans "OCR Language" %}:</label>
            {{ document.lang }}
          </li>
          <li class="collection-item">
            <label for="owner">{% trans "Owner" %}:</label>
            {{ document.user.username }}
          </li>
          <li class="collection-item">
            <label for="created_at">{% trans "Created" %}:</label>
            {% localized_datetime document.created_at%}
          </li>
          <li class="collection-item">
            <label for="updated_at">{% trans "Modified" %}:</label>
            {% localized_datetime document.updated_at%}
          </li>
          {% if tags|length > 0 %}
            <li class="collection-item">
              <div class="form-group mt-2">
                <label for="tags">{% trans "Tags" %}:</label>
                <div class="document tags-container d-flex">
                  {% for tag in tags %}
                    <div style="background: {{tag.bg_color}}; color: {{ tag.fg_color }}; border-color: {{tag.bg_color}}" class="tag d-flex align-items-center">
                      <span style="color: {{tag.fg_color}}; margin-right: 0.5rem;">{{ tag.name }}</span>
                    </div>
                  {% endfor %}
                </div>
              </div>
            </li>
          {% endif %}
          {% if versions|length > 0 %}
            <li class="collection-item">
              <div class="form-group mt-2">
                <label for="versions">{% trans "Version(s)" %}:</label>
                <select name="document-versions" id="document-versions">
                  {% for version in versions reversed %}
                    <option {% select_if_current_version version forloop.first %}  value="{{version}}">
                       {% if forloop.last  %}{% trans "Original" %} {% elif forloop.first %}{% trans "Latest" %}{% else %}{% endif %} v{{version}}
                    </option>
                  {% endfor %}
                </select>
              </div>
            </li>
          {% endif %}
          <li class="collection-item d-flex flex-row-reverse bordered">
            {% if versions|length > 0 %}
            <div class="dropdown">
                <button class="btn btn-flat btn-primary text-white download dropdown-toggle" type="button" id="download-versions-dropdown-button" data-bs-toggle="dropdown" data-toggle="dropdown" aria-expanded="false">
                   <i class="fa fa-download mx-1"></i>{% trans "Download" %}
                </button>
                <ul class="dropdown-menu" aria-labelledby="download-versions-dropdown-button">
                  {% for version in versions reversed %}
                    <li>
                      <a class="dropdown-item" href="{% url 'core:node_download' document.id %}?version={{version}}">
                        {% if forloop.last %}
                          {% trans "Original" %}
                        {% elif forloop.first  %}
                          {% trans "Latest" %} 
                        {% else %}
                        {% endif %}
                        v{{version}}
                      </a></li>
                  {% endfor %}
                </ul>
              </div>
            {% else %}
              <a href="{% url 'core:node_download' document.id %}" class="btn btn-flat btn-primary text-white download">
                <i class="fa fa-download mx-1"></i>{% trans "Download" %}
              </a>
            {% endif %}
          </li>
        </ul>
      </div> <!-- card text -->
    </div>
  </div>
  <!-- client managed -->
  <div id="widgetsbar-document">
    <div class="metadata-widget">
        <div class="card">
            <div class="card-body">
                <div class="card-title"><label>Metadata</label></div>
                <div class="card-text">
                    <ul class="collection">
                        <li class="collection-item d-flex flex-row-reverse">
                            <button class="btn btn-primary btn-flat add-metadata-key" type="button">
                                <i class="fa fa-plus"></i>
                                Add
                            </button>
                            
                            <button type="button" class="btn btn-success btn-flat save key mx-1">
                                <i class="fa fa-save"></i>
                                Save
                            </button>
                        </li>
                        <ul id="simple_keys" class="collection">
                            
                         </ul>
                    </ul>
                </div> <!-- card-text -->
            </div> <!-- card-body -->
        </div> <!-- card -->

    </div>
  </div>
{% endblock %}

{% block actions %}
<div id="document-actions" class="col-sm-12 d-flex flex-row justify-content-between">
    <button id="sw-left-panel" data-target-id="page-thumbnails" class="btn btn-default btn-flat btn-outline-light">
      <i class="icon-sw-left-panel"></i>
    </button>

    <select class="zoom" select="width">
        <option value="width">Fit Width</option>
        <option value="50">50%</option>
        <option value="75">75%</option>
        <option value="100">100%</option>
        <option value="125">125%</option>
        <option value="150">150%</option>
    </select>
</div>
{% endblock %}

{% block breadcrumb %}
    <div id="breadcrumb" class="col-sm-12">
      <ol class="breadcrumb float-sm-left">
          <li class="breadcrumb-item">
              <div class="d-none d-sm-inline-block">
                  <i class="preload"></i>
                  <a class="preload" href=""></a>
              </div>
          </li>
          <li class="breadcrumb-item">
              <a class="preload" href=""></a>
          </li>
          <li class="breadcrumb-item">
              <a class="preload" href=""></a>
          </li>
      </ol>
    </div><!-- /.col -->

{% endblock %}

{% block modals %}
    {% include 'admin/_forms.js.html' %}
{% endblock modals %}


{% block content %}
<div class="container-fluid">
  <div class="row">
    <div class="col-lg-12">
      <div id="pre-loader">
        <img src="{% static 'admin/img/pre-loader/loader-03.svg' %}" alt="">
      </div>
        <div id="document">
          <div id="viewer" class="d-flex flex-row">
            <div id="page-thumbnails">
              {% include 'admin/_page_thumbnails.html' with pages=pages document=document %}
            </div>
            <div id="actual-pages">
              {% include 'admin/_pages.html' with pages=pages %}
            </div>
          </div>
        </div>
    </div>
  </div>
  <!-- /.row -->
</div><!-- /.container-fluid -->

<input type="hidden" name="document_id" value="{{document.id}}" />
<ul id="context-menu" class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    {% if is_latest_version %}
      <li class="dropdown-item">
        <a href="{% url 'core:node_download' document.id %}"><i class="fa fa-download mx-2"></i>{% trans "Download" %}</a>
      </li>
    {% endif %}
    <li class="dropdown-item disabled" id="rename" data-target-id="rename-form" disabled>
      <a><i class="fa fa-edit mx-2"></i>{% trans "Rename" %}</a>
    </li>
    {% if has_perm_write and is_latest_version %}
      <li class="dropdown-item fl fl-i-center" id="delete-page" class="dropdown-item fl fl-i-center disabled">
         <a><i class="fa fa-trash mx-2"></i>{% trans "Delete Page" %}</a>
      </li>
    
      <li class="dropdown-divider"></li>
      <li class="dropdown-item disabled" id="cut-page">
        <a><i class="fa fa-cut mx-2"></i>{% trans "Cut" %}</a>
      </li>
      <!-- PASTE -->
       <li class="dropdown-item disabled" id="paste-page">
           <a><i class="fa fa-paste mx-2"></i>{% trans "Paste" %}</a>
       </li>
      <!-- PASTE -->
     {% endif %}
     <li class="dropdown-item disabled" id="view-ocr">
        <a><i class="fa fa-eye mx-2"></i>{% trans "View OCRed text" %}</a>
     </li>
     <li id="tags-menu-item" class="dropdown-item disabled">
         <a><i class="fa fa-tag mx-2"></i>{% trans "Tags" %}</a>
     </li>
     {% if has_perm_write and is_latest_version %}
       <li class="dropdown-divider"></li>
       <li id="apply-reorder-changes" class="dropdown-item disabled">
           <a><i class="fa fa-download mx-2 "></i>{% trans "Apply Reorder Changes" %}</a>
        </li>
      {% endif %}
  </ul>
{% endblock %}