hungnv
hungnv

Reputation: 111

Change ticket display in Trac

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!

Upvotes: 11

Views: 3979

Answers (3)

Mike Starov
Mike Starov

Reputation: 7296

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.

Upvotes: 2

Felix Schwarz
Felix Schwarz

Reputation: 3078

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

Upvotes: 8

Tom
Tom

Reputation: 14250

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

Upvotes: 3

Related Questions