1
#from prewikka import utils
2
#extends prewikka.templates.ClassicLayout
6
<script type="text/javascript"><!--
7
function newFilterElement(name, object, operator, object_value) {
8
objects = new Array($objects)
9
operators = new Array($operators)
11
table = document.getElementById("elements")
14
if ( table.lastChild.nodeName == "TR" ) {
15
child = table.lastChild.firstChild.firstChild
16
name = new String(child.nodeValue)
17
if ( name.charAt(name.length - 1) == "Z" ) {
18
name = name.concat("A")
20
name = name.substr(0, name.length - 1) +
21
String.fromCharCode(name.charCodeAt(name.length - 1) + 1)
28
row = document.createElement("tr")
29
table.appendChild(row)
31
field = document.createElement("td")
32
row.appendChild(field)
33
value = document.createTextNode(name)
34
field.appendChild(value)
36
field = document.createElement("td")
37
row.appendChild(field)
38
select = document.createElement("select")
39
field.appendChild(select)
40
select.setAttribute("name", "object_" + name)
41
for ( var i = 0; i < objects.length; i++ ) {
42
option = document.createElement("option")
43
if ( object == objects[i] ) {
44
option.setAttribute("selected", "true")
46
option.setAttribute("value", objects[i])
47
select.appendChild(option)
48
value = document.createTextNode(objects[i])
49
option.appendChild(value)
52
field = document.createElement("td")
53
row.appendChild(field)
54
select = document.createElement("select")
55
field.appendChild(select)
56
select.setAttribute("name", "operator_" + name)
57
for ( var i = 0; i < operators.length; i++ ) {
58
/* NB: setting selected to true before adding option to select is mandatory,
59
if it is done after, it won't work */
60
option = document.createElement("option")
61
if ( operator == operators[i] ) {
62
option.setAttribute("selected", "true")
64
select.appendChild(option)
65
option.setAttribute("value", operators[i])
66
value = document.createTextNode(operators[i])
67
option.appendChild(value)
70
field = document.createElement("td")
71
row.appendChild(field)
72
input = document.createElement("input")
73
field.appendChild(input)
74
/* NB: if type=text is set before value=something, the value won't be displayed */
75
/*input.setAttribute("type", "text")*/
76
input.setAttribute("name", "value_" + name)
77
input.setAttribute("value", object_value)
79
field = document.createElement("td")
80
row.appendChild(field)
81
link = document.createElement("a")
82
link.setAttribute("href", "#")
83
field.appendChild(link)
84
link.onclick = function() { this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode) }
85
link.setAttribute("style", "position: relative; float: right;")
86
value = document.createTextNode("-")
87
link.appendChild(value)
93
<div id="fieldset_page" style="display: table-cell;">
95
<fieldset class="fieldset_heading">
96
<legend>Available filters</legend>
97
<form action="?" method="post">
98
<input type="hidden" name="view" value="filter_edition"/>
100
<select style="width: 400px;" name="filter_name">
101
<option value=""> </option>
104
#set $selected = "selected=\"selected\""
108
<option value="$f" $selected>$f</option>
112
<input type="submit" name="mode" value="$_("Load")"/>
113
<input type="submit" name="mode" value="$_("Delete")"/>
119
<form action="?" method="post">
120
<input type="hidden" name="view" value="filter_edition"/>
123
<legend>Edition</legend>
127
<td style="text-align: right;" colspan="4"> </td>
128
<td><a style="text-align: right;" href="javascript:newFilterElement('', '', '', '')">+</a></td>
131
<tbody id="elements"></tbody>
137
<script type="text/javascript"><!--
138
#for $element in $elements
139
newFilterElement("$utils.escape_attribute($element.name)", "$utils.escape_attribute($element.object)", "$utils.escape_attribute($element.operator)", "$utils.escape_attribute($element.value)");
152
<td><input style="width: 400px;" type="text" name="formula" value="$formula"/></td>
156
<td><input style="width: 400px;" type="text" name="save_as" value="$fltr.name"/></td>
159
<th style="vertical-align: top;">comment:</th>
160
<td><textarea style="width: 400px;" name="filter_comment" rows="4" cols="55">$fltr.comment</textarea></td>
164
<input style="float: right;" type="submit" name="mode" value="$_("Save")"/>
170
#end block main_content