]> git.decadent.org.uk Git - maypole.git/blobdiff - templates/factory/list
fixed ordering
[maypole.git] / templates / factory / list
index 843f9a4d50b603bfced8da3c999ab0cc763eb22b..5e8a760e291fcf850d0efac3f4a47e1e824182da 100644 (file)
@@ -1,28 +1,43 @@
 [% PROCESS macros %]
 [% INCLUDE header %]
+[% INCLUDE title %]
 [% IF search %]
-    <h2>Search results</h2>
+    <div id="title">Search results</div>
 [% ELSE %]
-    <h2>Listing of all [% classmetadata.plural %]</h2>
+    <div id="title">Listing of all [% classmetadata.plural %]</div>
 [% END %]
 [% INCLUDE navbar %]
-[% INCLUDE search_form %]
 <div class="list">
     <table id="matrix" width="100%" >
         <tr>
-            [% FOR col = classmetadata.columns.list;
+            [% FOR col = classmetadata.list_columns.list;
                 NEXT IF col == "id";
                 "<th>"; 
+                SET title = classmetadata.colnames.$col;
                 SET additional = "?order=" _ col;
                 SET additional = additional _ "&amp;page=" _ pager.current_page
                     IF pager;
                 SET additional = additional _ "&amp;o2=desc" 
                 IF col == request.query.order and request.query.o2 != "desc";
-                link(classmetadata.table, "list", additional,
-                    classmetadata.colnames.$col);
+                SET action = "list";
+                FOR col = classmetadata.columns.list;
+                  IF request.query.$col;
+                    SET additional =
+                        additional  _ "&" _ col _ "=" _ request.query.$col;
+                    SET action = "search";
+                  END;
+                END;
+                link(classmetadata.table, action, additional, title);
+                IF col == request.query.order;
+                    IF request.query.o2 != "desc";
+                        "&darr;";
+                    ELSE;
+                        "&uarr;";
+                    END;
+                END;
                 "</th>";
             END %]
-           <th>Actions</th>
+           <th id="actionth">Actions</th>
         </tr>
         [%  SET count = 0;
         FOR item = objects;
@@ -34,7 +49,9 @@
             "</tr>";
         END %]
     </table>
+
 [% INCLUDE pager %]
 [% INCLUDE addnew %]
+[% INCLUDE search_form %]
 </div>
 [% INCLUDE footer %]