]> _ Git - cubist_cms-back.git/commitdiff
wait #6398 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Oct 2023 07:00:12 +0000 (09:00 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Oct 2023 07:00:12 +0000 (09:00 +0200)
src/public/bunchmultiple/bunchmultiple.js

index 8c97c7a2654cd051a9ce493ba9714ce73496f93f..4e3a97020afb6f755e67168c00c5e1a7173aa776 100644 (file)
         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});
             });
         },
         },
 
         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);