[Rt-commit] rt branch 5.0/add-queues-column-to-lifecycle-admin created. rt-5.0.3-224-g3d1334340b

BPS Git Server git at git.bestpractical.com
Fri Mar 3 20:34:57 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/add-queues-column-to-lifecycle-admin has been created
        at  3d1334340b2e0e76308e91b46996f0c6680a9b0a (commit)

- Log -----------------------------------------------------------------
commit 3d1334340b2e0e76308e91b46996f0c6680a9b0a
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Mar 3 17:34:18 2023 -0300

    Show objects where the lifecycle is applied
    
    Add an "Applied" column to Lifecycle administration which lists queues
    or catalogs where the lifecycle is applied.

diff --git a/share/html/Admin/Lifecycles/index.html b/share/html/Admin/Lifecycles/index.html
index a5bf77dd07..a76849672b 100644
--- a/share/html/Admin/Lifecycles/index.html
+++ b/share/html/Admin/Lifecycles/index.html
@@ -68,6 +68,7 @@
         <th class="collection-as-table"><&|/l&>Name</&></th>
         <th class="collection-as-table"><&|/l&>Type</&></th>
         <th class="collection-as-table"><&|/l&>Enabled</&></th>
+        <th class="collection-as-table"><&|/l&>Applied</&></th>
       </tr>
 % my $i = 0;
 % for my $key ( sort keys %lifecycles ) {
@@ -83,6 +84,29 @@
             <label class="custom-control-label" for="enable-lifecycle-<% $key %>"></label>
           </div>
         </td>
+        <td class="collection-as-table">
+%    my ($appliedref, $show_more_link) = $get_applied->($key);
+%    if ( $appliedref ) {
+%       my $j = 0;
+%       while( my $applied = $appliedref->Next ) {
+%          $j++;
+          <a href="<% RT->Config->Get('WebPath') %>/Admin/<%
+              $AppliedClass{$lifecycles{$key}{'type'} || 'ticket'}->{URI}
+          %>/Modify.html?id=<% $applied->id() %>"
+            target="_blank"><% $applied->Name() %></a><%
+                      (($j < $appliedref->CountAll())||$show_more_link) ? ', ' : '' %>
+%      }
+%      if ( $show_more_link ) {
+            <a href="<% RT->Config->Get('WebPath') %>/Admin/<%
+              $AppliedClass{$lifecycles{$key}{'type'} || 'ticket'}->{URI} .
+              '?'.$AppliedClass{$lifecycles{$key}{'type'} || 'ticket'}->{SearchFieldParam}.
+              '=Lifecycle&'.
+              $AppliedClass{$lifecycles{$key}{'type'} || 'ticket'}->{SearchValueParam}.
+              '='.$key
+            %>" target="_blank"><&|/l&>More</&>...</a>
+%      }
+%    }
+        </td>
       </tr>
 %    ++$i;
 % }
@@ -101,7 +125,48 @@
 <%INIT>
 my @results;
 
+my $applied_list_limit = 15;
 my %lifecycles = %{RT::Config->Get('Lifecycles')};
+$m->callback(
+    CallbackName     => 'Initial',
+    LifecycleConfig  => \%lifecycles,
+    AppliedListLimit => \$applied_list_limit,
+    ARGSRef          => \%ARGS
+);
+
+my %AppliedClass = (
+    'ticket' => {
+        'URI'              => 'Queues',
+        'SearchFieldParam' => 'QueueField',
+        'SearchValueParam' => 'QueueString',
+    },
+    'asset' => {
+        'URI'              => 'Assets/Catalogs',
+        'SearchFieldParam' => 'Field',
+        'SearchValueParam' => 'String',
+    }
+);
+
+my $get_applied = sub {
+    my $key       = shift;
+    my $lifecycle = RT::Lifecycle->Load(
+        Name => $key,
+        Type => $lifecycles{$key}{'type'} // 'ticket'
+    );
+    unless ($lifecycle) {
+        RT::Logger->error( 'Unable to load lifecycle ' . $key );
+        return;
+    }
+    my $list_method = $lifecycle->Type() eq 'asset' ? 'Catalogs' : 'Queues';
+    my $appliedobjs = $lifecycle->$list_method();
+    $appliedobjs->RowsPerPage($applied_list_limit);
+    if ( $appliedobjs->CountAll() ) {
+        my $show_more_link
+            = $appliedobjs->CountAll() > $applied_list_limit ? 1 : 0;
+        return ( $appliedobjs, $show_more_link );
+    }
+    return;
+};
 
 if ($Submit) {
     my $changed;

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list