2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

Refactor table_filters javascript file to prevent loading on every single page

This commit is contained in:
Oliver Walters
2020-05-16 21:02:25 +10:00
parent f3c71bd96f
commit fe99e92bfc
3 changed files with 2 additions and 5 deletions

View File

@ -0,0 +1,124 @@
{% load i18n %}
{% load status_codes %}
{% include "status_codes.html" with label='stock' options=StockStatus.list %}
{% include "status_codes.html" with label='build' options=BuildStatus.list %}
{% include "status_codes.html" with label='purchaseOrder' options=PurchaseOrderStatus.list %}
{% include "status_codes.html" with label='salesOrder' options=SalesOrderStatus.list %}
function getAvailableTableFilters(tableKey) {
tableKey = tableKey.toLowerCase();
// Filters for the "Stock" table
if (tableKey == 'stock') {
return {
cascade: {
type: 'bool',
title: '{% trans "Include sublocations" %}',
description: '{% trans "Include stock in sublocations" %}',
},
active: {
type: 'bool',
title: '{% trans "Active parts" %}',
description: '{% trans "Show stock for active parts" %}',
},
status: {
options: stockCodes,
title: '{% trans "Stock status" %}',
description: '{% trans "Stock status" %}',
},
allocated: {
type: 'bool',
title: '{% trans "Is allocated" %}',
description: '{% trans "Item has been alloacted" %}',
},
};
}
// Filters for the "Build" table
if (tableKey == 'build') {
return {
status: {
title: '{% trans "Build status" %}',
options: buildCodes,
},
};
}
// Filters for the "Order" table
if (tableKey == "purchaseorder") {
return {
status: {
title: '{% trans "Order status" %}',
options: purchaseOrderCodes,
},
};
}
if (tableKey == "salesorder") {
return {
status: {
title: '{% trans "Order status" %}',
options: salesOrderCodes,
},
};
}
// Filters for the "Parts" table
if (tableKey == "parts") {
return {
cascade: {
type: 'bool',
title: '{% trans "Include subcategories" %}',
description: '{% trans "Include parts in subcategories" %}',
},
active: {
type: 'bool',
title: '{% trans "Active" %}',
description: '{% trans "Show active parts" %}',
},
is_template: {
type: 'bool',
title: '{% trans "Template" %}',
},
has_stock: {
type: 'bool',
title: '{% trans "Stock available" %}'
},
low_stock: {
type: 'bool',
title: '{% trans "Low stock" %}',
},
assembly: {
type: 'bool',
title: '{% trans "Assembly" %}',
},
component: {
type: 'bool',
title: '{% trans "Component" %}',
},
starred: {
type: 'bool',
title: '{% trans "Starred" %}',
},
salable: {
type: 'bool',
title: '{% trans "Salable" %}',
},
trackable: {
type: 'bool',
title: '{% trans "Trackable" %}',
},
purchaseable: {
type: 'bool',
title: '{% trans "Purchasable" %}',
},
};
}
// Finally, no matching key
return {};
}