{% extends 'netbox_slm/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load view_helpers %}
{% load perms %}

{% block extra_controls %}
{{ block.super }}
{% endblock %}

{% block content %}
<div class="row">
    <div class="col col-md-6">
        <div class="card">
            <div class="card-header">
                Software Product
            </div>
            <div class="card-body">
                <table class="table table-hover attr-table">
                    <tr>
                        <th scope="row">Name</th>
                        <td>{{ object.name }}</td>
                    </tr>
                    <tr>
                        <th scope="row">Versions</th>
                        <td>
                        {% for version in object.softwareproduct_versions.all %}
                            <a href="{% url 'plugins:netbox_slm:softwareproductversion' pk=version.pk %}">
                                <span class="badge" style="color: #ffffff; background-color: #9e9e9e">{{ version }}</span>
                            </a>
                        {% endfor %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        {% include 'inc/custom_fields_panel.html' %}
    </div>
    <div class="col col-md-6">
        {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='plugins:netbox_slm:softwareproduct_list' %}
    </div>
</div>
<div class="row">
    <div class="col col-md-12">
        <div class="card">
            <h5 class="card-header">Versions</h5>
            <div class="card-body">
                <table class="table table-hover attr-table table-striped">
                    <thead>
                        <tr>
                            <th scope="col">NAME</th>
                            <th scope="col">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for version in versions %}
                        <tr>
                            <td>{{ version.name|truncatechars:32 }}</td>
                            <td class="noprint text-end text-nowrap">
                                {% if request.user|can_change:object %}
                                    {% plugin_edit_button version %}
                                {% endif %}
                                {% if request.user|can_delete:object %}
                                    {% plugin_delete_button version %}
                                {% endif %}
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}