Skip to content

Commit 58571ff

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent d22a1c4 commit 58571ff

File tree

3 files changed

+79
-14
lines changed

3 files changed

+79
-14
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Fixed:
1515
- have 'roundup-admin security' display property restrictions (sf bug
1616
1222135)
1717
- fixed templating menu() sort_on handling (sf bug 1221936)
18+
- allow specification of pagesize, sorting and filtering in "classhelp"
19+
popups (sf bug 1211800)
1820

1921

2022
2005-05-02 0.8.3

doc/customizing.txt

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

5-
:Version: $Revision: 1.161.2.16 $
5+
:Version: $Revision: 1.161.2.17 $
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
@@ -1762,6 +1762,32 @@ filter lists of items from this class, filtered and sorted. Two
17621762

17631763
classhelp display a link to a javascript popup containing this class'
17641764
"help" template.
1765+
1766+
This generates a link to a popup window which displays the
1767+
properties indicated by "properties" of the class named by
1768+
"classname". The "properties" should be a comma-separated list
1769+
(eg. 'id,name,description'). Properties defaults to all the
1770+
properties of a class (excluding id, creator, created and
1771+
activity).
1772+
1773+
You may optionally override the "label" displayed, the "width",
1774+
the "height", the number of items per page ("pagesize") and
1775+
the field on which the list is sorted ("sort").
1776+
1777+
With the "filter" arg it is possible to specify a filter for
1778+
which items are supposed to be displayed. It has to be of
1779+
the format "<field>=<values>;<field>=<values>;...".
1780+
1781+
The popup window will be resizable and scrollable.
1782+
1783+
If the "property" arg is given, it's passed through to the
1784+
javascript help_window function. This allows updating of a
1785+
property in the calling HTML page.
1786+
1787+
If the "form" arg is given, it's passed through to the
1788+
javascript help_window function - it's the name of the form
1789+
the "property" belongs to.
1790+
17651791
submit generate a submit button (and action hidden element)
17661792
renderWith render this class with the given template.
17671793
history returns 'New node - no history' :)
@@ -1946,7 +1972,9 @@ menu only on Link and Multilink properties - render a form select
19461972
lists properties which should be included in the label
19471973
sort_on
19481974
indicates the property to sort the list on as (direction,
1949-
property) where direction is '+' or '-'.
1975+
(direction, property) where direction is '+' or '-'. A
1976+
single string with the direction prepended may be used.
1977+
For example: ('-', 'order'), '+name'.
19501978

19511979
The remaining keyword arguments are used as conditions for
19521980
filtering the items in the list - they're passed as the

roundup/cgi/templating.py

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ def filter(self, request=None, filterspec={}, sort=(None,None),
620620
return l
621621

622622
def classhelp(self, properties=None, label=''"(list)", width='500',
623-
height='400', property='', form='itemSynopsis'):
623+
height='400', property='', form='itemSynopsis',
624+
pagesize=50, sort=None, filter=None):
624625
'''Pop up a javascript window with class help
625626
626627
This generates a link to a popup window which displays the
@@ -630,8 +631,16 @@ def classhelp(self, properties=None, label=''"(list)", width='500',
630631
properties of a class (excluding id, creator, created and
631632
activity).
632633
633-
You may optionally override the label displayed, the width and
634-
height. The popup window will be resizable and scrollable.
634+
You may optionally override the label displayed, the width,
635+
the height, the number of items per page and the field on which
636+
the list is sorted (defaults to username if in the displayed
637+
properties).
638+
639+
With the "filter" arg it is possible to specify a filter for
640+
which items are supposed to be displayed. It has to be of
641+
the format "<field>=<values>;<field>=<values>;...".
642+
643+
The popup window will be resizable and scrollable.
635644
636645
If the "property" arg is given, it's passed through to the
637646
javascript help_window function.
@@ -644,13 +653,31 @@ def classhelp(self, properties=None, label=''"(list)", width='500',
644653
properties = self._klass.getprops(protected=0).keys()
645654
properties.sort()
646655
properties = ','.join(properties)
656+
if sort is None:
657+
if 'username' in properties.split( ',' ):
658+
sort = '&amp;@sort=username'
659+
else:
660+
sort = ''
661+
else:
662+
sort = '&amp;@sort=' + sort
647663
if property:
648664
property = '&amp;property=%s'%property
649665
if form:
650666
form = '&amp;form=%s'%form
667+
if filter:
668+
filterprops = filter.split(';')
669+
filtervalues = []
670+
names = []
671+
for x in filterprops:
672+
(name, values) = x.split('=')
673+
names.append(name)
674+
filtervalues.append('&amp;%s=%s' % (name, urllib.quote(values)))
675+
filter = '&amp;@filter=%s%s' % (','.join(names), ''.join(filtervalues))
676+
else:
677+
filter = ''
651678
help_url = "%s?@startwith=0&amp;@template=help&amp;"\
652-
"properties=%s%s%s" % \
653-
(self.classname, properties, property, form)
679+
"properties=%s%s%s%s&amp;@pagesize=%s%s" % \
680+
(self.classname, properties, property, form, sort, pagesize, filter)
654681
onclick = "javascript:help_window('%s', '%s', '%s');return false;" % \
655682
(help_url, width, height)
656683
return '<a class="classhelp" href="%s" onclick="%s">%s</a>' % \
@@ -1643,16 +1670,16 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16431670
if value is None:
16441671
s = 'selected="selected" '
16451672
l.append(self._('<option %svalue="-1">- no selection -</option>')%s)
1673+
16461674
if sort_on is not None:
16471675
if not isinstance(sort_on, tuple):
16481676
if sort_on[0] in '+-':
16491677
sort_on = (sort_on[0], sort_on[1:])
16501678
else:
16511679
sort_on = ('+', sort_on)
1652-
elif linkcl.getprops().has_key('order'):
1653-
sort_on = ('+', 'order')
16541680
else:
1655-
sort_on = ('+', linkcl.labelprop())
1681+
sort_on = ('+', find_sort_key(linkcl))
1682+
16561683
options = linkcl.filter(None, conditions, sort_on, (None, None))
16571684

16581685
# make sure we list the current value if it's retired
@@ -1805,7 +1832,9 @@ def menu(self, size=None, height=None, showid=0, additional=[],
18051832
"additional" lists properties which should be included in the
18061833
label
18071834
"sort_on" indicates the property to sort the list on as
1808-
(direction, property) where direction is '+' or '-'.
1835+
(direction, property) where direction is '+' or '-'. A
1836+
single string with the direction prepended may be used.
1837+
For example: ('-', 'order'), '+name'.
18091838
18101839
The remaining keyword arguments are used as conditions for
18111840
filtering the items in the list - they're passed as the
@@ -1819,10 +1848,16 @@ def menu(self, size=None, height=None, showid=0, additional=[],
18191848
value = self._value
18201849

18211850
linkcl = self._db.getclass(self._prop.classname)
1822-
if sort_on is None:
1823-
sort_on = ('+', find_sort_key(linkcl))
1851+
1852+
if sort_on is not None:
1853+
if not isinstance(sort_on, tuple):
1854+
if sort_on[0] in '+-':
1855+
sort_on = (sort_on[0], sort_on[1:])
1856+
else:
1857+
sort_on = ('+', sort_on)
18241858
else:
1825-
sort_on = ('+', sort_on)
1859+
sort_on = ('+', find_sort_key(linkcl))
1860+
18261861
options = linkcl.filter(None, conditions, sort_on)
18271862
height = height or min(len(options), 7)
18281863
l = ['<select multiple name="%s" size="%s">'%(self._formname, height)]

0 commit comments

Comments
 (0)