Add user setting for configuring table string length (#3715)

This commit is contained in:
Oliver 2022-09-24 13:00:12 +10:00 committed by GitHub
parent 5a08ef908d
commit a7e4d27d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -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'

View File

@ -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 %}
</tbody>
</table>
</div>

View File

@ -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();