diff --git a/InvenTree/InvenTree/static/script/inventree/build.js b/InvenTree/InvenTree/static/script/inventree/build.js
index 03c33f7b57..c559f773d8 100644
--- a/InvenTree/InvenTree/static/script/inventree/build.js
+++ b/InvenTree/InvenTree/static/script/inventree/build.js
@@ -50,12 +50,17 @@ function loadBuildTable(table, options) {
sortable: true,
},
{
- field: 'status_text',
+ field: 'status',
title: 'Status',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ return buildStatusDisplay(value);
+ },
},
{
field: 'creation_date',
title: 'Created',
+ sortable: true,
},
],
});
diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js
index de9f987911..1c42ddf46b 100644
--- a/InvenTree/InvenTree/static/script/inventree/filters.js
+++ b/InvenTree/InvenTree/static/script/inventree/filters.js
@@ -216,8 +216,9 @@ function generateFilterInput(tableKey, filterKey) {
// Return a 'select' input with the available values
html = ``;
@@ -368,7 +369,6 @@ function getFilterOptionValue(tableKey, filterKey, valueKey) {
var filter = getFilterSettings(tableKey, filterKey);
-
var value = String(valueKey);
// Lookup for boolean options
@@ -381,11 +381,10 @@ function getFilterOptionValue(tableKey, filterKey, valueKey) {
// Iterate through a list of options
if ('options' in filter) {
- for (var option in filter.options) {
- var v = String(filter.options[option]);
+ for (var key in filter.options) {
- if (v == valueKey) {
- return option;
+ if (key == valueKey) {
+ return filter.options[key].value;
}
}
diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js
index a54a464b88..babdf34f83 100644
--- a/InvenTree/InvenTree/static/script/inventree/order.js
+++ b/InvenTree/InvenTree/static/script/inventree/order.js
@@ -187,7 +187,5 @@ function orderStatusLabel(code, label) {
html += label;
html += "";
- console.log(html);
-
return html;
}
\ No newline at end of file
diff --git a/InvenTree/InvenTree/status_codes.py b/InvenTree/InvenTree/status_codes.py
index 7037ccde65..3c68dceb75 100644
--- a/InvenTree/InvenTree/status_codes.py
+++ b/InvenTree/InvenTree/status_codes.py
@@ -7,6 +7,8 @@ class StatusCode:
This is used to map a set of integer values to text.
"""
+ labels = {}
+
@classmethod
def list(cls):
"""
@@ -16,10 +18,18 @@ class StatusCode:
codes = []
for key in cls.options.keys():
- codes.append({
+
+ opt = {
'key': key,
'value': cls.options[key]
- })
+ }
+
+ label = cls.labels.get(key)
+
+ if label:
+ opt['label'] = label
+
+ codes.append(opt)
return codes
@@ -61,6 +71,15 @@ class OrderStatus(StatusCode):
RETURNED: _("Returned"),
}
+ labels = {
+ PENDING: "primary",
+ PLACED: "primary",
+ COMPLETE: "success",
+ CANCELLED: "danger",
+ LOST: "warning",
+ RETURNED: "warning",
+ }
+
# Open orders
OPEN = [
PENDING,
@@ -91,6 +110,12 @@ class StockStatus(StatusCode):
LOST: _("Lost"),
}
+ labels = {
+ OK: 'success',
+ ATTENTION: 'warning',
+ DAMAGED: 'danger',
+ }
+
# The following codes correspond to parts that are 'available' or 'in stock'
AVAILABLE_CODES = [
OK,
@@ -120,6 +145,13 @@ class BuildStatus(StatusCode):
COMPLETE: _("Complete"),
}
+ labels = {
+ PENDING: 'primary',
+ ALLOCATED: 'info',
+ COMPLETE: 'success',
+ CANCELLED: 'danger',
+ }
+
ACTIVE_CODES = [
PENDING,
ALLOCATED
diff --git a/InvenTree/templates/status_codes.html b/InvenTree/templates/status_codes.html
new file mode 100644
index 0000000000..0d92b6f467
--- /dev/null
+++ b/InvenTree/templates/status_codes.html
@@ -0,0 +1,27 @@
+var {{ label }}Codes = {
+ {% for opt in options %}'{{ opt.key }}': {
+ key: '{{ opt.key }}',
+ value: '{{ opt.value }}',{% if opt.label %}
+ label: '{{ opt.label }}',{% endif %}
+ },{% endfor %}
+};
+
+function {{ label }}StatusDisplay(key) {
+
+ key = String(key);
+
+ var label = {{ label }}Codes[key].label;
+
+ var value = {{ label }}Codes[key].value;
+
+ if (value == null || value.length == 0) {
+ value = key;
+ }
+
+ // Label not found, return the original string
+ if (label == null || label.length == 0) {
+ return value;
+ }
+
+ return `${value}`;
+}
diff --git a/InvenTree/templates/table_filters.html b/InvenTree/templates/table_filters.html
index ca1f741fa6..0cefc2d9f5 100644
--- a/InvenTree/templates/table_filters.html
+++ b/InvenTree/templates/table_filters.html
@@ -5,6 +5,11 @@