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

Do not warn agents about empty article subjects by default (#88). #88

Merged
merged 3 commits into from
Jun 15, 2021
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
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