Filter parts by 'is_assembly'

Also greatly improve rendering of the Part table
This commit is contained in:
Oliver Walters 2020-04-11 22:57:40 +10:00
parent e1c6ad7761
commit 0f90e8f522
3 changed files with 15 additions and 5 deletions

View File

@ -125,6 +125,8 @@
.label-right { .label-right {
float: right; float: right;
margin-left: 3px;
margin-right: 3px;
} }
/* Bootstrap table overrides */ /* Bootstrap table overrides */

View File

@ -140,11 +140,15 @@ function loadPartTable(table, url, options={}) {
var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/'); var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/');
if (row.is_template) { if (row.is_template) {
display = display + "<span class='label label-info' style='float: right;'>TEMPLATE</span>"; display = display + `<span class='fas fa-clone label-right' title='Template part'></span>`;
}
if (row.assembly) {
display = display + `<span class='fas fa-tools label-right' title='Assembled part'></span>`;
} }
if (!row.active) { if (!row.active) {
display = display + "<span class='label label-warning' style='float: right;'>INACTIVE</span>"; display = display + `<span class='fas fa-times label-right' title='Inactive part'></span>`;
} }
return display; return display;
} }
@ -173,7 +177,7 @@ function loadPartTable(table, url, options={}) {
return renderLink(row.category__name, "/part/category/" + row.category + "/"); return renderLink(row.category__name, "/part/category/" + row.category + "/");
} }
else { else {
return ''; return 'No category';
} }
} }
}); });

View File

@ -80,7 +80,11 @@ function getAvailableTableFilters(tableKey) {
low_stock: { low_stock: {
type: 'bool', type: 'bool',
title: '{% trans "Low stock" %}', title: '{% trans "Low stock" %}',
} },
assembly: {
type: 'bool',
title: '{% trans "Assembly" %}',
},
}; };
} }