Skip to content

Commit 19d7aad

Browse files
author
Tobias Herp
committed
filtering helper for users (nosy etc.).
Uses frames; no <noframes> version so far (but most Javascript-capable browsers will support frames anyway)
1 parent 4200f07 commit 19d7aad

File tree

10 files changed

+486
-7
lines changed

10 files changed

+486
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<title>Empty page (no search performed yet)</title>
4+
</head>
5+
<body>
6+
<p i18n:translate="">Bitte suchen!</p>
7+
</body>
8+
</html>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!-- $Id: _generic.help-list.html,v 1.1 2006-09-18 00:03:02 tobias-herp Exp $ vim: sw=2 ts=8 et
2+
--><html tal:define="vok context/is_view_ok">
3+
<head>
4+
<title>Search result for user helper</title>
5+
<link rel="stylesheet" type="text/css" href="@@file/style.css" />
6+
<script language="Javascript" type="text/javascript"
7+
tal:content="structure string:<!--
8+
// this is the name of the field in the original form that we're working on
9+
form = parent.opener.document.${request/form/form/value};
10+
field = '${request/form/property/value}';
11+
//-->"></script>
12+
<script src="@@file/help_controls.js" type="text/javascript"></script>
13+
<script type="text/javascript"><!--
14+
var text_field = parent.submit.document.frm_help.text_preview;
15+
//--></script>
16+
</head>
17+
<body>
18+
<pre tal:content="request/env/QUERY_STRING" tal:condition=false />
19+
20+
<p tal:condition="not:vok" i18n:translate="">You are not
21+
allowed to view this page.</p>
22+
23+
<tal:if condition="context/is_view_ok">
24+
<tal:def define="batch request/batch;">
25+
<form name=dummyform>
26+
<table width="100%"
27+
tal:define="template string:help-list"
28+
metal:use-macro="templates/help/macros/batch_navi"
29+
>
30+
<tr class="navigation">
31+
<th>
32+
<a href="#">&lt;&lt; previous</a>
33+
</th>
34+
<th i18n:translate="">1..25 out of 50
35+
</th>
36+
<th>
37+
<a href="#">next &gt;&gt;</a>
38+
</th>
39+
</tr>
40+
</table>
41+
42+
<form name=dummyform>
43+
<table class="classhelp"
44+
tal:define="
45+
props python:request.form['properties'].value.split(',');
46+
legend templates/help/macros/legend;
47+
"><thead>
48+
<tr metal:use-macro="legend">
49+
<th>&nbsp;<b>x</b></th>
50+
<th tal:repeat="prop props" tal:content="prop" i18n:translate=""></th>
51+
</tr>
52+
</thead>
53+
<tfoot tal:condition=true>
54+
<tr metal:use-macro="legend" />
55+
</tfoot>
56+
<tbody>
57+
<tr tal:repeat="item batch">
58+
<tal:block tal:define="attr python:item[props[0]]" >
59+
<td>
60+
<input name="check"
61+
onclick="switch_val(text_field, this);" type="checkbox"
62+
tal:attributes="value attr; id string:id_$attr" />
63+
</td>
64+
<td tal:repeat="prop props">
65+
<label class="classhelp-label"
66+
tal:attributes="for string:id_$attr"
67+
tal:content="structure python:item[prop]"></label>
68+
</td>
69+
</tal:block>
70+
</tr>
71+
</tbody>
72+
</table>
73+
</form>
74+
</tal:def>
75+
</tal:if>
76+
77+
<pre tal:content=request tal:condition=false />
78+
<script type="text/javascript"><!--
79+
parent.submit.document.frm_help.cb_listpresent.checked=true;
80+
reviseList_framed(document.dummyform, text_field)
81+
//--></script>
82+
</body>
83+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<title>Frame for search input fields</title>
4+
</head>
5+
<body>
6+
<p i18n:translate="">Generic template
7+
<span tal:replace="request/template" i18n:name="template">help-search</span>
8+
or version for class
9+
<span tal:replace="request/classname" i18n:name="classname">user</span>
10+
is not yet implemented</p>
11+
</body>
12+
</html>
13+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<html>
2+
<head>
3+
<link rel="stylesheet" type="text/css" href="@@file/style.css" />
4+
<meta http-equiv="Content-Type"
5+
tal:attributes="content string:text/html;; charset=${request/client/charset}" />
6+
<tal:block tal:condition="python:request.form.has_key('property')">
7+
<title>Generic submit page for framed helper windows</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+
form = parent.opener.document.${request/form/form/value};
12+
callingform=form
13+
field = '${request/form/property/value}';
14+
var listform = null
15+
function listPresent() {
16+
return document.frm_help.cb_listpresent.checked
17+
}
18+
function getListForm() {
19+
if (listPresent()) {
20+
return parent.list.document.forms.dummyform
21+
} else {
22+
return null
23+
}
24+
}
25+
26+
27+
function checkListForm() {
28+
// global listform
29+
if (listform != null)
30+
if (parent.list.document.dummyform) {
31+
listform = parent.list.document.dummyform
32+
alert(listform)
33+
}
34+
35+
var bol= listform != null
36+
alert('checkListForm: bol='+bol)
37+
return bol
38+
}
39+
//-->">
40+
</script>
41+
<script src="@@file/help_controls.js" type="text/javascript"></script>
42+
</tal:block>
43+
</head>
44+
<body class="body" onload="parent.focus();" id="submit">
45+
<pre tal:content="request/env/QUERY_STRING" tal:condition=false />
46+
<form name="frm_help"
47+
tal:define="batch request/batch;
48+
props python:request.form['properties'].value.split(',')"
49+
class="help-submit"
50+
id="classhelp-controls">
51+
<!--input type="button" name="btn_clear"
52+
tal:attributes="action request/base"
53+
style="width:100%;margin-right:1em;margin-left:0"
54+
value="Clear" onClick="clearList()"/ -->
55+
<div style="width:100%;text-align:left;margin-bottom:0.2em">
56+
<input type="text" name="text_preview" size="24" class="preview"
57+
onchange="f=getListForm();if(f){ reviseList_framed(f, this)};"
58+
/>
59+
</div>
60+
<input type=checkbox name="cb_listpresent" readonly="readonly" style="display:none">
61+
<input type="button" id="btn_cancel"
62+
value=" Cancel " onclick="parent.close();return false;"
63+
i18n:attributes="value" />
64+
<input type="reset" id="btn_reset"
65+
onclick="text_field.value=original_field;f=getListForm();if (f) {reviseList_framed(f, this)};return false"
66+
/>
67+
<input type="submit" id="btn_apply" class="apply"
68+
value=" Apply " onclick="callingform[field].value=text_field.value; parent.close();"
69+
i18n:attributes="value" />
70+
</form>
71+
<script type="text/javascript"><!--
72+
var text_field = document.frm_help.text_preview;
73+
original_field=form[field].value;
74+
text_field.value=original_field;
75+
//--></script>
76+
</body>
77+
</html>

templates/classic/html/help.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
Macros for framed help windows
3+
-->
4+
5+
<!-- legend for helper search results -->
6+
<thead>
7+
<tr metal:define-macro="legend">
8+
<th><b>x</b></th>
9+
<th tal:repeat="prop props" tal:content="prop" i18n:translate=""></th>
10+
</tr>
11+
</thead>
12+
13+
<table width="100%"
14+
metal:define-macro="batch_navi"
15+
tal:define="prev batch/previous;
16+
next batch/next;
17+
"
18+
tal:condition="python:prev or next">
19+
<tr class="navigation">
20+
<th width="30%">
21+
<a tal:condition="prev"
22+
tal:attributes="href python:request.indexargs_url(request.classname, {'@template':'help-list', 'property': request.form['property'].value, 'properties': request.form['properties'].value, 'form': request.form['form'].value, '@startwith':prev.first, '@pagesize':prev.size})"
23+
i18n:translate="" >&lt;&lt; previous</a>
24+
&nbsp;
25+
</th>
26+
<th i18n:translate="" width="40%"><span tal:replace="batch/start" i18n:name="start"
27+
/>..<span tal:replace="python: batch.start + batch.length -1" i18n:name="end"
28+
/> out of <span tal:replace="batch/sequence_length" i18n:name="total"
29+
/>
30+
</th>
31+
<th width="30%">
32+
<a tal:condition="next"
33+
tal:attributes="href python:request.indexargs_url(request.classname, {'@template':'help-list', 'property': request.form['property'].value, 'properties': request.form['properties'].value, 'form': request.form['form'].value, '@startwith':next.first, '@pagesize':next.size})"
34+
i18n:translate="" >next &gt;&gt;</a>
35+
&nbsp;
36+
</th>
37+
</tr>
38+
</table>

templates/classic/html/help_controls.js

Lines changed: 123 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function trim(value) {
1717
function determineList() {
1818
// generate a comma-separated list of the checked items
1919
var list = new String('');
20-
20+
2121
// either a checkbox object or an array of checkboxes
2222
var check = document.frm_help.check;
23-
23+
2424
if ((check.length == undefined) && (check.checked != undefined)) {
2525
// only one checkbox on page
2626
if (check.checked) {
@@ -41,7 +41,7 @@ function determineList() {
4141
}
4242
}
4343
}
44-
return list;
44+
return list;
4545
}
4646

4747
/**
@@ -160,7 +160,7 @@ function focusField(name) {
160160
function selectField(name) {
161161
for(i=0; i < document.forms.length; ++i) {
162162
var obj = document.forms[i].elements[name];
163-
if (obj && obj.focus){obj.focus();}
163+
if (obj && obj.focus){obj.focus();}
164164
if (obj && obj.select){obj.select();}
165165
}
166166
}
@@ -203,3 +203,122 @@ function checkRequiredFields(fields)
203203
}
204204
}
205205

206+
/**
207+
* seeks the given value (2nd argument)
208+
* in the value of the given input element (1st argument),
209+
* which is considered a list of values, separated by commas
210+
*/
211+
function has_value(input, val)
212+
{
213+
var actval = input.value
214+
var arr = feld.value.split(',');
215+
var max = arr.length;
216+
for (i=0;i<max;i++) {
217+
if (trim(arr[i]) == val) {
218+
return true
219+
}
220+
}
221+
return false
222+
}
223+
224+
/**
225+
* Switch Value:
226+
* change the value of the given input field (might be of type text or hidden),
227+
* adding or removing the value of the given checkbox field (might be a radio
228+
* button as well)
229+
*
230+
* This function doesn't care whether or not the checkboxes of all values of
231+
* interest are present; but of course it doesn't have total control of the
232+
* text field.
233+
*/
234+
function switch_val(text, check)
235+
{
236+
var switched_val = check.value
237+
var arr = text.value.split(',')
238+
var max = arr.length
239+
if (check.checked) {
240+
for (i=0; i<max; i++) {
241+
if (trim(arr[i]) == switched_val) {
242+
return
243+
}
244+
}
245+
if (text.value)
246+
text.value = text.value+','+switched_val
247+
else
248+
text.value = switched_val
249+
} else {
250+
var neu = ''
251+
var changed = false
252+
for (i=0; i<max; i++) {
253+
if (trim(arr[i]) == switched_val) {
254+
changed=true
255+
} else {
256+
neu = neu+','+trim(arr[i])
257+
}
258+
}
259+
if (changed) {
260+
text.value = neu.substr(1)
261+
}
262+
}
263+
}
264+
265+
/**
266+
* append the given value (2nd argument) to an input field
267+
* (1st argument) which contains comma-separated values;
268+
* see --> remove_val()
269+
*
270+
* This will work nicely even for batched lists
271+
*/
272+
function append_val(name, val)
273+
{
274+
var feld = document.itemSynopsis[name];
275+
var actval = feld.value;
276+
if (actval == '') {
277+
feld.value = val
278+
} else {
279+
var arr = feld.value.split(',');
280+
var max = arr.length;
281+
for (i=0;i<max;i++) {
282+
if (trim(arr[i]) == val) {
283+
return
284+
}
285+
}
286+
feld.value = actval+','+val
287+
}
288+
}
289+
290+
/**
291+
* remove the given value (2nd argument) from the comma-separated values
292+
* of the given input element (1st argument); see --> append_val()
293+
*/
294+
function remove_val(name, val)
295+
{
296+
var feld = document.itemSynopsis[name];
297+
var actval = feld.value;
298+
var changed=false;
299+
if (actval == '') {
300+
return
301+
} else {
302+
var arr = feld.value.split(',');
303+
var max = arr.length;
304+
var neu = ''
305+
for (i=0;i<max;i++) {
306+
if (trim(arr[i]) == val) {
307+
changed=true
308+
} else {
309+
neu = neu+','+trim(arr[i])
310+
}
311+
}
312+
if (changed) {
313+
feld.value = neu.substr(1)
314+
}
315+
}
316+
}
317+
318+
/**
319+
* give the focus to the element given by id
320+
*/
321+
function focus2id(name)
322+
{
323+
document.getElementById(name).focus();
324+
}

templates/classic/html/issue.index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: issue.index.html,v 1.24 2006-09-17 23:27:21 tobias-herp Exp $ -->
1+
<!-- $Id: issue.index.html,v 1.25 2006-09-18 00:03:02 tobias-herp Exp $ -->
22
<tal:block metal:use-macro="templates/page/macros/icing">
33
<title metal:fill-slot="head_title" >
44
<span tal:omit-tag="true" i18n:translate="" >List of issues</span>

templates/classic/html/page.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ <h2><span metal:define-slot="body_title">body title</span></h2>
251251
</td>
252252

253253
<!-- currently, there is no convenient API to get a list of all roles -->
254-
<td metal:define-macro="search_select_roles">
255-
<select name=roles id=roles>
254+
<td metal:define-macro="search_select_roles"
255+
tal:define="onchange onchange | nothing">
256+
<select name=roles id=roles tal:attributes="onchange onchange">
256257
<option value="" i18n:translate="">don't care</option>
257258
<option value="" i18n:translate="" disabled="disabled">------------</option>
258259
<option value="User">User</option>

0 commit comments

Comments
 (0)