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

BPS Git Server git at git.bestpractical.com
Mon Jan 30 18:56:48 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  629bca784cf98a6ef118bfc8f6f03fa9cadbc6fc (commit)

- Log -----------------------------------------------------------------
commit 629bca784cf98a6ef118bfc8f6f03fa9cadbc6fc
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Dec 30 12:24:25 2022 -0300

    Show objects where the lifecycle is applied to on Lifecycle administration

diff --git a/share/html/Admin/Lifecycles/index.html b/share/html/Admin/Lifecycles/index.html
index a5bf77dd07..b6d6eca1d3 100644
--- a/share/html/Admin/Lifecycles/index.html
+++ b/share/html/Admin/Lifecycles/index.html
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2022 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
 %#                                          <sales at bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -68,12 +68,12 @@
         <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 ) {
 %    next if grep { $key eq $_ } qw/approvals __maps__/;
 %    next if $lifecycles{$key}{'disabled'} and !$FindDisabledLifecycles;
-
       <tr class="<% $i % 2 ? 'oddline' : 'evenline' %>">
         <td class="collection-as-table"><a href="<% RT->Config->Get('WebURL') %>Admin/Lifecycles/Modify.html?Type=<% $lifecycles{$key}{'type'} ? loc($lifecycles{$key}{'type'}) : loc('ticket') |u %>&Name=<% $key %>"><% $key %></a></td>
         <td class="collection-as-table"><% $lifecycles{$key}{'type'} ? loc($lifecycles{$key}{'type'}) : loc('ticket') %></td>
@@ -83,6 +83,25 @@
             <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('WebURL') %>Admin/<%
+              $AppliedClassTarget{$lifecycles{$key}{'type'} ? $lifecycles{$key}{'type'} : 'ticket'}
+          %>/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('WebURL') %>Admin/<%
+              $AppliedClassTarget{$lifecycles{$key}{'type'} ? $lifecycles{$key}{'type'} : 'ticket'}
+            %>" target="_blank"><&|/l&>More...</&></a>
+%      }
+%    }
+        </td>
       </tr>
 %    ++$i;
 % }
@@ -101,7 +120,38 @@
 <%INIT>
 my @results;
 
+my $max_queues_per_lifecycle = 15;
 my %lifecycles = %{RT::Config->Get('Lifecycles')};
+$m->callback( CallbackName => 'Lifecycles', Lifecycles => \%lifecycles,
+              MaxQueuesPerLifecycle => \$max_queues_per_lifecycle);
+
+my %AppliedClassTarget = (
+    'ticket' => 'Queues',
+    'asset' => 'Assets/Catalogs',
+);
+
+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 = 'Queues';
+    if ($lifecycle->Type() eq 'asset') {
+        $list_method = 'Catalogs';
+    }
+    my $appliedobjs = $lifecycle->$list_method();
+    $appliedobjs->RowsPerPage($max_queues_per_lifecycle);
+    if ($appliedobjs->CountAll()) {
+      my $show_more_link = 0;
+      if ($appliedobjs->CountAll() > $max_queues_per_lifecycle) {
+          $show_more_link = 1;
+      }
+        return ($appliedobjs, $show_more_link);
+    }
+    return;
+};
 
 if ($Submit) {
     my $changed;

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list