[Rt-commit] r4381 - in rtir/branches/1.9-EXPERIMENTAL: . html/RTIR/Elements html/RTIR/Incident html/RTIR/Incident/Elements html/RTIR/Investigation/Elements

ruz at bestpractical.com ruz at bestpractical.com
Thu Jan 12 00:25:58 EST 2006


Author: ruz
Date: Thu Jan 12 00:25:55 2006
New Revision: 4381

Added:
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Investigation/Elements/Create
Modified:
   rtir/branches/1.9-EXPERIMENTAL/   (props changed)
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Create.html
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildSummary
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/IncidentSummary
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowIncidents
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Create.html
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Elements/Create
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/LinkToIncident.html
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Split.html
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Split.html

Log:
 r603 at cubic-pc:  cubic | 2006-01-12 06:47:12 +0300
 * create incident and run investigation at once
 * handling Attachments in one place
 * child argument rename to 'Child'


Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Create.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Create.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Create.html	Thu Jan 12 00:25:55 2006
@@ -55,27 +55,27 @@
 %    $m->abort();
 % }
 
-<form action="<%$RT::WebPath%>/RTIR/Create.html" method="post" enctype="multipart/form-data">
+<form action="<% $RT::WebPath %>/RTIR/Create.html" method="post" enctype="multipart/form-data">
 <input type="hidden" name="id" value="new" />
 <input type="hidden" name="Queue" value="<% $QueueObj->Name %>" />
 <input type="hidden" name="Status" value="<% $Status || 'open' %>" />
 <input type="hidden" name="Incident" value="<% $ARGS{Incident} %>" />
 % my $parentvalue;
 % if ($IncidentObj) {
-% $parentvalue = $IncidentObj->Id;
+%   $parentvalue = $IncidentObj->Id;
 % } elsif ($TicketObj) {
 %   $parentvalue = $TicketObj->Id;
-%   my $query = "Queue = 'Incidents' AND HasMember = " . $TicketObj->Id;
-%   my $incidents = new RT::Tickets($session{'CurrentUser'});
-%   $incidents->FromSQL($query);
+%   my $incidents = new RT::Tickets( $session{'CurrentUser'} );
+%   $incidents->FromSQL( "Queue = 'Incidents' AND HasMember = " . $TicketObj->Id );
 %   while (my $incident = $incidents->Next) {
-%     $parentvalue = $parentvalue." ".$incident->Id;
+%     $parentvalue .= " ". $incident->Id;
 %   }
 % }
 % if (defined $parentvalue) {
 <input type="hidden" name="new-MemberOf" value="<% $parentvalue %>" />
 % }
-<a name="top">
+
+<a name="top"></a>
 
 <& /Widgets/TitleBoxStart, contentbg => "#cccccc", title => $Title &>
 <table border="0" cellpadding="0" cellspacing="2">
@@ -242,28 +242,9 @@
 	QueueObj => $QueueObj &>
     </td>
   </tr>
-<tr>
-% if (exists $session{'Attachments'}) {
-<td>
-<&|/l&>Attached file</&>:
-</td>
-<td colspan="5">
-<&|/l&>Check box to delete</&><br />
-% foreach my $attach_name (keys %{$session{'Attachments'}}) {
-<input type="checkbox" name="DeleteAttach-<%$attach_name%>" /><%$attach_name%><br />
-% } # end of foreach
-</td>
-</tr>
-<tr>
-% } # end of if
-<td class="label">
-<&|/l&>Attach file</&>:
-</td>
-<td class="value" colspan="5">
-<input type="file" name="Attach" />
-<input type="submit" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
-</td>
-</tr>
+
+<& SELF:AttachmentsForm &>
+
 <tr>
 <td class="labeltop">
 <&|/l&>Message</&>:
@@ -281,14 +262,14 @@
 %   # Investigations should quote their included text
 %   my $quote = 0;
 %   if ($Type eq 'Investigation') {
-%     $quote = 1;
+%       $quote = 1;
 %   }
 %   $ARGS{Content} = $m->scomp("/RTIR/Elements/TransactionData", 
 %      Transactions => $Transactions,
 %      Type => 'messages',
 %      Include => {'Create', 'Correspond'},
 %      QuoteText => $quote);
-%   $ARGS{Content} =~ s/\&gt;/>/g;
+%      $ARGS{Content} =~ s/\&gt;/>/g;
 %   }
 % }
 <& /Elements/MessageBox, Default => $ARGS{Content}, QuoteTransaction => $QuoteTransaction &>
@@ -332,102 +313,65 @@
 </form>
 
 <%INIT>
-my $QueueObj = new RT::Queue($session{'CurrentUser'});
-$QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
+my $QueueObj = new RT::Queue( $session{'CurrentUser'} );
+$QueueObj->Load( $Queue ) || Abort( loc("Queue could not be loaded.") );
 
-my ($Type, $Status);
-if ($Queue eq "Incidents") {
-  $Type = "Incident";
-  $Status = 'open';
-} elsif ($Queue eq "Incident Reports") {
-  $Type = "Report";
-  $Status = 'new';
-} elsif ($Queue eq "Investigations") {
-  $Type = "Investigation";
-  $Status = 'open';
-} elsif ($Queue eq "Blocks") {
-  $Type = "Block";
-  $Status = 'new';
+my ($Type) = $m->comp('/RTIR/Elements/Type', Queue => $Queue );
+if ($Type eq 'Incident') {
+    $m->comp("/RTIR/Incident/Create.html", %ARGS);
+    $m->abort;
 }
 
-# Incidents have their own Create.html
-if ($Type eq 'Incident') {
-  $m->comp("/RTIR/Incident/Create.html", %ARGS);
-  $m->abort;
+my $Status;
+if ($Queue eq "Incident Reports") {
+    $Status = 'new';
+} elsif ($Queue eq "Investigations") {
+    $Status = 'open';
+} elsif ($Queue eq "Blocks") {
+    $Status = 'new';
 }
 
 my ($Title, $IncidentObj);
-my $TicketObj = $ARGS{TicketObj};
+my $TicketObj = $ARGS{'TicketObj'};
 
-if ($Incident) {
-  $IncidentObj = new RT::Ticket($session{'CurrentUser'});
-  $IncidentObj = LoadTicket($Incident);
+if ( $Incident ) {
+    $IncidentObj = new RT::Ticket( $session{'CurrentUser'} );
+    $IncidentObj = LoadTicket( $Incident );
+    $Subject ||= $IncidentObj->Subject;
 }
 
-# if there isn't a subject, but there is an incident, use that one
-if ((!$Subject) and $IncidentObj) {
-  $Subject = $IncidentObj->Subject;
-}
 
 my $name;
-if ($Type eq 'Report') {
-    $name = "Incident Report";
+if ( $Type eq 'Report' ) {
+    $name = 'Incident Report';
 } else {
     $name = $Type;
 }
 
-if ($Split) {
+if ( $Split ) {
     $Title = loc("Split [_1] #[_2]: [_3]", $name, $TicketObj->id, $TicketObj->Subject);
 } else {
-    if ($Type eq 'Investigation') {
+    if ( $Type eq 'Investigation' ) {
         $Title = loc("Launch a new [_1]", $name);
     } else {
         $Title = loc("Create a new [_1]", $name);
     }
 }
 
-# {{{ deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
-    if ($key =~ m/^DeleteAttach-(.+)$/) {
-    	delete $session{'Attachments'}{$1};
-    }
-    $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# {{{ store the uploaded attachment in session
-if ($ARGS{'Attach'}) {			# attachment?
-    $session{'Attachments'} = {} unless defined $session{'Attachments'};
-
-    # strip leading directories
-    $ARGS{'Attach'} =~ s#^.*[\\/]##;
-
-    my $attachment = MakeMIMEEntity(
-        Subject             => "$ARGS{'Attach'}",
-        Body                => "",
-        AttachmentFieldName => 'Attach'
-    );
-    $session{'Attachments'} = { %{$session{'Attachments'} || {}},
-				$ARGS{'Attach'} => $attachment };
-}
-# }}}
-
 # delete temporary storage entry to make WebUI clean
 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
     delete $session{'Attachments'};
 }
 
 
-# }}}
-
 my @results;
-if ((!exists $ARGS{'AddMoreAttach'}) && ($ARGS{'id'} eq 'new')) { # new ticket?
-  if ($Type ne 'Investigation' ||
-      ($Type eq 'Investigation' &&  $ARGS{'Requestors'})) {
-    $m->comp('Display.html', %ARGS);
-    $m->abort();
-  } else {
-    push @results, loc( "Investigation launch failed: You must enter a correspondent.");
-  }
+if ( !$ARGS{'AddMoreAttach'} && $ARGS{'id'} eq 'new' ) {
+    if ( $Type ne 'Investigation' || $ARGS{'Requestors'} ) {
+        $m->comp( 'Display.html', %ARGS );
+        $m->abort;
+    } else {
+        push @results, loc( "Investigation launch failed: You must enter a correspondent.");
+    }
 }
 
 my $sla;
@@ -445,3 +389,60 @@
 $QuoteTransaction => undef
 </%ARGS>
 
+<%METHOD ProcessAttachments>
+<%ARGS>
+ at DeleteAttachments => ()
+$Attachment => '';
+</%ARGS>
+<%INIT>
+
+$session{'Attachments'} ||= {};
+
+# deal with deleting uploaded attachments
+foreach ( @DeleteAttachments ) {
+    next unless exists $session{'Attachments'}{ $_ };
+    delete $session{'Attachments'}{ $_ };
+    $session{'i'}++;
+}
+
+# store the uploaded attachment in session
+if ( $Attachment ) {
+    # strip leading directories
+    $Attachment =~ s{^.*[\\/]}{};
+
+    my $entity = MakeMIMEEntity(
+        Subject             => $Attachment,
+        Body                => '',
+        AttachmentFieldName => 'Attachment'
+    );
+    $session{'Attachments'}{ $Attachment } = $entity;
+    $session{'i'}++;
+}
+</%INIT>
+</%METHOD>
+
+<%METHOD AttachmentsForm>
+
+<table>
+
+% if ( exists $session{'Attachments'} && keys %{ $session{'Attachments'} } ) {
+<tr><td><&|/l&>Attached file</&>:</td>
+<td>
+<&|/l&>Check box to delete</&><br />
+<ul class="files">
+% foreach my $name (keys %{$session{'Attachments'}}) {
+<li><input type="checkbox" name="DeleteAttachments" value="<% $name %>" /><% $name %></li>
+% }
+</ul>
+</td></tr>
+% }
+
+<tr><td class="label"><&|/l&>Attach file</&>:</td>
+<td class="value">
+<input type="file" name="Attachment" />
+<input type="submit" name="AddAttachment" value="<&|/l&>Add More Files</&>" />
+</td></tr>
+
+</table>
+
+</%METHOD>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildSummary
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildSummary	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildSummary	Thu Jan 12 00:25:55 2006
@@ -41,7 +41,7 @@
 <td><& "/RTIR/Elements/ShowRTIRField", Ticket => $Ticket, Name => 'State' &>
 <td><%$Ticket->Priority%></td>
 % if ($Type eq 'Incident') {
-<td align="right"><a href="<%$RT::WebPath%>/RTIR/Display.html?child=<%$Ticket->Id%>&id=<%$ticket%>">[<%loc("Link")%>]</a></td>
+<td align="right"><a href="<%$RT::WebPath%>/RTIR/Display.html?Child=<%$Ticket->Id%>&id=<%$ticket%>">[<%loc("Link")%>]</a></td>
 % } elsif ($Type eq $t) {
 % if ($ticket ne $Ticket->Id) {
 <td align="right"><a href="<%$RT::WebPath%>/RTIR/Merge.html?id=<%$ticket%>&SelectedTicket=<%$Ticket->Id%>">[<%loc("Merge")%>]</a></td>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/IncidentSummary
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/IncidentSummary	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/IncidentSummary	Thu Jan 12 00:25:55 2006
@@ -43,7 +43,7 @@
 <td><%$Ticket->Priority%></td>
 <td align="right">
 % if ($Type eq 'Report' or $Type eq 'Investigation' or $Type eq 'Block') {
-<a href="<%$RT::WebPath%>/RTIR/Display.html?child=<%$ticket%>&id=<%$Ticket->Id%>">[<%loc("Link")%>]</a>
+<a href="<%$RT::WebPath%>/RTIR/Display.html?Child=<%$ticket%>&id=<%$Ticket->Id%>">[<%loc("Link")%>]</a>
 % } elsif ($ticket and $Type eq $t) {
 %   if ($ticket ne $Ticket->Id) {
 <a href="<%$RT::WebPath%>/RTIR/Merge.html?id=<%$ticket%>&SelectedTicket=<%$Ticket->Id%>">[<%loc("Merge")%>]</a>
@@ -60,7 +60,7 @@
 <tr>
 <td colspan="5">
 % if ($Type eq 'Report' or $Type eq 'Investigation' or $Type eq 'Block') {
-[<a href="<%$RT::WebPath%>/RTIR/Create.html?child=<%$ticket%>&Queue=Incidents"><b>New</b></a>]
+[<a href="<%$RT::WebPath%>/RTIR/Create.html?Child=<%$ticket%>&Queue=Incidents"><b>New</b></a>]
 % }
 [<a href="<%$RT::WebPath%>/RTIR/Search/Results.html?Queue=Incidents<%$QueryString%>"><%loc("Refine Search")%></a>]
 </td>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowIncidents
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowIncidents	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowIncidents	Thu Jan 12 00:25:55 2006
@@ -37,7 +37,7 @@
 % if ($depth == 1) {
 %   if ($Ticket->Owner == $session{'CurrentUser'}->id) {
 <b><a href="<%$RT::WebPath%>/RTIR/Incident/LinkToIncident.html?id=<% $Ticket->Id %>">[Link]</a></b>
-<b><a href="<%$RT::WebPath%>/RTIR/Create.html?child=<%$Ticket->Id%>&Queue=Incidents">[New]</a></b>
+<b><a href="<%$RT::WebPath%>/RTIR/Create.html?Child=<%$Ticket->Id%>&Queue=Incidents">[New]</a></b>
 %   }
 % }
 

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States	Thu Jan 12 00:25:55 2006
@@ -2,7 +2,7 @@
 my %meta = (
     'Incidents'        => { Active => ['new', 'open', 'stalled'], Inactive => [] },
     'Incident Reports' => { Active => ['new', 'open'], Inactive => ['rejected', 'resolved'] },
-    'Investigations'   => { Active => ['open'], Inactive => ['stalled'] },
+    'Investigations'   => { Active => ['new', 'open'], Inactive => ['stalled'] },
     'Blocks'        => { Active => ['pending activation', 'active', 'pending removal'], Inactive => [] },
 );
 </%ONCE>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Create.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Create.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Create.html	Thu Jan 12 00:25:55 2006
@@ -33,19 +33,19 @@
 
 <%PERL>
 if ( $link && !$link->CurrentUserHasRight('ModifyTicket') ) {
-    $m->out( loc('You are not allowed to edit this Incident.') );
-    $m->abort();
+    $m->out( loc('You are not allowed to [_1] #[_2].', lc( $label ), $link->id ) );
+    return;
 }
 </%PERL>
 
 <form action="Create.html" method="post" enctype="multipart/form-data">
 
-<input type="hidden" name="id" value="new" />
-<input type="hidden" name="Queue" value="<% $QueueObj->Name %>" />
-<input type="hidden" name="Status" value="<% $ARGS{'Status'} || 'open' %>" />
-<input type="hidden" name="child" value="<% $ARGS{'child'} %>" />
-<input type="hidden" name="new-MemberOf" value="<% $ARGS{'new-MemberOf'} %>" />
-<input type="hidden" name="MemberOf-new" value="<% $ARGS{'MemberOf-new'} %>" />
+<input type="hidden" name="id"           value="new" />
+<input type="hidden" name="Queue"        value="<% $QueueObj->Name       || '' %>" />
+<input type="hidden" name="Status"       value="<% $ARGS{'Status'}       || 'open' %>" />
+<input type="hidden" name="Child"        value="<% $ARGS{'Child'}        || '' %>" />
+<input type="hidden" name="new-MemberOf" value="<% $ARGS{'new-MemberOf'} || '' %>" />
+<input type="hidden" name="MemberOf-new" value="<% $ARGS{'MemberOf-new'} || '' %>" />
 <a name="top">
 
 <&| /Widgets/TitleBox, title => $Title &>
@@ -54,23 +54,23 @@
 % if ($link) {
 % my ($Type) = $m->comp("/RTIR/Elements/Type", TicketObj => $link );
 <tr><td class="label"><% $label %>:</td>
-<td><% loc("[_1] #[_2]: [_3]", $Type, $link->Id, $link->Subject) %></td></tr>
+<td class="value"><% loc("[_1] #[_2]: [_3]", $Type, $link->Id, $link->Subject) %></td></tr>
 % }
 
 <tr>
 % if ($ChildObj) {
     <td class="label"><&|/l&>Owner</&>:</td>
-    <td class="value"><% $ChildObj->OwnerObj->Name %></td>
+    <td class="value">
+    <% $ChildObj->OwnerObj->Name %>
     <input type="hidden" name="Owner" value="<% $ChildObj->Owner %>" />
+    </td>
 % } else {
     <td class="label"><&|/l&>Owner</&>:</td>
-    <td>
-      <& /Elements/SelectOwner, 
-          Name     => 'Owner',
-          QueueObj => $QueueObj,
-          Default  => $ARGS{Owner} || $session{'CurrentUser'}->Id
-      &>
-    </td>
+    <td><& /Elements/SelectOwner, 
+        Name     => 'Owner',
+        QueueObj => $QueueObj,
+        Default  => $ARGS{Owner} || $session{'CurrentUser'}->Id
+    &></td>
 % }
 </tr>
 
@@ -81,27 +81,26 @@
 <%PERL>
 unless ( exists $ARGS{Content} ) {
     my $Transactions;
-    if ($TicketObj) {
+    if ( $TicketObj ) {
         $Transactions = $TicketObj->Transactions;
     } elsif ( $ChildObj ) {
         $Transactions = $ChildObj->Transactions;
     }
     if ( $Transactions ) {
-        $ARGS{Content} = $m->scomp("/RTIR/Elements/TransactionData", 
+        $ARGS{Content} = $m->scomp("/RTIR/Elements/TransactionData",
             Transactions => $Transactions,
-            Type => 'messages',
-            Include => {'Create', 'Correspond'}
-         );
-         $ARGS{Content} =~ s/\&gt;/>/g;
+            Type         => 'messages',
+            Include      => {'Create', 'Correspond'},
+        );
+        $ARGS{Content} =~ s/\&gt;/>/g;
     }
 }
 </%PERL>
 <& /Elements/MessageBox, Default => $ARGS{Content} &>
+
 </td></tr>
-</table>
 
-<table border="0" cellpadding="0" cellspacing="2">
-<tr><td width="50%" valign="top">
+<tr><td>&nbsp;</td><td colspan="2">
 
 <&| /Widgets/TitleBox,
     title => loc('The Basics'),
@@ -123,8 +122,6 @@
 </table>
 </&>
 
-</td><td valign="top">
-
 <&| /Widgets/TitleBox,
     title => loc("Dates"),
     title_class=> 'inverse',  
@@ -142,21 +139,42 @@
 </&>
 
 </td></tr>
+
 </table>
 
 </&>
 
-<& /Elements/Submit, Label => loc("Create") &>
+<& /Elements/Submit, Name => 'CreateIncident', Label => loc("Create") &>
+
+<&| /Widgets/TitleBox,
+    title => loc("Run Investigation"),
+    title_class=> 'inverse',
+    color => "#663366",
+&>
+<& /RTIR/Investigation/Elements/Create,
+    %ARGS,
+    NamePrefix => 'Investigation',
+    Queue => 'Investigations',
+    Status => 'new',
+    SkipField => { Owner => 1, Attachments => 1, DateFields => 1 },
+&>
+<& /Elements/Submit,
+    Name => 'CreateWithInvestigation',
+    Label => loc("Create Incident and run Investigation"),
+&>
+</&>
+
 </form>
 
 
 <%INIT>
+my @results;
+
 # if there isn't a subject, but there is a child, use that one
 my $ChildObj;
-
-if ( !$ARGS{'Subject'} && $child ) {
-    $ChildObj = LoadTicket( $child );
-    $ARGS{'Subject'} = $ChildObj->Subject;
+if ( $Child ) {
+    $ChildObj = LoadTicket( $Child );
+    $ARGS{'Subject'} ||= $ChildObj->Subject;
 }
 
 my ($link, $label);
@@ -166,8 +184,8 @@
 } elsif ($ARGS{'MemberOf-new'}) {
     $link = LoadTicket($ARGS{'MemberOf-new'});
     $label = loc("Link with");
-} elsif ($child) {
-    $link = LoadTicket($child);
+} elsif ($Child) {
+    $link = LoadTicket($Child);
     $label = loc("Link with");
 }
 
@@ -176,49 +194,56 @@
 
 my $TicketObj = $ARGS{TicketObj};
 
-# {{{ deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
-    if ($key =~ m/^DeleteAttach-(.+)$/) {
-        delete $session{'Attachments'}{$1};
-    }
-    $session{'i'}++;
-}
-
-# {{{ store the uploaded attachment in session
-if ( $ARGS{'Attach'} ) { # attachment?
-    $session{'Attachments'} ||= {};
-
-    # strip leading directories
-    $ARGS{'Attach'} =~ s#^.*[\\/]##;
-
-    my $attachment = MakeMIMEEntity(
-        Subject             => "$ARGS{'Attach'}",
-        Body                => "",
-        AttachmentFieldName => 'Attach'
-    );
-    $session{'Attachments'}->{ $ARGS{'Attach'} } = $attachment;
-    $session{'i'}++;
-}
-# }}}
+$m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
 
 # delete temporary storage entry to make WebUI clean
 unless ( keys %{ $session{'Attachments'} } && $ARGS{'id'} eq 'new' ) {
     delete $session{'Attachments'};
 }
 
-# }}}
+if ( $CreateIncident ) {
+    my ($inc_obj, @tmp);
+    ($inc_obj, @tmp) = $m->comp(
+        '/RTIR/Investigation/Elements/Create:Process',
+        %ARGS,
+        NamePrefix => '',
+        DefualtsNamePrefix => '',
+    );
+    push @results, @tmp;
 
-my @results;
-if ( !exists $ARGS{'AddMoreAttach'} && $ARGS{'id'} eq 'new' ) { # new ticket?
-    $m->comp('Display.html', %ARGS);
-    return;
+    my $inv_obj;
+    if ( $inc_obj && $CreateWithInvestigation ) {
+        my (@tmp);
+        ($inv_obj, @tmp) = $m->comp(
+            '/RTIR/Investigation/Elements/Create:Process',
+            %ARGS,
+            NamePrefix => 'Investigation',
+            DefualtsNamePrefix => '',
+        );
+        push @results, @tmp;
+        if ( $inv_obj ) {
+            my($id, $msg) = $inv_obj->AddLink(
+                Type => 'MemberOf',
+                Target => $inc_obj->id
+            );
+            #XXX: correct message on success
+            push @results, $msg if !$id || $msg;
+        }
+    }
+    if( $inc_obj ) {
+        $m->comp('Display.html', id => $inc_obj->id, results => \@results );
+        return;
+    }
 }
+
 </%INIT>
 
 <%ARGS>
-$QuoteTransaction => undef
-$Title            => loc("Create a new Incident")
-$current_tab      => "RTIR/Create.html?Queue=Incidents"
-$current_subtab   => "RTIR/Create.html?Queue=Incidents"
-$child            => undef
+$QuoteTransaction        => undef
+$Title                   => loc("Create a new Incident")
+$Child                   => undef
+$CreateWithInvestigation => 0
+$CreateIncident          => $CreateWithInvestigation
+$current_tab             => "RTIR/Create.html?Queue=Incidents"
+$current_subtab          => "RTIR/Create.html?Queue=Incidents"
 </%ARGS>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Display.html	Thu Jan 12 00:25:55 2006
@@ -140,7 +140,7 @@
 % if ($Ticket->CurrentUserHasRight('ModifyTicket')) {
     <table width="100%"><tr><td align="right"><font size="-1">
         | <a href="<%$RT::WebPath%>/RTIR/Create.html?Incident=<%$Ticket->Id%>&Queue=Investigations"><%loc('Launch')%></a> 
-        | <a href="<%$RT::WebPath%>/RTIR/Incident/LinkChildren.html?id=<%$Ticket->Id%>&Queue=Investigations%>"><%loc("Link")%></a> |
+        | <a href="<%$RT::WebPath%>/RTIR/Incident/LinkChildren.html?id=<%$Ticket->Id%>&Queue=Investigations"><%loc("Link")%></a> |
     </font></td></tr></table>
 % }
 
@@ -201,9 +201,8 @@
 <%INIT>
 my ($Ticket, $ChildObj);
 $Ticket = new RT::Ticket( $session{'CurrentUser'} );
-if ( $ARGS{'child'} ) {
-    $ChildObj = LoadTicket( $ARGS{'child'} );
-}
+$ChildObj = LoadTicket( $Child ) if $Child;
+
 
 if ($SelectedTicket) {
     $id = $SelectedTicket;
@@ -328,6 +327,6 @@
 <%ARGS>
 $id => undef
 $SelectedTicket => undef
-$child => undef
+$Child => undef
 @results => ()
 </%ARGS>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Elements/Create
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Elements/Create	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Elements/Create	Thu Jan 12 00:25:55 2006
@@ -22,85 +22,58 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-  <tr>
-    <td class="label">
-      <&|/l&>Subject</&>:
-    </td>
-    <td class="value" colspan="5">
-      <input name="Subject" size="60" maxsize="100" value="<% $ARGS{'Subject'} %>" />
-    </td>
-  </tr>
-  <tr>
-    <td class="labeltop"><&|/l&>Description</&>:</td>
-    <td class="value">
-      <& /RTIR/Elements/EditRTIRField, 
-         QueueObj => $QueueObj, 
-	 Name => 'Description',
-	 Default => $RT::_RTIR_Description_default,
-	 Cols => 40 &>
-    </td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Constituency</&>:</td>
-    <td class="value">
-      <& /RTIR/Elements/EditRTIRField, 
-         QueueObj => $QueueObj, 
-	 Name => 'Constituency',
-	 Default => $RT::_RTIR_Constituency_default,
-	 Rows => 1 &>
-    </td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Function</&>:</td>
-    <td class="value">
-      <& /RTIR/Elements/EditRTIRField, 
-         QueueObj => $QueueObj, 
-	 Name => 'Function',
-	 Default => $RT::_RTIR_Function_default,
-	 Rows => 1 &>
-    </td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Classification</&>:</td>
-    <td class="value">
-      <& /RTIR/Elements/EditRTIRField, 
-         QueueObj => $QueueObj, 
-	 Name => 'Classification',
-	 Default => $RT::_RTIR_Classification_default,
-	 Rows => 1 &>
-    </td>
-  </tr>
-  <tr>
-    <td colspan="2">
-      <& /Ticket/Elements/EditCustomFields, 
-        TicketObj => $TicketObj, QueueObj => $QueueObj &>
-    </td>
-  </tr>
-<tr>
-% if (exists $session{'Attachments'}) {
-<td>
-<&|/l&>Attached file</&>:
-</td>
-<td colspan="5">
-<&|/l&>Check box to delete</&><br />
-% foreach my $attach_name (keys %{$session{'Attachments'}}) {
-<input type="checkbox" name="DeleteAttach-<%$attach_name%>" /><%$attach_name%><br />
-% } # end of foreach
-</td>
-</tr>
-<tr>
-% } # end of if
-<td class="label">
-<&|/l&>Attach file</&>:
-</td>
-<td class="value" colspan="5">
-<input type="file" name="Attach" />
-<input type="submit" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
-</td>
-</tr>
+
+<tr><td class="label"><&|/l&>Subject</&>:</td>
+<td class="value">
+<input name="Subject" size="60" maxsize="100" value="<% $ARGS{'Subject'} %>" />
+</td></tr>
+
+<tr><td class="labeltop"><&|/l&>Description</&>:</td>
+<td class="value">
+<& /RTIR/Elements/EditRTIRField,
+    QueueObj => $QueueObj,
+	Name => 'Description',
+	Default => $RT::_RTIR_Description_default,
+	Cols => 40,
+&></td></tr>
+
+<tr><td class="label"><&|/l&>Constituency</&>:</td>
+<td class="value">
+<& /RTIR/Elements/EditRTIRField,
+    QueueObj => $QueueObj,
+	Name => 'Constituency',
+	Default => $RT::_RTIR_Constituency_default,
+	Rows => 1,
+&></td></tr>
+
+<tr><td class="label"><&|/l&>Function</&>:</td>
+<td class="value">
+<& /RTIR/Elements/EditRTIRField, 
+    QueueObj => $QueueObj, 
+	Name => 'Function',
+	Default => $RT::_RTIR_Function_default,
+	Rows => 1,
+&></td></tr>
+
+<tr><td class="label"><&|/l&>Classification</&>:</td>
+<td class="value">
+<& /RTIR/Elements/EditRTIRField, 
+    QueueObj => $QueueObj, 
+    Name => 'Classification',
+    Default => $RT::_RTIR_Classification_default,
+    Rows => 1,
+&></td></tr>
+
+<tr><td colspan="2">
+<& /Ticket/Elements/EditCustomFields,
+    TicketObj => $TicketObj,
+    QueueObj => $QueueObj,
+&></td></tr>
+
+<tr><td colspan="2"><& /RTIR/Create.html:AttachmentsForm &></td></tr>
 
 <%ARGS>
-$Title => undef
+$NamePrefix => ''
 $QueueObj => undef
 $TicketObj => undef
 </%ARGS>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/LinkToIncident.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/LinkToIncident.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/LinkToIncident.html	Thu Jan 12 00:25:55 2006
@@ -41,7 +41,7 @@
 &>
 
 <form action="<%$RT::WebPath%>/RTIR/Incident/Display.html" method="post">
-<input type="hidden" name="child" value="<%$id%>" />
+<input type="hidden" name="Child" value="<%$id%>" />
 
 <& /RTIR/Search/Elements/ShowResults, 
     Queue => $Queue,

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Split.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Split.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Split.html	Thu Jan 12 00:25:55 2006
@@ -22,22 +22,23 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& Create.html, 'new-MemberOf' => $TicketObj->Id,
+<& /RTIR/Create.html,
+    'new-MemberOf'   => $TicketObj->Id,
     QuoteTransaction => $QuoteTransaction,
-    Queue => 'Incidents',
-    Subject => $TicketObj->Subject,
-    Requestors => $TicketObj->RequestorAddresses,
-    Cc => $TicketObj->CcAddresses,
-    AdminCc => $TicketObj->AdminCcAddresses,
-    TicketObj => $TicketObj,
-    Status => $TicketObj->Status,
-    Owner => $TicketObj->Owner,
-    InitialPriority => $TicketObj->InitialPriority,
-    FinalPriority => $TicketObj->FinalPriority,
-    Title => loc("Split Incident #[_1]: [_2]", $TicketObj->id, $TicketObj->Subject),
-    current_tab => "RTIR/Display.html?id=".$Ticket,
-    current_subtab => "RTIR/Split.html?Ticket=".$Ticket,
- &>
+    Queue            => $TicketObj->QueueObj->Name,
+    Subject          => $TicketObj->Subject,
+    Requestors       => $TicketObj->RequestorAddresses,
+    Cc               => $TicketObj->CcAddresses,
+    AdminCc          => $TicketObj->AdminCcAddresses,
+    TicketObj        => $TicketObj,
+    Status           => $TicketObj->Status,
+    Owner            => $TicketObj->Owner,
+    InitialPriority  => $TicketObj->InitialPriority,
+    FinalPriority    => $TicketObj->FinalPriority,
+    Title            => loc("Split Incident #[_1]: [_2]", $TicketObj->id, $TicketObj->Subject),
+    current_tab      => "RTIR/Display.html?id=".$Ticket,
+    current_subtab   => "RTIR/Split.html?Ticket=".$Ticket,
+&>
 
 <%INIT>
 my $TicketObj = LoadTicket($Ticket);

Added: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Investigation/Elements/Create
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Investigation/Elements/Create	Thu Jan 12 00:25:55 2006
@@ -0,0 +1,156 @@
+% foreach my $field( qw(Queue Status) ) {
+<input type="hidden" name="<% $NamePrefix . $field %>" value="<% $value_cb->( $field ) %>" />
+% }
+
+<table border="0" cellpadding="0" cellspacing="2">
+
+% unless ( $SkipField{'Owner'} || $HideField{'Owner'} ) {
+<tr><td class="label"><&|/l&>Owner</&>:</td>
+<td class="value"><& /Elements/SelectOwner,
+    Name     => $NamePrefix ."Owner",
+	QueueObj => $QueueObj,
+	Default  => $value_cb->('Owner') || $session{'CurrentUser'}->Id,
+&></td></tr>
+% }
+
+% unless ( $SkipField{'Subject'} || $HideField{'Subject'} ) {
+<tr><td class="label"><&|/l&>Subject</&>:</td>
+<td class="value">
+<input name="<% $NamePrefix %>Subject" size="60" maxsize="100" value="<% $value_cb->('Subject') %>" />
+</td></tr>
+% }
+
+% unless ( $SkipField{'TimeFields'} ) {
+<tr><td colspan="2"><table><tr>
+    <td align="right"><&|/l&>Time Worked</&>:</td>
+    <td><input size="3" name="<% $NamePrefix %>TimeWorked" value="<% $value_cb->('TimeWorked') %>" /></td>
+    <td align="right"><&|/l&>Time Left</&>:</td>
+	<td><input size="3" name="<% $NamePrefix %>TimeLeft" value="<% $value_cb->('TimeLeft') %>" /></td>
+</tr></table></td></tr>
+% }
+
+% unless ( $SkipField{'Requestors'} || $HideField{'Requestors'} ) {
+<tr><td class="label"><&|/l&>Correspondents</&>:</td>
+<td class="value"><input name="<% $NamePrefix %>Requestors" value="<% $value_cb->('Requestors') %>" size="40" /></td></tr>
+% }
+
+% unless ( $SkipField{'Cc'} || $HideField{'Cc'} ) {
+<tr><td class="label"><&|/l&>Cc</&>:</td>
+<td class="value"><input name="<% $NamePrefix %>Cc" value="<% $value_cb->('Cc') %>" size="40" /><br />
+<i><font size="-2"><&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of
+email addresses. These people <b>will</b> receive future updates.)</&></font></i>
+</td></tr>
+% }
+
+% unless ( $SkipField{'AdminCc'} && $HideField{'AdminCc'} ) {
+<tr><td class="label"><&|/l&>Admin Cc</&>:</td>
+<td class="value"><input name="<% $NamePrefix %>AdminCc" value="<% $value_cb->('AdminCc') %>" size="40" />
+<i><font size="-2"><&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of administrative
+email addresses. These people <b>will</b> receive future updates.)</&></font></i>
+</td></tr>
+% }
+
+% if ( $QueueObj || $ARGS{'TicketObj'} ) {
+% unless ( $SkipField{'CustomFields'} ) {
+<tr><td colspan="2"><& /Ticket/Elements/EditCustomFields,
+    TicketObj => $ARGS{'TicketObj'},
+	QueueObj  => $QueueObj,
+&></td></tr>
+% } }
+
+% unless ( $SkipField{'Attachments'} ) {
+<& /RTIR/Create.html:AttachmentsForm &>
+% }
+
+% unless ( $SkipField{'Content'} || $HideField{'Content'} ) {
+<tr><td class="labeltop"><&|/l&>Message</&>:</td>
+<td><& /Elements/MessageBox,
+    Name             => $NamePrefix .'Content',
+    Default          => $value_cb->('Content'),
+    QuoteTransaction => $value_cb->('QuoteTransaction'),
+&></td></tr>
+% }
+
+% unless ( $SkipField{'DateFields'} ) {
+<tr><td>&nbsp;</td><td valign="top"><&| /Widgets/TitleBox,
+    title => loc("Dates"),
+    title_class=> 'inverse',
+&><table>
+
+<tr><td class="label"><&|/l&>Starts</&>:</td>
+<td class="value"><input size="10" name="<% $NamePrefix %>Starts" value="<% $value_cb->('Starts') %>" /></td></tr>
+
+<tr><td class="label"><&|/l&>Due</&>:</td>
+<td class="value"><input size="10" name="<% $NamePrefix %>Due" value="<% $value_cb->('Due') %>" /></td></tr>
+
+</table></&></td></tr>
+% }
+
+</table>
+
+<%ARGS>
+$NamePrefix => ''
+$QueueObj => undef,
+%HideField => ()
+%SkipField => ()
+</%ARGS>
+<%INIT>
+my %DEFAULTS = (
+    Status => 'new',
+);
+my $value_cb = sub {
+    my $name = shift;
+    my $full_name = $NamePrefix . $name;
+    my $value;
+    $value = $ARGS{     $full_name };
+    $value = $ARGS{     $name } unless defined $value;
+    $value = $DEFAULTS{ $name } unless defined $value;
+    $value = ''                 unless defined $value;
+    return $value;
+};
+
+if ( !$QueueObj ) {
+    if ( my $queue = $value_cb->('Queue') ) {
+        my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
+        $QueueObj->Load( $queue );
+#        Abort( loc("Couldn't load queue '[_1]'.", $queue) );
+    }
+}
+</%INIT>
+
+<%METHOD Process>
+<%ARGS>
+$NamePrefix => '',
+$DefaultsNamePrefix => undef
+</%ARGS>
+<%INIT>
+if ( $NamePrefix ) {
+    foreach my $k( keys %ARGS ) {
+        next unless $k =~ /^\Q$NamePrefix\E(.*)$/;
+        $ARGS{ $1 } = delete $ARGS{ $k };
+    }
+}
+if ( $DefaultsNamePrefix && $DefaultsNamePrefix ne $NamePrefix ) {
+    foreach my $k( keys %ARGS ) {
+        next unless $k =~ /^\Q$DefaultsNamePrefix\E(.*)$/;
+        next if exists $ARGS{ $1 };
+        $ARGS{ $1 } = delete $ARGS{ $k };
+    }
+}
+delete $ARGS{'DefaultsNamePrefix'};
+delete $ARGS{'NamePrefix'};
+
+use Data::Dumper; $RT::Logger->crit(Dumper(\%ARGS));
+
+#unless ($QueueObj->CurrentUserHasRight('CreateTicket')) {
+#    Abort('You have no permission to create tickets in that queue.');
+#}
+my ($Ticket, @results) = CreateTicket(
+    Attachments => $session{'Attachments'},
+    %ARGS,
+);
+
+delete $session{'Attachments'} if $Ticket;
+return ($Ticket, @results);
+</%INIT>
+</%METHOD>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Split.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Split.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Split.html	Thu Jan 12 00:25:55 2006
@@ -23,36 +23,38 @@
 %# 
 %# END LICENSE BLOCK
 <& /RTIR/Create.html, 
-    Split => 1,
-    Incident => $Incident,
+    Split            => 1,
+    Incident         => $Incident,
     QuoteTransaction => $QuoteTransaction,
-    Queue => $TicketObj->QueueObj->Name,
-    Subject => $TicketObj->Subject,
-    Requestors => $TicketObj->RequestorAddresses,
-    Cc => $TicketObj->CcAddresses,
-    AdminCc => $TicketObj->AdminCcAddresses,
-    TicketObj => $TicketObj,
-    Status => $TicketObj->Status,
-    Owner => $TicketObj->Owner,
-    InitialPriority => $TicketObj->InitialPriority,
-    FinalPriority => $TicketObj->FinalPriority &>
+    Queue            => $TicketObj->QueueObj->Name,
+    Subject          => $TicketObj->Subject,
+    Requestors       => $TicketObj->RequestorAddresses,
+    Cc               => $TicketObj->CcAddresses,
+    AdminCc          => $TicketObj->AdminCcAddresses,
+    TicketObj        => $TicketObj,
+    Status           => $TicketObj->Status,
+    Owner            => $TicketObj->Owner,
+    InitialPriority  => $TicketObj->InitialPriority,
+    FinalPriority    => $TicketObj->FinalPriority,
+&>
 
 <%INIT>
 my $TicketObj = LoadTicket($Ticket);
 
 my ($Type) = $m->comp('Elements/Type', Ticket => $TicketObj->Id);
-
-my $Incident;
-if ($Type ne 'Incident') {
-    my $query = "Queue = 'Incidents' AND HasMember = " . $TicketObj->Id;
-    my $incidents = new RT::Tickets($session{'CurrentUser'});
-    $incidents->FromSQL($query);
-    $Incident = $incidents->First->Id;
-} else {
+if ($Type eq 'Incident') {
     $m->comp("/RTIR/Incident/Split.html", %ARGS);
     $m->abort;
 }
 
+my $query = "Queue = 'Incidents' AND HasMember = " . $TicketObj->Id;
+my $incidents = new RT::Tickets($session{'CurrentUser'});
+$incidents->FromSQL( $query );
+my $obj = $incidents->First;
+my $Incident;
+$Incident = $obj->Id if $obj && $obj->Id;
+
+
 </%INIT>
 <%ARGS>
 $MemberOf => undef


More information about the Rt-commit mailing list