mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Mark 'inactive' parts in part list table
- Fix part display in search results page
This commit is contained in:
parent
1f9aa7a8fc
commit
b4b9d1514e
@ -81,6 +81,7 @@ function loadPartTable(table, url, options={}) {
|
||||
* - table: HTML reference to the table
|
||||
* - url: Base URL for API query
|
||||
* - options: object containing following (optional) fields
|
||||
* allowInactive: If true, allow display of inactive parts
|
||||
* query: extra query params for API request
|
||||
* buttons: If provided, link buttons to selection status of this table
|
||||
*/
|
||||
@ -88,7 +89,10 @@ function loadPartTable(table, url, options={}) {
|
||||
// Default query params
|
||||
query = options.query;
|
||||
|
||||
query.active = true;
|
||||
if (!options.allowInactive) {
|
||||
// Only display active parts
|
||||
query.active = true;
|
||||
}
|
||||
|
||||
$(table).bootstrapTable({
|
||||
url: url,
|
||||
@ -99,6 +103,7 @@ function loadPartTable(table, url, options={}) {
|
||||
pagination: true,
|
||||
pageSize: 25,
|
||||
rememberOrder: true,
|
||||
formatNoMatches: function() { return "No parts found"; },
|
||||
queryParams: function(p) {
|
||||
return query;
|
||||
},
|
||||
@ -118,7 +123,11 @@ function loadPartTable(table, url, options={}) {
|
||||
title: 'Part',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return imageHoverIcon(row.image_url) + renderLink(value, row.url);
|
||||
var display = imageHoverIcon(row.image_url) + renderLink(value, row.url);
|
||||
if (!row.active) {
|
||||
display = display + "<span class='label label-warning' style='float: right;'>INACTIVE</span>";
|
||||
}
|
||||
return display;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -23,56 +23,14 @@
|
||||
$("#part-result-count").html("(found " + n + " results)");
|
||||
});
|
||||
|
||||
$("#part-results-table").bootstrapTable({
|
||||
sortable: true,
|
||||
search: true,
|
||||
pagination: true,
|
||||
formatNoMatches: function() { return "No parts found matching search query"; },
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
loadPartTable("#part-results-table",
|
||||
"{% url 'api-part-list' %}",
|
||||
{
|
||||
query: {
|
||||
search: "{{ query }}",
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'pk',
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: 'Name',
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, row.url);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'IPN',
|
||||
title: 'Internal Part Number',
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: 'Description',
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
field: 'available_stock',
|
||||
title: 'Stock',
|
||||
formatter: function(value, row, index, field) {
|
||||
if (value) {
|
||||
return renderLink(value, row.url + 'stock/');
|
||||
} else {
|
||||
return renderLink('No stock', row.url + 'stock/');
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
url: "{% url 'api-part-list' %}"
|
||||
});
|
||||
|
||||
|
||||
allowInactive: true,
|
||||
}
|
||||
);
|
||||
|
||||
{% endblock %}
|
@ -86,6 +86,7 @@ InvenTree
|
||||
|
||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/part.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/tables.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user