Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable InputFields::ModernizedSelection::MaxNumberOfOptions. #576

Merged
merged 11 commits into from
Nov 1, 2024
7 changes: 7 additions & 0 deletions Kernel/Config/Files/XML/Framework.xml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,13 @@
<Item ValueType="String" ValueRegex="^[0-9]{1,5}$">6000</Item>
</Value>
</Setting>
<Setting Name="MaxDropdownOptions" Required="1" Valid="1">
<Description Translatable="1">Sets the maximum number of dropdown field values before the select layout will be changed for performance reasons.</Description>
<Navigation>Frontend::Base</Navigation>
<Value>
<Item ValueType="String" ValueRegex="^\d*$">1000</Item>
</Value>
</Setting>
dennykorsukewitz marked this conversation as resolved.
Show resolved Hide resolved
<Setting Name="Frontend::MenuDragDropEnabled" Required="1" Valid="1">
<Description Translatable="1">Turns on drag and drop for the main navigation.</Description>
<Navigation>Frontend::Base</Navigation>
Expand Down
2 changes: 2 additions & 0 deletions Kernel/Language/de.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5608,6 +5608,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.',
dennykorsukewitz marked this conversation as resolved.
Show resolved Hide resolved
'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).',
Expand Down
8 changes: 8 additions & 0 deletions Kernel/Output/HTML/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

dennykorsukewitz marked this conversation as resolved.
Show resolved Hide resolved
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions var/httpd/htdocs/js/Core.UI.InputFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
dennykorsukewitz marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand Down
Loading