[Bps-public-commit] rt-extension-jsgantt branch, master, updated. fee8b82dc8b000174a677284ef5ab0330898c678
? sunnavy
sunnavy at bestpractical.com
Wed Feb 2 02:58:27 EST 2011
The branch, master has been updated
via fee8b82dc8b000174a677284ef5ab0330898c678 (commit)
from fb70ef0f8a75a7f22447462d6f38e2ea88f158a2 (commit)
Summary of changes:
README | 26 ++++---
html/Search/JSGantt.html | 15 +---
lib/RT/Extension/JSGantt.pm | 171 ++++++++++++++++++++++++++-----------------
3 files changed, 122 insertions(+), 90 deletions(-)
- Log -----------------------------------------------------------------
commit fee8b82dc8b000174a677284ef5ab0330898c678
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Feb 2 15:58:24 2011 +0800
use a generic JSGanttOptions config, also tweaked the days caculation from total time
diff --git a/README b/README
index da5f34a..71bb41e 100644
--- a/README
+++ b/README
@@ -9,20 +9,22 @@ How to install:
# add RT::Extension::JSGantt to @Plugins: e.g.
Set(@Plugins,'RT::Extension::JSGantt');
# customize JSGantt as you wish:
- Set($JSGanttDefaultFormat,'month'); # or day or year or quarter
- Set($JSGanttShowDuration,1);
- Set($JSGanttShowOwner,1);
- Set($JSGanttShowProgress,1);
- Set(@JSGanttColorScheme, 'ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff');
- # working hours per day, used to caculate day length
- Set($JSGanttWorkingHoursPerDay, 8);
+ Set(
+ %JSGanttOptions,
+ DefaultFormat => 'day', # or week or month or quarter
+ ShowOwner => 1,
+ ShowProgress => 1,
+ ShowDuration => 1,
+ ColorScheme => ['ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff'],
+ # if can't find both start and end dates, use this color
+ NullDatesColor => 333,
+ # to caculate day length
+ WorkingHoursPerDay => 8,
+ # used to set start/end if one exists but the other does not
+ DefaultDays => 7,
+ );
- # default day length, used to figure out start/end if one exists but the other not
- Set($JSGanttDefaultDays, 7);
-
- # if we can't find both start and end dates, use this color
- Set($JSGanttNullDatesColor, '333');
5. patch /Ticket/Elements/ShowSummary if you are using rt < 3.9
$ patch /path/to/Ticket/Elements/ShowSummary < /path/to/showsummary.diff
6. restart RT
diff --git a/html/Search/JSGantt.html b/html/Search/JSGantt.html
index 480d158..230f65e 100644
--- a/html/Search/JSGantt.html
+++ b/html/Search/JSGantt.html
@@ -10,17 +10,11 @@
// Future idea would be to allow XML file name to be passed in and chart tasks built from file.
var g = new JSGantt.GanttChart('g',document.getElementById('GanttChartDIV'),
- '<% RT->Config->Get('JSGanttDefaultFormat') || 'day' %>' );
+ '<% $options{'DefaultFormat'} || 'day' %>' );
- g.setShowRes(<% RT->Config->Get('JSGanttShowOwner')? 1 : 0 %>);
- g.setShowDur(<% RT->Config->Get('JSGanttShowDuration')? 1 : 0 %> );
-
-% my $show_progress = RT->Config->Get('JSGanttShowProgress' );
-% if ( $show_progress ) {
- g.setShowComp(1);
-% } else {
- g.setShowComp(0);
-% }
+ g.setShowRes(<% $options{'ShowOwner'}? 1 : 0 %>);
+ g.setShowDur(<% $options{'ShowDuration'}? 1 : 0 %> );
+ g.setShowComp(<% $options{'ShowProgress'} ? 1 : 0 %> );
g.setCaptionType('Resource'); // Set to Show Caption (None,Caption,Resource,Duration,Complete)
@@ -58,6 +52,7 @@
my $title = loc('JSGantt Results');
my @Tickets;
+my %options = RT->Config->Get('JSGanttOptions');
if ( $Ticket ) {
@Tickets = RT::Extension::JSGantt->AllRelatedTickets(
Ticket => $Ticket,
diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index c8d4e4d..fcc56e6 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -1,10 +1,72 @@
-package RT::Extension::JSGantt;
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
+# <jesse at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+
+=head1 NAME
+
+RT::Extension::JSGantt - Gantt charts for your tickets
-our $VERSION = '0.04';
+=head1 SYNOPSIS
+
+ use RT::Extension::JSGantt;
+
+=cut
+
+package RT::Extension::JSGantt;
use warnings;
use strict;
+=head2 AllRelatedTickets
+
+Given a ticket, return all the relative tickets, including the original ticket.
+
+=cut
+
sub AllRelatedTickets {
my $class = shift;
my %args = ( Ticket => undef, CurrentUser => undef, @_ );
@@ -40,6 +102,12 @@ sub AllRelatedTickets {
return @tickets;
}
+=head2 TicketsInfo
+
+Given tickets, resolve useful info for jsgantt.js
+Returns a 2 elements array, 1st is the ids arrayref, 2nd is the info hashref.
+
+=cut
sub TicketsInfo {
my $class = shift;
@@ -47,11 +115,17 @@ sub TicketsInfo {
my ( @ids, %info );
- my @colors = grep { defined } RT->Config->Get('JSGanttColorScheme');
- @colors = ( 'ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff' )
- unless @colors;
+ my %options = RT->Config->Get('JSGanttOptions');
+
+ my @colors;
+ if ( $options{ColorScheme} ) {
+ @colors = @{$options{ColorScheme}};
+ }
+ else {
+ @colors =
+ ( 'ff0000', 'ffff00', 'ff00ff', '00ff00', '00ffff', '0000ff' );
+ }
my $i;
- my $show_progress = RT->Config->Get('JSGanttShowProgress' );
my ( $min_start, $min_start_obj );
@@ -88,7 +162,7 @@ sub TicketsInfo {
}
}
- if ($show_progress) {
+ if ($options{ShowProgress}) {
my $total_time =
defined $Ticket->TimeLeft && $Ticket->TimeLeft =~ /\d/
? ( $Ticket->TimeWorked + $Ticket->TimeLeft )
@@ -132,7 +206,7 @@ sub TicketsInfo {
$min_start = join '/', $month + 1, $day, $year;
}
- my $no_dates_color = RT->Config->Get('JSGanttNullDatesColor') || '333';
+ my $no_dates_color = $options{NullDatesColor} || '333';
for my $id (@ids) {
$info{$id}{color} = $no_dates_color unless $info{$id}{start};
$info{$id}{start} ||= $min_start;
@@ -141,8 +215,18 @@ sub TicketsInfo {
return \@ids, \%info;
}
+
+=head2 GetTimeRange
+
+Given a ticket, resolve it's start/end.
+Returns an array like ( $start_obj, $start, $end_obj, $end )
+$start and $end are strings like 3/21/2011
+
+=cut
+
sub _GetTimeRange {
my ( $Ticket, %args ) = @_;
+ my %options = RT->Config->Get('JSGanttOptions');
# the, uh, long way
my ( $start_obj, $start ) = _GetDate( $Ticket, 'Starts', 'Started' );
@@ -164,18 +248,20 @@ sub _GetTimeRange {
}
}
-
# if $start or $end is empty still
unless ( $start && $end ) {
- my $hours_per_day = RT->Config->Get('JSGanttWorkingHoursPerDay')
- || 8;
+ my $hours_per_day = $options{WorkingHoursPerDay} || 8;
my $total_time =
defined $Ticket->TimeLeft && $Ticket->TimeLeft =~ /\d/
? ( $Ticket->TimeWorked + $Ticket->TimeLeft )
: $Ticket->TimeEstimated;
- $total_time ||= 0;
- my $days = int( $total_time / ( 60 * $hours_per_day ) );
- $days ||= RT->Config->Get('JSGanttDefaultDays') || 7;
+ my $days;
+ if ( $total_time ) {
+ $days = $total_time / ( 60 * $hours_per_day );
+ }
+ else {
+ $days = $options{'DefaultDays'} || 7;
+ }
# since we only use date without time, let's make days inclusive
# ( i.e. 5/12/2010 minus 3 days is 5/10/2010. 10,11,12, 3 days! )
@@ -185,7 +271,7 @@ sub _GetTimeRange {
if ( $start && !$end ) {
$end_obj = RT::Date->new( $args{CurrentUser} );
$end_obj->Set( Value => $start_obj->Unix );
- $end_obj->AddDays($days);
+ $end_obj->AddDays($days) if $days;
my ( $day, $month, $year ) =
( $end_obj->Localtime('user') )[ 3, 4, 5 ];
$end = join '/', $month + 1, $day, $year;
@@ -194,7 +280,7 @@ sub _GetTimeRange {
if ( $end && !$start ) {
$start_obj = RT::Date->new( $args{CurrentUser} );
$start_obj->Set( Value => $end_obj->Unix );
- $start_obj->AddDays( -1 * $days );
+ $start_obj->AddDays( -1 * $days ) if $days;
my ( $day, $month, $year ) =
( $start_obj->Localtime('user') )[ 3, 4, 5 ];
$start = join '/', $month + 1, $day, $year;
@@ -208,6 +294,7 @@ sub _GetTimeRange {
);
$start = $end if $end;
}
+
if ( !$end ) {
$RT::Logger->warning( "Ticket "
. $Ticket->id
@@ -306,56 +393,4 @@ sub _GetOrderedTickets {
}
}
-
-=head1 NAME
-
-RT::Extension::JSGantt - Gantt charts for your tickets
-
-
-=head1 SYNOPSIS
-
- use RT::Extension::JSGantt;
-
-
-=head1 DESCRIPTION
-
-
-=head1 AUTHOR
-
-sunnavy C<< <sunnavy at bestpractical.com> >>
-
-
-=head1 LICENCE AND COPYRIGHT
-
-Copyright (c) 2010, Best Practical Solutions, LLC. All rights reserved.
-
-This module is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself. See L<perlartistic>.
-
-
-=head1 DISCLAIMER OF WARRANTY
-
-BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
-EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
-ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
-YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
-NECESSARY SERVICING, REPAIR, OR CORRECTION.
-
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
-OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
-THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-=cut
-
1;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list