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,14 +81,18 @@ function loadPartTable(table, url, options={}) {
|
|||||||
* - table: HTML reference to the table
|
* - table: HTML reference to the table
|
||||||
* - url: Base URL for API query
|
* - url: Base URL for API query
|
||||||
* - options: object containing following (optional) fields
|
* - options: object containing following (optional) fields
|
||||||
|
* allowInactive: If true, allow display of inactive parts
|
||||||
* query: extra query params for API request
|
* query: extra query params for API request
|
||||||
* buttons: If provided, link buttons to selection status of this table
|
* buttons: If provided, link buttons to selection status of this table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Default query params
|
// Default query params
|
||||||
query = options.query;
|
query = options.query;
|
||||||
|
|
||||||
query.active = true;
|
if (!options.allowInactive) {
|
||||||
|
// Only display active parts
|
||||||
|
query.active = true;
|
||||||
|
}
|
||||||
|
|
||||||
$(table).bootstrapTable({
|
$(table).bootstrapTable({
|
||||||
url: url,
|
url: url,
|
||||||
@ -99,6 +103,7 @@ function loadPartTable(table, url, options={}) {
|
|||||||
pagination: true,
|
pagination: true,
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
rememberOrder: true,
|
rememberOrder: true,
|
||||||
|
formatNoMatches: function() { return "No parts found"; },
|
||||||
queryParams: function(p) {
|
queryParams: function(p) {
|
||||||
return query;
|
return query;
|
||||||
},
|
},
|
||||||
@ -118,7 +123,11 @@ function loadPartTable(table, url, options={}) {
|
|||||||
title: 'Part',
|
title: 'Part',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
formatter: function(value, row, index, field) {
|
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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -22,57 +22,15 @@
|
|||||||
var n = $("#part-results-table").bootstrapTable('getData').length;
|
var n = $("#part-results-table").bootstrapTable('getData').length;
|
||||||
$("#part-result-count").html("(found " + n + " results)");
|
$("#part-result-count").html("(found " + n + " results)");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#part-results-table").bootstrapTable({
|
loadPartTable("#part-results-table",
|
||||||
sortable: true,
|
"{% url 'api-part-list' %}",
|
||||||
search: true,
|
{
|
||||||
pagination: true,
|
query: {
|
||||||
formatNoMatches: function() { return "No parts found matching search query"; },
|
|
||||||
queryParams: function(p) {
|
|
||||||
return {
|
|
||||||
search: "{{ query }}",
|
search: "{{ query }}",
|
||||||
}
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'pk',
|
|
||||||
title: 'ID',
|
|
||||||
visible: false,
|
|
||||||
},
|
},
|
||||||
{
|
allowInactive: true,
|
||||||
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' %}"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% 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/inventree.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/api.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/tables.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user