diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html
index fd8f20d2aa..2d76b08ac9 100644
--- a/InvenTree/part/templates/part/category.html
+++ b/InvenTree/part/templates/part/category.html
@@ -156,6 +156,7 @@
{% endif %}
},
buttons: ['#part-options'],
+ checkbox: true,
},
);
diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js
index 1001ef11a1..7c933ef303 100644
--- a/InvenTree/static/script/inventree/part.js
+++ b/InvenTree/static/script/inventree/part.js
@@ -82,6 +82,7 @@ function loadPartTable(table, url, options={}) {
* - url: Base URL for API query
* - options: object containing following (optional) fields
* allowInactive: If true, allow display of inactive parts
+ * checkbox: Show the checkbox column
* query: extra query params for API request
* buttons: If provided, link buttons to selection status of this table
*/
@@ -94,6 +95,84 @@ function loadPartTable(table, url, options={}) {
query.active = true;
}
+ var columns = [
+ {
+ field: 'pk',
+ title: 'ID',
+ visible: false,
+ }
+ ];
+
+ if (options.checkbox) {
+ columns.push({
+ checkbox: true,
+ title: 'Select',
+ searchable: false,
+ });
+ }
+
+ columns.push({
+ field: 'full_name',
+ title: 'Part',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+
+ if (row.is_template) {
+ value = '' + value + '';
+ }
+
+ var display = imageHoverIcon(row.image_url) + renderLink(value, row.url);
+
+ if (!row.active) {
+ display = display + "INACTIVE";
+ }
+ return display;
+ }
+ });
+
+ columns.push({
+ sortable: true,
+ field: 'description',
+ title: 'Description',
+ formatter: function(value, row, index, field) {
+
+ if (row.is_template) {
+ value = '' + value + '';
+ }
+
+ return value;
+ }
+ });
+
+ columns.push({
+ sortable: true,
+ field: 'category_name',
+ title: 'Category',
+ formatter: function(value, row, index, field) {
+ if (row.category) {
+ return renderLink(row.category_name, "/part/category/" + row.category + "/");
+ }
+ else {
+ return '';
+ }
+ }
+ });
+
+ columns.push({
+ field: 'total_stock',
+ title: 'Stock',
+ searchable: false,
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ if (value) {
+ return renderLink(value, row.url + 'stock/');
+ }
+ else {
+ return "No Stock";
+ }
+ }
+ });
+
$(table).bootstrapTable({
url: url,
sortable: true,
@@ -107,76 +186,7 @@ function loadPartTable(table, url, options={}) {
queryParams: function(p) {
return query;
},
- columns: [
- {
- checkbox: true,
- title: 'Select',
- searchable: false,
- },
- {
- field: 'pk',
- title: 'ID',
- visible: false,
- },
- {
- field: 'full_name',
- title: 'Part',
- sortable: true,
- formatter: function(value, row, index, field) {
-
- if (row.is_template) {
- value = '' + value + '';
- }
-
- var display = imageHoverIcon(row.image_url) + renderLink(value, row.url);
-
- if (!row.active) {
- display = display + "INACTIVE";
- }
- return display;
- }
- },
- {
- sortable: true,
- field: 'description',
- title: 'Description',
- formatter: function(value, row, index, field) {
-
- if (row.is_template) {
- value = '' + value + '';
- }
-
- return value;
- }
- },
- {
- sortable: true,
- field: 'category_name',
- title: 'Category',
- formatter: function(value, row, index, field) {
- if (row.category) {
- return renderLink(row.category_name, "/part/category/" + row.category + "/");
- }
- else {
- return '';
- }
- }
- },
- {
- field: 'total_stock',
- title: 'Stock',
- searchable: false,
- sortable: true,
- formatter: function(value, row, index, field) {
- if (value) {
- return renderLink(value, row.url + 'stock/');
- }
- else {
- return "No Stock";
- }
- }
- }
- ],
+ columns: columns,
});
if (options.buttons) {
diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html
index 7de08fd9b6..70915a49fd 100644
--- a/InvenTree/templates/InvenTree/search.html
+++ b/InvenTree/templates/InvenTree/search.html
@@ -17,6 +17,10 @@ InvenTree | Search Results