{% extends 'blacklist/base.html' %}

{% load aa_i18n %}
{% load evelinks %}
{% load i18n %}
{% load humanize %}

{% block tb_block %}
    {% translate "Blacklist" as translated_header %}
{#    {% include "tnnt_templates/includes/header/page-header.html" with header_text=translated_header %}#}
    {% include "framework/header/page-header.html" with title=translated_header %}

    <div class="tab-pane in active" id="blacklist">
        <div class="panel panel-default clearfix">
            <div class="panel-heading">
                <div class="panel-title">
                    {% translate "Blacklisted Entities" %}
                </div>
            </div>

            <div class="panel-body clearfix" id="all-notes">
                {% if blacklist %}
                    <table class="table table-striped" style="max-width: 100%;" id="blacklist-table">
                        <thead>
                            <tr>
                                <th style="width: 64px;"></th>
                                <th>{% translate "Name" %}</th>
                                <th>{% translate "Reason" %}</th>
                                <th>{% translate "Category" %}</th>
                            </tr>
                        </thead>

                        <tbody>
                            {% for note in blacklist %}
                                <tr>
                                    <td>
                                        {% if note.eve_catagory == "character" %}
                                            <img
                                                src="{{ note.eve_id|character_portrait_url:64 }}"
                                                alt="{{ note.eve_name }}"
                                                title="{{ note.eve_name }}"
                                            >
                                        {% elif note.eve_catagory == "corporation" %}
                                            <img
                                                src="{{ note.eve_id|corporation_logo_url:64 }}"
                                                alt="{{ note.eve_name }}"
                                                title="{{ note.eve_name }}"
                                            >
                                        {% elif note.eve_catagory == "alliance" %}
                                            <img
                                                src="{{ note.eve_id|alliance_logo_url:64 }}"
                                                alt="{{ note.eve_name }}"
                                                title="{{ note.eve_name }}"
                                            >
                                        {% endif %}
                                    </td>

                                    <td>
                                        <p>
                                            {{ note.eve_name }}

                                            {% if note.eve_catagory == 'character' %}
                                                <br>
                                                <span class="label label-default">
                                                    {{ note.corporation_name }}
                                                </span>
                                                <br>
                                                <span class="label label-default">
                                                    {{ note.alliance_name|default_if_none:"" }}
                                                </span>
                                            {% endif %}
                                        </p>
                                    </td>

                                    <td>
                                        {% if note.restricted %}
                                            <p>
                                                {% blocktranslate with contact=note.added_by %}
                                                    Restricted Content! Contact {{ contact }} for more information.
                                                {% endblocktranslate %}
                                            </p>
                                        {% else %}
                                            {{ note.reason|linebreaks }}
                                        {% endif %}
                                    </td>

                                    <!-- for filtering -->
                                    <td>{{ note.eve_catagory }}</td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                {% else %}
                    <div class="alert alert-warning text-center">
                        {% translate "No one is yet to be Blacklisted. You guys are so nice!" %}
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock %}

{% block extra_javascript %}
    {% include 'bundles/datatables-js.html' %}
    {% include "bundles/filterdropdown-js.html" %}

    {% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}

    <script>
        $(document).ready(function () {
            $('#blacklist-table').DataTable({
                language: {
                    url: '{{ DT_LANG_PATH }}'
                },
                filterDropDown: {
                    columns: [{
                        idx: 3
                    }],
                    bootstrap: true
                },
                columnDefs: [
                    {
                        searchable: false,
                        targets: [0]
                    },
                    {
                        sortable: false,
                        targets: [0, 2]
                    },
                    {
                        visible: false,
                        targets: [3]
                    }

                ],
                order: [
                    [1, 'asc']
                ],
                pageLength: 25,
                responsive: true
            });
        });
    </script>
{% endblock %}
