{% extends 'base/layout.html' %}
{% load buttons %}
{% load custom_links %}
{% load helpers %}
{% load perms %}
{% load plugins %}

{% block header %}
  {# Breadcrumbs #}
  <nav class="breadcrumb-container px-3" aria-label="breadcrumb">
    <ol class="breadcrumb">
      {% block breadcrumbs %}{% endblock %}
    </ol>
  </nav>
  {{ block.super }}
{% endblock %}

{% block title %}{{ object }}{% endblock %}

{% block controls %}
  {# Clone/Edit/Delete Buttons #}
  <div class="controls pb-2 mx-0">
    <div class="d-flex flex-wrap justify-content-end mb-2">
      {% custom_links object %}
      {% plugin_buttons object %}
  
      {# Extra buttons #}
      {% block extra_controls %}{% endblock %}

        {% if request.user|can_add:object %}
          {% clone_button object %}
        {% endif %}
        {% if request.user|can_change:object %}
          {% edit_button object %}
        {% endif %}
        {% if request.user|can_delete:object %}
          {% delete_button object %}
        {% endif %}

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

{% block tabs %}
<ul class="nav nav-tabs mb-3 px-3">
  {% block tab_items %}
    <li class="nav-item" role="presentation">
      <a class="nav-link{% if not active_tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object|meta:"verbose_name"|bettertitle }}</a>
    </li>
  {% endblock tab_items %}
  {% if perms.extras.view_journalentry %}
    {% with journal_viewname=object|viewname:'journal' %}
    {% url journal_viewname pk=object.pk as journal_url %}
    {% if journal_url %}
      <li role="presentation" class="nav-item">
        <a href="{{ journal_url }}" class="nav-link{% if active_tab == 'journal'%} active{% endif %}">Journal</a>
      </li>
    {% endif %}
    {% endwith %}
  {% endif %}
  {% if perms.extras.view_objectchange %}
    {% with changelog_viewname=object|viewname:'changelog' %}
    {% url changelog_viewname pk=object.pk as changelog_url %}
      <li role="presentation" class="nav-item">
          <a href="{{ changelog_url }}" class="nav-link{% if active_tab == 'changelog'%} active{% endif %}">Change Log</a>
      </li>
    {% endwith %}
  {% endif %}
</ul>
{% endblock tabs %}

{% block content %}
<p>
  <small class="text-muted">
    Created {{ object.created|annotated_date }} &middot;
    Updated <span title="{{ object.last_updated|annotated_date }}">{{ object.last_updated|timesince }}</span> ago
  </small>
  <span class="badge bg-primary">{{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}</span>
</p>
{% endblock content %}
{% block components %}{% endblock %}
