diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js
index 811f1987ab..a991cb232c 100644
--- a/InvenTree/static/script/inventree/part.js
+++ b/InvenTree/static/script/inventree/part.js
@@ -81,14 +81,18 @@ 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
*/
// 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 + "INACTIVE";
+ }
+ return display;
}
},
{
diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html
index e868378ee4..cd700facc8 100644
--- a/InvenTree/templates/InvenTree/search.html
+++ b/InvenTree/templates/InvenTree/search.html
@@ -22,57 +22,15 @@
var n = $("#part-results-table").bootstrapTable('getData').length;
$("#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 %}
\ No newline at end of file
diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html
index 84e2e10963..90925cfe7e 100644
--- a/InvenTree/templates/base.html
+++ b/InvenTree/templates/base.html
@@ -86,6 +86,7 @@ InvenTree
+