Tetsuya Morimoto avatar Tetsuya Morimoto committed df293c1

changed to switch the verbose information shows title by clicking Relationships label

Comments (0)

Files changed (3)

ticketref/htdocs/ticket.css

 /* ticketref css for ticket.html */
+.tref-clickable {
+    cursor: pointer;
+}
+
 a.tref-link {
     background: none repeat scroll 0 0 transparent;
     border: 1px outset #CCCCCC;
     margin: 0 .2em;
     padding: .1em;
 }
+
+span.tref-display-none {
+    display: none;
+}

ticketref/htdocs/ticket.js

+$(function() {
+    // ticketref script for ticket.html
+    $('th#h_ticketref').addClass('tref-clickable');
+    $('th#h_ticketref').bind('click', function(e) {
+        if ($('#tref_summary').hasClass('tref-display-none')) {
+            $('#tref_summary').removeClass('tref-display-none');
+            $('#tref_ticketid').addClass('tref-display-none');
+        } else {
+            $('#tref_summary').addClass('tref-display-none');
+            $('#tref_ticketid').removeClass('tref-display-none');
+        }
+    });
+});

ticketref/web_ui.py

 from genshi.builder import tag
 from trac.core import *
 from trac.web.api import IRequestFilter, ITemplateStreamFilter
-from trac.web.chrome import ITemplateProvider, add_stylesheet
+from trac.web.chrome import ITemplateProvider, add_script, add_stylesheet
 from trac.resource import ResourceNotFound
 from trac.ticket.model import Ticket
 from trac.util.text import shorten_line
                 ticket = data["ticket"]
                 new = self._link_new(req, ticket, field)
                 if ticket[TREF]:
-                    field["rendered"] = self._link_refs(req, ticket[TREF])
+                    field["rendered"] = self._link_refs(req, ticket[TREF],
+                                                        verbose_link=True)
                     field["rendered"].append(new)
                 else:
                     field["rendered"] = tag([new])
                                 cell["value"] = self._link_refs(req,
                                                                 cell["value"])
 
-    def _link_refs(self, req, refs_text):
-        items = []
+    def _link_refs(self, req, refs_text, verbose_link=False):
+        items_tag = None
+        items, verbose_items = [], []
         for ref_id in sorted(cnv_text2list(refs_text)):
-            elem = "#%s" % ref_id
+            elem = verbose_elem = "#%s" % ref_id
             try:
                 ticket = Ticket(self.env, ref_id)
                 if "TICKET_VIEW" in req.perm(ticket.resource):
-                    elem = tag.a("#%s" % ref_id, class_=ticket["status"],
-                                 href=req.href.ticket(ref_id),
-                                 title=shorten_line(ticket["summary"]))
+                    title = shorten_line(ticket["summary"])
+                    attr = {
+                        "class_": ticket["status"],
+                        "href": req.href.ticket(ref_id),
+                        "title": title,
+                    }
+                    elem = tag.a("#%s" % ref_id, **attr)
+                    verbose_elem = tag.a("#%s %s" % (ref_id, title), **attr)
             except ResourceNotFound:
                 pass  # not supposed to happen, just in case
-            items.append(elem)
-            items.append(", ")
-        return items and tag(items[:-1]) or None
+            items.extend([elem, ", "])
+            verbose_items.extend([verbose_elem, tag.br()])
+        if items:
+            items_tag = [tag.span(items[:-1], id="tref_ticketid")]
+            if verbose_link:
+                vattr = {"id": "tref_summary", "class_": "tref-display-none"}
+                items_tag.append(tag.span(verbose_items, **vattr))
+        return tag(items_tag)
 
     def _link_new(self, req, ticket, field):
         param = {TREF: ticket.id}
     def post_process_request(self, req, template, data, content_type):
         if template == "ticket.html":
             add_stylesheet(req, "ticketref/ticket.css")
+            add_script(req, "ticketref/ticket.js")
         return template, data, content_type
 
     # ITemplateProvider methods
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.