{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2016-2022 CERN.

  Invenio 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 "invenio_requests/details/index.html" %}

{% set active_dashboard_menu_item = 'requests' %}
{% set active_community_header_menu_item = 'requests' %}

{%- block request_header %}
  <div class="ui grid rel-mt-2">
    <div class="sixteen wide mobile eight wide tablet eight wide computer column left floated left aligned">
      <h2 class="ui header">
        {% if not draft_is_accepted %}
          <div class="ui label green ml-0 mr-5">{{ _("New submission") }}</div>
        {% endif %}

        <span>{{ request.title }}</span>

        {% if draft_is_accepted %}
          <a href="{{ url_for('invenio_app_rdm_records.record_detail', pid_value=request.topic.record) }}"
             class="ui tiny button  ml-10"
             rel="noopener noreferrer" target="_blank"
             title="{{ _('Opens in new tab') }}"
          >
            {{ _("View record") }}
          </a>
        {% endif %}

      </h2>

      {% if record %}
        <div class="ui horizontal list" role="list">
          {% for item in record.metadata.creators %}
            <div class="item" role="listitem">
              <div class="content"><i class="user icon"></i>
                {{ item.person_or_org.name }}</div>
            </div>
          {% endfor %}
        </div>
      {% endif %}
    </div>

    <div class="sixteen wide mobile eight wide tablet eight wide computer column right floated right aligned">
      {% block request_actions %}
        {{ super() }}
      {% endblock request_actions %}
    </div>
  </div>
{%- endblock request_header %}

{% block request_timeline %}
  <div
    class="ui container invenio-tab-container fluid rel-pt-2"
    id="request-community-submission-tab-container"
  >
    <div
      class="ui secondary pointing menu invenio-tab-menu"
      id="request-community-submission-tab"
    >
      <a
        class="active item"
        data-tab="conversation"
        role="tab"
        aria-selected="true"
        aria-controls="conversation"
        id="conversation-tab-menu"
      >
        {{ _("Conversation") }}
      </a>

      {% if record %}
        <a
          class="item"
          data-tab="record"
          id="record-tab-menu"
          aria-controls="record"
        >
          {{ _("Record") }}
        </a>
      {% endif %}
    </div>

    <div
      class="ui bottom attached tab segment active borderless p-0"
      data-tab="conversation"
      role="tabpanel"
      aria-labelledby="conversation"
      id="conversation-tab"
    >
      {{ super() }}
    </div>

    {% if record %}
      <div class="ui bottom attached tab segment borderless" data-tab="record"
           role="tabpanel" aria-labelledby="record" id="record-tab"
           hidden="hidden">
        {% set use_theme_basic_template = false %}
        {% set preview_submission_request = true %}
        {% set is_draft = true %}
        {% include "invenio_app_rdm/records/detail.html" %}
      </div>
    {% endif %}
  </div>
{% endblock request_timeline %}
