[Rt-commit] rt branch, 4.6/row-colors-by-condition, created. rt-4.4.3-86-gb8abcaeea0

Craig Kaiser craig at bestpractical.com
Thu Dec 20 14:15:30 EST 2018


The branch, 4.6/row-colors-by-condition has been created
        at  b8abcaeea096838dee8a052af10766586f09a46e (commit)

- Log -----------------------------------------------------------------
commit b8abcaeea096838dee8a052af10766586f09a46e
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Dec 20 08:35:09 2018 -0500

    Inital commit

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 17d63b548b..96f97a2b5a 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1222,6 +1222,14 @@ our %META;
     ServiceAgreements => {
         Type => 'HASH',
     },
+    HighlightRowColor => {
+        Section         => 'User Color Prefs', #loc
+        Overridable     => 1,
+        Widget          => '/Widgets/Form/Criteria',
+        WidgetArguments => {
+            Description => 'Select conditions for row coloring' # loc
+        }
+    },
 );
 my %OPTIONS = ();
 my @LOADED_CONFIGS = ();
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 908cde342a..87196b4fa6 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2695,6 +2695,34 @@ sub __DependsOn
     return;
 }
 
+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 $preferences = $user->Preferences($RT::System);
+
+    my @classes;
+    my %color_config = %{$preferences->{'HighlightRowColor'}};
+    foreach my $condition (keys %color_config) {
+        if ( $color_config{$condition}->{record_type} eq $self->RecordType ) {
+            my ($attr, $value) = $condition =~ /(.*)-(.*)/;
+            if ( !$self->_CoreAccessible->{$attr} ) {
+                RT::Logger->error("$attr is not accessable on RT::Ticket");
+                next;
+            } else {
+                if ( $self->$attr eq $value ) {
+                    push @classes, "row-bg-color-". $color_config{$condition}->{color};
+                }
+            }
+        }
+    }
+
+    return \@classes;
+}
+
 # implement proxy method because some RT classes
 # override Delete method
 sub __Wipeout
diff --git a/share/html/Elements/CollectionList b/share/html/Elements/CollectionList
index a33b8e0fd9..d9770454b3 100644
--- a/share/html/Elements/CollectionList
+++ b/share/html/Elements/CollectionList
@@ -145,6 +145,9 @@ while ( my $record = $Collection->Next ) {
     my $warning = 0;
     my $Classes = '';
 
+    my $row_coloring = $record->HighLightOnCondition();
+    $Classes = join(' ', @{$row_coloring}) if $row_coloring;
+
     $m->callback(
         CallbackName => 'EachRow',
         Record       => $record,
diff --git a/share/html/Elements/SelectColor b/share/html/Elements/SelectColor
new file mode 100644
index 0000000000..ce6300ccb2
--- /dev/null
+++ b/share/html/Elements/SelectColor
@@ -0,0 +1,64 @@
+%# 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="">-</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
index 0000000000..9a282b1fed
--- /dev/null
+++ b/share/html/Widgets/Form/Criteria
@@ -0,0 +1,94 @@
+%# 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 }}}
+% my $i = 0;
+% foreach my $color (@colors) {
+    <div>
+        <& /Elements/SelectStatus, Name => "Color-RT::Ticket-Status-Arguement-$i", SkipDeleted => 1, Lifecycles => \@lifecycle_objs, ShowActiveInactive => 1 &>
+        <& /Elements/SelectColor, Name  => "Ticket::Color-$i" &>
+    </div>
+% $i++;
+% }
+<%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;
+</%INIT>
+
+<%METHOD Process>
+<%ARGS>
+</%ARGS>
+<%INIT>
+my %args = %{$ARGS{Arguments}};
+my @color_arguements = grep /Arguement-(\d*[^\'"'])/, keys %args;
+
+my %config;
+foreach my $color_arg (@color_arguements) {
+    next unless $args{$color_arg};
+    my $value  = $args{$color_arg};
+
+    $color_arg =~ /RT::(.*)-(.*)-Arguement-(\d*[^\"])/;
+    $config{$2 . '-' . $args{$color_arg}} = {
+        color        => $args{$1 . '::Color-'.$3},
+        record_type  => $1,
+    };
+}
+
+return \%config;
+</%INIT>
+</%METHOD>
diff --git a/share/static/css/base/highlight.css b/share/static/css/base/highlight.css
new file mode 100644
index 0000000000..6bf90a03dc
--- /dev/null
+++ b/share/static/css/base/highlight.css
@@ -0,0 +1,48 @@
+/* unset even and odd line colors. */
+tr.rowhighlight {background-color:#f0f8ff;margin:0;border:0;padding:0;spacing:0 !important; } 
+
+/* bg colors from highlight. */
+tr.row-bg-color-red td {
+ background-color: rgba(255, 85, 102, 0.1) !important
+}
+
+tr.row-bg-color-blue td {
+ background-color: rgba(0, 149, 191, 0.1) !important
+}
+
+tr.row-bg-color-green td {
+ background-color: rgba(68, 187, 119, 0.1) !important
+}
+
+tr.row-bg-color-yellow td {
+ background-color: rgba(255, 170, 68, 0.1) !important
+}
+
+tr.row-bg-color-purple td {
+ background-color: rgba(170, 68, 255, 0.1) !important
+}
+
+tr.row-bg-color-grey td {
+ background-color: rgba(153, 153, 153, 0.1) !important
+}
+
+/* Status Colours */
+tr.statusnew td {
+ background-color: rgba(255, 85, 102, 0.1) !important
+}
+
+tr.statusopen td {
+ background-color: rgba(255, 170, 68, 0.1) !important
+}
+
+tr.statusstalled td {
+ background-color: rgba(170, 68, 255, 0.1) !important
+}
+
+tr.statusresolved td {
+ background-color: rgba(68, 187, 119, 0.1) !important
+}
+
+tr.statusrejected td {
+ background-color: rgba(153, 153, 153, 0.1) !important
+}
diff --git a/share/static/css/base/main.css b/share/static/css/base/main.css
index 7cc29066bf..3e4ef4ea4c 100644
--- a/share/static/css/base/main.css
+++ b/share/static/css/base/main.css
@@ -1,3 +1,4 @@
+ at import "highlight.css";
 @import "yui-fonts.css";
 @import "jquery-ui.css";
 @import "jquery-ui-timepicker-addon.css";

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


More information about the rt-commit mailing list