[Bps-public-commit] rt-extension-jsgantt branch, master, updated. 57cd23d6db717e22d3f2eef7220801b59cc4fc84

? sunnavy sunnavy at bestpractical.com
Wed Oct 26 22:33:20 EDT 2011


The branch, master has been updated
       via  57cd23d6db717e22d3f2eef7220801b59cc4fc84 (commit)
       via  69ff69bec3a4416fb6b8b9266ef7d535a408b3d8 (commit)
       via  cecd16a0cf5e78b2ed5c69c8c6b5d57686a71d70 (commit)
       via  6cf564863e436996abe955bd873a5b9df74decdf (commit)
      from  45e91530cdbc60add458cd4616fab1b2c1d5d8ca (commit)

Summary of changes:
 Changes                     |    6 ++++-
 META.yml                    |    2 +-
 README                      |    2 +-
 lib/RT/Extension/JSGantt.pm |   49 +++++++++++++++++++-----------------------
 4 files changed, 29 insertions(+), 30 deletions(-)

- Log -----------------------------------------------------------------
commit 6cf564863e436996abe955bd873a5b9df74decdf
Author: sunnavy <sunnavy at gmail.com>
Date:   Thu Oct 27 09:36:39 2011 +0800

    tweak parent selection
    
    before taking the first parent, we should check if there is parent exists
    in the previous rows, and if there is, we should use that instead.
    
    consider:
    
    4 has 1 child: 1
    1 has 2 parents: 3 and 4
    
    if we get chart via ?Ticket=4, then we probably want 4 as the parent of 1
    instead of 3.

diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index da75579..e5aa2b8 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -150,7 +150,7 @@ sub TicketsInfo {
         my $progress = 0;
         my $subject = $Ticket->Subject;
 
-        my $parent = _ParentTicket( $Ticket );
+        my $parent = _ParentTicket( $Ticket, $args{Tickets} );
         $parent = $parent ? $parent->id : 0;
 
         # find start/end
@@ -163,23 +163,6 @@ sub TicketsInfo {
             $min_start     = $start;
         }
 
-        my $has_members = $Ticket->Members->Count ? 1 : 0;
-        if ($has_members) {
-
-           # need to examine more as it may not the first parent of it's members
-            my $members = $Ticket->Members;
-            my $indeed_has_members;
-            while ( my $member = $members->Next ) {
-                if ( $member->BaseObj->MemberOf->First->TargetObj->id == $Ticket->id )
-                {
-                    $indeed_has_members = 1;
-                    last;
-                }
-            }
-
-            $has_members = $indeed_has_members || 0;
-        }
-
         my $depends = $Ticket->DependsOn;
         my @depends;
         if ( $depends->Count ) {
@@ -221,13 +204,20 @@ sub TicketsInfo {
             owner =>
               ( $Ticket->OwnerObj->Name || $Ticket->OwnerObj->EmailAddress ),
             progress    => $progress,
-            has_members => $has_members,
             parent      => $parent,
             open        => 1,
             depends     => ( @depends ? join ',', @depends : 0 )
         };
     }
 
+    {
+        my @parents = uniq map { $_->{parent} || () } values %info;
+        for my $parent (@parents) {
+            next unless $info{$parent};
+            $info{$parent}{has_members} = 1;
+        }
+    }
+
     #let's tweak our results
     #set to now if all tickets don't have start/end dates
     unless ( $min_start_obj && $min_start_obj->Unix > 0 ) {
@@ -411,7 +401,7 @@ sub __GetOrderedTickets {
     if ( $type && $type eq 'Members' ) {
         while ( my $ticket = shift @$to_be_checked ) {
             unless ( grep { $ticket->id eq $_->id } @$tickets ) {
-                my $parent = _ParentTicket($ticket);
+                my $parent = _ParentTicket($ticket, $tickets);
 
                 if ( !$parent || !insert_after { $_->id == $parent->id } $ticket,
                     @$tickets )
@@ -454,10 +444,15 @@ sub __GetOrderedTickets {
 
 sub _ParentTicket {
     my $ticket = shift;
-    if ( $ticket->MemberOf->Count ) {
-        # skip the remote links
-        next unless $ticket->MemberOf->First->TargetObj;
-        return $ticket->MemberOf->First->TargetObj;
+    my $candidates = shift || [];
+    my @parents = _RelatedTickets( $ticket, 'MemberOf' );
+    if (@parents) {
+        for my $candidate (@$candidates) {
+            if ( grep { $_->id == $candidate->id } @parents ) {
+                return $candidate;
+            }
+        }
+        return $parents[0];
     }
     return;
 }

commit cecd16a0cf5e78b2ed5c69c8c6b5d57686a71d70
Author: sunnavy <sunnavy at gmail.com>
Date:   Thu Oct 27 09:47:24 2011 +0800

    JSGanttOptions may not be defined

diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index e5aa2b8..f42cef2 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -117,7 +117,7 @@ sub TicketsInfo {
 
 
     my ( @ids, %info );
-    my %options = RT->Config->Get('JSGanttOptions');
+    my %options = RT->Config->Get('JSGanttOptions') || ();
 
     my @colors;
     if ( $options{ColorScheme} ) {
@@ -248,7 +248,7 @@ $start and $end are strings like 3/21/2011
 
 sub _GetTimeRange {
     my ( $Ticket, %args ) = @_;
-    my %options = RT->Config->Get('JSGanttOptions');
+    my %options = RT->Config->Get('JSGanttOptions') || ();
 
     # the, uh, long way
     my ( $start_obj, $start ) = _GetDate( $Ticket, 'Starts', 'Started' );

commit 69ff69bec3a4416fb6b8b9266ef7d535a408b3d8
Author: sunnavy <sunnavy at gmail.com>
Date:   Thu Oct 27 10:30:51 2011 +0800

    release 0.16

diff --git a/Changes b/Changes
index 92f0c1d..d101a29 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
 Revision history for RT-Extension-JSGantt
 
-0.16
+0.16 Thu Oct 27 10:29:51 CST 2011
+
+    * tweak parent selection process
 
 0.15 Thu Oct 27 02:22:31 CST 2011
 

commit 57cd23d6db717e22d3f2eef7220801b59cc4fc84
Author: sunnavy <sunnavy at gmail.com>
Date:   Thu Oct 27 10:32:43 2011 +0800

    bump to 0.17

diff --git a/Changes b/Changes
index d101a29..e82b658 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for RT-Extension-JSGantt
 
+0.17
+
 0.16 Thu Oct 27 10:29:51 CST 2011
 
     * tweak parent selection process
diff --git a/META.yml b/META.yml
index 5601e6c..e8977cb 100644
--- a/META.yml
+++ b/META.yml
@@ -23,4 +23,4 @@ requires:
   List::MoreUtils: 0
 resources:
   repository: git://github.com/bestpractical/rt-extension-jsgantt.git
-version: 0.16
+version: 0.17
diff --git a/README b/README
index d7c20d6..d57eca4 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-RT-Extension-JSGantt version 0.16
+RT-Extension-JSGantt version 0.17
 
 How to install:
 
diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index f42cef2..21be9eb 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -58,7 +58,7 @@ RT::Extension::JSGantt - Gantt charts for your tickets
 
 package RT::Extension::JSGantt;
 
-our $VERSION = '0.16';
+our $VERSION = '0.17';
 
 use warnings;
 use strict;

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



More information about the Bps-public-commit mailing list