[Rt-commit] rtir branch, 3.0/incident-children-config, updated. 2.6.1-495-gfcfc5b8

Ruslan Zakirov ruz at bestpractical.com
Fri Oct 14 09:16:50 EDT 2011


The branch, 3.0/incident-children-config has been updated
       via  fcfc5b837bfbcb084e73d4ddec0e7f7be86946d0 (commit)
       via  34b43fc888e62a6d17695a8bad152e6ee9a7ad42 (commit)
       via  1e5d7729479f2d37c0bd9459e5ac897f8d26728c (commit)
       via  5ea0867d178f472a8a764f1166b2ce1b9c3eac89 (commit)
       via  169eae1e35268d4c64f366ba414180c0180f22f1 (commit)
       via  e080d67ad221b7f40542c49cd8c46d2e49a7a2aa (commit)
       via  513070a2f9e08e54c38c98574eb3e774e958200a (commit)
       via  d875f3c97db8ae9847b1482c0044b8c7e89f4741 (commit)
       via  ff661f51929166aeeb847c164ea6bcb2cc6a3a1a (commit)
      from  c317301e52bd528298ca00799ad2d497c86a1b04 (commit)

Summary of changes:
 etc/RTIR_Config.pm               |    7 +++-
 html/RTIR/Create.html            |    7 +++-
 html/RTIR/Display.html           |    4 +-
 html/RTIR/Elements/ShowIncidents |   64 ++++++++++++++++++-------------------
 html/RTIR/Incident/Display.html  |    3 +-
 lib/RT/IR.pm                     |   13 +++++--
 lib/RT/IR/Test/Web.pm            |    2 +-
 7 files changed, 56 insertions(+), 44 deletions(-)

- Log -----------------------------------------------------------------
commit ff661f51929166aeeb847c164ea6bcb2cc6a3a1a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Oct 13 17:44:07 2011 +0400

    wrong colspans, table only needs two columns

diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index b59a3aa..38b1db6 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -44,13 +44,13 @@
 <table>
   <tr>
     <td class="label"><% loc("Status") %>:</td>
-    <td class="value" colspan="2">
+    <td class="value">
       <% $Ticket->Status %>
     </td>
   </tr>
   <tr>
     <td class="label"><% loc("Incident") %>:</td>
-    <td class="value" colspan="2">
+    <td class="value">
       <& /RTIR/Elements/ShowIncidents, Ticket => $Ticket &>
     </td>
   </tr>

commit d875f3c97db8ae9847b1482c0044b8c7e89f4741
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Oct 13 17:53:32 2011 +0400

    don't walk incidents recursively
    
    nowhere in UI we allow to link incident to incidents,
    this is the only place where it's expected

diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index a1d4626..e9e0137 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -29,25 +29,20 @@
 % if ( $show_unlink ) {
 <a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $Ticket->Id %>&DeleteLink--MemberOf-<% $incident->Id %>=1">[<% loc('Unlink') %>]</a>
 % }
-% if ( $depth < 8 ) {
-<& /RTIR/Elements/ShowIncidents, Ticket => $incident, depth => ($depth+1) &>
-% }
 % $count++;
 </li>
 % }
 % $m->out('</ul>') if $count;
 
-% if ( $depth == 1 and $count == 0 ) {
+% unless ( $count ) {
 <i><% loc('(no Incidents)') %></i>
 % }
 
-% if ( $depth == 1 ) {
-%   unless ( $action ) {
+% unless ( $action ) {
 <b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Link/ToIncident/?id=<% $Ticket->Id %>">[Link]</a></b>
 <b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Create.html?Child=<% $Ticket->Id %>&Queue=Incidents">[New]</a></b>
-%   } elsif ( $action ne 'No' ) {
+% } elsif ( $action ne 'No' ) {
 <a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?Action=<% $action %>&id=<% $Ticket->Id %>">[<% loc( $action ) %>]</a>
-%   }
 % }
 
 <%INIT>
@@ -81,5 +76,4 @@ if ( $show_unlink && $Ticket->QueueObj->Name eq 'Blocks' ) {
 
 <%ARGS>
 $Ticket => undef
-$depth => 1
 </%ARGS>

commit 513070a2f9e08e54c38c98574eb3e774e958200a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 12:11:15 2011 +0400

    extract query generator from RelevantIncidents

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 8066aa9..c2a750b 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -329,16 +329,21 @@ is member of excluding abandoned incidents.
 
 =cut
 
-sub RelevantIncidents {
+sub RelevantIncidentsQuery {
     my $self = shift;
     my $ticket = shift;
 
-    my $query = "Queue = 'Incidents'"
-        ." AND HasMember = " . $ticket->id
+    return "Queue = 'Incidents' AND HasMember = ". $ticket->id
         ." AND Status != 'abandoned'"
     ;
+}
+
+sub RelevantIncidents {
+    my $self = shift;
+    my $ticket = shift;
+
     my $res = RT::Tickets->new( $ticket->CurrentUser );
-    $res->FromSQL( $query );
+    $res->FromSQL( $self->RelevantIncidentsQuery( $ticket, @_ ) );
     return $res;
 }
 

commit e080d67ad221b7f40542c49cd8c46d2e49a7a2aa
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 12:15:58 2011 +0400

    list Incs with new format string in config

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 01e0ebb..84ec993 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -358,6 +358,11 @@ Set($RTIRSearchResultFormats, {
           '<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></b>/TITLE:Subject',
           __OwnerName__, __CreatedRelative__},
 
+    ListIncidents =>
+        q{'<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#',
+          '<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></b>/TITLE:Subject',
+          __Status__},
+
     RejectReports =>
         q{'<a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a>/TITLE:#',
           '<a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a>/TITLE:Subject',
diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index e9e0137..9c68575 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -22,34 +22,26 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-% while ( my $incident = $incidents->Next ) {
-% $m->out('<ul>') unless $count;
-<li>
-<a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $incident->Id %>"><% $incident->Id %>: <% $incident->Subject %></a> <i>( <% $incident->Status %> )</i>
-% if ( $show_unlink ) {
-<a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?id=<% $Ticket->Id %>&DeleteLink--MemberOf-<% $incident->Id %>=1">[<% loc('Unlink') %>]</a>
-% }
-% $count++;
-</li>
-% }
-% $m->out('</ul>') if $count;
-
-% unless ( $count ) {
-<i><% loc('(no Incidents)') %></i>
-% }
+<& /RTIR/Search/Elements/ShowResults,
+    Query         => $query,
+    Rows          => 0,
+    Format        => $format,
+    DisplayFormat => $dformat,
+    AllowSorting  => 0,
+    ShowHeader    => 0,
+    EmptyLabel    => loc('(no Incidents)'),
+&>
 
+% my $wp = RT->Config->Get('WebPath');
 % unless ( $action ) {
-<b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Link/ToIncident/?id=<% $Ticket->Id %>">[Link]</a></b>
-<b><a href="<%RT->Config->Get('WebPath')%>/RTIR/Create.html?Child=<% $Ticket->Id %>&Queue=Incidents">[New]</a></b>
+<b><a href="<% $wp %>/RTIR/Link/ToIncident/?id=<% $id %>">[Link]</a></b>
+<b><a href="<% $wp %>/RTIR/Create.html?Child=<% $id %>&Queue=Incidents">[New]</a></b>
 % } elsif ( $action ne 'No' ) {
-<a href="<% RT->Config->Get('WebPath') %>/RTIR/Display.html?Action=<% $action %>&id=<% $Ticket->Id %>">[<% loc( $action ) %>]</a>
+<a href="<% $wp %>/RTIR/Display.html?Action=<% $action %>&id=<% $id %>">[<% loc( $action ) %>]</a>
 % }
 
 <%INIT>
-
-my $count = 0;
-
-my $incidents = RT::IR->RelevantIncidents( $Ticket );
+my $id = $Ticket->id;
 
 my $action = '';
 if ( $Ticket->Owner != $session{'CurrentUser'}->Id ) {
@@ -67,11 +59,23 @@ if ( $Ticket->Owner != $session{'CurrentUser'}->Id ) {
     }
 }
 
-my $show_unlink = !$action;
-if ( $show_unlink && $Ticket->QueueObj->Name eq 'Blocks' ) {
-    $show_unlink = 0 unless RT::IR->Incidents( $Ticket )->Count > 1;
+my $config = RT->Config->Get('RTIR_IncidentChildren')
+    ->{ RT::IR::TicketType( Ticket => $Ticket ) };
+
+my $has_incidents = RT::IR->Incidents( $Ticket )->Count;
+
+my $show_unlink = 1;
+if ( $config->{'Required'} && $has_incidents <= 1 ) {
+    $show_unlink = 0;
 }
 
+my $query = RT::IR->RelevantIncidentsQuery( $Ticket );
+
+my $format = RT->Config->Get('RTIRSearchResultFormats')->{'ListIncidents'};
+my $dformat = $format;
+if ( $show_unlink ) {
+    $dformat .= ", '<a href=\"__WebPath__/RTIR/Display.html?id=$id&DeleteLink--MemberOf-__id__=1\">". loc('Unlink') ."</a>/TITLE:'";
+}
 </%INIT>
 
 <%ARGS>

commit 169eae1e35268d4c64f366ba414180c0180f22f1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 13:42:21 2011 +0400

    blocks can be linked to multiple incidents

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 84ec993..73e3644 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -240,7 +240,7 @@ Set(%RTIR_IncidentChildren,
         Required => 0,
     },
     Block => {
-        Multiple => 0,
+        Multiple => 1,
         Required => 1,
     },
 );

commit 5ea0867d178f472a8a764f1166b2ce1b9c3eac89
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 13:44:06 2011 +0400

    use new config option when we link children to inc

diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index 4c7c157..96381f1 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -144,7 +144,8 @@ my $DoLinks = sub {
 
     # Blocks or Incedent Reports can have multiple incidents
     my $Type = RT::IR::TicketType( Ticket => $child );
-    unless( $Type eq 'Block' || $Type eq 'Report' ) {
+    my $config = RT->Config->Get('RTIR_IncidentChildren')->{$Type};
+    unless( $config->{'Multiple'} ) {
         my $incidents = RT::IR->Incidents( $child, Exclude => $parent );
         while ( my $incident = $incidents->Next ) {
             $deleted_links = 1;

commit 1e5d7729479f2d37c0bd9459e5ac897f8d26728c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 13:49:33 2011 +0400

    check $children_config->{'Required'} on create

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 27ace84..d32e2e9 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -369,7 +369,9 @@ foreach my $id ( grep $_, @Incident ) {
 }
 @Incident = map $_->id, @IncidentObj;
 
-if ( @Incident > 1 && !RT->Config->Get('RTIR_IncidentChildren')->{ $Type }{'Multiple'} ) {
+my $children_config = RT->Config->Get('RTIR_IncidentChildren')->{ $Type };
+
+if ( @Incident > 1 && !$children_config->{'Multiple'} ) {
     push @{ $m->{'request_args'} }, Incident => $Incident[-1];
     @Incident = ($Incident[-1]);
 }
@@ -396,7 +398,7 @@ unless ( $skip_create ) {
     if ( $Type eq 'Investigation' && !$ARGS{'Requestors'} ) {
         push @results, loc( "You must enter a correspondent" );
         $checks_failure = 1;
-    } elsif ( $Type eq 'Block' && !@IncidentObj ) {
+    } elsif ( $children_config->{'Required'} && !@IncidentObj ) {
         push @results, loc( "You must enter an Incident ID" );
         $checks_failure = 1;
     }

commit 34b43fc888e62a6d17695a8bad152e6ee9a7ad42
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 13:51:03 2011 +0400

    don't stop on first error, check both

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index d32e2e9..b651eb1 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -398,7 +398,8 @@ unless ( $skip_create ) {
     if ( $Type eq 'Investigation' && !$ARGS{'Requestors'} ) {
         push @results, loc( "You must enter a correspondent" );
         $checks_failure = 1;
-    } elsif ( $children_config->{'Required'} && !@IncidentObj ) {
+    }
+    if ( $children_config->{'Required'} && !@IncidentObj ) {
         push @results, loc( "You must enter an Incident ID" );
         $checks_failure = 1;
     }

commit fcfc5b837bfbcb084e73d4ddec0e7f7be86946d0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 14 17:15:21 2011 +0400

    fix tests that check linking

diff --git a/lib/RT/IR/Test/Web.pm b/lib/RT/IR/Test/Web.pm
index 406c91c..2362f85 100644
--- a/lib/RT/IR/Test/Web.pm
+++ b/lib/RT/IR/Test/Web.pm
@@ -142,7 +142,7 @@ sub ticket_is_linked_to_inc {
     foreach my $inc( ref $incs? @$incs : ($incs) ) {
         my $desc = shift || "Ticket #$id is linked to the Incident #$inc";
         $self->content_like(
-            qr{Incident:\s*</td>\s*<td[^>]*?>.*?<a\s+href="/RTIR/Display.html\?id=\Q$inc\E">\Q$inc\E:\s+}ism,
+            qr{Incident:\s*</td>\s*<td[^>]*?>.*?<td[^>]*?><b><a\s+href="/(?:RTIR|Ticket)/Display.html\?id=\Q$inc\E">\Q$inc\E</a></b></td>}ism,
             $desc
         ) or return 0;
     }

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


More information about the Rt-commit mailing list