[rt-devel] Option for Priority labels ...
Eric Berggren
ericb at fpt.fujitsu.com
Wed Feb 27 15:16:06 EST 2002
> My thought is "Let me give you mine first". I've already done what
> you've described, but without PriorityType. I haven't sat down and
> separated out our local modifications feature by feature, but I'll try
> to do so for this one today or tonight.
>
> Mine doesn't
> - handle ranges, if you use bubbling priority -- in fact,
> let's call priority settings not corresponding to labels
> "undefined behaviour" :-)
> - use FinalPriority at all
> - let you turn it off
Too l8... forgive me :( Right after posting i went straight to work,
and wrapped it up by late afternoon, comes up very clean tho. yay! :)
Check it out ...
This patch changes the presentation and selection of ticket/queue
priorities to user-defined labels and menu pull-downs. It does not make
any changes to the database or the tickets themselves, just the Web
front-end. Thus it should still work with existing priority escalation
schemes (EscalatePriority.pm); it was coded to avoid ticket priorities
from getting "snap"ed back to their base priority value. It can be
turned on and off at will (with a web server restart in between). We'll
be using this feature heavily; would love to see this or similar added
into the main distro. if anything, less hacking for me with each
release :)
Presentation of priorities is controlled in "config.pm" :
# How to display ticket priority
# This can change to/from anytime; presentation only & doesn't affect the
# database; must restart web server to take effect
#
# 0 - DEFAULT: integer value (0-99)
# 1 - use label values (as seen in %PriorityLabels)
# >1 - use label values, but also display ## (eg "General/35")
# if using "bubbling priorities", good to set this
#
$PriorityType = 1;
# Priority labels; 1 >= Low < 20; 20 >= General < 40; 40 >= High < 60; etc..
%PriorityLabels = ( 'None' => 0, 'Low' => 1, 'General' => 20,
'High' => 40, 'Critical' => 60, 'Fatal' => 99 );
#
# (leave @PrioritySortedKeys alone; used to set label for priorities)
@PrioritySortedKeys = reverse sort { $PriorityLabels{ $a } <=>
$PriorityLabels{ $b } }
keys %PriorityLabels;
Might also be valuable to add an additional column to the display when using
this (or just otherwise when tracking priority is important, but change
'PriorityAsString' to just 'Priority' if not using this patch) :
QueueListingCols =>
[
{ Header => 'Id',
TicketLink => 1,
TicketAttribute => 'Id'
},
+ { Header => 'Priority',
+ TicketAttribute => 'PriorityAsString'
+ },
{ Header => 'Subject',
TicketAttribute => 'Subject'
},
......
The patch here is based on 2.0.11 release into an installed system,
assuming it survives e-mail mangling (with tabs n' all). To patch the
build tree, simply symlink webrt -> WebRT, and . -> WebRT/html .
jeers,
-eric
( cd /topof/RT; .../gnu/bin/patch -p1 < /tmp/rt.patch )
*** ./WebRT/html/Admin/Elements/ModifyQueue-old Tue Nov 6 17:06:10 2001
--- ./WebRT/html/Admin/Elements/ModifyQueue Tue Feb 26 20:23:16 2002
***************
*** 26,36 ****
<TD ALIGN=RIGHT>
Priority starts at:
! </TD><TD><INPUT NAME="InitialPriority" value="<%$QueueObj->InitialPriority %>">
</TD>
<TD ALIGN=RIGHT>
Over time, priority moves toward:
! </TD><TD><INPUT NAME="FinalPriority" value="<%$QueueObj->FinalPriority %>">
</TD>
</TR>
<TR>
--- 26,36 ----
<TD ALIGN=RIGHT>
Priority starts at:
! </TD><TD><INPUT NAME="InitialPriority" value="<%$QueueObj->InitialPriorityAsString() %>">
</TD>
<TD ALIGN=RIGHT>
Over time, priority moves toward:
! </TD><TD><INPUT NAME="FinalPriority" value="<%$QueueObj->FinalPriorityAsString() %>">
</TD>
</TR>
<TR>
*** ./WebRT/html/Admin/Queues/Modify.html-old Mon Dec 3 18:13:24 2001
--- ./WebRT/html/Admin/Queues/Modify.html Tue Feb 26 20:47:09 2002
***************
*** 37,47 ****
<TD ALIGN=RIGHT>
Priority starts at:
! </TD><TD><INPUT NAME="InitialPriority" value="<%$QueueObj->InitialPriority %>">
</TD>
<TD ALIGN=RIGHT>
Over time, priority moves toward:
! </TD><TD><INPUT NAME="FinalPriority" value="<%$QueueObj->FinalPriority %>">
</TD>
</TR>
<TR>
--- 37,57 ----
<TD ALIGN=RIGHT>
Priority starts at:
! </TD><TD>
! % if ($RT::PriorityType) {
! <& /Elements/SelectPriority, Name => "InitialPriority", Default => $QueueObj->InitialPriority &>
! % } else {
! <INPUT NAME="InitialPriority" value="<%$QueueObj->InitialPriority %>">
! % }
</TD>
<TD ALIGN=RIGHT>
Over time, priority moves toward:
! </TD><TD>
! % if ($RT::PriorityType) {
! <& /Elements/SelectPriority, Name => "FinalPriority", Default => $QueueObj->FinalPriority &>
! % } else {
! <INPUT NAME="FinalPriority" value="<%$QueueObj->FinalPriority %>">
! % }
</TD>
</TR>
<TR>
*** ./WebRT/html/Elements/SelectPriority-old Sun Nov 4 17:04:00 2001
--- ./WebRT/html/Elements/SelectPriority Wed Feb 27 13:31:21 2002
***************
*** 0 ****
--- 1,33 ----
+ %#
+
+ <SELECT NAME ="<%$Name%>">
+ % foreach $priidx (@RT::PrioritySortedKeys) {
+ % my($value)=$RT::PriorityLabels{$priidx};
+ % my($prilabel)=$priidx;
+ % if ( $priidx eq $defprilabel ) {
+ % $prilabel .= "/".$defprivalue if ($RT::PriorityType > 1);
+ <OPTION VALUE="<%$defprivalue%>" SELECTED><%$prilabel%></OPTION>
+ % } else {
+ % $prilabel .= "/".$value if ($RT::PriorityType > 1);
+ <OPTION VALUE="<%$value%>"><%$prilabel%></OPTION>
+ % }
+ % }
+ </SELECT>
+ <%ARGS>
+ $Name => undef
+ $Default => undef
+
+ </%ARGS>
+ <%INIT>
+ my($priidx,$defprilabel,$defprivalue);
+ foreach $priidx (@RT::PrioritySortedKeys) {
+ if ( $Default >= $RT::PriorityLabels{$priidx}) {
+ # save current equivalent priority label
+ $defprilabel=$priidx;
+ # save current priority value to prevent tickets from having
+ # their priorities "snap"ed to closest level
+ $defprivalue=$Default;
+ last;
+ }
+ }
+ </%INIT>
*** ./WebRT/html/Search/Bulk.html-old Tue Nov 6 17:07:01 2001
--- ./WebRT/html/Search/Bulk.html Tue Feb 26 19:52:20 2002
***************
*** 74,80 ****
--- 74,84 ----
<TD VALIGN=TOP>
<UL>
<li> Make subject <INPUT Name="Subject" SIZE=20>
+ % if ($RT::PriorityType) {
+ <li> Make priority <& /Elements/SelectPriority, Name => "Priority" &>
+ % } else {
<li> Make priority <INPUT Name="Priority" SIZE=4>
+ % }
<li> Make queue <& /Elements/SelectQueue, Name => "Queue" &>
<li>Make Status <& /Elements/SelectStatus, Name => "Status" &>
***************
*** 117,123 ****
map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
my ($bgcolor, @results);
! my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorsAsString DueAsString );
Abort("No search to operate on") unless ($session{'tickets'});
--- 121,127 ----
map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
my ($bgcolor, @results);
! my @cols = qw(id Status PriorityAsString Subject QueueObj->Name OwnerObj->Name RequestorsAsString DueAsString );
Abort("No search to operate on") unless ($session{'tickets'});
*** ./WebRT/html/Search/PickRestriction-old Tue Nov 6 17:07:00 2001
--- ./WebRT/html/Search/PickRestriction Tue Feb 26 19:55:35 2002
***************
*** 30,36 ****
--- 30,40 ----
<li>Priority <& /Elements/SelectEqualityOperator, Name => "PriorityOp" &>
+ % if ($RT::PriorityType) {
+ <& /Elements/SelectPriority, Name => 'ValueOfPriority' &>
+ % } else {
<INPUT Name="ValueOfPriority" SIZE=5>
+ % }
<li>
*** ./WebRT/html/SelfService/Display.html-old Tue Nov 6 17:07:02 2001
--- ./WebRT/html/SelfService/Display.html Tue Feb 26 19:10:48 2002
***************
*** 54,60 ****
Priority
</TD>
<TD>
! <%$Ticket->Priority %>
</TD>
</TR>
--- 54,60 ----
Priority
</TD>
<TD>
! <%$Ticket->PriorityAsString() %>
</TD>
</TR>
*** ./WebRT/html/Ticket/Elements/EditBasics-old Tue Nov 6 17:07:00 2001
--- ./WebRT/html/Ticket/Elements/EditBasics Tue Feb 26 18:43:36 2002
***************
*** 29,35 ****
<TD>
<& /Elements/ShadedBox,
title => 'Priority',
! content => "<input name=Priority value=\"".$TicketObj->Priority."\" SIZE=3>"
&>
</TD>
--- 29,35 ----
<TD>
<& /Elements/ShadedBox,
title => 'Priority',
! content => $RT::PriorityType ? $SelectPriority : "<input name=Priority value=\"".$TicketObj->Priority."\" SIZE=3>"
&>
</TD>
***************
*** 36,42 ****
<TD>
<& /Elements/ShadedBox,
title => 'Final Priority',
! content => "<input name=FinalPriority value=\"".$TicketObj->FinalPriority."\" SIZE=3>"
&>
--- 36,42 ----
<TD>
<& /Elements/ShadedBox,
title => 'Final Priority',
! content => $RT::PriorityType ? $SelectFinalPriority : "<input name=FinalPriority value=\"".$TicketObj->FinalPriority."\" SIZE=3>"
&>
***************
*** 53,58 ****
--- 53,60 ----
<%INIT>
#It's hard to do this inline, so we'll preload the html of the selectstatus in here.
my $SelectStatus = $m->scomp("/Elements/SelectStatus", Name => 'Status', Default=> $TicketObj->Status);
+ my $SelectPriority = $m->scomp("/Elements/SelectPriority", Name => 'Priority', Default=> $TicketObj->Priority);
+ my $SelectFinalPriority = $m->scomp("/Elements/SelectPriority", Name => 'FinalPriority', Default=> $TicketObj->FinalPriority);
my $SelectQueue = $m->scomp("/Elements/SelectQueue", Name => 'Queue', Default =>$TicketObj->QueueObj->Id);
</%INIT>
*** ./WebRT/html/Ticket/Elements/ShowBasics-old Tue Nov 6 17:07:10 2001
--- ./WebRT/html/Ticket/Elements/ShowBasics Tue Feb 26 18:59:03 2002
***************
*** 9,15 ****
<& /Elements/ShadedBox, title => 'Worked' , content => $TimeWorked ." min" &>
</TD>
<TD VALIGN=TOP WIDTH="20%">
! <& /Elements/ShadedBox, title => 'Priority', content=> $Ticket->Priority."/".$Ticket->FinalPriority &>
</TD>
<TD VALIGN=TOP WIDTH="20%">
<& /Elements/ShadedBox, title => 'Queue', content=> $Ticket->QueueObj->Name &>
--- 9,15 ----
<& /Elements/ShadedBox, title => 'Worked' , content => $TimeWorked ." min" &>
</TD>
<TD VALIGN=TOP WIDTH="20%">
! <& /Elements/ShadedBox, title => 'Priority', content=> $Ticket->PriorityAsString()."/".$Ticket->FinalPriorityAsString() &>
</TD>
<TD VALIGN=TOP WIDTH="20%">
<& /Elements/ShadedBox, title => 'Queue', content=> $Ticket->QueueObj->Name &>
*** ./lib/RT/Queue.pm-old Fri Dec 14 13:03:08 2001
--- ./lib/RT/Queue.pm Tue Feb 26 20:20:50 2002
***************
*** 752,757 ****
--- 752,782 ----
# }}}
+ sub InitialPriorityAsString {
+ my $self=shift;
+
+ return priorityString($self->InitialPriority)
+ }
+ sub FinalPriorityAsString {
+ my $self=shift;
+
+ return priorityString($self->FinalPriority)
+ }
+ sub priorityString {
+ my $priority=shift;
+
+ if ( $RT::PriorityType ) {
+ foreach my $pridx ( @RT::PrioritySortedKeys ) {
+ if ( $priority >= $RT::PriorityLabels{ $pridx } ) {
+ return($pridx."/".$priority) if ( $RT::PriorityType != 1 );
+ return($pridx);
+ }
+ }
+ return "unknown";
+ }
+ return ($priority);
+ }
+
# {{{ Dealing with keyword selects
# {{{ sub AddKeywordSelect
*** ./lib/RT/Ticket.pm-old Mon Dec 17 13:26:10 2001
--- ./lib/RT/Ticket.pm Tue Feb 26 20:17:32 2002
***************
*** 1009,1014 ****
--- 1009,1060 ----
return ($self->Requestors->EmailsAsString() );
}
+ =head2 PriorityAsString
+
+ B<Returns> String: Various Ticket Priorities as either a string or integer
+
+ =cut
+
+ sub PriorityAsString {
+ my $self=shift;
+
+ unless ($self->CurrentUserHasRight('ShowTicket')) {
+ return undef;
+ }
+ return priorityString($self->Priority)
+ }
+ sub InitialPriorityAsString {
+ my $self=shift;
+
+ unless ($self->CurrentUserHasRight('ShowTicket')) {
+ return undef;
+ }
+ return priorityString($self->InitialPriority)
+ }
+ sub FinalPriorityAsString {
+ my $self=shift;
+
+ unless ($self->CurrentUserHasRight('ShowTicket')) {
+ return undef;
+ }
+ return priorityString($self->FinalPriority)
+ }
+
+ sub priorityString {
+ my $priority=shift;
+
+ if ( $RT::PriorityType ) {
+ foreach my $pridx ( @RT::PrioritySortedKeys ) {
+ if ( $priority >= $RT::PriorityLabels{ $pridx } ) {
+ return($pridx."/".$priority) if ( $RT::PriorityType != 1 );
+ return($pridx);
+ }
+ }
+ return "unknown";
+ }
+ return ($priority);
+ }
+
=head2 WatchersAsString
B<Returns> String: All Ticket Watchers email addresses as a string
More information about the Rt-devel
mailing list