[rt-users] CONTRIB: Labeled priorities for RT 3.6
Todd Chapman
todd at chaka.net
Tue Jul 11 17:44:04 EDT 2006
I updated the patch found here: http://www.parliant.com/~cmh/rt/
to work for RT 3.6.
This gives RT labeled priorities instead of numeric ones.
See attached.
-Todd
-------------- next part --------------
--- html/Elements/RT__Ticket/ColumnMap (revision 7319)
+++ html/Elements/RT__Ticket/ColumnMap (local)
@@ -158,17 +158,17 @@
},
Priority => {
attribute => 'Priority',
- value => sub { return $_[0]->Priority }
+ value => sub { return $RT::PriorityType?$_[0]->PriorityAsString() : $_[0]->Priority }
},
InitialPriority => {
attribute => 'InitialPriority',
name => 'Initial Priority',
- value => sub { return $_[0]->InitialPriority }
+ value => sub { return $RT::PriorityType?$_[0]->InitialPriorityAsString(): $_[0]->InitialPriority }
},
FinalPriority => {
attribute => 'FinalPriority',
name => 'Final Priority',
- value => sub { return $_[0]->FinalPriority }
+ value => sub { return $RT::PriorityType?$_[0]->FinalPriorityAsString():$_[0]->FinalPriority }
},
EffectiveId => {
attribute => 'EffectiveId',
--- html/Elements/SelectPriority (revision 7319)
+++ html/Elements/SelectPriority (local)
@@ -0,0 +1,34 @@
+%#
+
+<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>
+
--- html/Search/Bulk.html (revision 7319)
+++ html/Search/Bulk.html (local)
@@ -100,7 +100,11 @@
<tr><td class="label"> <&|/l&>Make subject</&>: </td>
<td class="value"> <input name="Subject" size="20" /> </td></tr>
<tr><td class="label"> <&|/l&>Make priority</&>: </td>
-<td class="value"> <input name="Priority" size="4" /> </td></tr>
+% if ($RT::PriorityType) {
+ <td class=value><& /Elements/SelectPriority, Name => 'Priority', Default => 0 &></td></tr>
+% } else {
+ <td class=value> <INPUT Name="Priority" SIZE=4> </td></tr>
+% }
<tr><td class="label"> <&|/l&>Make queue</&>: </td>
<td class="value"> <& /Elements/SelectQueue, Name => "Queue" &> </td></tr>
<tr><td class="label"> <&|/l&>Make Status</&>: </td>
--- html/Search/Elements/PickBasics (revision 7319)
+++ html/Search/Elements/PickBasics (local)
@@ -151,7 +151,11 @@
</td><td>
<& /Elements/SelectEqualityOperator, Name => "PriorityOp" &>
</td><td>
-<input name="ValueOfPriority" size="5" />
+% if ($RT::PriorityType) {
+ <&/Elements/SelectPriority, Name=>"ValueOfPriority" &>
+% } else {
+ <INPUT Name="ValueOfPriority" SIZE=5>
+% }
</td>
</tr>
<tr>
--- html/Ticket/Create.html (revision 7319)
+++ html/Ticket/Create.html (local)
@@ -177,8 +177,16 @@
title_class=> 'inverse',
color => "#993333" &>
<table border="0">
+% if ($RT::PriorityType) {
+<tr><td align=right><&|/l&>Priority</&>:</td><td><&/Elements/SelectPriority, name=>"InitialPriority", default=> $ARGS{InitialPriority}?$ARGS{InitialPriority} :$QueueObj->InitialPriority &></td></tr>
+%} else {
<tr><td align="right"><&|/l&>Priority</&>:</td><td><input size="3" name="InitialPriority" value="<% $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority %>" /></td></tr>
+%}
+% if ($RT::PriorityType) {
+<tr><td align=right><&|/l&>Final Priority</&>:</td><td><&/Elements/SelectPriority, name=>"FinalPriority", default=> $ARGS{FinalPriority}?$ARGS{FinalPriority} :$QueueObj->FinalPriority &></td></tr>
+%} else {
<tr><td align="right"><&|/l&>Final Priority</&>:</td><td><input size="3" name="FinalPriority" value="<% $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority %>" /></td></tr>
+%}
<tr><td align="right"><&|/l&>Time Estimated</&>:</td>
<td>
<input size="3" name="TimeEstimated" value="<%$ARGS{TimeEstimated}%>" />
@@ -200,7 +208,7 @@
</&>
<br />
<&|/Widgets/TitleBox, title => loc("Dates"),
- title_class=> 'inverse',
+ Title_class=> 'inverse',
color => "#663366" &>
<table>
--- html/Ticket/Elements/EditBasics (revision 7319)
+++ html/Ticket/Elements/EditBasics (local)
@@ -85,12 +85,20 @@
<tr>
<td class="label"><&|/l&>Priority</&>:</td>
+% if ($RT::PriorityType) {
+ <td class="value"><&/Elements/SelectPriority, name=>"Priority", default=>$TicketObj->Priority &></td>
+% } else {
<td class="value"><input name="Priority" value="<%$TicketObj->Priority|h%>" size="5" /></td>
+% }
</tr>
<tr>
<td class="label"><&|/l&>Final Priority</&>:</td>
+% if ($RT::PriorityType) {
+ <td class="value"><&/Elements/SelectPriority, name=>"FinalPriority", default=>$TicketObj->FinalPriority &></td>
+% } else {
<td class="value"><input name="FinalPriority" value="<%$TicketObj->FinalPriority|h%>" size="5" /></td>
+% }
</tr>
--- html/Ticket/Elements/ShowBasics (revision 7319)
+++ html/Ticket/Elements/ShowBasics (local)
@@ -70,7 +70,11 @@
</tr>
<tr>
<td class="label"><&|/l&>Priority</&>:</td>
+% if ($RT::PriorityType) {
+ <td class="value"><%$Ticket->PriorityAsString()%>/<%$Ticket->FinalPriorityAsString()%></td>
+% } else {
<td class="value"><%$Ticket->Priority%>/<%$Ticket->FinalPriority %></td>
+% }
</tr>
<tr>
<td class="label"><&|/l&>Queue</&>:</td>
--- lib/RT/Ticket_Overlay.pm (revision 7319)
+++ lib/RT/Ticket_Overlay.pm (local)
@@ -3770,6 +3770,56 @@
"RT::Queue-RT::Ticket";
}
+
+
+=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);
+}
+
+
+
1;
=head1 AUTHOR
=== html/Elements/RT__Ticket/ColumnMap
==================================================================
=== html/Elements/SelectPriority
==================================================================
=== html/Search/Bulk.html
==================================================================
=== html/Search/Elements/PickBasics
==================================================================
=== html/Ticket/Create.html
==================================================================
=== html/Ticket/Elements/EditBasics
==================================================================
=== html/Ticket/Elements/ShowBasics
==================================================================
=== lib/RT/Ticket_Overlay.pm
==================================================================
More information about the rt-users
mailing list