[Rt-commit] rtir branch, 3.0/incident-children-config, created. 2.6.1-477-g56e878d

Ruslan Zakirov ruz at bestpractical.com
Tue Oct 11 19:48:50 EDT 2011


The branch, 3.0/incident-children-config has been created
        at  56e878d72c7e813f8d4d2bb6c06a007c59497145 (commit)

- Log -----------------------------------------------------------------
commit c2aa3b5febb33c429f2f91a99ca890aa3c5eb603
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 12 00:54:16 2011 +0400

    free incident field so it can be changed
    
    also, Split should has more priority over Incident value

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index d1b52a5..7d49a2a 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -60,12 +60,7 @@
 <&| /Widgets/TitleBox, title => loc("Basics"), class=>'ticket-info-basics' &>
 <table width="100%" border="0">
 
-% if ( $Incident ) {
-  <tr class="incident">
-    <td class="label"><&|/l&>Incident</&>:</td>
-    <td class="value"><% $Incident %><input type="hidden" name="Incident" value="<% $Incident || '' %>" /></td>
-  </tr>
-% } elsif ( $SplitObj ) {
+% if ( $SplitObj ) {
   <tr class="split">
     <td class="label"><&|/l&>Split from</&>:</td>
     <td class="value"><% $SplitObj->id %></td>
@@ -76,7 +71,7 @@
     <td class="value"><% $parentvalue %></td>
   </tr>
 % }
-% } else {
+% elsif ( $Incident ) {
   <tr class="incident">
     <td class="label"><&|/l&>Incident</&>:</td>
     <td class="value"><input type="text" name="Incident" size="16" maxsize="16" value="<% $Incident || '' %>" /></td>

commit 0ec529fb8b6eb05d832f87bd6e6d15451a9e5a55
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 12 01:25:37 2011 +0400

    first move towards multiple incidents on create

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 7d49a2a..c49bd33 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -60,35 +60,20 @@
 <&| /Widgets/TitleBox, title => loc("Basics"), class=>'ticket-info-basics' &>
 <table width="100%" border="0">
 
-% if ( $SplitObj ) {
-  <tr class="split">
-    <td class="label"><&|/l&>Split from</&>:</td>
-    <td class="value"><% $SplitObj->id %></td>
-  </tr>
-% if ( $parentvalue ) {
-  <tr class="incident">
-    <td class="label"><&|/l&>Will be linked to Incident(s)</&>:</td>
-    <td class="value"><% $parentvalue %></td>
-  </tr>
-% }
-% elsif ( $Incident ) {
-  <tr class="incident">
-    <td class="label"><&|/l&>Incident</&>:</td>
-    <td class="value"><input type="text" name="Incident" size="16" maxsize="16" value="<% $Incident || '' %>" /></td>
-  </tr>
-  <tr>
-    <td class="label"> </td>
-    <td class="comment">
-        (<&|/l&>Id of an Incident to link a new ticket to</&>. <% $Type eq 'Block'? '<strong>'.loc('Required').'</strong>': loc('Optional') |n %>.)
-    </td>
-  </tr>
-% }
-
   <& /Ticket/Elements/EditBasics,
     InTable => 1,
     fields  => [
         {
             name => 'Status',
+            comp => '/Elements/SelectIncident',
+            args => {
+                Name         => 'Incident',
+                Default      => @Incident,
+                QueueObj     => $QueueObj,
+            },
+        },
+        {
+            name => 'Status',
             comp => '/Elements/SelectStatus',
             args => {
                 Name         => "Status",
@@ -115,9 +100,9 @@
   <tr>
     <td class="label"><&|/l&>Constituency</&>:</td>
     <td class="value">
-% if ( !$Incident || RT->Config->Get('_RTIR_Constituency_Propagation') eq 'no' ) {
+% if ( !$Incident[0] || RT->Config->Get('_RTIR_Constituency_Propagation') eq 'no' ) {
 % my $default;
-% $default = $IncidentObj->FirstCustomFieldValue('Constituency') if $Incident;
+% $default = $IncidentObj[0]->FirstCustomFieldValue('Constituency') if $Incident[0];
 % $default ||= RT::IR::DefaultConstituency( $QueueObj );
 % $default ||= scalar RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'};
       <& /RTIR/Elements/EditRTIRField, 
@@ -127,8 +112,8 @@
 % } else {
 % #TODO: hacks, we need way to define CF value on Create, but don't allow user to change it
       <input type="hidden" class="hidden" name="<% $constituency_field %>-Magic" value="1" />
-      <input type="hidden" class="hidden" name="<% $constituency_field %>" value="<% $IncidentObj->FirstCustomFieldValue('Constituency') %>" />
-      <& /RTIR/Elements/ShowRTIRField, Ticket => $IncidentObj, Name => 'Constituency' &>
+      <input type="hidden" class="hidden" name="<% $constituency_field %>" value="<% $IncidentObj[0]->FirstCustomFieldValue('Constituency') %>" />
+      <& /RTIR/Elements/ShowRTIRField, Ticket => $IncidentObj[0], Name => 'Constituency' &>
 % }
     </td>
   </tr>
@@ -138,7 +123,7 @@
     %ARGS,
     TicketOnj => undef,
     QueueObj => $QueueObj,
-    DefaultsFrom => $SplitObj || $IncidentObj,
+    DefaultsFrom => $SplitObj || $IncidentObj[0],
   &>
   <& /Ticket/Elements/EditTransactionCustomFields,
     %ARGS, QueueObj => $QueueObj, InTable => 1,
@@ -209,8 +194,8 @@
 %   my $Transactions;
 %   if ($SplitObj) {
 %     $Transactions = $SplitObj->Transactions;
-%   } elsif ($IncidentObj) {
-%     $Transactions = $IncidentObj->Transactions;
+%   } elsif (@IncidentObj) {
+%     $Transactions = $IncidentObj[0]->Transactions;
 %   }
 %
 %   if ($Transactions) {
@@ -304,8 +289,8 @@
 &>
 </table></&>
 
-% if ( $Type eq "Investigation" && $IncidentObj ) {
-  <& /RTIR/Elements/AttachReports, Ticket => $IncidentObj &>
+% if ( $Type eq "Investigation" && @IncidentObj ) {
+  <& /RTIR/Elements/AttachReports, Ticket => \@IncidentObj &>
 % }
 
 </div>
@@ -345,47 +330,42 @@ $constituency_field =
     'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values'
         if $constituency_cf;
 
-my $IncidentObj;
-if ( $Incident ) {
-    $IncidentObj = RT::Ticket->new( $session{'CurrentUser'} );
-    $IncidentObj->Load( $Incident );
-    unless ( $IncidentObj->id ) {
+my $SplitObj;
+if ( $Split ) {
+    $SplitObj = LoadTicket( $Split );
+    $ARGS{'Split'} = $Split = $SplitObj->id;
+
+    @Incident = map $_->id, @{ RT::IR->Incidents( $SplitObj )->ItemsArrayRef || [] }
+        unless @Incident;
+}
+
+my @IncidentObj;
+foreach my $id ( grep $_, @Incident ) {
+    my $error = 1;
+
+    my $inc = RT::Ticket->new( $session{'CurrentUser'} );
+    $inc->Load( $Incident );
+    unless ( $inc->id ) {
         push @results, loc("Couldn't load incident #[_1]", $Incident );
-        ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef);
     }
-    elsif ( $IncidentObj->QueueObj->Name ne 'Incidents' ) {
+    elsif ( $inc->QueueObj->Name ne 'Incidents' ) {
         push @results, loc('Ticket #[_1] is not an Incident', $Incident );
-        ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef);
     }
     elsif ( !$skip_create && $constituency_field 
         && RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject'
-        && lc $ARGS{$constituency_field} ne lc $IncidentObj->FirstCustomFieldValue('Constituency') )
+        && lc $ARGS{$constituency_field} ne lc $inc->FirstCustomFieldValue('Constituency') )
     {
-        push @results, loc('Incident #[_1] has constituency [_2], choose the same value for a new ticket or use another Incident', $Incident, $IncidentObj->FirstCustomFieldValue('Constituency') );
-        ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef);
+        push @results, loc('Incident #[_1] has constituency [_2], choose the same value for a new ticket or use another Incident', $Incident, $inc->FirstCustomFieldValue('Constituency') );
     }
     else {
-        $Subject ||= $IncidentObj->Subject;
+        push @IncidentObj, $inc;
+        $error = 0;
     }
+    $checks_failure += $error;
 }
-$Incident = $ARGS{'Incident'} = $IncidentObj->id if $IncidentObj;
+ at Incident = map $_->id, @IncidentObj;
 
-my $SplitObj;
-if ( $Split ) {
-    $SplitObj = LoadTicket( $Split );
-    $ARGS{'Split'} = $Split = $SplitObj->id;
-}
-
-my $parentvalue = '';
-if ( $IncidentObj ) {
-    $parentvalue = $IncidentObj->Id;
-} elsif ( $SplitObj ) {
-    my $incidents = RT::IR->Incidents( $SplitObj );
-    while ( my $incident = $incidents->Next ) {
-        $parentvalue .= ' ' if $parentvalue;
-        $parentvalue .= $incident->Id;
-    }
-}
+$Subject ||= $IncidentObj[0]->Subject if @IncidentObj;
 
 push @results, $m->comp( 'SELF:ProcessAttachments', %ARGS );
 
@@ -407,7 +387,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' and not $IncidentObj ) {
+    } elsif ( $Type eq 'Block' && !@IncidentObj ) {
         push @results, loc( "You must enter an Incident ID" );
         $checks_failure = 1;
     }
@@ -445,7 +425,7 @@ $m->callback(
 );
 
 unless ( $skip_create || $checks_failure ) {
-    $ARGS{'new-MemberOf'} = $parentvalue if $parentvalue;
+    $ARGS{'new-MemberOf'} = join ', ', @Incident;
     $m->callback(CallbackName => 'BeforeDisplay', Ticket => $SplitObj, ARGSRef => \%ARGS);
     push @{ $session{'Actions'}{''} ||= [] }, @results;
     return $m->comp( 'Display.html', %ARGS, SkipNotification => \@SkipNotification );
@@ -480,8 +460,8 @@ $Queue            => undef
 $Subject          => undef
 $QuoteTransaction => undef
 
-# Parent Incident
-$Incident         => undef
+# Parent Incident(s)
+ at Incident         => ()
 
 $Split            => undef
 </%ARGS>

commit 34ce8c8618c261434165eacff766aed44f9a7f03
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 12 01:36:20 2011 +0400

    make AttachReports work with multiple tickets

diff --git a/html/RTIR/Elements/AttachReports b/html/RTIR/Elements/AttachReports
index 61571a0..4419012 100644
--- a/html/RTIR/Elements/AttachReports
+++ b/html/RTIR/Elements/AttachReports
@@ -8,18 +8,19 @@
 &>
 </&>
 <%ARGS>
-$Ticket => undef
+ at Ticket => ()
 $Name   => 'AttachTickets'
 </%ARGS>
 <%INIT>
-return unless $Ticket;
+return unless @Ticket;
 
 my @parents;
-my $type = RT::IR::TicketType( Ticket => $Ticket );
-if ( $type eq 'Incident' ) {
-    push @parents, $Ticket->id;
-} else {
-    push @parents, map $_->id, @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] };
+foreach my $e ( @Ticket ) {
+    if ( RT::IR::TicketType( Ticket => $e ) eq 'Incident' ) {
+        push @parents, $e->id;
+    } else {
+        push @parents, map $_->id, @{ RT::IR->Incidents( $e )->ItemsArrayRef || [] };
+    }
 }
 return unless @parents;
 
@@ -27,7 +28,7 @@ my $siblings = RT::Tickets->new( $Ticket->CurrentUser );
 $siblings->FromSQL( RT::IR->Query(
     Queue    => 'Incident Reports',
     MemberOf => \@parents,
-    Exclude  => $Ticket,
+    Exclude  => \@Ticket,
 ) );
 $siblings->_DoSearch;
 return unless $siblings->Count;

commit eaeeb31027b46d6fd9ec2390c640d2ee3db0ca8f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 12 02:19:48 2011 +0400

    stab at SelectIncident, just copy from Create.html

diff --git a/html/RTIR/Elements/SelectIncident b/html/RTIR/Elements/SelectIncident
new file mode 100644
index 0000000..21c5c12
--- /dev/null
+++ b/html/RTIR/Elements/SelectIncident
@@ -0,0 +1,25 @@
+% if ( $SplitObj ) {
+  <tr class="split">
+    <td class="label"><&|/l&>Split from</&>:</td>
+    <td class="value"><% $SplitObj->id %></td>
+  </tr>
+% if ( $parentvalue ) {
+  <tr class="incident">
+    <td class="label"><&|/l&>Will be linked to Incident(s)</&>:</td>
+    <td class="value"><% $parentvalue %></td>
+  </tr>
+% }
+% elsif ( $Incident ) {
+  <tr class="incident">
+    <td class="label"><&|/l&>Incident</&>:</td>
+    <td class="value"><input type="text" name="Incident" size="16" maxsize="16" value="<% $Incident || '' %>" /></td>
+  </tr>
+  <tr>
+    <td class="label"> </td>
+    <td class="comment">
+        (<&|/l&>Id of an Incident to link a new ticket to</&>. <% $Type eq 'Block'? '<strong>'.loc('Required').'</strong>': loc('Optional') |n %>.)
+    </td>
+  </tr>
+% }
+
+

commit 56e878d72c7e813f8d4d2bb6c06a007c59497145
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 12 02:27:59 2011 +0400

    add RTIR_IncidentChildren option to the config

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 6aa4686..01e0ebb 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -225,6 +225,26 @@ Set(
     },
 );
 
+
+=item C<%RTIR_IncidentChildren>
+
+=cut
+
+Set(%RTIR_IncidentChildren,
+    Report => {
+        Multiple => 1,
+        Required => 0,
+    },
+    Investigation => {
+        Multiple => 0,
+        Required => 0,
+    },
+    Block => {
+        Multiple => 0,
+        Required => 1,
+    },
+);
+
 =back
 
 =head1 Web Interface Configuration

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


More information about the Rt-commit mailing list