{% extends "admin/base_site.html" %}
{% load i18n admin_urls cms_tags djangocms_alias_tags %}

{% block extrahead %}{{ block.super }}
<script>
    function closeSideframe() {
        try {
            window.top.CMS.$('.cms-sideframe-close').trigger('click.cms.sideframe');
        } catch(e) {}
    }
</script>
{% endblock %}

{% block breadcrumbs %}
    <div class="breadcrumbs">
    <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
    &rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
    &rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst|escape }}</a>
    &rsaquo; <a href="{% url opts|admin_urlname:'change' object.pk|admin_urlquote %}">{{ object|truncatewords:"18" }}</a>
    &rsaquo; {% trans 'Usage of alias' %}
    </div>
{% endblock %}


{% block content %}
{% if show_back_btn %}<a href="javascript:history.back()" class="button cancel-link cms-btn">{% trans "Back" %}</a>{% endif %}
<div class="results">
    <table id="result_list">
        <thead>
            <tr>
                <th>{% trans 'Type' %}</th>
                <th>{% trans 'Name' %}</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for item in objects_list %}
            <tr>
                {% with item|verbose_name as object_type %}
                <td>{{ object_type|capfirst|escape }}</td>
                <td>
                  <a target="_top" onclick="closeSideframe()" href="{{ item.get_absolute_url }}">{{ item }}</a>
                </td>
                <td>
                    {% if object_type == 'alias' %}
                    <a href="{% get_alias_usage_view_url alias=item back=1 %}">{% trans 'View usage' %}</a>
                    {% endif %}
                </td>
                {% endwith %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock content %}
