Skip to content

Commit

Permalink
Do not warn agents about empty article subjects by default (#88).
Browse files Browse the repository at this point in the history
  • Loading branch information
reneeb authored Jun 15, 2021
1 parent 42c5e42 commit d52b558
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
37 changes: 30 additions & 7 deletions Kernel/Modules/AgentTicketCompose.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1295,20 +1295,43 @@ 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},
Type => 'Small',
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');

Expand Down
25 changes: 25 additions & 0 deletions var/httpd/htdocs/js/Core.Agent.TicketCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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('<div class="MessageBox Notice" id="SubjectWarning"><p>' + Response.Message + '</div>');
}
}
});
}

Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');

return TargetNS;
Expand Down

0 comments on commit d52b558

Please sign in to comment.