[Rt-commit] rt branch, 4.2/refresh-intervals, created. rt-4.2.12-127-gab169c2
Shawn Moore
shawn at bestpractical.com
Wed Jun 1 14:40:44 EDT 2016
The branch, 4.2/refresh-intervals has been created
at ab169c273aa112092ff99bbae69cec406868562a (commit)
- Log -----------------------------------------------------------------
commit e5e5e3d026d9cb90d4a1b2487809dd2e7e1c42c2
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 1 18:36:18 2016 +0000
Handle ValuesLabels loc strings with parameters
For example:
$labels{$value} = ['Refresh home page every [quant,_1,minute,minutes].', $value / 60];
See next commit for more context.
diff --git a/share/html/Widgets/Form/Select b/share/html/Widgets/Form/Select
index d08cea9..a8eea54 100644
--- a/share/html/Widgets/Form/Select
+++ b/share/html/Widgets/Form/Select
@@ -91,7 +91,7 @@ $Multiple => 0,
% foreach my $v( @Values ) {
% my $selected = '';
% $selected = 'selected="selected"' if delete $CurrentValue{ $v };
-<option value="<% $v %>" <% $selected |n %>><% loc($ValuesLabel{ $v } || $v) %></option>
+<option value="<% $v %>" <% $selected |n %>><% loc(ref($ValuesLabel{ $v }) ? @{ $ValuesLabel{ $v } } : $ValuesLabel{ $v } || $v) %></option>
% }
% if ( $Alternative ) {
@@ -120,7 +120,7 @@ if ( $ValuesCallback ) {
}
unless (defined $DefaultLabel ) {
$DefaultLabel = loc('Use system default ([_1])',
- join ', ', map loc($ValuesLabel{$_} || $_), grep defined,
+ join ', ', map loc(ref($ValuesLabel{$_}) ? @{ $ValuesLabel{$_ }} : $ValuesLabel{$_} || $_), grep defined,
@DefaultValue
);
}
commit ab169c273aa112092ff99bbae69cec406868562a
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 1 18:37:18 2016 +0000
Add RefreshIntervals config option
This handles 30, 60, and 90 second values, not just multiple minutes
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index a2817a7..069655e 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1223,10 +1223,23 @@ search results on the front page.
Set($DefaultSummaryRows, 10);
+=item C<@RefreshIntervals>
+
+This setting defines the possible homepage and search result refresh
+options. Each value is a number of seconds. You should not include a value
+of C<0>, as that is always provided as an option.
+
+See also L</HomePageRefreshInterval> and L</SearchResultsRefreshInterval>.
+
+=cut
+
+Set(@RefreshIntervals, qw(120 300 600 1200 3600 7200));
+
=item C<$HomePageRefreshInterval>
C<$HomePageRefreshInterval> is default number of seconds to refresh
-the RT home page. Choose from [0, 120, 300, 600, 1200, 3600, 7200].
+the RT home page. Choose from any value in L</@RefreshIntervals>,
+or the default of C<0> for no automatic refresh.
=cut
@@ -1284,9 +1297,9 @@ Set($TicketsItemMapSize, 1000);
=item C<$SearchResultsRefreshInterval>
-C<$SearchResultsRefreshInterval> is default number of seconds to
-refresh search results in RT. Choose from [0, 120, 300, 600, 1200,
-3600, 7200].
+C<$SearchResultsRefreshInterval> is default number of seconds to refresh
+search results in RT. Choose from any value in L</@RefreshIntervals>, or
+the default of C<0> for no automatic refresh.
=cut
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 2ec63f8..71e727f 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -307,23 +307,42 @@ our %META;
Hints => 'Only for entry, not display', #loc
},
},
+ RefreshIntervals => {
+ Type => 'ARRAY',
+ PostLoadCheck => sub {
+ my $self = shift;
+ my @intervals = $self->Get('RefreshIntervals');
+ if (grep { $_ == 0 } @intervals) {
+ $RT::Logger->warning("Please do not include a 0 value in RefreshIntervals, as that default is already added for you.");
+ }
+ },
+ },
SearchResultsRefreshInterval => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 9,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
- Description => 'Search results refresh interval', #loc
- Values => [qw(0 120 300 600 1200 3600 7200)],
- ValuesLabel => {
- 0 => "Don't refresh search results.", #loc
- 120 => "Refresh search results every 2 minutes.", #loc
- 300 => "Refresh search results every 5 minutes.", #loc
- 600 => "Refresh search results every 10 minutes.", #loc
- 1200 => "Refresh search results every 20 minutes.", #loc
- 3600 => "Refresh search results every 60 minutes.", #loc
- 7200 => "Refresh search results every 120 minutes.", #loc
- },
+ Description => 'Search results refresh interval', #loc
+ Callback => sub {
+ my @values = RT->Config->Get('RefreshIntervals');
+ my %labels = (
+ 0 => "Don't refresh search results.", # loc
+ );
+
+ for my $value (@values) {
+ if ($value % 60 == 0) {
+ $labels{$value} = ['Refresh search results every [quant,_1,minute,minutes].', $value / 60]; # loc
+ }
+ else {
+ $labels{$value} = ['Refresh search results every [quant,_1,second,seconds].', $value]; # loc
+ }
+ }
+
+ unshift @values, 0;
+
+ return { Values => \@values, ValuesLabel => \%labels };
+ },
},
},
@@ -335,16 +354,25 @@ our %META;
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Home page refresh interval', #loc
- Values => [qw(0 120 300 600 1200 3600 7200)],
- ValuesLabel => {
- 0 => "Don't refresh home page.", #loc
- 120 => "Refresh home page every 2 minutes.", #loc
- 300 => "Refresh home page every 5 minutes.", #loc
- 600 => "Refresh home page every 10 minutes.", #loc
- 1200 => "Refresh home page every 20 minutes.", #loc
- 3600 => "Refresh home page every 60 minutes.", #loc
- 7200 => "Refresh home page every 120 minutes.", #loc
- },
+ Callback => sub {
+ my @values = RT->Config->Get('RefreshIntervals');
+ my %labels = (
+ 0 => "Don't refresh home page.", # loc
+ );
+
+ for my $value (@values) {
+ if ($value % 60 == 0) {
+ $labels{$value} = ['Refresh home page every [quant,_1,minute,minutes].', $value / 60]; # loc
+ }
+ else {
+ $labels{$value} = ['Refresh home page every [quant,_1,second,seconds].', $value]; # loc
+ }
+ }
+
+ unshift @values, 0;
+
+ return { Values => \@values, ValuesLabel => \%labels };
+ },
},
},
diff --git a/share/html/Elements/Refresh b/share/html/Elements/Refresh
index 67fddfa..b3c06a7 100644
--- a/share/html/Elements/Refresh
+++ b/share/html/Elements/Refresh
@@ -51,18 +51,18 @@
selected="selected"
%}
><&|/l&>Don't refresh this page.</&></option>
-%foreach my $value (@refreshevery) {
+%foreach my $value (RT->Config->Get('RefreshIntervals')) {
<option value="<%$value%>"
% if ( $Default && ($value == $Default)) {
selected="selected"
% }
+% if ($value % 60 == 0) {
><&|/l, $value/60 &>Refresh this page every [quant,_1,minute,minutes].</&></option>
-%}
+% } else {
+><&|/l, $value &>Refresh this page every [quant,_1,second,seconds].</&></option>
+% }
+% }
</select>
-
-<%INIT>
-my @refreshevery = qw(120 300 600 1200 3600 7200);
-</%INIT>
<%ARGS>
$Name => undef
$Default => 0
-----------------------------------------------------------------------
More information about the rt-commit
mailing list