2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Instead of creating a custom filter for "latest" parts,

simply make use of the existing "ordering" query as part of DRF
This commit is contained in:
Oliver Walters
2020-09-19 20:26:17 +10:00
parent a218b6b351
commit eaf42b8abe
3 changed files with 26 additions and 11 deletions

View File

@ -55,10 +55,12 @@ InvenTree | Index
{{ block.super }}
loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", {
loadSimplePartTable("#latest-parts-table", "{% url 'api-part-list' %}", {
params: {
"latest_parts": true,
}
ordering: "-creation_date",
limit: 10,
},
name: 'latest_parts',
});
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {

View File

@ -155,6 +155,14 @@ function loadPartVariantTable(table, partId, options) {
}
function loadSimplePartTable(table, url, options={}) {
options.disableFilters = true;
loadPartTable(table, url, options);
}
function loadPartTable(table, url, options={}) {
/* Load part listing data into specified table.
*
@ -332,7 +340,7 @@ function loadPartTable(table, url, options={}) {
method: 'get',
queryParams: filters,
groupBy: false,
name: 'part',
name: options.name || 'part',
original: params,
formatNoMatches: function() { return "{% trans "No parts found" %}"; },
columns: columns,