Related part table now uses "loadPartTable" function call

This commit is contained in:
Oliver 2021-11-25 14:13:49 +11:00
parent b497569228
commit a532babde8
2 changed files with 16 additions and 32 deletions

View File

@ -326,37 +326,11 @@
<div class='panel-content'>
<div id='related-button-bar'>
<div class='btn-group' role='group'>
{% include "filter_list.html" with id="related" %}
{% include "filter_list.html" with id="parts" %}
</div>
</div>
<table id='table-related-part' class='table table-condensed table-striped' data-toolbar='#related-button-toolbar'>
<thead>
<tr>
<th data-field='part' data-serachable='true'>{% trans "Part" %}</th>
</tr>
</thead>
<tbody>
{% for item in part.get_related_parts %}
{% with part_related=item.0 part=item.1 %}
<tr>
<td>
<a class='hover-icon'>
<img class='hover-img-thumb' src='{{ part.get_thumbnail_url }}'>
<img class='hover-img-large' src='{{ part.get_thumbnail_url }}'>
</a>
<a href='/part/{{ part.id }}/'>{{ part }}</a>
<div class='btn-group' style='float: right;'>
{% if roles.part.change %}
<button title='{% trans "Delete" %}' class='btn btn-outline-secondary delete-related-part' url="{% url 'part-related-delete' part_related.id %}" type='button'><span class='fas fa-trash-alt icon-red'/></button>
{% endif %}
</div>
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
<table id='related-parts-table' class='table table-striped table-condensed' data-toolbar='#related-button-toolbar'></table>
</div>
</div>
@ -771,8 +745,18 @@
// Load the "related parts" tab
onPanelLoad("related-parts", function() {
$('#table-related-part').inventreeTable({
});
loadPartTable(
'#related-parts-table',
'{% url "api-part-list" %}',
{
params: {
related: {{ part.pk }},
},
gridView: true,
checkbox: false,
}
);
$("#add-related-part").click(function() {
launchModalForm("{% url 'part-related-create' %}", {

View File

@ -273,7 +273,7 @@ function setupFilterList(tableKey, table, target) {
var element = $(target);
if (!element) {
if (!element || !element.exists()) {
console.log(`WARNING: setupFilterList could not find target '${target}'`);
return;
}