Skip to content

Commit f181b0a

Browse files
committed
Improve query UI.
1 parent 95e7948 commit f181b0a

File tree

5 files changed

+115
-37
lines changed

5 files changed

+115
-37
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<tal:block tal:define="vok context/is_view_ok">
2+
<p tal:condition="not:vok" i18n:translate="">You are not
3+
allowed to view this page.</p>
4+
5+
<tal:if condition="context/is_view_ok">
6+
<tal:def define="batch request/batch">
7+
<form>
8+
<table class="classhelp"
9+
tal:define="props python:request.form['properties'].value.split(',');
10+
legend templates/query/macros/legend;
11+
navigation templates/query/macros/navigation;">
12+
<thead>
13+
<tr metal:use-macro="navigation"/>
14+
<tr metal:use-macro="legend"/>
15+
</thead>
16+
<tfoot tal:condition=true>
17+
<tr metal:use-macro="legend"/>
18+
<tr metal:use-macro="navigation"/>
19+
</tfoot>
20+
<tbody>
21+
<tr tal:repeat="item request/batch">
22+
<tal:block tal:define="attr python:item[props[0]]" >
23+
<td>
24+
<input name="check"
25+
onclick="switch_val(text_field, this);" type="checkbox"
26+
tal:attributes="value attr; id string:id_$attr" />
27+
</td>
28+
<td tal:repeat="prop props">
29+
<label class="classhelp-label"
30+
tal:attributes="for string:id_$attr"
31+
tal:content="structure python:item[prop]"></label>
32+
</td>
33+
</tal:block>
34+
</tr>
35+
</tbody>
36+
</table>
37+
</form>
38+
</tal:def> <!-- batch -->
39+
</tal:if>
40+
</tal:block>
41+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- Query-related macros -->
2+
3+
<!-- legend for query results -->
4+
<tr metal:define-macro="legend">
5+
<th><b>x</b></th>
6+
<th tal:repeat="prop props" tal:content="prop" i18n:translate=""></th>
7+
</tr>
8+
9+
<!-- navigation for query results -->
10+
<tr metal:define-macro="navigation"
11+
tal:define="prev batch/previous;
12+
next batch/next;"
13+
tal:condition="python:prev or next">
14+
<th tal:condition="prev" width="30%">
15+
<input type="button" value="prev"
16+
tal:attributes="onclick string:query_start(${prev/start}, ${prev/size})"/>
17+
</th>
18+
<th i18n:translate="" width="40%">
19+
<span tal:replace="batch/start" i18n:name="start"/>..
20+
<span tal:replace="python: batch.start + batch.length -1" i18n:name="end"/> out of
21+
<span tal:replace="batch/sequence_length" i18n:name="total"/>
22+
</th>
23+
<th tal:condition="next" width="30%">
24+
<input type="button" value="next"
25+
tal:attributes="onclick string:query_start(${next/start}, ${next/size})"/>
26+
</th>
27+
</tr>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var action;
2+
3+
function display(data)
4+
{
5+
var list = $("div.list");
6+
list.empty();
7+
list.append(data);
8+
}
9+
10+
// Run a query with a specific starting point and size
11+
function query_start(start, size)
12+
{
13+
var inputs = $(":input");
14+
var data = {}
15+
if (start > 0) data['@startwith'] = start
16+
if (size > -1) data['@pagesize'] = size
17+
for (var i = 0; i < inputs.length; i++)
18+
data[inputs[i].name] = inputs[i].value;
19+
jQuery.get(action, data, display);
20+
return false;
21+
}
22+
23+
// Run a query, starting at the first element
24+
function query()
25+
{
26+
return query_start(0, -1)
27+
}
28+
29+
// Deactivate the form's submit action, and instead
30+
// invoke the action as part of (inline) query.
31+
function replace_submit()
32+
{
33+
var form = $("form");
34+
action = form.attr("action");
35+
form.attr("action",""); // reset
36+
form.submit(query);
37+
}
38+
39+
40+
$(document).ready(replace_submit);

share/roundup/templates/devel/html/search.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

share/roundup/templates/devel/html/user.help.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
form request/form/form/value;
66
field request/form/property/value">
77
<tal:block metal:fill-slot="more-javascript">
8-
<script language="Javascript" type="text/javascript" tal:content="structure string:<!--
8+
<script language="Javascript" type="text/javascript">
99
// this is the name of the field in the original form that we're working on
1010
form = parent.opener.document.${request/form/form/value};
1111
callingform=form
@@ -31,10 +31,9 @@
3131
alert('checkListForm: bol='+bol)
3232
return bol
3333
}
34-
//-->">
3534
</script>
3635
<script src="@@file/jquery.js" type="text/javascript"></script>
37-
<script src="@@file/search.js" type="text/javascript"></script>
36+
<script src="@@file/query.js" type="text/javascript"></script>
3837
</tal:block>
3938
<tal:block metal:fill-slot="content">
4039
<div name="search">
@@ -50,7 +49,7 @@
5049
search_select_roles templates/page/macros/search_select_roles;
5150
required python:[];
5251
th_label templates/page/macros/th_label; ">
53-
<input type="hidden" name="@template" value="help-list">
52+
<input type="hidden" name="@template" value="query">
5453
<input type="hidden" name="property" value="" tal:attributes="value property">
5554
<input type="hidden" name="form" value="" tal:attributes="value request/form/form/value">
5655
<table>
@@ -85,8 +84,10 @@
8584
</form>
8685
<script type="text/javascript"><!-- focus2id('username'); //--></script>
8786
</div>
88-
<!-- for search results: help-list -->
89-
<div class="list"><p i18n:translate="">Please specify your search parameters!</p></div>
87+
<!-- for search results: query -->
88+
<div class="list">
89+
<p i18n:translate="">Please specify your search parameters!</p>
90+
</div>
9091
<div class="submit" onload="parent.focus();" id="submit">
9192
<form name="frm_help"
9293
tal:define="batch request/batch;

0 commit comments

Comments
 (0)