~ubuntu-branches/ubuntu/gutsy/prewikka/gutsy

« back to all changes in this revision

Viewing changes to prewikka/templates/FilterEdition.tmpl

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2007-04-11 14:41:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070411144109-2hh7zx3amwd27b4l
Tags: upstream-0.9.10
ImportĀ upstreamĀ versionĀ 0.9.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#from prewikka import utils
 
2
#extends prewikka.templates.ClassicLayout
 
3
 
 
4
#block main_content
 
5
 
 
6
<script type="text/javascript"><!--
 
7
function newFilterElement(name, object, operator, object_value) {
 
8
        objects = new Array($objects)
 
9
        operators = new Array($operators)
 
10
 
 
11
        table = document.getElementById("elements")
 
12
 
 
13
        if ( ! name ) {
 
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")
 
19
                        } else {
 
20
                                name = name.substr(0, name.length - 1) +
 
21
                                                   String.fromCharCode(name.charCodeAt(name.length - 1) + 1)
 
22
                        }
 
23
                } else {
 
24
                        name = "A"
 
25
                }
 
26
        }
 
27
 
 
28
        row = document.createElement("tr")
 
29
        table.appendChild(row)
 
30
 
 
31
        field = document.createElement("td")
 
32
        row.appendChild(field)
 
33
        value = document.createTextNode(name)
 
34
        field.appendChild(value)
 
35
 
 
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")
 
45
                }
 
46
                option.setAttribute("value", objects[i])
 
47
                select.appendChild(option)
 
48
                value = document.createTextNode(objects[i])
 
49
                option.appendChild(value)
 
50
        }
 
51
 
 
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")
 
63
                }
 
64
                select.appendChild(option)
 
65
                option.setAttribute("value", operators[i])
 
66
                value = document.createTextNode(operators[i])
 
67
                option.appendChild(value)
 
68
        }
 
69
 
 
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)
 
78
 
 
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)
 
88
}
 
89
//--></script>
 
90
 
 
91
 
 
92
#filter CleanOutput
 
93
<div id="fieldset_page" style="display: table-cell;">
 
94
 
 
95
<fieldset class="fieldset_heading">
 
96
<legend>Available filters</legend>
 
97
<form action="?" method="post">
 
98
  <input type="hidden" name="view" value="filter_edition"/>
 
99
 
 
100
  <select style="width: 400px;" name="filter_name">
 
101
    <option value="">&nbsp;</option>
 
102
  #for $f in $filters
 
103
    #if $f == $fltr.name
 
104
      #set $selected = "selected=\"selected\""
 
105
    #else
 
106
      #set $selected =""
 
107
    #end if
 
108
    <option value="$f" $selected>$f</option>
 
109
  #end for
 
110
  </select>
 
111
 
 
112
  <input type="submit" name="mode" value="$_("Load")"/>
 
113
  <input type="submit" name="mode" value="$_("Delete")"/>
 
114
</form>
 
115
</fieldset>
 
116
 
 
117
<br/>
 
118
 
 
119
<form action="?" method="post">
 
120
<input type="hidden" name="view" value="filter_edition"/>
 
121
 
 
122
<fieldset>
 
123
<legend>Edition</legend>
 
124
<table>
 
125
 <tfoot>
 
126
  <tr>
 
127
   <td style="text-align: right;" colspan="4">&nbsp;</td>
 
128
   <td><a style="text-align: right;" href="javascript:newFilterElement('', '', '', '')">+</a></td>
 
129
  </tr>
 
130
 </tfoot>
 
131
 <tbody id="elements"></tbody>
 
132
</table>
 
133
 
 
134
#end filter
 
135
#filter Filter
 
136
 
 
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)");
 
140
#end for
 
141
//--></script>
 
142
 
 
143
#end filter
 
144
#filter CleanOutput
 
145
 
 
146
<br />
 
147
 
 
148
 
 
149
<table>
 
150
 <tr>
 
151
  <th>Formula:</th>
 
152
  <td><input style="width: 400px;" type="text" name="formula" value="$formula"/></td>
 
153
 </tr>
 
154
 <tr>
 
155
  <th>name:</th>
 
156
  <td><input style="width: 400px;" type="text" name="save_as" value="$fltr.name"/></td>
 
157
 </tr>
 
158
 <tr>
 
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>
 
161
 </tr>
 
162
</table>
 
163
 
 
164
<input style="float: right;" type="submit" name="mode" value="$_("Save")"/> 
 
165
</fieldset>
 
166
</form>
 
167
 
 
168
</div>
 
169
#end filter
 
170
#end block main_content