{% extends "stock/item_base.html" %}

{% load static %}
{% load i18n %}

{% block details %}

{% include "stock/tabs.html" with tab='installed' %}

<h4>{% trans "Installed Stock Items" %}</h4>
<hr>

<table class='table table-striped table-condensed' id='installed-table'></table>

{% endblock %}

{% block js_ready %}

{{ block.super }}

loadInstalledInTable(
    $('#installed-table'),
    {
        stock_item: {{ item.pk }},
        part: {{ item.part.pk }},
        quantity: {{ item.quantity }},
    }
);

$('#multi-item-uninstall').click(function() {

    var selections = $('#installed-table').bootstrapTable('getSelections');

    var items = [];

    selections.forEach(function(item) {
        items.push(item.pk);
    });

    launchModalForm(
        "{% url 'stock-item-uninstall' %}",
        {
            data: {
                'items[]': items,
            },
            reload: true,
        }
    );
});

{% endblock %}