diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index fb9f422b67..69a4c5460d 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -938,7 +938,7 @@ function getFormFieldElement(name, options) { /* * Check that a "numerical" input field has a valid number in it. * An invalid number is expunged at the client side by the getFormFieldValue() function, - * which means that an empty string '' is sent to the server if the number is not valud. + * which means that an empty string '' is sent to the server if the number is not valid. * This can result in confusing error messages displayed under the form field. * * So, we can invalid numbers and display errors *before* the form is submitted! @@ -947,7 +947,8 @@ function validateFormField(name, options) { if (getFormFieldElement(name, options)) { - var el = document.getElementById(`id_${name}`); + var field_name = getFieldName(name, options); + var el = document.getElementById(`id_${field_name}`); if (el.validity.valueMissing) { // Accept empty strings (server will validate) diff --git a/InvenTree/templates/js/translated/model_renderers.js b/InvenTree/templates/js/translated/model_renderers.js index 7be7c2d656..5f3d9e8279 100644 --- a/InvenTree/templates/js/translated/model_renderers.js +++ b/InvenTree/templates/js/translated/model_renderers.js @@ -31,6 +31,18 @@ */ +/* + * Trim the supplied string to ensure the string length is limited to the provided value + */ +function trim(data, max_length=100) { + if (data.length > max_length) { + data = data.slice(0, max_length - 3) + '...'; + } + + return data; +} + + // Should the ID be rendered for this string function renderId(title, pk, parameters={}) { @@ -55,7 +67,7 @@ function renderCompany(name, data, parameters={}, options={}) { var html = select2Thumbnail(data.image); - html += `${data.name} - ${data.description}`; + html += `${data.name} - ${trim(data.description)}`; html += renderId('{% trans "Company ID" %}', data.pk, parameters); @@ -141,7 +153,7 @@ function renderStockLocation(name, data, parameters={}, options={}) { } if (render_description && data.description) { - html += ` - ${data.description}`; + html += ` - ${trim(data.description)}`; } html += renderId('{% trans "Location ID" %}', data.pk, parameters); @@ -177,7 +189,7 @@ function renderPart(name, data, parameters={}, options={}) { html += ` ${data.full_name || data.name}`; if (data.description) { - html += ` - ${data.description}`; + html += ` - ${trim(data.description)}`; } var stock_data = ''; @@ -256,7 +268,7 @@ function renderPurchaseOrder(name, data, parameters={}, options={}) { } if (data.description) { - html += ` - ${data.description}`; + html += ` - ${trim(data.description)}`; } html += renderId('{% trans "Order ID" %}', data.pk, parameters); @@ -282,7 +294,7 @@ function renderSalesOrder(name, data, parameters={}, options={}) { } if (data.description) { - html += ` - ${data.description}`; + html += ` - ${trim(data.description)}`; } html += renderId('{% trans "Order ID" %}', data.pk, parameters); @@ -319,7 +331,7 @@ function renderPartCategory(name, data, parameters={}, options={}) { var html = `${level}${data.pathstring}`; if (data.description) { - html += ` - ${data.description}`; + html += ` - ${trim(data.description)}`; } html += renderId('{% trans "Category ID" %}', data.pk, parameters);