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

Show parameters of transition actions #1565

Merged
Merged
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
11 changes: 11 additions & 0 deletions Kernel/Config/Files/XML/ProcessManagement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
<Item Key="JavaScript">
<Array>
<Item>Core.Agent.Admin.ProcessManagement.js</Item>
<Item>Core.Agent.Admin.ProcessManagement.TransitionActionParameters.js</Item>
</Array>
</Item>
</Hash>
Expand Down Expand Up @@ -646,4 +647,14 @@
</Item>
</Value>
</Setting>
<Setting Name="TransitionActionParams::SetOptionalParameters" Required="0" Valid="1">
<Description Translatable="1">
Show optional parameters in parameter list, too. If disabled, the optional parameters are only shown
in an extra table
</Description>
<Navigation>Frontend::Admin::View::AdminProcessManagement</Navigation>
<Value>
<Item ValueType="Checkbox">1</Item>
</Value>
</Setting>
</otobo_config>
48 changes: 48 additions & 0 deletions Kernel/Modules/AdminProcessManagementTransitionAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ sub Run {
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
my $EntityObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::DB::Entity');
my $TransitionActionObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::DB::TransitionAction');
my $MainObject = $Kernel::OM->Get('Kernel::System::Main');
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');

# ------------------------------------------------------------ #
# TransitionActionNew
Expand Down Expand Up @@ -429,6 +431,52 @@ sub Run {
);
}

# ------------------------------------------------------------ #
# Get parameters of transition action module
# ------------------------------------------------------------ #
elsif ( $Self->{Subaction} eq 'ActionParams' ) {
my $TransAction = $ParamObject->GetParam( Param => 'TransitionAction' );
my $ModuleOrig = ( split /::/, $TransAction // '' )[-1];
my $Module = $ModuleOrig =~ s{[^A-Za-z1-2]}{}gr;
my $Class = sprintf "Kernel::System::ProcessManagement::TransitionAction::%s",
$Module || 'ThisModuleLikelyDoesntExistInThisInstallation';

my $ClassExists = $MainObject->Require(
$Class,
Silent => 1,
);

my @ModuleParams;

if ( $Module && $Module eq $ModuleOrig && $ClassExists ) {
my $Object = $Kernel::OM->Get($Class);

if ( $Object->can('Params') ) {
@ModuleParams = $Object->Params();

for my $Param ( @ModuleParams ) {
$Param{Value} = $LayoutObject->{LanguageObject}->Translate( $Param{Value} );
}
}
}

my $Optionals = $ConfigObject->Get('TransitionActionParams::SetOptionalParameters') // '';

my $JSON = $LayoutObject->JSONEncode(
Data => {
Params => \@ModuleParams,
NoOptionals => ( $Optionals ? 0 : 1 ),
},
);

return $LayoutObject->Attachment(
ContentType => 'application/json; charset=' . $LayoutObject->{Charset},
Content => $JSON,
Type => 'inline',
NoCache => 1,
);
}

# ------------------------------------------------------------ #
# Error
# ------------------------------------------------------------ #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ sub new {
return $Self;
}

=head2 Params()

Returns the configuration params for this transition action module

my @Params = $Object->Params();

Each element is a hashreference that describes the config parameter.
Currently only the keys I<Key>, I<Value> and I<Optional> are used.

=cut

sub Params {
my ($Self) = @_;

my @Params = (
{
Key => 'Fieldname (replace with the real fieldname)',
Value => 'New value (required)',
},
{
Key => 'UserID',
Value => '1 (can overwrite the logged in user)',
Optional => 1,
},
);

return @Params;
}

=head2 Run()

Run Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,83 @@ sub new {
return $Self;
}

=head2 Params()

Returns the configuration params for this transition action module

my @Params = $Object->Params();

Each element is a hashreference that describes the config parameter.
Currently only the keys I<Key>, I<Value> and I<Optional> are used.

=cut

sub Params {
my ($Self) = @_;

my @Params = (
{
Key => 'CommunicationChannel',
Value => 'Email|Phone|Internal (required)',
},
{
Key => 'From',
Value => 'agent@example.tld',
Optional => 1,
},
{
Key => 'To',
Value => 'customer@example.tld',
Optional => 1,
},
{
Key => 'Subject',
Value => 'A subject (required)',
},
{
Key => 'Body',
Value => 'A text for the article (required)',
},
{
Key => 'ContentType',
Value => 'text/html; charset=utf-8 (required)',
},
{
Key => 'IsVisibleForCustomer',
Value => '0|1 (required)',
},
{
Key => 'DynamicField_<Name> (replace <Name>)',
Value => 'A value',
Optional => 1,
},
{
Key => 'HistoryType',
Value => 'EmailCustomer|AddNote|WebRequestCustomer|... (required)',
},
{
Key => 'HistoryComment',
Value => 'Article created (required)',
},
{
Key => 'SenderType',
Value => 'agent|customer|system (required)',
},
{
Key => 'UnlockOnAway',
Value => '0|1',
Optional => 1,
},
{
Key => 'UserID',
Value => '1 (can overwrite the logged in user)',
Optional => 1,
},
);

return @Params;
}

=head2 Run()

Run Data
Expand Down
156 changes: 156 additions & 0 deletions Kernel/System/ProcessManagement/TransitionAction/TicketCreate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,162 @@ sub new {
return $Self;
}

=head2 Params()

Returns the configuration params for this transition action module

my @Params = $Object->Params();

Each element is a hashreference that describes the config parameter.
Currently only the keys I<Key>, I<Value> and I<Optional> are used.

=cut

sub Params {
my ($Self) = @_;

my @Params = (
{
Key => 'Title',
Value => 'A title (required)',
},
{
Key => 'CommunicationChannel',
Value => 'Email|Phone|Internal (required)',
},
{
Key => 'From',
Value => 'agent@example.tld',
Optional => 1,
},
{
Key => 'To',
Value => 'customer@example.tld',
Optional => 1,
},
{
Key => 'Subject',
Value => 'A subject (required)',
},
{
Key => 'Body',
Value => 'A text for the article (required)',
},
{
Key => 'ContentType',
Value => 'text/html; charset=utf-8 (required)',
},
{
Key => 'CustomerID',
Value => '12345',
Optional => 1,
},
{
Key => 'CustomerUser',
Value => 'customer@example.tld',
Optional => 1,
},
{
Key => 'IsVisibleForCustomer',
Value => '0|1 (required)',
},
{
Key => 'DynamicField_<Name> (replace <Name>)',
Value => 'A value',
Optional => 1,
},
{
Key => 'Attachments',
Value => '...',
Optional => 1,
},
{
Key => 'State',
Value => 'open (required)',
},
{
Key => 'Lock',
Value => 'lock|unlock (required)',
},
{
Key => 'Owner',
Value => 'ownerlogin (required)',
},
{
Key => 'Priority',
Value => '3 normal (required)',
},
{
Key => 'Queue',
Value => 'Misc (required)',
},
{
Key => 'Type',
Value => 'A type',
Optional => 1,
},
{
Key => 'Service',
Value => 'ServiceName',
Optional => 1,
},
{
Key => 'SLA',
Value => 'SLA-Name',
Optional => 1,
},
{
Key => 'Responsible',
Value => 'responsiblelogin',
Optional => 1,
},
{
Key => 'TimeUnit',
Value => 'responsiblelogin',
Optional => 1,
},
{
Key => 'HistoryType',
Value => 'EmailCustomer|AddNote|WebRequestCustomer|... (required)',
},
{
Key => 'HistoryComment',
Value => 'Article created (required)',
},
{
Key => 'SenderType',
Value => 'agent|customer|system (required)',
},
{
Key => 'PendingTime',
Value => '2022-19-21 14:25:00',
Optional => 1,
},
{
Key => 'PendingTimeDiff',
Value => 'diff in minutes',
Optional => 1,
},
{
Key => 'LinkAs',
Value => 'Normal|Parent|Child|...',
Optional => 1,
},
{
Key => 'ArchiveFlag',
Value => 'y|n',
Optional => 1,
},
{
Key => 'UserID',
Value => '1 (can overwrite the logged in user)',
Optional => 1,
},
);

return @Params;
}

=head2 Run()

Run Data
Expand Down
Loading