[Rt-commit] rt branch, 4.6/row-colors-by-condition, repushed

Craig Kaiser craig at bestpractical.com
Mon Dec 31 12:00:26 EST 2018


The branch 4.6/row-colors-by-condition was deleted and repushed:
       was b8abcaeea096838dee8a052af10766586f09a46e
       now f4af2044a862f75d2b80f31be5dbcdbe775cb8c0

-:  ------- > 1: 81390e43fa Create ReplaceAttachments, ReplaceHeader and ReplaceContent Methods
-:  ------- > 2: 5bec6babae Create rt-munge-attachments executable
-:  ------- > 3: 765817052e Add tests for methods that munge the attachments table
1: b8abcaeea0 ! 4: f4af2044a8 Inital commit
    @@ -10,7 +10,7 @@
              Type => 'HASH',
          },
     +    HighlightRowColor => {
    -+        Section         => 'User Color Prefs', #loc
    ++        Section         => 'User Color Preferences', #loc
     +        Overridable     => 1,
     +        Widget          => '/Widgets/Form/Criteria',
     +        WidgetArguments => {
    @@ -28,6 +28,12 @@
          return;
      }
      
    ++=head2 HighLightOnCondition
    ++
    ++Add css class to collection row if user prefs criteria are met.
    ++
    ++=cut
    ++
     +sub HighLightOnCondition {
     +    my $self = shift;
     +
    @@ -38,17 +44,16 @@
     +    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};
    -+                }
    ++        my ($attr, $value) = $condition =~ /(.*)-(.*)/;
    ++        if ( !$self->_CoreAccessible->{$attr} ) {
    ++            next;
    ++        } else {
    ++            if ( $self->$attr eq $value ) {
    ++                push @classes, "row-bg-color-". $color_config{$condition}->{color};
     +            }
     +        }
     +    }
    @@ -127,7 +132,7 @@
     +%#
     +%# END BPS TAGGED BLOCK }}}
     +<select name="<% $Name %>">
    -+    <option value="">-</option>
    ++    <option value="" selected="selected">(no value)</option>
     +%   foreach my $color (@Colors) {
     +    <option value="<% $color %>"
     +%      if ($Default && $Default eq $color) {
    @@ -196,16 +201,30 @@
     +%# those contributions and any derivatives thereof.
     +%#
     +%# END BPS TAGGED BLOCK }}}
    ++<div>
     +% 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" &>
    ++        <select name="Color-Arguement-<%$i%>" class="cascade-by-optgroup">
    ++%              if ( $defaults{$i}->{attribute} ) {
    ++                    <option value="<% $defaults{$i}->{attribute} %>"><% $defaults{$i}->{value} %></option>
    ++%              } else {
    ++                    <optgroup label="-"></optgroup>
    ++%              }
    ++            <optgroup label="Status">
    ++%              foreach my $status (@statuses) {
    ++                    <option value="<% $status %>"><% $status %></option>
    ++%               }
    ++            </optgroup>
    ++        </select>
    ++        <& /Elements/SelectColor, Name  => "Color-$i", Default => $defaults{$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;
     +
    @@ -219,6 +238,28 @@
     +};
     +
     +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;
    ++}
    ++
    ++my %defaults;
    ++foreach my $key (keys %{$ARGS{'CurrentValue'}}) {
    ++    if ( $ARGS{'CurrentValue'}{$key}{'attribute'} eq 'Queue' ) {
    ++        my $queueObj = RT::Queue->new($session{CurrentUser});
    ++        $queueObj->Load($ARGS{'CurrentValue'}{$key}{'value'});
    ++
    ++        $ARGS{'CurrentValue'}{$key}{'attribute'} = $queueObj->Name;
    ++    }
    ++
    ++    $defaults{$ARGS{'CurrentValue'}{$key}{'input_id'}} = {
    ++        value       => $ARGS{'CurrentValue'}{$key}{'value'},
    ++        color       => $ARGS{'CurrentValue'}{$key}{'color'},
    ++        attribute   => $ARGS{'CurrentValue'}{$key}{'attribute'}
    ++    };
    ++}
     +</%INIT>
     +
     +<%METHOD Process>
    @@ -226,17 +267,24 @@
     +</%ARGS>
     +<%INIT>
     +my %args = %{$ARGS{Arguments}};
    -+my @color_arguements = grep /Arguement-(\d*[^\'"'])/, keys %args;
    ++my @color_arguements = grep /Color-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,
    ++
    ++    $color_arg =~ /Color-Arguement-(\d*[^\"])(?-)/;
    ++
    ++    my $value     = $args{"Color-Arguement-$1"};
    ++    my $attribute = $args{"Color-Arguement-$1-Groups"};
    ++
    ++    next unless $value and $attribute;
    ++
    ++    $config{$attribute . '-' . $value} = {
    ++        color        => $args{'Color-'.$1},
    ++        input_id     => $1,
    ++        value        => $value,
    ++        attribute    => $attribute,
     +    };
     +}
     +
    @@ -306,3 +354,59 @@
      @import "yui-fonts.css";
      @import "jquery-ui.css";
      @import "jquery-ui-timepicker-addon.css";
    +
    +diff --git a/share/static/css/base/misc.css b/share/static/css/base/misc.css
    +--- a/share/static/css/base/misc.css
    ++++ b/share/static/css/base/misc.css
    +@@
    +     vertical-align: top;
    +     padding-left: 50px;
    + }
    ++
    ++.inline-row {
    ++    margin-bottom: 10px;
    ++    display: inline-flex;
    ++    width: 100%;
    ++}
    ++
    ++div.inline-row div {
    ++    width: 175px;
    ++    display: block;
    ++}
    ++
    ++div.inline-row a {
    ++    text-align: center;
    ++    width: 85%;
    ++}
    ++
    ++div.inline-row i {
    ++    text-align: left;
    ++    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> ...



More information about the rt-commit mailing list