Change ticket display in Trac
Asked Answered
R

3

11

With default template, trac ticket is available for viewing only, I must click modify to expand properties tab to modify, change state of a ticket. Now I want to expand that tab automatically? How can I change it quickly without changing the template itself? Is it possible to change it with trac.ini file? I cannot find where's location of default template to change, so I cannot change myself. Thanks!

Rabat answered 27/7, 2010 at 4:57 Comment(3)
I have exactly the same need - even some help with how to change the template would be useful.Mute
Are you two talking about trac 0.12? IF so, it would probably be good to add that information to the question. I don't have any "Modify" tab in trac 0.11. Actually, I don't have any tabs on the ticket at all...Gayegayel
yes, I'm using Trac 0.12Rabat
E
8

I think the best way to enable the behavior you're looking for is to add a custom JS file (which can be injected much like a custom CSS, read TracInterfaceCustomization).

In that file do this:

$(document).ready(function() {
 window.setTimeout(function() {
    $("#modify").parent().removeClass('collapsed')
 }, 0);
});

This code is untested but it should give you the idea. Basically we need to wait until the DOM is ready ($(document).ready) but as there are multiple JS functions called during that event, the setTimeOut sets a slight delay to make sure that the collapse command went through before.

HTH from a professional Trac developer :-)

Epithelioma answered 27/7, 2010 at 20:31 Comment(3)
I had to use $(document).ready to get this to work, but other than that worked great in trac 0.12. Thanks!Jesher
I've tried this numerous times, and couldn't for the life of me get it to work, I even responded to this Question and then deleted it after I realized my false assumption I made. icco's result is the same as mine, change the first line from $.ready to $(document).ready, AND IT WORKS! YAY! Now to get the TRAC developers to undo this horrible change in the webapp itself. I cannot even fathom the assumption they made in the first place.Capuchin
yes, you're right I forgot the $(document).ready, changed that :-)Epithelioma
M
3

I'm using trac 0.12 and had the same issue.

...without changing the template itself

I couldn't find a option to configure it but I did notice if you click the "modify" quick link at the top right of the ticket then the "Modify Ticket" foldable area is automatically uncollapsed for you.

I know you didn't ask for it, but just in case, you want a horrible template hack...

Open the template file in editor, e.g. for me in CentOS 5.5:

sudo emacs  /usr/lib/python2.4/site-packages/Trac-0.12-py2.4.egg/trac/ticket/templates/ticket.html

Comment out the jQuery line that triggers the modify section to collapse on page ready:

//$("#modify").parent().toggleClass("collapsed");

I found the edit didn't take effect straight away - perhaps the template is cached or something? It worked after a few minutes of shift-refreshing and restarting apache.

Lets hope someone else answers with a better solution...

Mute answered 27/7, 2010 at 15:22 Comment(3)
yes, templates are cached. you need to set [trac] auto_reload = True in your trac.iniEpithelioma
But for me, the directory you're talking about /usr/lib/python2.4/site-packages/Trac-0.12-py2.4.egg is just a file with egg extension? It's so strange with me, this's first time I use Trac, why your directory becomes my file with same version of Trac?Rabat
Your egg is zipped whereas mine is unzipped. I installed Trac using easy_install --always-unzip Trac==0.12 because my OS can't recognise zipped eggs. You could unzip your egg using unzip, then remove the zipped version (otherwise you'll have two tracs installed).Mute
B
2

This is basically Schwarz's answer but in a simpler form

To get ticket contols expanded on load do following. Put following code

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="">

  <!--! Add site-specific style sheet -->
  <head py:match="head" py:attrs="select('@*')">
    ${select('*|comment()|text()')}
    <script type="text/JavaScript">
    <!--
    // EXPAND TICKET CONROLS ON LOAD.
    jQuery(document).ready(function() {
     window.setTimeout(function() {
        $("#modify").parent().removeClass('collapsed')
     }, 1);
    });
    //-->
    </script>
  </head>

  <body py:match="body" py:attrs="select('@*')">
    ${select('*|text()')}
  </body>
</html>

in /path/to/your/trac/project/templates directory in file site.html.

Butyrate answered 17/10, 2011 at 22:19 Comment(1)
I think this way is cleaner.Froemming

© 2022 - 2024 — McMap. All rights reserved.