Skip to content

Commit

Permalink
Configurable MaxNumberOfOptions znuny#575
Browse files Browse the repository at this point in the history
  • Loading branch information
itweserems committed Jun 27, 2024
1 parent ad36fe5 commit 1ab41a6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
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>
<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 @@ -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).',
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,
);

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) {
return;
}

Expand Down

0 comments on commit 1ab41a6

Please sign in to comment.