{% load django_ledger %}
{% load i18n %}

<div class="box">
    <div class="table-container">
        <table class="table is-fullwidth is-striped is-hoverable is-narrow django-ledger-table-bottom-margin-75">
            <thead>
            <tr>
                <th>{% trans 'Vendor Number' %}</th>
                <th>{% trans 'Vendor' %}</th>
                <th>{% trans 'Address' %}</th>
                <th>{% trans 'Code' %}</th>
                <th class="has-text-centered">{% trans 'Active' %}</th>
                <th class="has-text-centered">{% trans 'Hidden' %}</th>
                <th class="has-text-centered">{% trans 'Actions' %}</th>
            </tr>
            </thead>
            <tbody>
            {% for vendor_model in vendor_list %}
                <tr>
                    <td><span class="has-text-weight-bold">{{ vendor_model.vendor_number }}</span></td>
                    <td>
                        <a href="{{ vendor_model.get_detail_url }}">
                            {{ vendor_model.vendor_name }}
                        </a>
                    </td>
                    <td>{% if vendor_model.address_1 %}{{ vendor_model.address_1 }}{% endif %}</td>
                    <td>{% if vendor_model.vendor_code %}{{ vendor_model.vendor_code }}{% endif %}</td>
                    <td class="has-text-centered">
                        {% if vendor_model.active %}
                            <span class="icon has-text-success" title="{% trans 'Active' %}">
                                {% icon 'ant-design:check-circle-filled' 20 %}
                            </span>
                        {% else %}
                            <span class="icon has-text-danger" title="{% trans 'Inactive' %}">
                                {% icon 'mdi:dangerous' 20 %}
                            </span>
                        {% endif %}
                    </td>
                    <td class="has-text-centered">
                        {% if vendor_model.hidden %}
                            <span class="icon has-text-warning" title="{% trans 'Hidden' %}">
                                {% icon 'bi:eye-slash-fill' 20 %}
                            </span>
                        {% else %}
                            <span class="icon has-text-grey-lighter" title="{% trans 'Visible' %}">
                                {% icon 'bi:eye-fill' 20 %}
                            </span>
                        {% endif %}
                    </td>
                    <td class="has-text-centered">
                        <div class="dropdown is-right is-hoverable" id="vendor-action-{{ vendor_model.uuid }}">
                            <div class="dropdown-trigger">
                                <button class="button is-small is-rounded is-white"
                                        aria-haspopup="true"
                                        aria-controls="dropdown-menu">
                                    <span class="icon is-small">{% icon 'bi:three-dots-vertical' 20 %}</span>
                                </button>
                            </div>
                            <div class="dropdown-menu" id="dropdown-menu-{{ vendor_model.uuid }}" role="menu">
                                <div class="dropdown-content">
                                    <a href="{{ vendor_model.get_detail_url }}"
                                       class="dropdown-item">
                                        <span class="icon is-small mr-2">{% icon 'bi:eye' 16 %}</span>
                                        {% trans 'View' %}
                                    </a>
                                    <a href="{{ vendor_model.get_update_url }}"
                                       class="dropdown-item">
                                        <span class="icon is-small mr-2">{% icon 'bi:pencil' 16 %}</span>
                                        {% trans 'Update' %}
                                    </a>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
