Template cleanup

This commit is contained in:
Oliver 2021-07-29 12:31:07 +10:00
parent 6fe5f0e0e6
commit 4381a16b0e
10 changed files with 50 additions and 54 deletions

View File

@ -82,7 +82,7 @@
}, },
{ {
success: function(response) { success: function(response) {
var prefix = '{% settings_value "BUILDORDER_REFERENCE_PREFIX" %}'; var prefix = global_settings.BUILDORDER_REFERENCE_PREFIX;
for (var idx = 0; idx < response.length; idx++) { for (var idx = 0; idx < response.length; idx++) {

View File

@ -812,6 +812,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
help_text=_('Settings key (must be unique - case insensitive'), help_text=_('Settings key (must be unique - case insensitive'),
) )
class InvenTreeUserSetting(BaseInvenTreeSetting): class InvenTreeUserSetting(BaseInvenTreeSetting):
""" """
An InvenTreeSetting object with a usercontext An InvenTreeSetting object with a usercontext

View File

@ -198,9 +198,8 @@
); );
}); });
{% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} if (global_settings.INVENTREE_DOWNLOAD_FROM_URL) {
{% if allow_download %}
$('#company-image-url').click(function() { $('#company-image-url').click(function() {
launchModalForm( launchModalForm(
'{% url "company-image-download" company.id %}', '{% url "company-image-download" company.id %}',
@ -209,6 +208,6 @@
} }
) )
}); });
{% endif %} }
{% endblock %} {% endblock %}

View File

@ -164,7 +164,7 @@ $("#edit-order").click(function() {
constructForm('{% url "api-po-detail" order.pk %}', { constructForm('{% url "api-po-detail" order.pk %}', {
fields: { fields: {
reference: { reference: {
prefix: "{% settings_value 'PURCHASEORDER_REFERENCE_PREFIX' %}", prefix: global_settings.PURCHASEORDER_REFERENCE_PREFIX,
}, },
{% if order.lines.count == 0 and order.status == PurchaseOrderStatus.PENDING %} {% if order.lines.count == 0 and order.status == PurchaseOrderStatus.PENDING %}
supplier: { supplier: {

View File

@ -157,7 +157,7 @@ $("#edit-order").click(function() {
constructForm('{% url "api-so-detail" order.pk %}', { constructForm('{% url "api-so-detail" order.pk %}', {
fields: { fields: {
reference: { reference: {
prefix: "{% settings_value 'SALESORDER_REFERENCE_PREFIX' %}", prefix: global_settings.SALESORDER_REFERENCE_PREFIX,
}, },
{% if order.lines.count == 0 and order.status == SalesOrderStatus.PENDING %} {% if order.lines.count == 0 and order.status == SalesOrderStatus.PENDING %}
customer: { customer: {

View File

@ -67,7 +67,7 @@
{ {
success: function(response) { success: function(response) {
var prefix = '{% settings_value "SALESORDER_REFERENCE_PREFIX" %}'; var prefix = global_settings.SALESORDER_REFERENCE_PREFIX;
for (var idx = 0; idx < response.length; idx++) { for (var idx = 0; idx < response.length; idx++) {
var order = response[idx]; var order = response[idx];

View File

@ -394,8 +394,7 @@
{% if roles.part.change %} {% if roles.part.change %}
{% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} if (global_settings.INVENTREE_DOWNLOAD_FROM_URL) {
{% if allow_download %}
$("#part-image-url").click(function() { $("#part-image-url").click(function() {
launchModalForm( launchModalForm(
'{% url "part-image-download" part.id %}', '{% url "part-image-download" part.id %}',
@ -404,7 +403,7 @@
} }
); );
}); });
{% endif %} }
$("#part-image-select").click(function() { $("#part-image-select").click(function() {
launchModalForm("{% url 'part-image-select' part.id %}", launchModalForm("{% url 'part-image-select' part.id %}",

View File

@ -91,11 +91,7 @@ function inventreeDocReady() {
url: '/api/part/', url: '/api/part/',
data: { data: {
search: request.term, search: request.term,
{% if request.user %} limit: user_settings.SEARCH_PREVIEW_RESULTS,
limit: {% settings_value 'SEARCH_PREVIEW_RESULTS' user=request.user %},
{% else %}
limit: 25,
{% endif %}
offset: 0 offset: 0
}, },
success: function (data) { success: function (data) {

View File

@ -5,7 +5,7 @@
function buildFormFields() { function buildFormFields() {
return { return {
reference: { reference: {
prefix: "{% settings_value 'BUILDORDER_REFERENCE_PREFIX' %}", prefix: global_settings.BUILDORDER_REFERENCE_PREFIX,
}, },
title: {}, title: {},
part: {}, part: {},
@ -232,7 +232,7 @@ function loadBuildOrderAllocationTable(table, options={}) {
switchable: false, switchable: false,
title: '{% trans "Build Order" %}', title: '{% trans "Build Order" %}',
formatter: function(value, row) { formatter: function(value, row) {
var prefix = "{% settings_value 'BUILDORDER_REFERENCE_PREFIX' %}"; var prefix = global_settings.BUILDORDER_REFERENCE_PREFIX;
var ref = `${prefix}${row.build_detail.reference}`; var ref = `${prefix}${row.build_detail.reference}`;
@ -848,7 +848,7 @@ function loadBuildTable(table, options) {
switchable: true, switchable: true,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
var prefix = "{% settings_value 'BUILDORDER_REFERENCE_PREFIX' %}"; var prefix = global_settings.BUILDORDER_REFERENCE_PREFIX;
if (prefix) { if (prefix) {
value = `${prefix}${value}`; value = `${prefix}${value}`;

View File

@ -6,8 +6,6 @@
* Requires api.js to be loaded first * Requires api.js to be loaded first
*/ */
{% settings_value 'BARCODE_ENABLE' as barcodes %}
function stockStatusCodes() { function stockStatusCodes() {
return [ return [
{% for code in StockStatus.list %} {% for code in StockStatus.list %}
@ -1037,7 +1035,7 @@ function loadStockTable(table, options) {
if (row.purchase_order_reference) { if (row.purchase_order_reference) {
var prefix = '{% settings_value "PURCHASEORDER_REFERENCE_PREFIX" %}'; var prefix = global_settings.PURCHASEORDER_REFERENCE_PREFIX;
text = prefix + row.purchase_order_reference; text = prefix + row.purchase_order_reference;
} }
@ -1090,15 +1088,18 @@ function loadStockTable(table, options) {
} }
*/ */
var buttons = [
'#stock-print-options',
'#stock-options';
];
if (global_settings.BARCODE_ENABLE) {
buttons.push('#stock-barcode-options');
}
linkButtonsToSelection( linkButtonsToSelection(
table, table,
[ buttons,
'#stock-print-options',
{% if barcodes %}
'#stock-barcode-options',
{% endif %}
'#stock-options',
]
); );
@ -1138,7 +1139,7 @@ function loadStockTable(table, options) {
printTestReports(items); printTestReports(items);
}) })
{% if barcodes %} if (global_settings.BARCODE_ENABLE) {
$('#multi-item-barcode-scan-into-location').click(function() { $('#multi-item-barcode-scan-into-location').click(function() {
var selections = $('#stock-table').bootstrapTable('getSelections'); var selections = $('#stock-table').bootstrapTable('getSelections');
@ -1150,7 +1151,7 @@ function loadStockTable(table, options) {
scanItemsIntoLocation(items); scanItemsIntoLocation(items);
}); });
{% endif %} }
$('#multi-item-stocktake').click(function() { $('#multi-item-stocktake').click(function() {
stockAdjustment('count'); stockAdjustment('count');