2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

BOM now uses DRF / ajax

This commit is contained in:
Oliver
2018-05-02 23:42:57 +10:00
parent be0797c6e6
commit 7d21c4ef1c
4 changed files with 103 additions and 31 deletions

View File

@@ -11,30 +11,7 @@
<h3>Bill of Materials</h3>
<table class="table table-striped" id='bom-table' data-filtering='true' data-sorting='true'>
<thead>
<tr>
<th>Part</th>
<th>Description</th>
<th data-type='number'>Quantity</th>
<th data-sortable='false'></th>
</tr>
</thead>
<tbody>
{% for bom_item in part.bom_items.all %}
{% with sub_part=bom_item.sub_part %}
<tr>
<td><a href="{% url 'part-detail' sub_part.id %}">{{ sub_part.name }}</a></td>
<td>{{ sub_part.description }}</td>
<td>{{ bom_item.quantity }}</td>
<td>
<button type='button' url="{% url 'bom-item-edit' bom_item.id %}" class='btn btn-success edit-row-button'>Edit</button>
<button type='button' url="{% url 'bom-item-delete' bom_item.id %}" class='btn btn-danger delete-row-button'>Delete</button>
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
<table class='table table-striped table-condensed' id='bom-table'>
</table>
<div class='container-fluid'>
@@ -47,8 +24,8 @@
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
{% endblock %}
{% block js_ready %}
$('#bom-table').on('click', '.delete-row-button', function () {
$('#bom-table').on('click', '.delete-button', function () {
var button = $(this);
launchDeleteForm("#modal-delete",
@@ -58,11 +35,14 @@
});
});
$('#bom-table').on('click', '.edit-row-button', function () {
$("#bom-table").on('click', '.edit-button', function () {
var button = $(this);
launchModalForm("#modal-form",
button.attr('url'));
button.attr('url'),
{
reload: true
});
});
@@ -76,4 +56,45 @@
}
});
});
$("#bom-table").bootstrapTable({
sortable: true,
search: true,
queryParams: function(p) {
return {
part: {{ part.id }}
}
},
columns: [
{
field: 'pk',
title: 'ID',
visible: false,
},
{
field: 'sub_part',
title: 'Part',
sortable: true,
formatter: function(value, row, index, field) {
return renderLink(value.name, value.url);
}
},
{
field: 'sub_part.description',
title: 'Description',
},
{
field: 'quantity',
title: 'Quantity',
searchable: false,
sortable: true
},
{
formatter: function(value, row, index, field) {
return editButton(row.url + 'edit') + ' ' + deleteButton(row.url + 'delete');
}
}
],
url: "{% url 'api-bom-list' %}"
});
{% endblock %}