Show status field in color and priority background in color


#1

Hi Team,
I was using RT 4.0.5 and the color of status field was there. (like the new was showing in red , open was showing in blue ). And also the background color of priority field was there.(like for priority low the field was blue).

Now I upgraded it to 4.2.15 ,but not able to get any color. Neither the status color or priority color is coming. Could anyone please kindly help.


#2

Were you using some custom code to make the coloring?


#3

Hi Craig,
I have not changed any thing now. Whatever code was there for 4.0.5 it’s there. After upgrade to 4.2.15 RT might be using some thing internally.

I can see there is one columnmap file where the methods are defined and one statuscolor. Css and main.css which is doing the same. I can see for 4.2.15 the default theme is rudder now but for the previous version it’s aileron. And when I am checking the RT_config.pm file… In 4.2.15 The theme was picking from f<share/static/css> folder but in the prew version it was picking from f<share /html/NoAuth/css> folder.
Could you please help me on this.


#4

Do you have any styling code in your local directory in your main RT directory (usually /opt/rt4)? I think it is likely that some custom CSS was added in the past to add these styles and either the class names that it used to style the HTML elements were changed in the upgrade or the styling was added to the core code and was over written in the upgrade process.


#5

So, As per my knowledge opt/rt4/local folder never gets overridden after the upgrade.
And yes the css file is there which is ised to style it. But I think it is not picking from the server. In the developers tool in chrome if you will add the same css class it’s working fine. But the same css is not picking from the server.

Could you please help me how can I get back my colours for the atatus and priority field.

And one more clarification needed: Does RT not provide any css from their side to color these fields? These css fields is written by the user who needs it?


#6

Do the CSS selectors that the custom CSS file uses to add these color styling still exist if you inspect the RT element that is being targeted?

It could be that the class names or IDs being used in 4.0 have changed when moving to 4.2 or are not as specific as the new themes selectors and therefore are being overridden.

Does RT not provide any css from their side to color these fields

By default, RT does not color these fields based on status.

See: https://docs.bestpractical.com/rt/4.2.16/customizing/styling_rt.html#Additional-files


#7

Thanks Craig for your help!!
I can see the main. Css file over there. But I will have to research why it is not picking the colour.
Is that the reason that some folder structure changed, that’s why it is not picking the same?
I will follow the instructions in the above link which you have share.

Please let me know if you want to add anything or want to inform me the process to get my older customization back in my newer RT version


#8

Just a quick thought, have you tried an incognito window, incase you’ve cached static files?


#9

I think the first thing to check is that if you go to the display page there is a selector on the div/select or which ever element you are trying to add some style to that matches what your CSS is selecting with. For example maybe I have:

tr.status {
    background-color: yellow;
}

You would confirm that the element that I want to make yellow is a table row element and has a class name of ‘status’.

Also as G.Booth pointed out make sure you are opening an incognito tab or doing a hard refresh (cmd+shift+R for Firefox on Mac) so that you are not caching old CSS, you may also need to restart your web server after some changes to the CSS file as well.


#10

Thanks Craig. I will try the same and get back to you


#11

Hi,

we used this code from here to get it working on RT 3.8

https://rt-wiki.bestpractical.com/wiki/ShowStatusInColor

After upgrading to 4.2 the feature didn’t work anymore, some paths had to be changed, eg. the whole script goes to /opt/rt4/local/html/Callbacks/MyCallbacks/Elements/RT__Ticket/ColumnMap/Once

Now it’s working again


#12

Hi Booth,
I have already tried , but it’s not working. Could you please help me if you have got any other idea.


#13

Hi Ramin,
I have already tried the same. I got some difference by renaming the ColumnMap file to Once (like I got the red colour phone and envelope symbol there).But I ma not getting the colour of the status and priority colour for the same.
Could you please explain me in some detail that how can I get it done in 4.2.15 version.


#14

You’ll have to step through your code in the Callback, as its not Best Practical code that’s doing this


#15

Hi Sudeepta,

here is our version, that is working on 4.2.15:
#cat /opt/rt4/local/html/Callbacks/MyCallbacks/Elements/RT__Ticket/ColumnMap/Once

<%INIT>

  # Show status in colour.
  sub statusInColor {
    my $Ticket = shift;
    my $status = $Ticket->Status;
    my $css = "status" . lc $status;
    my $cssreply = "status" . lc "reply";
    my $LastUpdater = $Ticket->LastUpdatedByObj->EmailAddress;
    my $TicketRequestors = $Ticket->Requestors->MemberEmailAddressesAsString;
    my $TicketCC = $Ticket->Cc->MemberEmailAddressesAsString;
    my $CurrentUser = $session{'CurrentUser'}->EmailAddress;
    my $color = undef;

if ($status eq 'new') {
    $color = "#bb0000";
} elsif ($status eq 'open') {
    $color = "#3858a3";
} elsif ($status eq 'stalled') {
    $color = "#009000";
} elsif ($status eq 'rejected') {
    $color = "#884444";
} elsif ($status eq 'resolved') {
    $color = "#737373";
}

$status = loc($status);

if ( $Ticket->HasUnresolvedDependencies ) {
    $status = "<b>$status<b>"
}

     if ($color) {
        $status = "<div style=\"color: $color;\">$status</div>"
    }
    return \"$status";

  }

  # Show extended status in colour. This will change the front page and other search pages where the ExtendedStatus is displayed.
  sub extStatusInColor {
    my $Ticket = shift;
    if ( my $count = $Ticket->HasUnresolvedDependencies ) {
        my $status;
        $status = loc($status);
        if ( $Ticket->HasUnresolvedDependencies( Type => 'approval' )
                or $Ticket->HasUnresolvedDependencies( Type => 'code' ) ) {
            $status = "<b>" . loc('(pending approval)') . "</b>";
        } else {
            $status = "<b>" . loc('(pending [quant,_1,other ticket,other tickets])',$count) . "</b>";
            }
        return \$status;
    } else {
        return statusInColor($Ticket);

    }
  }

  # Set the priority numbers to a colour.
  sub PriorityInColor {
    my $Ticket = shift;

    my $priority = $Ticket->Priority;
    my $colors = undef;
    # Change priority numbers to reflect your priority system.
       if ($priority >= '50') {
           $colors = "#FF0000";
       } elsif ($priority >= '45') {
           $colors = "#FF2000";
       } elsif ($priority >= '40') {
           $colors = "#FF4000";
       } elsif ($priority >= '35') {
           $colors = "#FF6A00";
       } elsif ($priority >= '30') {
           $colors = "#FF6600";
       } elsif ($priority >= '25') {
           $colors = "#FFA000";
       } elsif ($priority >= '20') {
           $colors = "#0033CC";
       } elsif ($priority >= '15') {
           $colors = "#809FFE";
       } elsif ($priority >= '10') {
           $colors = "#004600";
       } elsif ($priority >= '5') {
           $colors = "#006400";
       } elsif ($priority >= '0') {
           $colors = "#009000";
       }

       if ($colors) {
           $priority = "<div style=\"color: $colors;\">$priority</div>"
       }

           return \"<b>$priority</b>";
     }

     # Comment out any line to disable colour change.
     $COLUMN_MAP->{Priority}->{value} = \&PriorityInColor;
     $COLUMN_MAP->{Status}->{value} = \&statusInColor;
     $COLUMN_MAP->{ExtendedStatus}->{value} = \&extStatusInColor;

     </%INIT>
     <%ARGS>
     $COLUMN_MAP => undef
     </%ARGS>

#16

Hi Ramin,
Thank you very much for sharing the code!!
By this I can able to color the status created field. This is great!! Could you please also share the code for the “Priority Time Left” field. There was some background color for the field for my old version. For example for low the background color is blue. Please find the attached screenshot for your reference.


#17

Hi Sudeepta,

we only use the integer values for priority, these are also displayed in color.
Your setup seems to use a customization or an addon for priority as text string. I have no experiance with that, sorry.


#18

Ok . Will check it .Thanks!!


#19

Hi ,
I have fixed the color of status issue . Thanks for all your help !! Could anyone please help me to set the background color of the PriorityTimeLeft field. When I upgraded from 4.0.5 to 4.2.15 I lost the featuPriorityCOlor re. I am not able to see the background color of this field. PFA screenshot for reference.