[Bps-public-commit] RT-Extension-PriorityAsString branch, master, updated. 0.04-12-g04e15f2

Alex Vandiver alexmv at bestpractical.com
Tue Aug 28 22:31:03 EDT 2012


The branch, master has been updated
       via  04e15f2e6354d78ecb0f8e4496feaf3fa2d032f0 (commit)
       via  557f5e565ba81bc53a5b9c595f20e1352dd13b13 (commit)
       via  5349d39c38999e0a85829897820e088027039c85 (commit)
       via  1498a5fea0f1dd8ee5cd303eeefda290e3a5514a (commit)
      from  f9dfdfb988cfb565143bd4baa74f788787fbbcd1 (commit)

Summary of changes:
 .../PriorityAsString/Elements/RT__Ticket/ColumnMap/Once      |  2 +-
 .../PriorityAsString/Search/Elements/PickBasics/Default      |  2 +-
 .../Ticket/Elements/EditBasics/MassageFields                 |  2 +-
 html/Elements/SelectPriority                                 |  2 +-
 html/Elements/SelectPriorityAsString                         |  2 +-
 html/Ticket/Elements/ShowPriority                            |  7 +++----
 lib/RT/Extension/PriorityAsString.pm                         | 12 +++++++-----
 7 files changed, 15 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit 1498a5fea0f1dd8ee5cd303eeefda290e3a5514a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Aug 28 21:01:03 2012 -0400

    Fix simple %PriorityAsString configuration
    
    69c1881 mistakenly changed the _PriorityAsString method to never check
    the plain %PriorityAsString setting.  Change it to read from
    PriorityAsString rather than from PriorityAsStringQueues.

diff --git a/lib/RT/Extension/PriorityAsString.pm b/lib/RT/Extension/PriorityAsString.pm
index ee776af..b18154b 100644
--- a/lib/RT/Extension/PriorityAsString.pm
+++ b/lib/RT/Extension/PriorityAsString.pm
@@ -81,7 +81,7 @@ sub _PriorityAsString {
     } elsif ($queues and $queues->{$self->QueueObj->Name}) {
         %map = %{ $queues->{$self->QueueObj->Name} };
     } else {
-        %map = RT->Config->Get('PriorityAsStringQueues');
+        %map = RT->Config->Get('PriorityAsString');
     }
     if ( my ($res) = grep $map{$_} == $priority, keys %map ) {
         return $res;

commit 5349d39c38999e0a85829897820e088027039c85
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Aug 28 21:33:40 2012 -0400

    Only call ->PriorityAsString if necessary

diff --git a/html/Ticket/Elements/ShowPriority b/html/Ticket/Elements/ShowPriority
index 345d4d2..37e8628 100644
--- a/html/Ticket/Elements/ShowPriority
+++ b/html/Ticket/Elements/ShowPriority
@@ -1,6 +1,8 @@
 % if (keys %queues and not $queues{$Ticket->QueueObj->Name}) {
 <% $Ticket->Priority %>/<% $Ticket->FinalPriority || ''%>
 % } else {
+% my $current = $Ticket->PriorityAsString || '';
+% my $final = $Ticket->FinalPriorityAsString || '';
 <span class="ticket-info-priority-<% lc($current) %>"><% loc($current) %></span>/\
 <span class="ticket-info-final-priority-<% lc($final) %>"><% loc($final) %></span>
 % }
@@ -9,7 +11,4 @@ $Ticket => undef
 </%ARGS>
 <%INIT>
 my %queues = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
-
-my $current = $Ticket->PriorityAsString || '';
-my $final = $Ticket->FinalPriorityAsString || '';
 </%INIT>

commit 557f5e565ba81bc53a5b9c595f20e1352dd13b13
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Aug 28 21:38:52 2012 -0400

    Explicitly state the Type of the configuration variables used
    
    RT::Config->Get uses the Type of the configuration entry, as determined
    from its META hash, to decide what to return in array contexts.
    Additionally, RT::Config->Set explcitly alters the same Type based on
    how it is called.  Thus for array values, in the absence of an explicit
    Type, the ->Get method returns (undef) if it has never been ->Set, and a
    (possibly empty) list otherwise.  This leads to ->Get being extremely
    unreliable in hash contexts.
    
    Explicitly set the Types of the three configuration variables used in
    the extension.  This allows them to be reliably passed to ->Get in list
    context, which simplifies their access considerably.  Notably, for
    instance, the PriorityAsStringOrder variable no longer needs to filter
    out undefined values, as were previously encountered if it had never
    been ->Set.

diff --git a/html/Callbacks/PriorityAsString/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/PriorityAsString/Elements/RT__Ticket/ColumnMap/Once
index ef82e29..93b0965 100644
--- a/html/Callbacks/PriorityAsString/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/PriorityAsString/Elements/RT__Ticket/ColumnMap/Once
@@ -19,7 +19,7 @@ foreach my $field (qw(Priority InitialPriority FinalPriority)) {
 
     my $method = $field .'AsString';
 
-    my %queues = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
+    my %queues = RT->Config->Get('PriorityAsStringQueues');
     if (not keys %queues) {
         $COLUMN_MAP->{ $field }{'value'} = sub {
             return $printer->( $class, $_[0]->$method() );
diff --git a/html/Callbacks/PriorityAsString/Search/Elements/PickBasics/Default b/html/Callbacks/PriorityAsString/Search/Elements/PickBasics/Default
index acfa0c0..8015dc7 100644
--- a/html/Callbacks/PriorityAsString/Search/Elements/PickBasics/Default
+++ b/html/Callbacks/PriorityAsString/Search/Elements/PickBasics/Default
@@ -4,7 +4,7 @@ $Conditions => undef
 <%INIT>
 my %queues = %{ $m->caller_args(1)->{queues} || {} };
 
-my %as_string = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
+my %as_string = RT->Config->Get('PriorityAsStringQueues');
 
 # Leave it as-is if all queues use PriorityAsString; the overridden
 # /Elements/SelectPriority catches this case and always shows the
diff --git a/html/Callbacks/PriorityAsString/Ticket/Elements/EditBasics/MassageFields b/html/Callbacks/PriorityAsString/Ticket/Elements/EditBasics/MassageFields
index ea6dc76..45a24cd 100644
--- a/html/Callbacks/PriorityAsString/Ticket/Elements/EditBasics/MassageFields
+++ b/html/Callbacks/PriorityAsString/Ticket/Elements/EditBasics/MassageFields
@@ -3,7 +3,7 @@ $TicketObj => undef
 $Fields => undef
 </%ARGS>
 <%INIT>
-my %as_string = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
+my %as_string = RT->Config->Get('PriorityAsStringQueues');
 
 # Leave it as-is if all queues use PriorityAsString; the overridden
 # /Elements/SelectPriority catches this case and always shows the
diff --git a/html/Elements/SelectPriority b/html/Elements/SelectPriority
index 1d83cdc..ef21c70 100644
--- a/html/Elements/SelectPriority
+++ b/html/Elements/SelectPriority
@@ -5,7 +5,7 @@ $Default => undef
 </%ARGS>
 <%INIT>
 
-my %queues = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
+my %queues = RT->Config->Get('PriorityAsStringQueues');
 
 # If enabled for all queues, always show the drop-down
 return $m->comp("/Elements/SelectPriorityAsString",%ARGS)
diff --git a/html/Elements/SelectPriorityAsString b/html/Elements/SelectPriorityAsString
index de95534..11db60b 100644
--- a/html/Elements/SelectPriorityAsString
+++ b/html/Elements/SelectPriorityAsString
@@ -22,7 +22,7 @@ $Mapping => undef
 <%INIT>
 
 my %map   = $Mapping ? %{ $Mapping } : RT->Config->Get('PriorityAsString');
-my @order = grep defined && length, RT->Config->Get('PriorityAsStringOrder');
+my @order = RT->Config->Get('PriorityAsStringOrder');
 @order = sort { $map{$a} <=> $map{$b} } keys %map
     unless @order;
 
diff --git a/html/Ticket/Elements/ShowPriority b/html/Ticket/Elements/ShowPriority
index 37e8628..cf8af51 100644
--- a/html/Ticket/Elements/ShowPriority
+++ b/html/Ticket/Elements/ShowPriority
@@ -10,5 +10,5 @@
 $Ticket => undef
 </%ARGS>
 <%INIT>
-my %queues = %{ RT->Config->Get('PriorityAsStringQueues') || {} };
+my %queues = RT->Config->Get('PriorityAsStringQueues');
 </%INIT>
diff --git a/lib/RT/Extension/PriorityAsString.pm b/lib/RT/Extension/PriorityAsString.pm
index b18154b..78ed954 100644
--- a/lib/RT/Extension/PriorityAsString.pm
+++ b/lib/RT/Extension/PriorityAsString.pm
@@ -53,6 +53,11 @@ RT::Extension::PriorityAsString - show priorities in RT as strings instead of nu
 require RT::Ticket;
 package RT::Ticket;
 
+$RT::Config::META{PriorityAsString}{Type} = 'HASH';
+$RT::Config::META{PriorityAsStringOrder}{Type} = 'ARRAY';
+$RT::Config::META{PriorityAsStringQueues}{Type} = 'HASH';
+
+
 # Returns String: Various Ticket Priorities as either a string or integer
 sub PriorityAsString {
     my $self = shift;
@@ -87,7 +92,7 @@ sub _PriorityAsString {
         return $res;
     }
 
-    my @order = reverse grep defined && length, RT->Config->Get('PriorityAsStringOrder');
+    my @order = reverse RT->Config->Get('PriorityAsStringOrder');
     @order = sort { $map{$b} <=> $map{$a} } keys %map
         unless @order;
 

commit 04e15f2e6354d78ecb0f8e4496feaf3fa2d032f0
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Aug 28 21:45:41 2012 -0400

    Remove some commented out stub code

diff --git a/lib/RT/Extension/PriorityAsString.pm b/lib/RT/Extension/PriorityAsString.pm
index 78ed954..ac7673c 100644
--- a/lib/RT/Extension/PriorityAsString.pm
+++ b/lib/RT/Extension/PriorityAsString.pm
@@ -96,9 +96,6 @@ sub _PriorityAsString {
     @order = sort { $map{$b} <=> $map{$a} } keys %map
         unless @order;
 
-    # XXX: not supported yet
-    #my $show  = RT->Config->Get('PriorityAsStringShow') || 'string';
-
     foreach my $label ( @order ) {
         return $label if $priority >= $map{ $label };
     }

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



More information about the Bps-public-commit mailing list