From 9fb9161592ad65eb4cd639e172833e10c3bbb844 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 16 Oct 2023 09:00:12 +0200 Subject: [PATCH] wait #6398 @1 --- src/public/bunchmultiple/bunchmultiple.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/public/bunchmultiple/bunchmultiple.js b/src/public/bunchmultiple/bunchmultiple.js index 8c97c7a..4e3a970 100644 --- a/src/public/bunchmultiple/bunchmultiple.js +++ b/src/public/bunchmultiple/bunchmultiple.js @@ -119,7 +119,7 @@ resize: function () { this.element.find('.legendsize').each(function () { var parent = $(this).closest('.legend'); - var aw = $(parent).innerWidth() - 100; + var aw = $(parent).innerWidth() - 160; $(this).css({width: aw, maxWidth: aw, minWidth: aw}); }); }, @@ -174,18 +174,24 @@ }, updateLegends: function () { + const sizeLimit = 60; $('[data-legend]' + this.bmidselector).each(function () { var item = $(this).closest('.item'); var form = item.find('.subform'); var txt = $(this).data('legend').replace(/\%([a-zA-Z0-9_]+)/gm, function (match, varname) { - var input = form.find('[name="' + varname + '"]'); - if (input.length === 0) { input = form.find('[name="' + form.data('bmid') + '___' + varname + '"]'); } - var res = $(input).val(); - + // All fields + let res = $(input).val(); + // Select2 fields + if ($(input).closest('.form-group').find('.select2-selection__rendered').length > 0) { + res = $(input).closest('.form-group').find('.select2-selection__rendered').text(); + } + if (res.length > sizeLimit) { + res = res.substring(0, sizeLimit) + '...'; + } return res; }); $(this).html(txt); -- 2.39.5