{% extends 'core_main_app/_render/admin/theme/tools/box.html' %}
{% load special_plural %}

{% block box_title %}
    {% if data.title %}
        {{data.title}}
    {% else %}
        {% if come_from_admin %}
            <span>{{ data.document|special_plural|capfirst}} list</span>
        {% else %}
            <span style="font-size: 2rem">My {{data.document|special_plural}}</span>
        {% endif %}
        {% if data.user_data %}
            <span style="background-color: #10309a !important" class="badge bg-primary item-count-badge">
            {{ data.number_total }} items
        </span>
        {% endif %}
    {% endif %}
{% endblock %}

{% block box_tools %}
    {% if data.create_workspace %}
        <a class="m-3 btn btn-secondary create-workspace-btn">
            <i class="fas fa-file-alt"></i> Create workspace
        </a>
    {% endif %}

    {% if data.title %}
        <a href="#" class="m-3 btn btn-secondary back-to-previous">
             <i class="fas fa-arrow-left"></i> Previous page
        </a>
    {% endif %}
{% endblock %}

{% block box_body %}
    {% if data.administration and data.owner %}
        <p>Owner: <a href="{{ data.owner_change_url }}">{{ data.owner }}</a></p>
    {% endif %}

    {% if data.menu and not data.title %}
        <div class="dropdown" id="id_actions" style="display:none">
            <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu1" {% if BOOTSTRAP_VERSION|first == "4" %}data-toggle{% elif BOOTSTRAP_VERSION|first == "5"  %}data-bs-toggle{% endif %}="dropdown"
                    aria-haspopup="true" aria-expanded="true">
                Choose action
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                {% for value, text in data.action_form.fields.actions.choices %}
                    <li style="cursor:  pointer;" onclick="action_dashboard({{value}});">{{text}}</li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}

    {% if data.resources %}
        {% include 'core_main_registry_app/resource_banner/resource_banner.html' %}
        <ul class="nav nav-tabs">
            <li class="nav-item pointer">
                <a class="nav-link {% if data.ispublished == 'all' %}active{% endif %}" onclick="get_url('all', '');">All</a>
            </li>
            <li class="nav-item pointer">
                <a class="nav-link {% if data.ispublished == 'published' %}active{% endif %}" onclick="get_url('published', '');">Published</a>
            </li>
            <li class="nav-item pointer">
                <a class="nav-link {% if data.ispublished == 'unpublished' %}active{% endif %}" onclick="get_url('unpublished', '');">Not Published</a>
            </li>
            {% if data.ALLOW_MULTIPLE_SCHEMAS %}
            <li class="nav-item pointer">
                <a class="nav-link {% if data.ispublished == 'other' %}active{% endif %}" onclick="get_url('other', '');">Other</a>
            </li>
            {% endif %}
            <li id="draft" class="nav-item pointer">
                <a class="nav-link {% if data.ispublished == 'draft' %}active{% endif %}" onclick="get_url('draft', '');">Drafts</a>
            </li>
        </ul>
    {% endif %}

    <div class="tab-content">
        {% include data.template with objects=data.user_data group='user' %}
    </div>
{% endblock %}


