Skip to content

Commit

Permalink
Issue #1449: Send ActivityDialogID to server and handle processing in…
Browse files Browse the repository at this point in the history
… backend
  • Loading branch information
stefanhaerter committed Jan 24, 2022
1 parent e0de195 commit 7b37852
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
24 changes: 16 additions & 8 deletions Kernel/Modules/AgentDynamicFieldDBDetailedSearch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OTOBO is a web-based ticketing system for service organisations.
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# Copyright (C) 2019-2021 Rother OSS GmbH, https://otobo.de/
# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
# --
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -40,13 +40,19 @@ sub Run {
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');

# get params
for (qw(DynamicFieldName TicketID)) {
for (qw(DynamicFieldName TicketID ActivityDialogID)) {
$Param{$_} = $ParamObject->GetParam( Param => $_ );
}

# get the pure DynamicField name without prefix
my $DynamicFieldName = substr( $Param{DynamicFieldName}, 13 );

# if ActivityDialogID is set, strip it from DynamicFieldName
my $DynamicFieldNameLong = $DynamicFieldName;
if ( defined $Param{ActivityDialogID} && $Param{ActivityDialogID} != '' ) {
$DynamicFieldName = substr( $DynamicFieldName, 0, index( $DynamicFieldName, '_' . $Param{ActivityDialogID} ) );
}

# get the dynamic field value for the current ticket
my $DynamicFieldConfig = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(
Name => $DynamicFieldName,
Expand Down Expand Up @@ -127,16 +133,17 @@ sub Run {
$LayoutObject->Block(
Name => 'SearchResultAction',
Data => {
FieldName => $DynamicFieldName,
SearchParam => $SearchAttributeParameters,
TicketID => $Param{TicketID},
FieldName => $DynamicFieldNameLong,
ActivityDialogID => $Param{ActivityDialogID},
SearchParam => $SearchAttributeParameters,
TicketID => $Param{TicketID},
},
);

$LayoutObject->Block(
Name => 'SearchResult',
Data => {
DynamicFieldName => $DynamicFieldName,
DynamicFieldName => $DynamicFieldNameLong,
},
);

Expand Down Expand Up @@ -230,7 +237,8 @@ sub Run {
$LayoutObject->Block(
Name => 'SearchOverview',
Data => {
DynamicFieldName => $DynamicFieldName,
DynamicFieldName => $DynamicFieldNameLong,
ActivityDialogID => $Param{ActivityDialogID},
TicketID => $Param{TicketID},
},
);
Expand Down Expand Up @@ -339,7 +347,7 @@ sub Run {
TemplateFile => 'AgentDynamicFieldDBDetailedSearch',
Data => {
%Param,
DynamicFieldName => $DynamicFieldName,
DynamicFieldName => $DynamicFieldNameLong,
}
);
$Output .= $LayoutObject->Footer( Type => 'Small' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OTOBO is a web-based ticketing system for service organisations.
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# Copyright (C) 2019-2021 Rother OSS GmbH, https://otobo.de/
# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
# --
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand All @@ -22,7 +22,7 @@
<div class="Content">
<ul class="ActionList">
<li>
<a href="[% Env("Baselink") %]Action=CustomerDynamicFieldDBDetailedSearch;DynamicFieldName=DynamicField_[% Data.FieldName | html %];[% Data.SearchParam | html %]" class="CallForAction">
<a href="[% Env("Baselink") %]Action=CustomerDynamicFieldDBDetailedSearch;DynamicFieldName=DynamicField_[% Data.FieldName | html %];ActivityDialogID=[% Data.ActivityDialogID | html %];[% Data.SearchParam | html %]" class="CallForAction">
<span><i class="fa fa-caret-left"></i> [% Translate("Back") | html %]</span>
</a>
</li>
Expand Down
18 changes: 16 additions & 2 deletions var/httpd/htdocs/js/Core.Agent.DynamicFieldDBSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// OTOBO is a web-based ticketing system for service organisations.
// --
// Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
// Copyright (C) 2019-2021 Rother OSS GmbH, https://otobo.de/
// Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
// --
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -195,6 +195,16 @@ Core.Agent.DynamicFieldDBSearch = (function(TargetNS) {

if(isJQueryObject($Element)) {

# check if there exists an ActivityDialogEntityID input element exists and derive ActivityDialogID
# TODO Think about case when closest ActivityDialogEntityID element doesn't belong to current DynamicField
var ActivityDialogID = '';
var ActivityDialogElem = $('[name="ActivityDialogEntityID"]').closest('input');
if ( DynamicFieldName.indexOf(ActivityDialogElem.val().substr('ActivityDialog-'.length)) != -1 ) {

ActivityDialogID = ActivityDialogElem.val().substr('ActivityDialog-'.length);

}

// Get the ticket id.
/TicketID=(\d+)/.exec(document.URL);
TicketID = RegExp.$1;
Expand Down Expand Up @@ -265,6 +275,7 @@ Core.Agent.DynamicFieldDBSearch = (function(TargetNS) {
QueryString += ";Term="+encodeURIComponent(Request.term);
QueryString += ";MaxResults="+Core.Config.Get('Autocomplete.MaxResultsDisplayed');
QueryString += ";DynamicFieldName="+encodeURIComponent(DynamicFieldName);
QueryString += ";ActivityDialogID="+encodeURIComponent(ActivityDialogID);
QueryString += ";TicketID="+encodeURIComponent(TicketID);

URL = Core.Config.Get('Baselink');
Expand Down Expand Up @@ -350,6 +361,7 @@ Core.Agent.DynamicFieldDBSearch = (function(TargetNS) {
Data = {
Action: FrontendInterface,
DynamicFieldName: DynamicFieldName,
ActivityDialogID: ActivityDialogID,
Search: DynamicFieldName + 'Restore' + this,
Identifier: this,
TicketID: TicketID
Expand Down Expand Up @@ -552,6 +564,7 @@ Core.Agent.DynamicFieldDBSearch = (function(TargetNS) {
* @param {String} ElementValue The result element value.
* @param {String} IdentifierKey The ID of the DF
* @param {Boolean} Focus The parameter for focus element.
// Description seems to be wrong
* @description This function shows an alert dialog for duplicated entries.
*/
TargetNS.CheckMultiselect = function(Field, ElementValue, IdentifierKey, Focus){
Expand All @@ -573,7 +586,8 @@ Core.Agent.DynamicFieldDBSearch = (function(TargetNS) {
Data = {
Action: FrontendInterface,
Subaction: 'AJAXGetDynamicFieldConfig',
DynamicFieldName: Field
DynamicFieldName: Field,
ActivityDialogID: ActivityDialogID
};

Core.AJAX.FunctionCall(URL, Data, function (Response) {
Expand Down

0 comments on commit 7b37852

Please sign in to comment.