views:

183

answers:

2

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!

A: 

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...

Tom
yes, templates are cached. you need to set[trac] auto_reload = True in your trac.ini
Felix Schwarz
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?
hungnv
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).
Tom
ok, I got it. Thank you very much!
hungnv
+2  A: 

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 :-)

Felix Schwarz
I had to use $(document).ready to get this to work, but other than that worked great in trac 0.12. Thanks!
icco
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.
VxJasonxV
yes, you're right I forgot the $(document).ready, changed that :-)
Felix Schwarz