Commit a2cc5c2d authored by sunnavy's avatar sunnavy
Browse files

add ColorSchemeByOwner option to show the same color for each owner

parent cc03b29d
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment