[Rt-commit] rt 02/04: Implement queue level filtering of ticket history

craig kaiser craig at bestpractical.com
Fri Jul 30 16:21: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 417f5d664f20203be82b7074c064f1646ae334ae
Author: craig kaiser <craig at bestpractical.com>
AuthorDate: Mon Jul 12 11:26:54 2021 -0400

    Implement queue level filtering of ticket history
---
 share/html/Admin/Elements/EditHistoryFilter | 31 +++++++++++++++++++++++++++++
 share/html/Admin/Queues/Modify.html         | 25 +++++++++++++++++++++++
 share/html/Elements/ShowHistoryPage         |  6 ++++++
 3 files changed, 62 insertions(+)

diff --git a/share/html/Admin/Elements/EditHistoryFilter b/share/html/Admin/Elements/EditHistoryFilter
new file mode 100644
index 0000000000..52d0ea969a
--- /dev/null
+++ b/share/html/Admin/Elements/EditHistoryFilter
@@ -0,0 +1,31 @@
+<input type='hidden' name='HistoryFilter-Magic' value=1>
+
+<div class="form-row">
+  <div class="label col-3">
+    <&|/l&>History Filter</&>:
+  </div>
+  <div class="value col-9">
+    <select name="HistoryFilter" class="selectpicker form-control" multiple>
+%     foreach my $type ( @options ) {
+%         my $selected = '';
+%         $selected = 'selected="selected"' if grep {$_ eq $type} @{$default};
+
+          <option <% $selected |n %> value="<% $type %>"><% loc( $type ) %></option>
+%     }
+    </select>
+  </div>
+</div>
+
+<%INIT>
+return unless $QueueObj;
+
+my $queue_attribute = $QueueObj->FirstAttribute( 'HistoryFilter' );
+my $default = $queue_attribute ? $queue_attribute->Content : [];
+
+my @options = RT->Config->Get( 'HistoryFilterTypes' );
+</%INIT>
+
+<%ARGS>
+$QueueObj      => undef
+ at HistoryFilter => ()
+</%ARGS>
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index e9e859632e..5301027eb0 100644
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -239,6 +239,12 @@
   </div>
 % }
 
+  <div class="form-row">
+    <div class="col-12"> <% # colspan=4 %>
+      <& /Admin/Elements/EditHistoryFilter, QueueObj => $QueueObj, %ARGS &>
+    </div>
+  </div>
+
 </&>
   <div class="form-row">
     <div class="col-12">
@@ -325,6 +331,24 @@ if ( $QueueObj->Id ) {
     if ( !$QueueObj->SLADisabled && !( RT->Config->Get('ServiceAgreements') && keys %{RT->Config->Get('ServiceAgreements')}) ) {
         push @no_redirect_results, loc("You enabled [_1] but [_2] hasn't been configured in RT_SiteConfig.pm, please check '[_3]' for more help", 'SLA', '%ServiceAgreements', 'docs/customizing/sla.pod');
     }
+
+    if ( $ARGS{'HistoryFilter-Magic'} ) {
+      unless ( ref $HistoryFilter ) {
+          $HistoryFilter = [$HistoryFilter];
+      }
+        my $history_filter_attribute = $QueueObj->FirstAttribute( 'HistoryFilter' );
+        my $default_history_filter = $history_filter_attribute ? $history_filter_attribute->Content : [];
+
+        # Don't update if nothing needs changing
+        my ($ret, $msg) = $QueueObj->SetAttribute( Name => 'HistoryFilter', Content => $HistoryFilter );
+        if ( $ret ) {
+            push @results, loc("Histroy Filter Updated");
+        }
+        else {
+            RT::Logger->error( "Could not set History Filter queue attribute: $msg" );
+            push @results, loc("Failed to update History Filter setting");
+        }
+    }
 } else {
     $title = loc("Create a queue");
 }
@@ -355,4 +379,5 @@ $SetCrypt => undef
 $SLAEnabled => undef
 $Enabled => undef
 $SortOrder => undef
+$HistoryFilter => []
 </%ARGS>
diff --git a/share/html/Elements/ShowHistoryPage b/share/html/Elements/ShowHistoryPage
index 1c01345bdf..8184dbbd7b 100644
--- a/share/html/Elements/ShowHistoryPage
+++ b/share/html/Elements/ShowHistoryPage
@@ -128,6 +128,12 @@ 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' ) ) {
+        my $filter_types = $Object->QueueObj->FirstAttribute( 'HistoryFilter' )->Content;
+
+        $skip = 1 if not grep {$_ eq $Transaction->Type} @{$filter_types};
+    }
+
     $m->callback(
         %ARGS,
         Transaction   => $Transaction,

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list