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

ruz at bestpractical.com ruz at bestpractical.com
Mon Oct 31 10:53:20 EST 2005


Author: ruz
Date: Mon Oct 31 10:53:20 2005
New Revision: 4008

Added:
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildrenQuery
Modified:
   rtir/branches/1.9-EXPERIMENTAL/   (props changed)
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowChildren
   rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/ShowChildren.html
Log:
 r230 at cubic-pc:  cubic | 2005-10-31 18:50:56 +0300
  r212 at cubic-pc:  cubic | 2005-10-31 11:14:40 +0300
  * state selector
  * children query component
  * show total count in braces
 


Added: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildrenQuery
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ChildrenQuery	Mon Oct 31 10:53:20 2005
@@ -0,0 +1,19 @@
+<%INIT>
+my @parts;
+push @parts, $BaseQuery || $m->comp('/RTIR/Elements/BaseQuery', Queue => $Queue);
+push @parts, $m->comp('/RTIR/Elements/NewQuery', Queue  => $Queue,
+                                                 states => [@States],
+                                                 add_states => [@AddStates],
+                     );
+push @parts, "MemberOf = ". $Ticket->id if $Ticket;
+
+return join " AND ", map "($_)", @parts;
+
+</%INIT>
+<%ARGS>
+$BaseQuery => ''
+$Ticket => undef
+$Queue => ''
+ at States => ()
+ at AddStates => ()
+</%ARGS>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowChildren
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowChildren	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/ShowChildren	Mon Oct 31 10:53:20 2005
@@ -22,84 +22,70 @@
 %# 
 %# 
 %# END LICENSE BLOCK
+
+% if( $ShowStatesSelector ) {
+%   foreach my $s( @possible_states ) {
+%       my $checked = (grep { $_ eq $s } @States)? 'checked': '';
+<input type="checkbox" name="States" value="<% $s %>" <% $checked %> />&nbsp;<% $s %>
+%   }
+<& /Elements/Submit, Name => 'RefineStates', Label => loc('Filter states') &>
+% }
+
 % if ($Delete) {
 <i><%loc("Check box to unlink")%></i><br>
 % }
-
 <& /Elements/TicketList, 
-   Collection => $MyTickets,
+   Collection => $children,
    Format => $Format,
    Rows => $Rows,
+   ShowHeader => $ShowHeader,
    OrderBy => $OrderBy,
-   ShowHeader => 0,
-   ShowNavigation => 0,
-&>
-
-<& /Elements/TicketList, 
-   Collection     => $ClosedTickets,
-   Format         => $Format,
-   Rows           => $Rows,
-   OrderBy        => 'Resolved',
-   Order          => 'DESC',
-   ShowHeader     => 0,
    ShowNavigation => 0,
 &>
-
-% if ($depth eq 1 and $MyTickets->Count eq 0) {
-% if (defined $Queue) {
-  <i>(<% loc("no [_1]", $Queue) %>)</i>
-% } else {
-  <i>loc("no children")</i>
-% }
-% } else {
-% if (($Rows > 0) && ($MyTickets->Count >= $Rows)) {
-% if (defined $FullList) {
-<a href="<%$FullList%>"><i><%loc("More... ([_1] total)", $MyTickets->Count)%></i></a><br>
-% }
+% unless( $children->Count ) {
+%   if ($Queue) {
+        <i>(<% loc("no [_1]", $Queue) %>)</i>
+%   } else {
+        <i>(<% loc("no children") %>)</i>
+%   }
 % }
+<br />
+
+% if( $FullList && $Rows > 0 && $children->Count >= $Rows ) {
+<a href="<%$FullList%>"><i><%loc("More... ([_1] total)", $children->Count)%></i></a><br>
 % }
 
 <%INIT>
-my ($Type, @states) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
-$Format = $RT::RTIRSearchResultFormats->{'Child' . $Type};
-
-my %seen = ();
- at states = map lc, grep $_ && !$seen{$_}++, (@states, @AddStates);
+unless( @States ) {
+    @States = $m->comp("/RTIR/Elements/States", Queue => $Queue);
+}
+my @possible_states = $m->comp("/RTIR/Elements/States", Queue => $Queue, Inactive => 1 );
+my ($Type) = $m->comp("/RTIR/Elements/Type", Queue => $Queue);
 
+$Format ||= $RT::RTIRSearchResultFormats->{'Child' . $Type};
 if ($Delete) {
     $Format = "___RTIR_Check__, " . $Format;
 }
 
-if (!$BaseQuery) {
-    $BaseQuery = $m->comp('/RTIR/Elements/BaseQuery', Queue => $Queue);
-}
-
-$Query  = $m->comp('/RTIR/Elements/NewQuery', Queue => $Queue, states => [@states] );
-$Query .= " AND MemberOf = " . $Ticket->Id;
-$Query  = "$BaseQuery AND ( $Query )";
-
-my $MyTickets = new RT::Tickets($session{'CurrentUser'});
-$MyTickets->FromSQL($Query);
-
-my $ClosedQuery = "MemberOf = ". $Ticket->Id ." AND Status = 'resolved'";
-$ClosedQuery  = "$BaseQuery AND ( $ClosedQuery )";
-
-my $ClosedTickets = new RT::Tickets($session{'CurrentUser'});
-$ClosedTickets->FromSQL($ClosedQuery);
+my $children = new RT::Tickets($session{'CurrentUser'});
+$children->FromSQL( $m->comp( '/RTIR/Elements/ChildrenQuery',
+                              Queue  => $Queue,
+                              Ticket => $Ticket,
+                              States => [@States],
+                            )
+                  );
 
 </%INIT>
 
 <%ARGS>
-$Query => undef
-$BaseQuery => undef
-$QueryString => undef
 $Format => undef
 $Queue => undef
 $Ticket => undef
 $OrderBy => 'Due'
-$depth => 1
 $Rows => 0
 $Delete => 0
 $FullList => undef
- at AddStates => ()
+ at States => ()
+$ShowHeader => 0
+$ShowStatesSelector => 0
 </%ARGS>

Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/ShowChildren.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/ShowChildren.html	(original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/ShowChildren.html	Mon Oct 31 10:53:20 2005
@@ -25,66 +25,81 @@
 <& /RTIR/Elements/Header, Title => $Title &>
 <& /RTIR/Incident/Elements/LinkTabs, 
     Queue => $Queue,
-    Ticket => $Incident, 
-    current_tab => 'RTIR/Incident/ShowChildren.html?Queue=' . $Queue . 'id='.$Incident->id,
-    Title => $Title &>
+    Ticket => $Incident,
+    current_tab => "RTIR/Incident/ShowChildren.html?Queue=$Queue&id=". $Incident->id,
+    Title => $Title,
+&>
 
 <& /Elements/ListActions, actions => \@results &>
 
-<h2><% loc('Total [_1]: [_2]', $Queue, $count) %></h2>
-<form action="ShowChildren.html" method="post">
+% if( $children->CountAll == $all_children->CountAll ) {
+<h2><% loc('Total [_1]: [_2]', $Queue, $children->CountAll) %></h2>
+% } else {
+<h2><% loc('Total [_1]: [_2]([_3])', $Queue, $children->CountAll, $all_children->CountAll) %></h2>
+% }
+
+<form action="ShowChildren.html" method="POST">
 <input type="hidden" name="id" value="<%$Incident->id%>">
 <input type="hidden" name="Queue" value="<%$Queue%>">
-% my $delete = 0;
-% if ($Incident->CurrentUserHasRight('ModifyTicket')) {
-% $delete = 1;
-% }
 
-<& /RTIR/Elements/ShowChildren, 
-    Delete => $delete,
-    Ticket => $Incident, 
-    Queue => $Queue,
-    FullList => $RT::WebPath."/RTIR/Incident/ShowChildren.html?Queue=$Queue&id=".$Incident->id
-    &>
-<& /Elements/Submit, Caption=> loc('Unlink Report') &>
+<& /RTIR/Elements/ShowChildren,
+    Ticket             => $Incident,
+    Queue              => $Queue,
+    States             => [@States],
+    FullList           => $RT::WebPath."/RTIR/Incident/ShowChildren.html?Queue=$Queue&id=".$Incident->id,
+    Delete             => $delete,
+    ShowHeader         => 1,
+    ShowStatesSelector => 1,
+&>
+
+<& /Elements/Submit, Name => 'Unlink', Label => loc('Unlink Report') &>
 </form>
 
 <%INIT>
-  my ($Incident, $Title, $count);
+unless ($id) {
+    Abort('No incident specified');
+}
 
-  $Incident = new RT::Ticket($session{'CurrentUser'});
-  $Incident = LoadTicket($id);
+my @results;
+my $Incident = LoadTicket($id);
 
-  # translate the checkbox args to what ProcessTicketLinks expects
-  foreach my $arg (keys %ARGS) {
-      if ($arg =~ /^UpdateTicket(\d+)/) {
-	  $ARGS{'DeleteLink-' . $1 . '-MemberOf-'} = 1;
+if( $ARGS{'Unlink'} ) {
+      # translate the checkbox args to what ProcessTicketLinks expects
+      foreach my $arg (keys %ARGS) {
+          if ($arg =~ /^UpdateTicket(\d+)/) {
+              $ARGS{'DeleteLink-' . $1 . '-MemberOf-'} = 1;
+          }
       }
-  }
+      push @results, ProcessTicketLinks( TicketObj => $Incident, ARGSRef => \%ARGS );
+}
 
-  my @results = ProcessTicketLinks( TicketObj => $Incident, ARGSRef => \%ARGS);
-
-  $Title = loc("$Queue for Incident #[_1]: [_2]", $Incident->Id, $Incident->Subject);
-
-  unless ($id) {
-    Abort('No incident specified');
-  }
-
-  $Incident = LoadTicket($ARGS{'id'});
-  unless ($Incident->CurrentUserHasRight('ShowTicket')) {
+unless ($Incident->CurrentUserHasRight('ShowTicket')) {
     Abort("No permission to view ticket");
-  }
-
-  my $query = "Queue = '$Queue' AND MemberOf = " . $Incident->Id;
+}
 
-  my $members = new RT::Tickets($session{'CurrentUser'});
-  $members->FromSQL($query);
+my $Title = loc("$Queue for Incident #[_1]: [_2]", $Incident->Id, $Incident->Subject);
 
-  $count = $members->Count;
+my $delete = $Incident->CurrentUserHasRight('ModifyTicket') ? 1: 0;
 
+my $children = new RT::Tickets($session{'CurrentUser'});
+$children->FromSQL( $m->comp( '/RTIR/Elements/ChildrenQuery',
+                              Queue  => $Queue,
+                              Ticket => $Incident,
+                              States => [@States],
+                            )
+                  );
+
+my @possible_states = $m->comp("/RTIR/Elements/States", Queue => $Queue, Inactive => 1 );
+my $all_children = new RT::Tickets($session{'CurrentUser'});
+$all_children->FromSQL( $m->comp( '/RTIR/Elements/ChildrenQuery',
+                                  Queue  => $Queue,
+                                  Ticket => $Incident,
+                                  States => [@possible_states],
+                                )
+                      );
 </%INIT>
-
 <%ARGS>
 $id => undef
 $Queue => 'Incident Reports'
+ at States => ()
 </%ARGS>


More information about the Rt-commit mailing list