Skip to content

Commit

Permalink
Added configurable InputFields::ModernizedSelection::MaxNumberOfOptio…
Browse files Browse the repository at this point in the history
…ns. (#576)

* Configurable MaxNumberOfOptions #575

* Update Kernel/Output/HTML/Layout.pm

* Update Kernel/Language/de.pm

* Update Kernel/Config/Files/XML/Framework.xml

* Update var/httpd/htdocs/js/Core.UI.InputFields.js

---------

Co-authored-by: Denny Korsukéwitz <[email protected]>
  • Loading branch information
itweserems and dennykorsukewitz authored Nov 1, 2024
1 parent a3e3855 commit cd5b268
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="InputFields::ModernizedSelection::MaxNumberOfOptions" Required="1" Valid="1">
<Description Translatable="1">Limits the number of options for modernized selection fields. If this limit will be exceeded, the selection field will for performance reasons be shown as non-modernized.</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 @@ -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).',
'Limits the number of options for modernized selection fields. If this limit will be exceeded, the selection field will for performance reasons be shown as non-modernized.' =>
'Limitiert die Anzahl an Optionen für modernized Auswahlfelder. Wenn das Limit überschritten ist, wird das Auswahlfeld aus Performancegründen als nicht-modernized angezeigt.',
'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 modernized input fields on selections with many entries
my $MaxNumberOfOptions = $Kernel::OM->Get('Kernel::Config')->Get("InputFields::ModernizedSelection::MaxNumberOfOptions");
$Self->AddJSData(
Key => 'InputFields::ModernizedSelection::MaxNumberOfOptions',
Value => $MaxNumberOfOptions,
);

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) {
MaxNumberOfOptions = Core.Config.Get('InputFields::ModernizedSelection::MaxNumberOfOptions');
if ($(SelectObj).children('option').length > MaxNumberOfOptions) {
return;
}

Expand Down

0 comments on commit cd5b268

Please sign in to comment.