Skip to content

Commit af34980

Browse files
author
Ralf Schlatterbeck
committed
Sorting/grouping by multiple properties.
- Implement sorting/grouping by multiple properties for the web interface. I'm now using @sort0/@sortdir0,@sort1/@sortdir1,... and @group0/@groupdir0,... when generating URLs from a search template. These are converted to a list internally. When saving URLs (e.g. when storing queries) I'm using @sort=prop1,prop2,... and @group=... with optional '-' prepended to individual props. This means saved URLs are backward compatible with existing trackers (and yes, this was a design goal). I need the clumsy version with @sort0,@Sort1 etc, because I'm currently using several selectors and checkboxes (as the classic template does, too). I don't think there is a way around that in HTML? - Updated (hopefully all) documentation to reflect the new URL format and the consequences in the web-interface. - I've set the number of sort/group properties in the classic template to two -- this can easily be reverted by changing n_sort to 1. Richard, would you look over these changes? I've set a tag before and (will set) after commit, so that it would be easy to merge out. Don't be too scared about the size of the change, most is documentation, the guts are in cgi/templating.py and small changes in the classic template.
1 parent 4d66755 commit af34980

File tree

8 files changed

+197
-103
lines changed

8 files changed

+197
-103
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Feature:
1717
- new "exporttables" command in roundup-admin (sf bug 1533791)
1818
- roundup-admin "export" may specify classes to exclude (sf bug 1533791)
1919
- sorting and grouping by multiple properties is now supported by the
20-
backends
20+
backends *and* the classic template.
2121
- sorting, grouping, and searching by transitive properties (e.g.,
2222
messages.author.supervisor) is now supported in all backends
2323
- added filter_sql to SQL backends which takes an arbitrary SQL statement

doc/customizing.txt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.205 $
5+
:Version: $Revision: 1.206 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1865,7 +1865,8 @@ filter lists of items from this class, filtered and sorted. Two
18651865
1. by the current *request* filterspec/filter/sort/group args
18661866
2. by the "filterspec", "sort" and "group" keyword args.
18671867
"filterspec" is ``{propname: value(s)}``. "sort" and
1868-
"group" are ``(dir, prop)`` where dir is '+', '-' or None
1868+
"group" are an optionally empty list ``[(dir, prop)]``
1869+
where dir is '+', '-' or None
18691870
and prop is a prop name or None.
18701871

18711872
eg. ``issue.filter(filterspec={"priority": "1"},
@@ -2195,8 +2196,8 @@ Variable Holds
21952196
columns dictionary of the columns to display in an index page
21962197
show a convenience access to columns - request/show/colname will
21972198
be true if the columns should be displayed, false otherwise
2198-
sort index sort column (direction, column name)
2199-
group index grouping property (direction, column name)
2199+
sort index sort columns [(direction, column name)]
2200+
group index grouping properties [(direction, column name)]
22002201
filter properties to filter the index on
22012202
filterspec values to filter the index on
22022203
search_text text to perform a full-text search on for an index
@@ -2432,7 +2433,7 @@ been added for clarity)::
24322433

24332434
/issue?status=unread,in-progress,resolved&
24342435
topic=security,ui&
2435-
@group=priority&
2436+
@group=priority,-status&
24362437
@sort=-activity&
24372438
@filters=status,topic&
24382439
@columns=title,status,fixer
@@ -2454,19 +2455,30 @@ of items with values matching any specified Multilink properties.
24542455
The example specifies an index of "issue" items. Only items with a
24552456
"status" of either "unread" or "in-progress" or "resolved" are
24562457
displayed, and only items with "topic" values including both "security"
2457-
and "ui" are displayed. The items are grouped by priority, arranged in
2458-
ascending order; and within groups, sorted by activity, arranged in
2459-
descending order. The filter section shows filters for the "status" and
2460-
"topic" properties, and the table includes columns for the "title",
2461-
"status", and "fixer" properties.
2458+
and "ui" are displayed. The items are grouped by priority arranged in
2459+
ascending order and in descending order by status; and within
2460+
groups, sorted by activity, arranged in descending order. The filter
2461+
section shows filters for the "status" and "topic" properties, and the
2462+
table includes columns for the "title", "status", and "fixer"
2463+
properties.
24622464

24632465
============ =============================================================
24642466
Argument Description
24652467
============ =============================================================
24662468
@sort sort by prop name, optionally preceeded with '-' to give
2467-
descending or nothing for ascending sorting.
2469+
descending or nothing for ascending sorting. Several
2470+
properties can be specified delimited with comma.
2471+
Internally a search-page using several sort properties may
2472+
use @sort0, @sort1 etc. with option @sortdir0, @sortdir1
2473+
etc. for the direction of sorting (a non-empty value of
2474+
sortdir0 specifies reverse order).
24682475
@group group by prop name, optionally preceeded with '-' or to sort
2469-
in descending or nothing for ascending order.
2476+
in descending or nothing for ascending order. Several
2477+
properties can be specified delimited with comma.
2478+
Internally a search-page using several grouping properties may
2479+
use @group0, @group1 etc. with option @groupdir0, @groupdir1
2480+
etc. for the direction of grouping (a non-empty value of
2481+
groupdir0 specifies reverse order).
24702482
@columns selects the columns that should be displayed. Default is
24712483
all.
24722484
@filter indicates which properties are being used in filtering.
@@ -3248,8 +3260,8 @@ The category search code above would expand to the following::
32483260
</select>
32493261
</td>
32503262
<td><input type="checkbox" name=":columns" value="category"></td>
3251-
<td><input type="radio" name=":sort" value="category"></td>
3252-
<td><input type="radio" name=":group" value="category"></td>
3263+
<td><input type="radio" name=":sort0" value="category"></td>
3264+
<td><input type="radio" name=":group0" value="category"></td>
32533265
</tr>
32543266

32553267
Adding category to the default view

doc/design.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ clarity)::
12511251

12521252
/issue?status=unread,in-progress,resolved&
12531253
topic=security,ui&
1254-
:group=priority&
1254+
:group=priority,-status&
12551255
:sort=-activity&
12561256
:filters=status,topic&
12571257
:columns=title,status,fixer
@@ -1275,11 +1275,11 @@ of issues with values matching any specified Multilink properties.
12751275
The example specifies an index of "issue" items. Only issues with a
12761276
"status" of either "unread" or "in-progres" or "resolved" are displayed,
12771277
and only issues with "topic" values including both "security" and "ui"
1278-
are displayed. The issues are grouped by priority, arranged in
1279-
ascending order; and within groups, sorted by activity, arranged in
1280-
descending order. The filter section shows filters for the "status" and
1281-
"topic" properties, and the table includes columns for the "title",
1282-
"status", and "fixer" properties.
1278+
are displayed. The items are grouped by priority arranged in ascending
1279+
order and in descending order by status; and within groups, sorted by
1280+
activity, arranged in descending order. The filter section shows
1281+
filters for the "status" and "topic" properties, and the table includes
1282+
columns for the "title", "status", and "fixer" properties.
12831283

12841284
Associated with each issue class is a default layout specifier. The
12851285
layout specifier in the above example is the default layout to be

doc/upgrading.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,37 @@ steps.
1313

1414
.. contents::
1515

16+
Migrating from 1.1.2 to 1.X.X
17+
=============================
18+
19+
1.X.X Sorting and grouping by multiple properties
20+
-------------------------------------------------
21+
22+
Starting with this version, sorting and grouping by multiple properties
23+
is possible. This means that request.sort and request.group are now
24+
lists. This is reflected in several places:
25+
26+
* ``renderWith`` now has list attributes for ``sort`` and ``group``,
27+
where you previously wrote::
28+
29+
renderWith(... sort=('-', 'activity'), group=('+', 'priority')
30+
31+
you write now::
32+
33+
renderWith(... sort=[('-', 'activity')], group=[('+', 'priority')]
34+
35+
* In templates that permit to edit sorting/grouping, request.sort and
36+
request.group are (possibly empty) lists. You can now sort and group
37+
by multiple attributes. For an example, see the classic template. You
38+
may want search for the variable ``n_sort`` which can be set to the
39+
number of sort/group properties.
40+
41+
* Templates that diplay new headlines for each group of items with
42+
equal group properties can now use the modified ``batch.propchanged``
43+
method that can take several properties which are checked for
44+
changes. See the example in the classic template which makes use of
45+
``batch.propchanged``.
46+
1647
Migrating from 1.1.0 to 1.1.1
1748
=============================
1849

doc/user_guide.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
User Guide
33
==========
44

5-
:Version: $Revision: 1.33 $
5+
:Version: $Revision: 1.34 $
66

77
.. contents::
88

@@ -338,9 +338,11 @@ arguments:
338338
Argument Description
339339
============ =============================================================
340340
@sort sort by prop name, optionally preceeded with '-' to give
341-
descending or nothing for ascending sorting.
341+
descending or nothing for ascending sorting. The sort
342+
argument can have several props separated with comma.
342343
@group group by prop name, optionally preceeded with '-' or to sort
343-
in descending or nothing for ascending order.
344+
in descending or nothing for ascending order. The group
345+
argument can have several props separated with comma.
344346
@columns selects the columns that should be displayed. Default is
345347
all.
346348
@filter indicates which properties are being used in filtering.
@@ -356,7 +358,7 @@ You may manually write URLS that contain these arguments, like so
356358

357359
/issue?status=unread,in-progress,resolved&
358360
topic=security,ui&
359-
@group=priority&
361+
@group=priority,-status&
360362
@sort=-activity&
361363
@filters=status,topic&
362364
@columns=title,status,fixer

0 commit comments

Comments
 (0)