Skip to content

Commit 3bd5241

Browse files
author
Richard Jones
committed
batch the (list) listings at 500 entries per page [SF#759906]
Unfortunately, the doovy javascript falls over when the next/prev links are used, so I've added some simple checking to remove that stuff when we're paging through the results (the simple test fails if you page back to the first page, but it'll do for now)
1 parent 5ed9271 commit 3bd5241

File tree

4 files changed

+105
-21
lines changed

4 files changed

+105
-21
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ are given with the most recent entry first.
88
- logfile must be specified if pidfile is (sf bug 772820)
99
- timelog editing via csv interface crashes (sf bug 699837)
1010
- sort multilinks a little better for grouping (sf bug 772935)
11+
- batch the (list) listings at 500 entries per page (sf bug 759906)
1112

1213

1314
2003-07-29 0.6.0b4

roundup/cgi/templating.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,10 @@ def classhelp(self, properties=None, label='(list)', width='500',
466466
properties = ','.join(properties)
467467
if property:
468468
property = '&property=%s'%property
469-
return '<a class="classhelp" href="javascript:help_window(\'%s?:'\
470-
'template=help&properties=%s%s\', \'%s\', \'%s\')">%s</a>'%(
471-
self.classname, properties, property, width, height, label)
469+
return '<a class="classhelp" href="javascript:help_window(\'%s?'\
470+
':startwith=0&:template=help&properties=%s%s\', \'%s\', \
471+
\'%s\')">%s</a>'%(self.classname, properties, property, width,
472+
height, label)
472473

473474
def submit(self, label="Submit New Entry"):
474475
''' Generate a submit button (and action hidden element)

templates/classic/html/_generic.help.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
</tal:block>
1616
</head>
1717
<body class="body" marginwidth="0" marginheight="0" onload="resetList();">
18-
<form name="frm_help" action="">
18+
<form name="frm_help" action=""
19+
tal:define="start python:int(request.form[':startwith'].value);
20+
batch python:utils.Batch(context.list(), 500, start);
21+
props python:request.form['properties'].value.split(',')">
1922

20-
<div id="classhelp-controls">
23+
<div id="classhelp-controls" tal:condition="python:start==0">
2124
<!--input type="button" name="btn_clear"
2225
value="Clear" onClick="clearList()"/ -->
2326
<input type="text" name="text_preview" size="24" class="preview"
@@ -28,16 +31,16 @@
2831
value=" Apply " onclick="updateList(); window.close();"/>
2932
</div>
3033

31-
<table class="classhelp"
32-
tal:define="props python:request.form['properties'].value.split(',')">
34+
<table class="classhelp">
3335
<tr>
3436
<th>&nbsp;<b>x</b></th>
3537
<th tal:repeat="prop props" tal:content="prop"></th>
3638
</tr>
37-
<tr tal:repeat="item context/list">
39+
<tr tal:repeat="item batch">
3840
<td>
3941
<input type="checkbox" name="check"
4042
onclick="updatePreview();"
43+
tal:condition="python:start==0"
4144
tal:define="attr python:item[props[0]]"
4245
tal:attributes="value attr; id attr" />
4346
</td>
@@ -52,7 +55,24 @@
5255
<th tal:repeat="prop props" tal:content="prop"></th>
5356
</tr>
5457
</table>
58+
<table width="100%">
59+
<tr class="navigation">
60+
<th>
61+
<a tal:define="prev batch/previous" tal:condition="prev"
62+
tal:attributes="href string:${request/classname}?:template=help&:startwith=${prev/first}&properties=${request/form/properties/value}">&lt;&lt; previous</a>
63+
&nbsp;
64+
</th>
65+
<th tal:content="python: '%d...%d out of %d'%(batch.start,
66+
batch.start+batch.length-1, batch.sequence_length)">current</th>
67+
<th>
68+
<a tal:define="next batch/next" tal:condition="next"
69+
tal:attributes="href string:${request/classname}?:template=help&:startwith=${next/first}&properties=${request/form/properties/value}">next &gt;&gt;</a>
70+
&nbsp;
71+
</th>
72+
</tr>
73+
</table>
5574

5675
</form>
5776
</body>
5877
</html>
78+
<!-- SHA: 97d46e2f10096a13afc6e5c48a3e6175ada9738f -->
Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,78 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
12
<html>
2-
<head>
3-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
4-
<link rel="stylesheet" type="text/css" href="_file/style.css">
5-
</head>
6-
<body class="body" marginwidth="0" marginheight="0">
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="_file/style.css" />
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
6+
<tal:block tal:condition="python:request.form.has_key('property')">
7+
<title tal:content="string:${request/form/property/value} help">Property</title>
8+
<script language="Javascript" type="text/javascript"
9+
tal:content="structure string:
10+
// this is the name of the field in the original form that we're working on
11+
field = '${request/form/property/value}';" >
12+
</script>
13+
<script src="_file/help_controls.js" type="text/javascript"><!--
14+
//--></script>
15+
</tal:block>
16+
</head>
17+
<body class="body" marginwidth="0" marginheight="0" onload="resetList();">
18+
<form name="frm_help" action=""
19+
tal:define="start python:int(request.form[':startwith'].value);
20+
batch python:utils.Batch(context.list(), 500, start);
21+
props python:request.form['properties'].value.split(',')">
22+
23+
<div id="classhelp-controls" tal:condition="python:start==0">
24+
<!--input type="button" name="btn_clear"
25+
value="Clear" onClick="clearList()"/ -->
26+
<input type="text" name="text_preview" size="24" class="preview"
27+
onchange="reviseList(this.value);"/>
28+
<input type="button" name="btn_reset"
29+
value=" Cancel " onclick="resetList(); window.close();"/>
30+
<input type="button" name="btn_apply" class="apply"
31+
value=" Apply " onclick="updateList(); window.close();"/>
32+
</div>
733

8-
<table class="classhelp"
9-
tal:define="props python:request.form['properties'].value.split(',')">
10-
<tr><th tal:repeat="prop props" tal:content="prop"></th></tr>
11-
<tr tal:repeat="item context/list">
12-
<td tal:repeat="prop props" tal:content="python:item[prop]"></td>
13-
</tr>
14-
</table>
34+
<table class="classhelp">
35+
<tr>
36+
<th>&nbsp;<b>x</b></th>
37+
<th tal:repeat="prop props" tal:content="prop"></th>
38+
</tr>
39+
<tr tal:repeat="item batch">
40+
<td>
41+
<input type="checkbox" name="check"
42+
onclick="updatePreview();"
43+
tal:condition="python:start==0"
44+
tal:define="attr python:item[props[0]]"
45+
tal:attributes="value attr; id attr" />
46+
</td>
47+
<td tal:repeat="prop props">
48+
<label class="classhelp-label"
49+
tal:attributes="for python:item[props[0]]"
50+
tal:content="structure python:item[prop]"></label>
51+
</td>
52+
</tr>
53+
<tr>
54+
<th>&nbsp;<b>x</b></th>
55+
<th tal:repeat="prop props" tal:content="prop"></th>
56+
</tr>
57+
</table>
58+
<table width="100%">
59+
<tr class="navigation">
60+
<th>
61+
<a tal:define="prev batch/previous" tal:condition="prev"
62+
tal:attributes="href string:${request/classname}?:template=help&:startwith=${prev/first}&properties=${request/form/properties/value}">&lt;&lt; previous</a>
63+
&nbsp;
64+
</th>
65+
<th tal:content="python: '%d...%d out of %d'%(batch.start,
66+
batch.start+batch.length-1, batch.sequence_length)">current</th>
67+
<th>
68+
<a tal:define="next batch/next" tal:condition="next"
69+
tal:attributes="href string:${request/classname}?:template=help&:startwith=${next/first}&properties=${request/form/properties/value}">next &gt;&gt;</a>
70+
&nbsp;
71+
</th>
72+
</tr>
73+
</table>
1574

16-
</body>
75+
</form>
76+
</body>
77+
</html>
78+
<!-- SHA: 97d46e2f10096a13afc6e5c48a3e6175ada9738f -->

0 commit comments

Comments
 (0)