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

? sunnavy sunnavy at bestpractical.com
Wed Oct 26 03:54:33 EDT 2011


The branch, master has been updated
       via  a2cc5c2d66798b72fbfb1360dd95a506c861f4a9 (commit)
      from  cc03b29d6d85fe0f10de6a69b2c42576e7311f66 (commit)

Summary of changes:
 README                      |    3 +++
 lib/RT/Extension/JSGantt.pm |   27 ++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit a2cc5c2d66798b72fbfb1360dd95a506c861f4a9
Author: sunnavy <sunnavy at gmail.com>
Date:   Wed Oct 26 15:39:15 2011 +0800

    add ColorSchemeByOwner option to show the same color for each owner

diff --git a/README b/README
index c408b7a..56f6d65 100644
--- a/README
+++ b/README
@@ -16,7 +16,10 @@ How to install:
         ShowOwner     => 1,
         ShowProgress  => 1,
         ShowDuration  => 1,
+        # define your own color scheme
         ColorScheme => ['ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff'],
+        # use the same color for each owner and specify colors to use for some owners
+        ColorSchemeByOwner => { root => 'ff0000', foo => '00ff00' },
         # if can't find both start and end dates, use this color
         NullDatesColor => 333,
         # to caculate day length
diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index a27aacc..fb8376d 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -62,7 +62,7 @@ our $VERSION = '0.14';
 
 use warnings;
 use strict;
-use List::MoreUtils 'insert_after';
+use List::MoreUtils 'insert_after', 'uniq';
 
 =head2 AllRelatedTickets
 
@@ -124,13 +124,26 @@ sub TicketsInfo {
         @colors = @{$options{ColorScheme}};
     }
     else {
-        @colors =
-          ( 'ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff' );
+        @colors = (
+            '66cc66', 'ff6666', 'ffcc66', '663399', '3333cc', '339933',
+            '993333', '996633', '33cc33', 'cc3333', 'cc9933', '6633cc'
+        );
     }
     my $i;
 
     my ( $min_start, $min_start_obj );
 
+    my %color_map;
+    if ( $options{ColorSchemeByOwner} ) {
+        my @owner_names = uniq map { $_->OwnerObj->Name } @{ $args{Tickets} };
+        @color_map{@owner_names} = @colors[0 .. $#owner_names];
+        if (   ref $options{ColorSchemeByOwner}
+            && ref $options{ColorSchemeByOwner} eq 'HASH' )
+        {
+            %color_map = ( %color_map, %{ $options{ColorSchemeByOwner} } );
+        }
+    }
+
     for my $Ticket (@{$args{Tickets}}) {
         my $progress = 0;
         my $subject = $Ticket->Subject;
@@ -192,8 +205,12 @@ sub TicketsInfo {
             name  => ( $Ticket->id . ': ' . substr $subject, 0, 30 ),
             start => $start,
             end   => $end,
-            color => $colors[ $i++ % @colors ],
-            link  => (
+            color => (
+                  $options{ColorSchemeByOwner}
+                ? $color_map{ $Ticket->OwnerObj->Name }
+                : $colors[ $i++ % @colors ]
+            ),
+            link => (
                     RT->Config->Get('WebPath')
                   . '/Ticket/Display.html?id='
                   . $Ticket->id

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



More information about the Bps-public-commit mailing list