mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
Break JS status codes into new javascript file
- Always difficult to track down where these are rendered - Enough to warrant their own file now
This commit is contained in:
@ -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,
|
||||
|
@ -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'),
|
||||
|
@ -169,6 +169,7 @@
|
||||
<script defer type='text/javascript' src="{% i18n_static 'report.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'sales_order.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'search.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'status_codes.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'stock.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'plugin.js' %}"></script>
|
||||
<script defer type='text/javascript' src="{% i18n_static 'pricing.js' %}"></script>
|
||||
|
@ -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 += `<span class='float-right fas fa-users'></span>`;
|
||||
} else {
|
||||
html += `<span class='float-right fas fa-user'></span>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
23
InvenTree/templates/js/translated/status_codes.js
Normal file
23
InvenTree/templates/js/translated/status_codes.js
Normal file
@ -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 %}
|
@ -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,
|
||||
*/
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user