From 1ab41a60d2a1e9c624ef53470d530f47c0eddcf7 Mon Sep 17 00:00:00 2001 From: itweserems Date: Thu, 27 Jun 2024 13:09:04 +0200 Subject: [PATCH] Configurable MaxNumberOfOptions #575 --- Kernel/Config/Files/XML/Framework.xml | 7 +++++++ Kernel/Language/de.pm | 2 ++ Kernel/Output/HTML/Layout.pm | 8 ++++++++ var/httpd/htdocs/js/Core.UI.InputFields.js | 4 ++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Kernel/Config/Files/XML/Framework.xml b/Kernel/Config/Files/XML/Framework.xml index a04063da9bd..9394dcbc7ff 100644 --- a/Kernel/Config/Files/XML/Framework.xml +++ b/Kernel/Config/Files/XML/Framework.xml @@ -550,6 +550,13 @@ 6000 + + Sets the maximum number of dropdown field values before the select layout will be changed for performance reasons. + Frontend::Base + + 1000 + + Turns on drag and drop for the main navigation. Frontend::Base diff --git a/Kernel/Language/de.pm b/Kernel/Language/de.pm index 6571f66723f..a65e23cae21 100644 --- a/Kernel/Language/de.pm +++ b/Kernel/Language/de.pm @@ -5636,6 +5636,8 @@ sub Data { 'Automatischer Zeilenumbruch in Textnachrichten nach x-Zeichen.', 'Sets the number of lines that are displayed in text messages (e.g. ticket lines in the QueueZoom).' => 'Legt die Anzahl an Zeilen fest, die von Textnachrichten angezeigt werden sollen (z. B. von Tickets in der Queue-Ansicht).', + 'Sets the maximum number of dropdown field values before the select layout will be changed for performance reasons.' => + 'Legt die maximale Anzahl an Werten fest, bevor das Auswahlfeld-Layout zu Performancezwecken geändert wird.', 'Turns on drag and drop for the main navigation.' => 'Aktiviert Drag und Drop für die Hauptnavigation.', 'Defines the date input format used in forms (option or input fields).' => 'Definiert das benutzte Datumseingabeformat in Formularen (Option für Eingabefelder).', diff --git a/Kernel/Output/HTML/Layout.pm b/Kernel/Output/HTML/Layout.pm index 5bf587c527e..018314f861b 100644 --- a/Kernel/Output/HTML/Layout.pm +++ b/Kernel/Output/HTML/Layout.pm @@ -508,6 +508,14 @@ sub Block { Data => $Param{Data}, }; + # For performance reasons: + # Do not initialize modern inputfields on selects with many entries + my $MaxDropdownOptions = $Kernel::OM->Get('Kernel::Config')->Get("MaxDropdownOptions"); + $Self->AddJSData( + Key => 'MaxDropdownOptions', + Value => $MaxDropdownOptions, + ); + return 1; } diff --git a/var/httpd/htdocs/js/Core.UI.InputFields.js b/var/httpd/htdocs/js/Core.UI.InputFields.js index fa8fd7220d7..8ffc548acdc 100644 --- a/var/httpd/htdocs/js/Core.UI.InputFields.js +++ b/var/httpd/htdocs/js/Core.UI.InputFields.js @@ -40,7 +40,6 @@ Core.UI.InputFields = (function (TargetNS) { ResizeEvent: 'onorientationchange' in window ? 'orientationchange' : 'resize', ResizeTimeout: 0, SafeMargin: 30, - MaxNumberOfOptions: 1000, MinQueryLength: 4, Diacritics: { "\u24B6":"A", "\uFF21":"A", "\u00C0":"A", "\u00C1":"A", "\u00C2":"A", "\u1EA6":"A", @@ -1189,7 +1188,8 @@ Core.UI.InputFields = (function (TargetNS) { // For performance reasons: // Do not initialize modern inputfields on selects with many entries - if ($(SelectObj).children('option').length > Config.MaxNumberOfOptions) { + MaxDropdownOptions = Core.Config.Get('MaxDropdownOptions'); + if ($(SelectObj).children('option').length > MaxDropdownOptions) { return; }