[Rt-commit] rt branch, 4.6/priority-as-string, repushed

Brian Duggan brian at bestpractical.com
Mon Jun 11 14:47:39 EDT 2018


The branch 4.6/priority-as-string was deleted and repushed:
       was 0f00df04f39abf5b113a302d4f466df702bc9e28
       now 980e9ee08dfd9c5757e5dc84ed203ac02f4f30b7

1: 1ee888e05 ! 1: 980e9ee08 Core RT::Extension::PriorityAsString
    @@ -5,6 +5,78 @@
         Port functionality of RT::Extension::PriorityAsString. Replicate
         existing behavior of extension.
     
    +diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
    +--- a/etc/RT_Config.pm.in
    ++++ b/etc/RT_Config.pm.in
    +@@
    + 
    + =back
    + 
    ++
    ++
    ++
    ++=head1 Priority strings
    ++
    ++=over 4
    ++
    ++=item C<%PriorityAsString>
    ++
    ++RT can assign a priority value to tickets. Priority is stored as an
    ++integer in the database, but RT supports mapping strings to numerical
    ++values. For example, the default mapping is:
    ++
    ++    Set(%PriorityAsString, (Low => 0, Medium => 50, High => 100));
    ++
    ++Redefine C<%PriorityAsString> in C<RT_SiteConfig.pm> to set site
    ++priority strings.
    ++
    ++=cut
    ++
    ++Set(%PriorityAsString, (Low => 0, Medium => 50, High => 100));
    ++
    ++=item C<%PriorityAsStringOrder>
    ++
    ++Administrators can alter the order of priority strings as they appear
    ++in selection drop-downs with C<@PriorityStringOrder>. Administrators
    ++can also use this setting to limit the available priority strings on
    ++ticket update pages. When this options is defined, scrips and other RT
    ++code will still have access to all of the priority strings defined in
    ++C<%PriorityAsString>. To set a priority string order:
    ++
    ++    Set(@PriorityAsStringOrder, qw(Low Medium High));
    ++
    ++=cut
    ++
    ++=item C<%PriorityAsStringQueues>
    ++
    ++RT supports different priority string mappings for individual queues
    ++with C<%PriorityAsStringQueues>. Use queue names as keys in this
    ++hash. Then define priority string-number hash maps for each queue's
    ++value. Tickets in queues that aren't defined in this hash will fall
    ++back to RT's numerical priorities.
    ++
    ++When C<%PriorityAsStringQueues> is set, RT ignores both
    ++C<%PriorityAsString> and C<@PriorityAsStringOrder>. Administrators do
    ++not need to define C<%PriorityAsStringQueues> or C<%PriorityAsString>
    ++when they set C<%PriorityAsStringQueues>.
    ++
    ++To set per-queue priority strings:
    ++
    ++    Set(%PriorityAsStringQueues,
    ++      General => { Low => 0, Medium => 50, High => 100 },
    ++      Binary  => { Low => 0, High => 10 },
    ++    );
    ++
    ++=cut
    ++
    ++=back
    ++
    ++
    ++
    + =head1 Administrative interface
    + 
    + =over 4
    +
     diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
     --- a/lib/RT/Ticket.pm
     +++ b/lib/RT/Ticket.pm
    @@ -19,6 +91,36 @@
      sub LifecycleColumn { "Queue" }
      
      my %ROLES = (
    +@@
    + Returns the current value of InitialPriority.
    + (In the database, InitialPriority is stored as int(11).)
    + 
    ++=head2 InitialPriorityAsString
    + 
    ++Returns the current mapped string value of InitialPriority.
    + 
    + =head2 SetInitialPriority VALUE
    + 
    +@@
    + Returns the current value of FinalPriority.
    + (In the database, FinalPriority is stored as int(11).)
    + 
    ++=head2 FinalPriorityAsString
    + 
    ++Returns the current mapped string value of FinalPriority.
    + 
    + =head2 SetFinalPriority VALUE
    + 
    +@@
    + Returns the current value of Priority.
    + (In the database, Priority is stored as int(11).)
    + 
    ++=head2 PriorityAsString
    + 
    ++Returns the current mapped string value of Priority.
    + 
    + =head2 SetPriority VALUE
    + 
     @@
          return %store;
      }
    @@ -138,6 +240,48 @@
      $Default = '' unless defined $Default;
      </%INIT>
     
    +diff --git a/share/html/Elements/SelectPriorityAsString b/share/html/Elements/SelectPriorityAsString
    +new file mode 100644
    +--- /dev/null
    ++++ b/share/html/Elements/SelectPriorityAsString
    +@@
    ++<select class="select-priority" name="<% $Name %>">
    ++% unless ( defined $Default ) {
    ++<option value="">-</option>
    ++% }
    ++<%PERL>
    ++foreach my $label ( @order ) {
    ++    my ($value, $selected);
    ++    if ( $label eq $default_label ) {
    ++        ($value, $selected) = ($Default, 'selected="selected"');
    ++    } else {
    ++        ($value, $selected) = ($map{ $label }, '');
    ++    }
    ++</%PERL>
    ++<option class="<% lc $label %>" value="<% $value %>" <% $selected |n %>><% loc($label) %></option>
    ++% }
    ++</select>
    ++<%ARGS>
    ++$Name => 'Priority'
    ++$Default => undef
    ++$Mapping => undef
    ++</%ARGS>
    ++<%INIT>
    ++
    ++my %map   = $Mapping ? %{ $Mapping } : RT->Config->Get('PriorityAsString');
    ++my @order;
    ++if (not $Mapping and RT->Config->Get('PriorityAsStringOrder')) {
    ++    @order = grep {exists $map{$_}} RT->Config->Get('PriorityAsStringOrder');
    ++} else {
    ++    @order = sort { $map{$a} <=> $map{$b} } keys %map;
    ++}
    ++
    ++my $default_label = '';
    ++if ( defined $Default && length $Default ) {
    ++    $default_label = RT::Ticket->_PriorityAsString( $Default, \%map ) || '';
    ++}
    ++</%INIT>
    +
     diff --git a/share/html/Search/Elements/PickBasics b/share/html/Search/Elements/PickBasics
     --- a/share/html/Search/Elements/PickBasics
     +++ b/share/html/Search/Elements/PickBasics
    @@ -161,10 +305,10 @@
     +    # in another, we can't use names
     +    my %values;
     +    for my $q (keys %queues) {
    -+	for my $priority (keys %{$as_string{$q}}) {
    -+	    return if exists $values{$priority} and $as_string{$q}{$priority} != $values{$priority};
    -+	    $values{$priority} = $as_string{$q}{$priority};
    -+	}
    ++        for my $priority (keys %{$as_string{$q}}) {
    ++            return if exists $values{$priority} and $as_string{$q}{$priority} != $values{$priority};
    ++            $values{$priority} = $as_string{$q}{$priority};
    ++        }
     +    }
     +
     +    # Swap out the /Elements/SelectPriority for /Elements/SelectPriorityAsString
    @@ -203,14 +347,14 @@
                          name => $_,
     -                    comp => '/Elements/SelectPriority',
     +                    comp => $TicketObj->PriorityIsString
    -+			? '/Elements/SelectPriorityAsString'
    -+			: '/Elements/SelectPriority',
    ++                        ? '/Elements/SelectPriorityAsString'
    ++                        : '/Elements/SelectPriority',
                          args => {
                              Name => $field,
                              Default => $defaults{$field} || $TicketObj->$field,
    -+			Mapping => $TicketObj->PriorityIsString
    -+			    ? $queue_priority_strings{$TicketObj->QueueObj->Name}
    -+			    : undef,
    ++                        Mapping => $TicketObj->PriorityIsString
    ++                            ? $queue_priority_strings{$TicketObj->QueueObj->Name}
    ++                            : undef,
                          }
                      }
                  } ('Priority', 'Final Priority')
    @@ -243,3 +387,15 @@
     +};
     +</%INIT>
     
    +diff --git a/t/web/mobile.t b/t/web/mobile.t
    +--- a/t/web/mobile.t
    ++++ b/t/web/mobile.t
    +@@
    + $m->content_contains( 'open', 'status' );
    + $m->content_contains( 'cc at example.com', 'cc' );
    + $m->content_contains( 'admincc at example.com', 'admincc' );
    +-$m->content_contains( '13/93', 'priority' );
    ++$m->text_contains( 'Low/Medium', 'priority' );
    + $m->content_contains( '2 hour', 'time estimates' );
    + $m->content_contains( '30 min', 'time worked' );
    + $m->content_contains( '60 min', 'time left' );
2: 0f00df04f < -:  ------- Add pod for PriorityAsString



More information about the rt-commit mailing list