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

Sector Nord AG: New feature - Refactor of search function to allow multi-page search #534

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Kernel/Modules/AdminDynamicField.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ sub _ShowOverview {
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
my $FieldTypeConfig = $ConfigObject->Get('DynamicFields::Driver');
my $Search = $ParamObject->GetParam( Param => 'Search' ) || '';

my $Output = $LayoutObject->Header();
$Output .= $LayoutObject->NavigationBar();
Expand Down Expand Up @@ -249,6 +251,7 @@ sub _ShowOverview {
# print the list of dynamic fields
$Self->_DynamicFieldsListShow(
DynamicFields => $DynamicFieldsList,
Search => $Search,
Total => scalar @{$DynamicFieldsList},
);

Expand Down Expand Up @@ -281,6 +284,16 @@ sub _DynamicFieldsListShow {
my $PageShown = $Self->{$PageShownPreferencesKey} || 35;
my $Group = 'DynamicFieldsOverviewPageShown';

# retrieve list of dynamic field IDs based on the search criteria
my @DynamicFields = @{$Param{DynamicFields}};
my $SearchLink;
if ($Self->{Subaction} eq 'Search' || $Param{Search} ne '') {
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
@DynamicFields = grep { $DynamicFieldObject->DynamicFieldGet( ID => $_ )->{Name} =~ /\Q$Param{Search}\E/i } @{ $Param{DynamicFields} };
}

# limit amount of hits dependent on situation
my $AllHits = scalar @DynamicFields;
# get data selection
my %Data;
my $Config = $ConfigObject->Get('PreferencesGroups');
Expand All @@ -300,9 +313,9 @@ sub _DynamicFieldsListShow {
Limit => $Limit,
StartHit => $StartHit,
PageShown => $PageShown,
AllHits => $Param{Total} || 0,
AllHits => $AllHits || 0,
Action => 'Action=' . $LayoutObject->{Action},
Link => $Param{LinkPage},
Link => $SearchLink,
IDPrefix => $LayoutObject->{Action},
);

Expand Down Expand Up @@ -332,13 +345,13 @@ sub _DynamicFieldsListShow {
}

# check if at least 1 dynamic field is registered in the system
if ( $Param{Total} ) {
if ( $AllHits > 0 ) {

# get dynamic fields details
my $Counter = 0;

DYNAMICFIELDID:
for my $DynamicFieldID ( @{ $Param{DynamicFields} } ) {
for my $DynamicFieldID ( @DynamicFields ) {
$Counter++;
if ( $Counter >= $StartHit && $Counter < ( $PageShown + $StartHit ) ) {

Expand Down Expand Up @@ -405,7 +418,7 @@ sub _DynamicFieldsListShow {
$LayoutObject->Block(
Name => 'MaxFieldOrder',
Data => {
MaxFieldOrder => scalar @{ $Param{DynamicFields} },
MaxFieldOrder => scalar @DynamicFields,
},
);

Expand Down
7 changes: 6 additions & 1 deletion Kernel/Output/HTML/Templates/Standard/AdminDynamicField.tt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
<h2><label for="FilterDynamicFields">[% Translate("Filter for Dynamic Fields") | html %]</label></h2>
</div>
<div class="Content">
<input type="text" id="FilterDynamicFields" class="FilterBox" placeholder="[% Translate("Just start typing to filter...") | html %]" name="FilterDynamicFields" value="" title="[% Translate("Filter for dynamic fields") | html %]">
<form class="SearchBox" action="[% Env("CGIHandle") %]" method="post">
<i class="fa fa-search"></i>
<input type="hidden" name="Action" value="[% Env("Action") %]"/>
<input type="hidden" name="Subaction" value="Search"/>
<input type="text" name="Search" value="[% Data.Search | html %]" id="Search" title="[% Translate("Search") | html %]"/>
</form>
</div>
</div>
[% RenderBlockStart("Hint") %]
Expand Down
3 changes: 0 additions & 3 deletions var/httpd/htdocs/js/Core.Agent.Admin.DynamicField.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ Core.Agent.Admin.DynamicField = (function (TargetNS) {
TargetNS.ShowContextSettingsDialog();
TargetNS.DynamicFieldDelete();

// Initialize dynamic field filter
Core.UI.Table.InitTableFilter($('#FilterDynamicFields'), $('#DynamicFieldsTable'));

Core.Config.Set('EntityType', 'DynamicField');

};
Expand Down
Loading