# HG changeset patch
# Parent 7154aa4a3de9f58067459bc8789c9da5c5d85af6
#9604: add a link to the last query and to a new custom query at the top of the list of reports.

The first link leads to the saved query if there's one (that can be a report or a custom query), the second goes to a new custom query.

diff -r 7154aa4a3de9 trac/ticket/query.py
--- a/trac/ticket/query.py	Mon Sep 06 21:19:50 2010 +0200
+++ b/trac/ticket/query.py	Tue Sep 07 09:55:07 2010 +0200
@@ -1067,7 +1067,7 @@ class QueryModule(Component):
                self.env.is_component_enabled(ReportModule):
             data['report_href'] = req.href.report()
             add_ctxtnav(req, _('Available Reports'), req.href.report())
-            add_ctxtnav(req, _('Custom Query'))
+            add_ctxtnav(req, _('Custom Query'), req.href.query())
             if query.id:
                 cursor = db.cursor()
                 cursor.execute("SELECT title,description FROM report "
diff -r 7154aa4a3de9 trac/ticket/report.py
--- a/trac/ticket/report.py	Mon Sep 06 21:19:50 2010 +0200
+++ b/trac/ticket/report.py	Tue Sep 07 09:55:07 2010 +0200
@@ -132,6 +132,7 @@ class ReportModule(Component):
                 self.env.is_component_enabled(QueryModule):
             add_ctxtnav(req, _('Custom Query'), href=req.href.query())
             data['query_href'] = req.href.query()
+            data['saved_query_href'] = req.session['query_href']
         else:
             data['query_href'] = None
 
diff -r 7154aa4a3de9 trac/ticket/templates/report_list.html
--- a/trac/ticket/templates/report_list.html	Mon Sep 06 21:19:50 2010 +0200
+++ b/trac/ticket/templates/report_list.html	Tue Sep 07 09:55:07 2010 +0200
@@ -13,23 +13,40 @@
   <body>
     <div id="content" class="report">
 
-      <h1>Available Reports
-      <span id="trac-sort-order" py:with="report_asc = asc if sort == 'report' else None;
-                                          title_asc = asc if sort == 'title' else None">
-        Sorted by:
-        <a href="${href.report(sort='report', asc=report_asc and '0' or '1')}"
-           class="${('desc', 'asc')[report_asc] if report_asc is not None else None}">
-          Identifier</a>
-        <a href="${href.report(sort='title', asc=title_asc and '0' or '1')}"
-           class="${('desc', 'asc')[title_asc] if title_asc is not None else None}">
-          Title</a>
-        </span>
-      </h1>
+      <h1>Available Reports</h1>
 
       <div id="description" />
 
       <div py:choose="" class="reports">
+        <div py:if="saved_query_href">
+          <h2><a href="$saved_query_href"><em>Return to last query</em></a></h2>
+          <div class="description">
+            <p>Continue browsing through the current list of results,
+              from the selected report or custom query.</p>
+          </div>
+        </div>
+
+        <div py:if="query_href">
+          <h2><a href="$query_href"><em>Custom Query</em></a></h2>
+          <div class="description">
+            <p>Compose a new ticket query by selecting filters and columns to display.</p>
+          </div>
+        </div>
+
         <py:when test="reports">
+          <h3>&nbsp;
+            <span id="trac-sort-order" py:with="report_asc = asc if sort == 'report' else None;
+                                                title_asc = asc if sort == 'title' else None">
+              All reports sorted by:
+              <a href="${href.report(sort='report', asc=report_asc and '0' or '1')}"
+                 class="${('desc', 'asc')[report_asc] if report_asc is not None else None}">
+                Identifier</a>
+              <a href="${href.report(sort='title', asc=title_asc and '0' or '1')}"
+                 class="${('desc', 'asc')[title_asc] if title_asc is not None else None}">
+                Title</a>
+            </span>
+          </h3>
+
           <div py:for="id, title, description, can_edit, can_delete in reports">
             <h2>
               <a title="View report" href="${href.report(id)}">{$id} <em>$title</em></a>

