From 42dc9796a2559435dc53cf25c5f9ab7c308760c5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 Mar 2023 23:37:06 +1100 Subject: [PATCH] Break JS status codes into new javascript file - Always difficult to track down where these are rendered - Enough to warrant their own file now --- InvenTree/InvenTree/context.py | 5 ++-- InvenTree/InvenTree/urls.py | 1 + InvenTree/templates/base.html | 1 + .../templates/js/translated/return_order.js | 24 +++++++++++++++++-- .../templates/js/translated/status_codes.js | 23 ++++++++++++++++++ .../templates/js/translated/table_filters.js | 11 --------- 6 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 InvenTree/templates/js/translated/status_codes.js diff --git a/InvenTree/InvenTree/context.py b/InvenTree/InvenTree/context.py index 6c82137d3b..ef1fa1e9f1 100644 --- a/InvenTree/InvenTree/context.py +++ b/InvenTree/InvenTree/context.py @@ -4,8 +4,8 @@ import InvenTree.status from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus, - SalesOrderStatus, StockHistoryCode, - StockStatus) + ReturnOrderStatus, SalesOrderStatus, + StockHistoryCode, StockStatus) from users.models import RuleSet, check_user_role @@ -58,6 +58,7 @@ def status_codes(request): return { # Expose the StatusCode classes to the templates + 'ReturnOrderStatus': ReturnOrderStatus, 'SalesOrderStatus': SalesOrderStatus, 'PurchaseOrderStatus': PurchaseOrderStatus, 'BuildStatus': BuildStatus, diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index c9a86d26e1..4b28f92358 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -114,6 +114,7 @@ translated_javascript_urls = [ re_path(r'^sales_order.js', DynamicJsView.as_view(template_name='js/translated/sales_order.js'), name='sales_order.js'), re_path(r'^search.js', DynamicJsView.as_view(template_name='js/translated/search.js'), name='search.js'), re_path(r'^stock.js', DynamicJsView.as_view(template_name='js/translated/stock.js'), name='stock.js'), + re_path(r'^status_codes.js', DynamicJsView.as_view(template_name='js/translated/status_codes.js'), name='status_codes.js'), re_path(r'^plugin.js', DynamicJsView.as_view(template_name='js/translated/plugin.js'), name='plugin.js'), re_path(r'^pricing.js', DynamicJsView.as_view(template_name='js/translated/pricing.js'), name='pricing.js'), re_path(r'^news.js', DynamicJsView.as_view(template_name='js/translated/news.js'), name='news.js'), diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 4343c3e086..73912bcafe 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -169,6 +169,7 @@ + diff --git a/InvenTree/templates/js/translated/return_order.js b/InvenTree/templates/js/translated/return_order.js index 9059b4b2b7..d5c2a163f4 100644 --- a/InvenTree/templates/js/translated/return_order.js +++ b/InvenTree/templates/js/translated/return_order.js @@ -201,8 +201,7 @@ function loadReturnOrderTable(table, options={}) { field: 'status', title: '{% trans "Status" %}', formatter: function(value, row) { - return 'todo'; - return salesOrderStatusDisplay(row.status); + return returnOrderStatusDisplay(row.status); } }, { @@ -213,6 +212,27 @@ function loadReturnOrderTable(table, options={}) { return renderDate(value); } }, + { + field: 'responsible', + title: '{% trans "Responsible" %}', + switchable: true, + sortable: true, + formatter: function(value, row) { + if (!row.responsible_detail) { + return '-'; + } + + let html = row.responsible_detail.name; + + if (row.responsible_detail.label == 'group') { + html += ``; + } else { + html += ``; + } + + return html; + } + } ] }); } diff --git a/InvenTree/templates/js/translated/status_codes.js b/InvenTree/templates/js/translated/status_codes.js new file mode 100644 index 0000000000..6eed4cc725 --- /dev/null +++ b/InvenTree/templates/js/translated/status_codes.js @@ -0,0 +1,23 @@ +{% load i18n %} +{% load status_codes %} +{% load inventree_extras %} + +/* globals + global_settings +*/ + +/* exported + buildStatusDisplay, + returnOrderStatusDisplay, + purchaseOrderStatusDisplay, + salesOrderStatusDisplay, + stockHistoryStatusDisplay, + stockStatusDisplay, +*/ + +{% include "status_codes.html" with label='stock' options=StockStatus.list %} +{% include "status_codes.html" with label='stockHistory' options=StockHistoryCode.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 %} +{% include "status_codes.html" with label='returnOrder' options=ReturnOrderStatus.list %} diff --git a/InvenTree/templates/js/translated/table_filters.js b/InvenTree/templates/js/translated/table_filters.js index 4070bf565c..d6a1c13879 100644 --- a/InvenTree/templates/js/translated/table_filters.js +++ b/InvenTree/templates/js/translated/table_filters.js @@ -2,23 +2,12 @@ {% load status_codes %} {% load inventree_extras %} -{% include "status_codes.html" with label='stock' options=StockStatus.list %} -{% include "status_codes.html" with label='stockHistory' options=StockHistoryCode.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 %} - /* globals global_settings */ /* exported - buildStatusDisplay, getAvailableTableFilters, - purchaseOrderStatusDisplay, - salesOrderStatusDisplay, - stockHistoryStatusDisplay, - stockStatusDisplay, */