Commits

Anonymous committed 868fcbb

Ported [2890] and [2891] to 0.9-stable (fixing #2606, #2459, and #2706).

  • Participants
  • Parent commits fa63421
  • Branches 0.9-stable

Comments (0)

Files changed (4)

htdocs/css/report.css

 .reports tbody td :link, .reports tbody td :visited,
 .tickets tbody td :link, .tickets tbody td :visited { display: block }
 .tickets { border-bottom: none }
-.tickets thead th { text-transform: capitalize }
+.tickets thead th { text-transform: capitalize; white-space: nowrap; }
 .tickets tbody td, .reports tbody td { padding: .1em .5em !important }
 .tickets tbody td a, .reports tbody td a { border-bottom: none }
 .tickets tbody td.id :link, .tickets tbody td.id :visited {

templates/query.cs

     /if ?><?cs
    /each ?><?cs
   /def ?>
-  <table summary="Query filters"><?cs each:field = query.fields ?><?cs
+  <table summary="Query filters">
+   <tbody><tr style="height: 1px"><td colspan="4"></td></tr></tbody><?cs
+   each:field = query.fields ?><?cs
    each:constraint = query.constraints ?><?cs
     if:name(field) == name(constraint) ?>
      <tbody><tr class="<?cs var:name(field) ?>">
 </script>
 
 <?cs def:thead() ?>
- <thead><tr><?cs each:header = query.headers ?><?cs
-  if:name(header) == 0 ?><?cs
-   call:sortable_th(query.order, query.desc, 'id', 'ticket', query.href) ?><?cs
-  else ?><?cs
-   call:sortable_th(query.order, query.desc, header.name, header.name, query.href) ?><?cs
-  /if ?>
- <?cs /each ?></tr></thead>
+ <thead><tr><?cs each:header = query.headers ?>
+  <th class="<?cs var:header.name ?><?cs if:query.order == header.name ?> <?cs
+    if:query.desc ?>desc<?cs else ?>asc<?cs /if ?><?cs /if ?>">
+   <a title="Sort by <?cs var:header.label ?><?cs
+     if:query.order == header.name && !query.desc ?> (descending)<?cs
+     /if ?>" href="<?cs var:header.href ?>"><?cs var:header.label ?></a>
+  </th><?cs
+ /each ?></tr></thead>
 <?cs /def ?>
 
 <?cs if:len(query.results) ?><?cs

trac/ticket/api.py

                 'name': name,
                 'type': self.config.get('ticket-custom', name),
                 'order': int(self.config.get('ticket-custom', name + '.order', '0')),
-                'label': self.config.get('ticket-custom', name + '.label', ''),
+                'label': self.config.get('ticket-custom', name + '.label') \
+                         or name.capitalize(),
                 'value': self.config.get('ticket-custom', name + '.value', '')
             }
             if field['type'] == 'select' or field['type'] == 'radio':

trac/ticket/query.py

         cursor.close()
         return results
 
-    def get_href(self, format=None):
-        return self.env.href.query(order=self.order,
-                                   desc=self.desc and 1 or None,
+    def get_href(self, order=None, desc=None, format=None):
+        if desc is None:
+            desc = self.desc
+        if order is None:
+            order = self.order
+        return self.env.href.query(order=order, desc=desc and 1 or None,
                                    group=self.group or None,
                                    groupdesc=self.groupdesc and 1 or None,
                                    verbose=self.verbose and 1 or None,
-                                   format=format,
-                                   **self.constraints)
+                                   format=format, **self.constraints)
 
     def get_sql(self):
         """Return a (sql, params) tuple for the query."""
                     del req.session[var]
             req.redirect(query.get_href())
 
-        add_link(req, 'alternate', query.get_href('rss'), 'RSS Feed',
+        add_link(req, 'alternate', query.get_href(format='rss'), 'RSS Feed',
                  'application/rss+xml', 'rss')
-        add_link(req, 'alternate', query.get_href('csv'),
+        add_link(req, 'alternate', query.get_href(format='csv'),
                  'Comma-delimited Text', 'text/plain')
-        add_link(req, 'alternate', query.get_href('tab'), 'Tab-delimited Text',
-                 'text/plain')
+        add_link(req, 'alternate', query.get_href(format='tab'),
+                 'Tab-delimited Text', 'text/plain')
 
         constraints = {}
         for k, v in query.constraints.items():
                 req.hdf['query.constraints.%s.values.%d' % (field, idx)] = ''
 
         cols = query.get_columns()
-        for i in range(len(cols)):
-            header = {'name': cols[i]}
-            req.hdf['query.headers.%d' % i] = header
+        labels = dict([(f['name'], f['label']) for f in query.fields])
+        for idx, col in enumerate(cols):
+            req.hdf['query.headers.%d' % idx] = {
+                'name': col, 'label': labels.get(col, 'Ticket'),
+                'href': query.get_href(order=col, desc=(col == query.order and
+                                                        not query.desc))
+            }
 
         href = self.env.href.query(group=query.group,
                                    groupdesc=query.groupdesc and 1 or None,