[Rt-commit] rt 04/04: Allow history filtering on ticket pages
craig kaiser
craig at bestpractical.com
Fri Jul 30 15:09:54 UTC 2021
This is an automated email from the git hooks/post-receive script.
craig pushed a commit to branch 5.0/core-history-filter
in repository rt.
commit ba49ff215b8ae8fb093672eda393d38b10ce8e86
Author: craig kaiser <craig at bestpractical.com>
AuthorDate: Wed Jul 14 13:04:25 2021 -0400
Allow history filtering on ticket pages
---
share/html/Elements/ShowHistoryHeader | 33 ++++++++++++++++++++++++++++
share/html/Elements/ShowHistoryPage | 7 +++++-
share/html/Helpers/TicketHistory | 1 +
share/html/Helpers/TicketHistoryPage | 1 +
share/html/Ticket/Display.html | 6 ++++-
share/html/Ticket/Elements/ScrollShowHistory | 1 +
share/html/Ticket/History.html | 3 ++-
7 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/share/html/Elements/ShowHistoryHeader b/share/html/Elements/ShowHistoryHeader
index 1fc930f342..d48c6e2466 100644
--- a/share/html/Elements/ShowHistoryHeader
+++ b/share/html/Elements/ShowHistoryHeader
@@ -52,6 +52,7 @@ $ShowTitle => 1
$ShowDisplayModes => 1
$ScrollShowHistory => 0
$SingleTransaction => 0
+ at HistoryFilter => ()
</%ARGS>
<%INIT>
my $record_type = $Object->RecordType;
@@ -67,6 +68,11 @@ else {
# Oldest Txns first is ASC, so reverse it for this option default
$reverse_txns = RT->Config->Get("OldestTransactionsFirst", $session{'CurrentUser'}) ? 'DESC' : 'ASC';
}
+
+# If we do not have a page HistoryFilter arg, check queue config
+if ( !@HistoryFilter && $Object->isa('RT::Ticket') && $Object->QueueObj->FirstAttribute( 'HistoryFilter' ) ) {
+ @HistoryFilter = @{$Object->QueueObj->FirstAttribute( 'HistoryFilter' )->Content};
+}
</%INIT>
<div class="history <% lc $record_type %>" id="<% $histid %>">
<%perl>
@@ -128,6 +134,33 @@ if ( $ShowDisplayModes or $ShowTitle or $ScrollShowHistory ) {
$titleright .= q{</ul></div>};
}
+ my @types = RT->Config->Get( 'HistoryFilterTypes' );
+ my $history_filter = q{
+ <ul class="dropdown-menu dropdown-menu-right">
+ <li>
+ <form class="m-2" action="}.RT->Config->Get('WebPath').q{">
+ <input type="hidden" name="id" value="}.$Object->Id.q{">
+ };
+
+ # Use counting variable for checkbox ID incase a transaction type has a space
+ my $i = 1;
+ foreach my $type ( @types ) {
+ my $checked = grep {$_ eq $type} @HistoryFilter, ? 'checked="checked"' : '';
+
+ $history_filter .= qq{
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" id="HistoryFilter-$i" name="HistoryFilter" $checked value="$type" class="custom-control-input">
+ <label class="custom-control-label" for="HistoryFilter-$i">}.loc($type).q{</label>
+ </div>};
+ $i = $i + 1;
+ }
+
+ $history_filter .= q{
+ <input type="submit" class="button btn btn-primary" value="}.loc('Filter').q{">
+ </li></form></ul>};
+
+ $titleright .= qq{<div class="btn-group dropdown"><a href="#" id="history-filter" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="fas fa-filter icon-bordered fa-2x" alt="Filter History" data-toggle="tooltip" data-placement="top" data-original-title="Filter History"></span></a>$history_filter</div>};
+
</%perl>
% $m->callback( CallbackName => 'BeforeTitle', %ARGS, title => \$title, titleright => \$titleright, ARGSRef => \%ARGS );
<& /Widgets/TitleBoxStart, title => $title, titleright_raw => $titleright, class => 'fullwidth' &>
diff --git a/share/html/Elements/ShowHistoryPage b/share/html/Elements/ShowHistoryPage
index 8184dbbd7b..6f881bc5c9 100644
--- a/share/html/Elements/ShowHistoryPage
+++ b/share/html/Elements/ShowHistoryPage
@@ -54,6 +54,8 @@ $AttachmentContent => $Object->TextAttachments
$ShowHeaders => 0
$PathPrefix => ''
+
+ at HistoryFilter => ()
</%ARGS>
<%INIT>
my $trans_content = {};
@@ -128,7 +130,10 @@ while ( my $Transaction = $Transactions->Next ) {
and RT::Config->Get('SelfServiceCorrespondenceOnly')
and ($Transaction->Type ne "Correspond" && $Transaction->Type ne "Create");
- if ( $Object->isa('RT::Ticket') && $Object->QueueObj->FirstAttribute( 'HistoryFilter' ) ) {
+ if ( scalar @HistoryFilter ) {
+ $skip = 1 if not grep {$_ eq $Transaction->Type} @{HistoryFilter};
+ }
+ elsif ( $Object->isa('RT::Ticket') && $Object->QueueObj->FirstAttribute( 'HistoryFilter' ) ) {
my $filter_types = $Object->QueueObj->FirstAttribute( 'HistoryFilter' )->Content;
$skip = 1 if not grep {$_ eq $Transaction->Type} @{$filter_types};
diff --git a/share/html/Helpers/TicketHistory b/share/html/Helpers/TicketHistory
index 778d2e8c7a..6aafacab72 100644
--- a/share/html/Helpers/TicketHistory
+++ b/share/html/Helpers/TicketHistory
@@ -63,6 +63,7 @@ $m->callback( CallbackName => 'ExtraShowHistoryArguments', Ticket => $TicketObj,
ReverseTxns => $ARGS{'ReverseTxns'},
Attachments => $attachments,
AttachmentContent => $attachment_content,
+ HistoryFilter => $ARGS{'HistoryFilter'},
%extra_args,
&>
<script type="text/javascript">ReplaceUserReferences()</script>
diff --git a/share/html/Helpers/TicketHistoryPage b/share/html/Helpers/TicketHistoryPage
index f67baf80c8..c3f025fef6 100644
--- a/share/html/Helpers/TicketHistoryPage
+++ b/share/html/Helpers/TicketHistoryPage
@@ -91,6 +91,7 @@ if ($focusTransactionId) { # make sure we load enough if we need to focus a tran
<& /Elements/ShowHistoryPage,
Object => $TicketObj,
ShowHeaders => $ARGS{'ShowHeaders'},
+ HistoryFilter => $ARGS{'HistoryFilter'},
Transactions => $transactions,
%extra_args,
&>
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 87883d5419..1d0d662c3e 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -98,18 +98,21 @@ my $titleright = qq{
Ticket => $TicketObj,
ShowHeaders => $ARGS{'ShowHeaders'},
ReverseTxns => $ARGS{'ReverseTxns'},
+ HistoryFilter => $ARGS{'HistoryFilter'}
&>
% } elsif ($ShowHistory eq "delay") {
<& /Ticket/Elements/DelayShowHistory,
Ticket => $TicketObj,
ShowHeaders => $ARGS{'ShowHeaders'},
ReverseTxns => $ARGS{'ReverseTxns'},
+ HistoryFilter => $ARGS{'HistoryFilter'}
&>
% } elsif (not $ForceShowHistory and $ShowHistory eq "click") {
<& /Ticket/Elements/ClickToShowHistory,
Ticket => $TicketObj,
ShowHeaders => $ARGS{'ShowHeaders'},
ReverseTxns => $ARGS{'ReverseTxns'},
+ HistoryFilter => $ARGS{'HistoryFilter'}
&>
% } else {
<& /Elements/ShowHistory ,
@@ -118,7 +121,8 @@ my $titleright = qq{
ShowHeaders => $ARGS{'ShowHeaders'},
ReverseTxns => $ARGS{'ReverseTxns'},
Attachments => $attachments,
- AttachmentContent => $attachment_content
+ AttachmentContent => $attachment_content,
+ HistoryFilter => $ARGS{'HistoryFilter'}
&>
% }
diff --git a/share/html/Ticket/Elements/ScrollShowHistory b/share/html/Ticket/Elements/ScrollShowHistory
index 6a676ad9a6..149aae2e7c 100644
--- a/share/html/Ticket/Elements/ScrollShowHistory
+++ b/share/html/Ticket/Elements/ScrollShowHistory
@@ -59,6 +59,7 @@ my $url = RT->Config->Get('WebPath') . "/Helpers/TicketHistoryPage?" .
my %extra_args = map { $_ => $ARGS{$_} // 1 } qw/ShowDisplayModes ShowTitle ScrollShowHistory/;
$extra_args{ShowHeaders} = $ARGS{ShowHeaders};
$extra_args{ReverseTxns} = $ARGS{ReverseTxns};
+$extra_args{HistoryFilter} = $ARGS{HistoryFilter};
$m->callback( CallbackName => 'ExtraShowHistoryArguments', Ticket => $Ticket, ExtraArgs => \%extra_args );
diff --git a/share/html/Ticket/History.html b/share/html/Ticket/History.html
index 3ed3314d26..e27a10228b 100644
--- a/share/html/Ticket/History.html
+++ b/share/html/Ticket/History.html
@@ -55,7 +55,8 @@
ShowHeaders => $ARGS{'ShowHeaders'},
Attachments => $attachments,
AttachmentContent => $attachment_content,
- &>
+ HistoryFilter => $ARGS{'HistoryFilter'} || []
+ &>
% $m->callback( %ARGS, CallbackName => 'AfterShowHistory', Ticket => $Ticket );
--
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.
More information about the rt-commit
mailing list