[Rt-commit] rt branch, 4.6/row-colors-by-condition, repushed
Craig Kaiser
craig at bestpractical.com
Fri Jan 11 14:20:42 EST 2019
The branch 4.6/row-colors-by-condition was deleted and repushed:
was c02ed4938b64fffa27b513eebade1fad6c9f02d9
now 041a7108e34a707aa3fb14f33790f78eb186a2f2
1: 81390e43f = 1: 81390e43f Create ReplaceAttachments, ReplaceHeader and ReplaceContent Methods
2: 5bec6baba = 2: 5bec6baba Create rt-munge-attachments executable
3: 765817052 = 3: 765817052 Add tests for methods that munge the attachments table
4: 55f3ae8c6 ! 4: a898c6fd9 Inital commit
@@ -18,7 +18,8 @@
+You can use "__CurrentUser__" under the Value key to have the attribute checked against the current user.
+Names of attributes should conincide with the method names for the object collection being targeted.
+
-+The color condition that is appears first will have the prioirty if multiple conditions are met.
++The color condition that appears first will have the prioirty if multiple conditions are met. The available
++colors by default are blue, green, red, yellow, purple, grey.
+
+ Set(@HighLightOnCondition,
+ { "Attribute" => "Status", "Value" => "open", "Color" => "green" },
@@ -31,33 +32,6 @@
+Set(@HighLightOnCondition, undef );
+
1;
-
-diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
---- a/lib/RT/Config.pm
-+++ b/lib/RT/Config.pm
-@@
- ServiceAgreements => {
- Type => 'HASH',
- },
-+ HighLightOnCondition => {
-+ Section => 'User Color Preferences', #loc
-+ Overridable => 1,
-+ Widget => '/Widgets/Form/Criteria',
-+ WidgetArguments => {
-+ Description => 'Select conditions for row coloring' # loc
-+ }
-+ },
- );
- my %OPTIONS = ();
- my @LOADED_CONFIGS = ();
-@@
- }
- $res = $OPTIONS{$name} unless defined $res;
- $res = $META{$name}->{'Default'} unless defined $res;
-+
- return $self->_ReturnValue( $res, $META{$name}->{'Type'} || 'SCALAR' );
- }
-
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
--- a/lib/RT/Record.pm
@@ -75,11 +49,7 @@
+sub HighLightOnCondition {
+ my $self = shift;
+
-+ my $user = RT::User->new($self->CurrentUser);
-+ my ($ret, $msg) = $user->Load($self->CurrentUser);
-+ RT::Logger->error($msg) unless $ret;
-+
-+ my $color_config = RT::Config->Get('HighLightOnCondition', $user);
++ my $color_config = RT::Config->Get('HighLightOnCondition');
+ foreach my $condition (@{$color_config}) {
+ my ($attr, $value) = ( $condition->{Attribute}, $condition->{Value} );
+ next unless $attr and $value;
@@ -120,200 +90,6 @@
$m->callback(
CallbackName => 'EachRow',
Record => $record,
-
-diff --git a/share/html/Elements/SelectColor b/share/html/Elements/SelectColor
-new file mode 100644
---- /dev/null
-+++ b/share/html/Elements/SelectColor
-@@
-+%# BEGIN BPS TAGGED BLOCK {{{
-+%#
-+%# COPYRIGHT:
-+%#
-+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-+%# <sales at bestpractical.com>
-+%#
-+%# (Except where explicitly superseded by other copyright notices)
-+%#
-+%#
-+%# LICENSE:
-+%#
-+%# This work is made available to you under the terms of Version 2 of
-+%# the GNU General Public License. A copy of that license should have
-+%# been provided with this software, but in any event can be snarfed
-+%# from www.gnu.org.
-+%#
-+%# This work is distributed in the hope that it will be useful, but
-+%# WITHOUT ANY WARRANTY; without even the implied warranty of
-+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+%# General Public License for more details.
-+%#
-+%# You should have received a copy of the GNU General Public License
-+%# along with this program; if not, write to the Free Software
-+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-+%# 02110-1301 or visit their web page on the internet at
-+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-+%#
-+%#
-+%# CONTRIBUTION SUBMISSION POLICY:
-+%#
-+%# (The following paragraph is not intended to limit the rights granted
-+%# to you to modify and distribute this software under the terms of
-+%# the GNU General Public License and is only of importance to you if
-+%# you choose to contribute your changes and enhancements to the
-+%# community by submitting them to Best Practical Solutions, LLC.)
-+%#
-+%# By intentionally submitting any modifications, corrections or
-+%# derivatives to this work, or any other work intended for use with
-+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-+%# you are the copyright holder for those contributions and you grant
-+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-+%# royalty-free, perpetual, license to use, copy, create derivative
-+%# works based on those contributions, and sublicense and distribute
-+%# those contributions and any derivatives thereof.
-+%#
-+%# END BPS TAGGED BLOCK }}}
-+<select name="<% $Name %>">
-+ <option value=""<% !$Default && qq[ selected="selected"] |n %>><&|/l&>(no value)</&></option>
-+% foreach my $color (@Colors) {
-+ <option value="<% $color %>"
-+% if ($Default && $Default eq $color) {
-+ selected="selected"
-+% }
-+ ><% $color %>
-+ </option>
-+% }
-+</select>
-+
-+<%ARGS>
-+$Name => ''
-+$Default => ''
-+ at Colors => qw/blue green yellow purple grey red/
-+</%ARGS>
-
-diff --git a/share/html/Widgets/Form/Criteria b/share/html/Widgets/Form/Criteria
-new file mode 100644
---- /dev/null
-+++ b/share/html/Widgets/Form/Criteria
-@@
-+%# BEGIN BPS TAGGED BLOCK {{{
-+%#
-+%# COPYRIGHT:
-+%#
-+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
-+%# <sales at bestpractical.com>
-+%#
-+%# (Except where explicitly superseded by other copyright notices)
-+%#
-+%#
-+%# LICENSE:
-+%#
-+%# This work is made available to you under the terms of Version 2 of
-+%# the GNU General Public License. A copy of that license should have
-+%# been provided with this software, but in any event can be snarfed
-+%# from www.gnu.org.
-+%#
-+%# This work is distributed in the hope that it will be useful, but
-+%# WITHOUT ANY WARRANTY; without even the implied warranty of
-+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+%# General Public License for more details.
-+%#
-+%# You should have received a copy of the GNU General Public License
-+%# along with this program; if not, write to the Free Software
-+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-+%# 02110-1301 or visit their web page on the internet at
-+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-+%#
-+%#
-+%# CONTRIBUTION SUBMISSION POLICY:
-+%#
-+%# (The following paragraph is not intended to limit the rights granted
-+%# to you to modify and distribute this software under the terms of
-+%# the GNU General Public License and is only of importance to you if
-+%# you choose to contribute your changes and enhancements to the
-+%# community by submitting them to Best Practical Solutions, LLC.)
-+%#
-+%# By intentionally submitting any modifications, corrections or
-+%# derivatives to this work, or any other work intended for use with
-+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-+%# you are the copyright holder for those contributions and you grant
-+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-+%# royalty-free, perpetual, license to use, copy, create derivative
-+%# works based on those contributions, and sublicense and distribute
-+%# those contributions and any derivatives thereof.
-+%#
-+%# END BPS TAGGED BLOCK }}}
-+<div>
-+% my $i = 0;
-+% foreach my $color (@colors) {
-+ <div>
-+ <select name="Color-Argument" class="cascade-by-optgroup">
-+ <optgroup label="Status">
-+% if ( $ARGS{'CurrentValue'}->[$i]->{Attribute} ) {
-+ <option selected="selected" value="<% $ARGS{'CurrentValue'}->[$i]->{Attribute} %>"><% $ARGS{'CurrentValue'}->[$i]->{Value} %></option>
-+% }
-+ <option value=""<% !$ARGS{'CurrentValue'}->[$i]->{Value} && qq[ selected="selected"] |n %>><&|/l&>(no value)</&></option>
-+% foreach my $status (@statuses) {
-+ <option value="<% $status %>"><% $status %></option>
-+% }
-+ </optgroup>
-+ </select>
-+ <& /Elements/SelectColor, Name => "Color", Default => $ARGS{'CurrentValue'}->[$i]->{Color} &>
-+ </div>
-+% $i++;
-+% }
-+</div>
-+<%INIT>
-+my @colors = qw/blue green yellow purple grey red/;
-+
-+my @lifecycles = RT::Lifecycle->new($session{CurrentUser})->ListAll;
-+my @lifecycle_objs;
-+
-+my $LoadLifecycle = sub {
-+ my $lifecycle_name = shift;
-+
-+ my $lifecycle = RT::Lifecycle->new($session{CurrentUser});
-+ $lifecycle->Load($lifecycle_name);
-+
-+ return $lifecycle;
-+};
-+
-+map { push @lifecycle_objs, $LoadLifecycle->($_) unless $_ eq 'approvals' } @lifecycles;
-+
-+my @statuses;
-+foreach my $lifecycle (@lifecycle_objs) {
-+ my @temp_statuses = $lifecycle->Valid;
-+ push @statuses, @temp_statuses;
-+}
-+</%INIT>
-+
-+<%METHOD Process>
-+<%INIT>
-+my %args = %{$ARGS{Arguments}};
-+
-+my @attributes = ref $args{'Color-Argument-Groups'} eq "ARRAY"
-+ ? @{$args{'Color-Argument-Groups'}}
-+ : ($args{'Color-Argument-Groups'});
-+
-+my @colors = ref $args{'Color'} eq "ARRAY" ? @{$args{'Color'}} : ($args{'Color'});
-+my @color_arguments = ref $args{'Color-Argument'} eq 'ARRAY' ? @{$args{'Color-Argument'}}
-+ : ($args{'Color-Argument'});
-+
-+my @HighLightOnCondition;
-+my $i = 0;
-+foreach my $color_argument (@color_arguments) {
-+ my $value = $color_argument;
-+ my $attribute = $attributes[$i];
-+ my $color = $colors[$i];
-+
-+ next unless $value and $attribute and $color;
-+ push @HighLightOnCondition, { Attribute => $attribute, Value => $value, Color => $color };
-+ $i++;
-+}
-+
-+return scalar @HighLightOnCondition ? \@HighLightOnCondition : undef;
-+</%INIT>
-+</%METHOD>
diff --git a/share/static/css/base/highlight.css b/share/static/css/base/highlight.css
new file mode 100644
@@ -407,30 +183,3 @@
+ width: 85%;
+}
-diff --git a/share/static/js/cascaded.js b/share/static/js/cascaded.js
---- a/share/static/js/cascaded.js
-+++ b/share/static/js/cascaded.js
-@@
- }
-
- function filter_cascade_select (select, complete_select, vals) {
-+ console.log(select);
-+ console.log(complete_select);
-+ console.log(vals);
- if ( !( vals instanceof Array ) ) {
- vals = [vals];
- }
-
-diff --git a/share/static/js/event-registration.js b/share/static/js/event-registration.js
---- a/share/static/js/event-registration.js
-+++ b/share/static/js/event-registration.js
-@@
- jQuery(function() {
- jQuery("select.cascade-by-optgroup").each(function(){
- var name = this.name;
-+ console.log('here');
-+ console.log(name);
- if (!name) return;
-
- // Generate elements for cascading based on the master <select> ...
-
5: c02ed4938 ! 5: 041a7108e Create tests for row colors by condition
@@ -58,25 +58,6 @@
+
+ $element = $m->dom->at('tr[class*="row-bg-color-blue"]');
+ like( $element->attr( 'class' ), qr/row-bg-color-blue/, 'Successfully apply row color class by global condition for status open');
-+
-+ # Test overriding global row highlight options with user preferences
-+ $m->get_ok( $baseurl . '/Prefs/Other.html' );
-+ $m->submit_form_ok( {
-+ form_name => 'ModifyPreferences',
-+ fields => {
-+ "Color-Argument" => 'open',
-+ "Color-Argument-Groups" => 'Status',
-+ "Color" => 'green',
-+ },
-+ button => 'Update',
-+ }, 'Set user prefs for color row by condition' );
-+ $m->get_ok( $baseurl );
-+
-+ $element = $m->dom->at('tr[class*="row-bg-color-green"]');
-+ like( $element->attr( 'class' ), qr/row-bg-color-green/, 'Successfully apply row color class by user prefs for status open');
-+
-+ $element = $m->dom->at('tr[class*="row-bg-color-blue"]');
-+ is($element, undef, 'Successfully overode global color settings')
}
done_testing();
More information about the rt-commit
mailing list