diff --git a/Kernel/Modules/AgentTicketCompose.pm b/Kernel/Modules/AgentTicketCompose.pm index 84a0a92eb4b..214f451c686 100644 --- a/Kernel/Modules/AgentTicketCompose.pm +++ b/Kernel/Modules/AgentTicketCompose.pm @@ -1295,6 +1295,36 @@ sub Run { NoCache => 1, ); } + elsif ( $Self->{Subaction} eq 'CheckSubject' ) { + + # Inform a user that article subject will be empty if contains only the ticket hook (if nothing is modified). + my $Message = $LayoutObject->{LanguageObject}->Translate( + 'Article subject will be empty if the subject contains only the ticket hook!' + ); + + my $Subject = $ParamObject->GetParam( Param => 'Subject' ); + + my $CleanedSubject = $TicketObject->TicketSubjectClean( + TicketNumber => $Ticket{TicketNumber}, + Subject => $Subject, + ); + + my $Empty = !length $CleanedSubject; + + my $JSON = $LayoutObject->JSONEncode( + Data => { + Empty => $Empty ? 1 : 0, + Message => $Message, + } + ); + + return $LayoutObject->Attachment( + ContentType => 'application/json; charset=' . $LayoutObject->{Charset}, + Content => $JSON, + Type => 'inline', + NoCache => 1, + ); + } else { my $Output = $LayoutObject->Header( Value => $Ticket{TicketNumber}, @@ -1302,13 +1332,6 @@ sub Run { BodyClass => 'Popup', ); - # Inform a user that article subject will be empty if contains only the ticket hook (if nothing is modified). - $Output .= $LayoutObject->Notify( - Data => $LayoutObject->{LanguageObject}->Translate( - 'Article subject will be empty if the subject contains only the ticket hook!' - ), - ); - # get std attachment object my $StdAttachmentObject = $Kernel::OM->Get('Kernel::System::StdAttachment'); diff --git a/var/httpd/htdocs/js/Core.Agent.TicketCompose.js b/var/httpd/htdocs/js/Core.Agent.TicketCompose.js index 49d1e8d8c38..0eca54a94cc 100644 --- a/var/httpd/htdocs/js/Core.Agent.TicketCompose.js +++ b/var/httpd/htdocs/js/Core.Agent.TicketCompose.js @@ -44,6 +44,10 @@ Core.Agent.TicketCompose = (function (TargetNS) { Core.AJAX.FormUpdate($('#ComposeTicket'), 'AJAXUpdate', 'StateID', Core.Config.Get('DynamicFieldNames')); }); + // check subject + CheckSubject(); + $('#Subject').on('change', CheckSubject); + // add 'To' customer users if (typeof EmailAddressesTo !== 'undefined') { EmailAddressesTo.forEach(function(ToCustomer) { @@ -68,6 +72,27 @@ Core.Agent.TicketCompose = (function (TargetNS) { } }; + function CheckSubject () { + var CurrentSubject = $('#Subject').val(); + $('#SubjectWarning').remove(); + + $.ajax({ + url: Core.Config.Get('Baselink'), + type: 'POST', + data: { + Action: Core.Config.Get('Action'), + Subaction: 'CheckSubject', + Subject: CurrentSubject, + TicketID: $('input[name=TicketID]').val(), + }, + success : function(Response) { + if (Response.Empty) { + $('#AppWrapper').prepend('

' + Response.Message + '

'); + } + } + }); + } + Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE'); return TargetNS;