{% extends "stock/item_base.html" %} {% load static %} {% load i18n %} {% block menubar %} {% include "stock/navbar.html" with tab='tests' %} {% endblock %} {% block heading %} {% trans "Test Data" %} {% endblock %} {% block details %}
{% if user.is_staff %} {% endif %}
{% endblock %} {% block js_ready %} {{ block.super }} loadStockTestResultsTable( $("#test-result-table"), { part: {{ item.part.id }}, stock_item: {{ item.id }}, } ); function reloadTable() { $("#test-result-table").bootstrapTable("refresh"); } {% if item.has_test_reports %} $("#test-report").click(function() { printTestReports([{{ item.pk }}]); }); {% endif %} {% if user.is_staff %} $("#delete-test-results").click(function() { launchModalForm( "{% url 'stock-item-delete-test-data' item.id %}", { success: reloadTable, } ); }); {% endif %} $("#add-test-result").click(function() { constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', fields: { test: {}, result: {}, value: {}, attachment: {}, notes: {}, stock_item: { value: {{ item.pk }}, hidden: true, } }, title: '{% trans "Add Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-add', function() { var button = $(this); var test_name = button.attr('pk'); constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', fields: { test: { value: test_name, }, result: {}, value: {}, attachment: {}, notes: {}, stock_item: { value: {{ item.pk }}, hidden: true, } }, title: '{% trans "Add Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-edit', function() { var button = $(this); var pk = button.attr('pk'); var url = `/api/stock/test/${pk}/`; constructForm(url, { fields: { test: {}, result: {}, value: {}, attachment: {}, notes: {}, }, title: '{% trans "Edit Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-delete', function() { var button = $(this); var pk = button.attr('pk'); var url = `/api/stock/test/${pk}/`; constructForm(url, { method: 'DELETE', title: '{% trans "Delete Test Result" %}', onSuccess: reloadTable, }); }); {% endblock %}