Search code examples
reporttrac

Control over trac TicketQuery: Is it possible to change the ticket color according to its priority?


I am configuring a trac installation (ver 0.12) at the moment and I am trying to make the startingpage a bit more talkative.

In the report module of trac it was possible to change the backgroundcolor of a ticket according to its priority using SQL as described here, but I did not find any information on how to change it in the TicketQuery macro.

Can anybody give me a hint?

regards, Chris


Solution

  • The colors are defined by CSS classes in report.css of Trac core for ticket tables generated by reports, custom query and the TicketQueryMacro. So you can only change this site-wide in Trac 0.12 by adding custom styles.

    The appropriate CSS statements to add to your own style.css are (with default values):

    • table.tickets tbody tr.prio1 { background: #FFDDCC none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio1 { background: #FFEEDD none repeat scroll 0 0 }
    • table.tickets tbody tr.prio2 { background: #FFFFBB none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio2 { background: #FFFFDD none repeat scroll 0 0 }
    • table.tickets tbody tr.prio3 { background: #FBFBFB none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio3 { background: #F6F6F6 none repeat scroll 0 0 }
    • table.tickets tbody tr.prio4 { background: #E7FFFF none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio4 { background: #DDFFFF none repeat scroll 0 0 }
    • table.tickets tbody tr.prio5 { background: #E7EEFF none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio5 { background: #DDE7FF none repeat scroll 0 0 }
    • table.tickets tbody tr.prio6 { background: #F0F0F0 none repeat scroll 0 0 }
    • table.tickets tbody tr.even.prio6 { background: #F7F7F7 none repeat scroll 0 0 }

    These max 6 prio's corresponding to slightly different odd/even row color each ranging from red over grey to blue. Only 5 prio's are used per default, prio6 defaults are in darker gray again.

    Order matters, make sure to have your priority names properly sorted in the priority admin panel (http://<host>:<port>/<env>/admin/ticket/priority).