diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index e09a08a0bb..b9dc4559f3 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -1642,6 +1642,16 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'default': True, 'validator': bool, }, + + 'TABLE_STRING_MAX_LENGTH': { + 'name': _('Table String Length'), + 'description': _('Maximimum length limit for strings displayed in table views'), + 'validator': [ + int, + MinValueValidator(0), + ], + 'default': 100, + } } typ = 'user' diff --git a/InvenTree/templates/InvenTree/settings/user_display.html b/InvenTree/templates/InvenTree/settings/user_display.html index 1e0b4a1ca3..136725b951 100644 --- a/InvenTree/templates/InvenTree/settings/user_display.html +++ b/InvenTree/templates/InvenTree/settings/user_display.html @@ -19,6 +19,7 @@ {% include "InvenTree/settings/setting.html" with key="FORMS_CLOSE_USING_ESCAPE" icon="fa-window-close" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="DISPLAY_SCHEDULE_TAB" icon="fa-calendar-alt" user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="TABLE_STRING_MAX_LENGTH" icon="fa-table" user_setting=True %} diff --git a/InvenTree/templates/js/translated/helpers.js b/InvenTree/templates/js/translated/helpers.js index edd12a4ac5..2a62bca027 100644 --- a/InvenTree/templates/js/translated/helpers.js +++ b/InvenTree/templates/js/translated/helpers.js @@ -45,10 +45,11 @@ function deleteButton(url, text='{% trans "Delete" %}') { */ function shortenString(input_string, options={}) { - var max_length = options.max_length || 100; + // Maximum length can be provided via options argument, or via a user-configurable setting + var max_length = options.max_length || user_settings.TABLE_STRING_MAX_LENGTH; - if (input_string == null) { - return null; + if (!max_length || !input_string) { + return input_string; } input_string = input_string.toString();