[Checkins] SVN: z3c.table/trunk/ Allow to switch the sort order on the header link. This was blocked to

Christophe Combelles ccomb at free.fr
Sun Oct 12 08:26:49 EDT 2008


Log message for revision 92074:
  Allow to switch the sort order on the header link. This was blocked to
  descending after the first click
  

Changed:
  U   z3c.table/trunk/CHANGES.txt
  U   z3c.table/trunk/src/z3c/table/README.txt
  U   z3c.table/trunk/src/z3c/table/header.py

-=-
Modified: z3c.table/trunk/CHANGES.txt
===================================================================
--- z3c.table/trunk/CHANGES.txt	2008-10-12 10:57:49 UTC (rev 92073)
+++ z3c.table/trunk/CHANGES.txt	2008-10-12 12:26:46 UTC (rev 92074)
@@ -5,6 +5,9 @@
 Version 0.6dev (unreleased)
 ---------------------------
 
+- Bugfix: Allow to switch the sort order on the header link. This was blocked to
+  descending after the first click
+
 - Bugfix: CheckBoxColumn, ensure that we allways use a list for compare
   selected items. It was possible that if only one item get selected
   we compared a string. If this string was a sub string of another existing

Modified: z3c.table/trunk/src/z3c/table/README.txt
===================================================================
--- z3c.table/trunk/src/z3c/table/README.txt	2008-10-12 10:57:49 UTC (rev 92073)
+++ z3c.table/trunk/src/z3c/table/README.txt	2008-10-12 12:26:46 UTC (rev 92074)
@@ -1685,7 +1685,39 @@
   ...
   </table>
 
+If the table is initially set to descending, the link should allow to switch to
+ascending again:
 
+  >>> myTable.sortOrder = 'descending'
+  >>> print myTable.render()
+  <table>
+   <thead>
+    <tr>
+     <th><a
+      href="?table-sortOrder=ascending&table-sortOn=table-titleColumn-0"
+      title="Sort">Title</a></th>
+  ...
+  </table>
+
+If the table is ascending but the request was descending, the link should allow to switch again to ascending:
+
+  >>> descendingRequest = TestRequest(form={'table-sortOn': 'table-titleColumn-0',
+  ...                                   'table-sortOrder':'descending'})
+  >>> myTable = myTableClass(container, descendingRequest)
+  >>> myTable.sortOrder = 'ascending'
+  >>> myTable.update()
+  >>> print myTable.render()
+  <table>
+   <thead>
+    <tr>
+     <th><a
+      href="?table-sortOrder=ascending&table-sortOn=table-titleColumn-0"
+      title="Sort">Title</a></th>
+  ...
+  </table>
+
+
+
 Miscellaneous
 -------------
 

Modified: z3c.table/trunk/src/z3c/table/header.py
===================================================================
--- z3c.table/trunk/src/z3c/table/header.py	2008-10-12 10:57:49 UTC (rev 92073)
+++ z3c.table/trunk/src/z3c/table/header.py	2008-10-12 12:26:46 UTC (rev 92074)
@@ -84,7 +84,9 @@
         sortOrder = table.sortOrder
         if int(sortID) == int(currentSortID):
             # ordering the same column so we want to reverse the order
-            if currentSortOrder == table.sortOrder:
+            if currentSortOrder in table.reverseSortOrderNames:
+                sortOrder = 'ascending'
+            elif currentSortOrder == 'ascending':
                 sortOrder = table.reverseSortOrderNames[0]
 
         args = self.getQueryStringArgs()



More information about the Checkins mailing list