{#
  Copyright (C) 2020-2021 CERN.
  Copyright (C) 2020 Northwestern University.
  Copyright (C) 2021 TU Wien.
  Copyright (C) 2021 Graz University of Technology.

  Invenio RDM Records is free software; you can redistribute it and/or modify
  it under the terms of the MIT License; see LICENSE file for more details.
#}

{%- extends config.BASE_TEMPLATE %}

{%- from "invenio_app_rdm/records/macros/files.html" import file_list_box, preview_file_box %}
{%- from "invenio_app_rdm/records/macros/detail.html" import show_detail %}

{%- set metadata = record.metadata %}


{%- block page_body %}
{% if permissions.can_update_draft %}
  <div
    id="recordManagement"
    data-recid='{{ record["id"] | tojson }}'>
  </div>
{% endif %}
<div class="ui container">
  <div class="ui relaxed grid">
    <div class="two column row top-padded">
      <div class="eleven wide column">
        {%- block record_body -%}
        {%- block record_header -%}
        <div class="ui grid middle aligned">
          <div class="two column row">
            <div class="left floated left aligned column">
              <span class="ui" title="Publication date">{{ record.ui.publication_date_l10n_long }}</span>
              {%- if metadata.version %}
              <span class="label text-muted"> | Version {{ metadata.version }}</span>
              {% endif %}
            </div>
            <div class="right floated right aligned column">
              <span class="ui label small grey">{{ record.ui.resource_type }}</span>
              <!--TODO: Re-enable in next releases-->
              <!-- <span class="ui label small access-right {{ 'unlock' }}">
                <i class="icon {{ 'unlock' }}"></i>{{ _("Open Access") }}</span> -->
            </div>
          </div>
        </div>
        {%- endblock record_header -%}
        {%- block record_title -%}
        <h1>{{ metadata.title }}</h1>
        <p>{%- include "invenio_app_rdm/records/details/creators.html" %}</p>
        {%- endblock record_title -%}
        {%- block record_content -%}
        <p>{%- include "invenio_app_rdm/records/details/contributors.html" %}</p>

        {%- include "invenio_app_rdm/records/details/subjects.html" %}
        <div class="top-padded">
        {%- include "invenio_app_rdm/records/details/description.html" %}
        </div>
        <div class="top-padded">
        {%- include "invenio_app_rdm/records/details/licenses.html" %}
        </div>
        {%- endblock record_content -%}
        {# files #}
        {%- block record_files -%}
        {%- if files is not none -%}
          {%- if files.enabled and record|can_list_files %}
            {%- set default_preview = files.default_preview %}
            {%- set files = files|order_entries %}
            {%- if files|has_previewable_files -%}
              {%- set default_preview_file = files|select_preview_file(default_preview=default_preview) %}
              {{ preview_file_box(default_preview_file, pid) }}
            {%- endif -%}
            {{ file_list_box(files, pid) }}
          {% endif %}
        {%- else -%}
          {# TODO: come up with a proper display #}
          <div>Sorry, the files are restricted!</div>
        {%- endif -%}
        {%- endblock record_files -%}
        {%- block record_details -%}
        {# More details #}
        <div class="top-padded">
        {%- include "invenio_app_rdm/records/details/details.html" %}
        </div>
        {%- endblock record_details -%}
        {%- block record_footer -%}
        <div class="ui grid">
          <div class="two column row top-bottom-padded font-small">
            <div class="four wide column">
              <p><b>Upload infromation</b></p>
            </div>
            <div class="twelve wide column">
              <span class="label text-muted">
                <b>Created:</b> {{ record.ui.created_date_l10n_long }} | <b>Modified:</b> {{ record.ui.updated_date_l10n_long }}
              </span>
            </div>
          </div>
        </div>
        {%- endblock record_footer -%}
        {%- block jump -%}
        <div class="ui grid">
          <div class="centered row" id="jump-btn">
            <a style="cursor: pointer;">
              <span class="ui button">
                <i class="arrow alternate circle up outline icon"></i>Jump up</span>
            </a>
          </div>
        </div>
        {%- endblock jump -%}
        {%- endblock record_body %}
      </div>
      <div class="five wide column">
        {% block record_sidebar %}
        {%- include "invenio_app_rdm/records/details/side_bar.html" %}
        {% endblock record_sidebar %}
      </div>
    </div>
  </div>
</div>

{%- endblock page_body %}

{%- block javascript %}
{{ super() }}
{{ webpack['invenio-app-rdm-landing-page.js'] }}
{# Communities management -- TODO include again when communities are ready #}
{# {{ webpack['invenio-communities-records.js'] }} #}
{{ webpack['previewer_theme.js'] }}
{%- endblock javascript %}
