1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
# <rdean@cambianetworks.com>
# Frédéric Buclin <LpSolit@gmail.com>
# Guy Pyrzak <guy.parzak@gmail.com>
#%]
[%# INTERFACE:
# buglistbase: The base query for this table, in URL form
# col_field: string. Name of the field being plotted as columns.
# row_field: string. Name of the field being plotted as rows.
# tbl_field: string. Name of the field being plotted as tables.
# col_names: array. List of values for the field being plotted as columns.
# row_names: array. List of values for the field being plotted as rows.
# data: <depends on format>. Data to plot. Only data.$tbl is accessed.
# tbl: Name of a hash in data which is the table to be plotted.
#%]
[% PROCESS "global/field-descs.none.tmpl" %]
[% col_field_disp = field_descs.$col_field || col_field %]
[% row_field_disp = field_descs.$row_field || row_field %]
[% urlbase = BLOCK %]buglist.cgi?[% buglistbase FILTER html %][% END %]
[% IF tbl == "-total-" %]
[% IF tbl_vals %]
[% urlbase = urlbase _ "&" _ tbl_vals %]
[% END %]
[% ELSIF tbl_field %]
[% urlbase = BLOCK %][% urlbase %]&[% tbl_field FILTER uri %]=[% tbl FILTER uri %][% END %]
[% END %]
<script [% script_nonce FILTER none %]>
function bz_encode (str, decode) {
// First decode HTML entities, if requested.
if (decode)
str = str.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"')
.replace(/ /g, " ").replace(/&/g, "&").replace(/\s+$/,"");
// encodeURIComponent() doesn't escape single quotes.
return encodeURIComponent(str).replace(/'/g, escape);
};
YAHOO.util.Event.addListener(window, "load", function() {
this.Linkify = function(elLiner, oRecord, oColumn, oData) {
if (oData == 0)
elLiner.innerHTML = ".";
else if (oRecord.getData("row_title") == "Total")
elLiner.innerHTML = '<a href="[% urlbase FILTER js %]&[% col_field FILTER uri FILTER js %]='
+ bz_encode(oColumn.field)
+ '[% "&" _ row_vals IF row_vals %]">' + oData + '</a>';
else
elLiner.innerHTML = '<a href="[% urlbase FILTER js %]&[% row_field FILTER uri FILTER js %]='
+ bz_encode(oRecord.getData("row_title"), 1)
+ '&[% col_field FILTER uri FILTER js %]='
+ bz_encode(oColumn.field) + '">' + oData + '</a>';
};
this.LinkifyTotal = function(elLiner, oRecord, oColumn, oData) {
if (oData == 0)
elLiner.innerHTML = ".";
else if (oRecord.getData("row_title") == "Total")
elLiner.innerHTML = '<a href="[% urlbase FILTER js %][% "&" _ row_vals IF row_vals %]
[%~ "&" _ col_vals IF col_vals %]">'
+ oData + '</a>';
else
elLiner.innerHTML = '<a href="[% urlbase FILTER js %]&[% row_field FILTER uri FILTER js %]='
+ bz_encode(oRecord.getData("row_title"), 1)
+ '[% "&" _ col_vals IF col_vals %]">' + oData + '</a>';
YAHOO.util.Dom.addClass(elLiner.parentNode, "ttotal");
};
var totalRowFormatter = function( elTr, oRecord ) {
if ( oRecord.getData('row_title') == "Total" ) {
YAHOO.util.Dom.addClass( elTr, 'ttotal' );
}
return true;
};
var totalNumberSorter = function( a, b, desc, field ){
var a_value = a.getData(field);
var b_value = b.getData(field);
var a_total_test = a.getData("row_title");
var b_total_test = b.getData("row_title");
var comp_result = YAHOO.util.Sort.compare(a_value, b_value, desc);
if( a_total_test == "Total" ){
comp_result = 1;
}else if( b_total_test == "Total" ){
comp_result = -1;
}
return comp_result;
};
var myColumnDefs = [
{key:"row_title", label:"", sortable:true, sortOptions: { sortFunction:totalNumberSorter }},
[% FOREACH col = col_names %]
{key:"[% col FILTER js %]", label:"[% display_value(col_field, col) FILTER html FILTER js %]", sortable:true,
formatter:this.Linkify, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC, sortFunction:totalNumberSorter }},
[% END %]
{key:"total", label:"Total", sortable:true, formatter:this.LinkifyTotal,
sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC, sortFunction:totalNumberSorter }}
];
this.parseString = function(str) {
return YAHOO.lang.trim(str);
};
this.parseNumber = function(str) {
if (str.match(/^\s*\.\s*$/m))
return 0;
// Do not use <\/a>$. For some reason, IE6 doesn't understand it.
// We use [^\d]+$ instead.
var res = str.match(/>(\d+)[^\d]+$/m);
if (res && res[1])
return parseFloat(res[1]);
};
this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("tabular_report"));
this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
this.myDataSource.responseSchema = {
fields: [
{key:"row_title", parser:this.parseString},
[% FOREACH col = col_names %]
{key:"[% col FILTER js %]", parser:this.parseNumber},
[% END %]
{key:"total", parser:this.parseNumber}
]
};
this.myDataTable = new YAHOO.widget.DataTable("tabular_report_container_
[% tbl FILTER js %]", myColumnDefs, this.myDataSource,
{formatRow: totalRowFormatter});
});
</script>
[% IF tbl_field %]
<h2>[% tbl_disp FILTER email FILTER html %]</h2>
[% END %]
<table>
<tr>
<td>
</td>
<td align="center">
<strong>[% col_field_disp FILTER html %]</strong>
</td>
</tr>
<tr>
<td valign="middle">
<strong>[% row_field_disp FILTER html %]</strong>
</td>
<td>
[% classes = [ [ "t1", "t2" ] , [ "t3", "t4" ] ] %]
[% col_idx = 0 %]
[% row_idx = 0 %]
[% grand_total = 0 %]
<div id="tabular_report_container_[% tbl FILTER html %]">
<table id="tabular_report" border="1">
[% IF col_field %]
<thead>
<tr>
<th class="[% classes.$row_idx.$col_idx %]">
</th>
[% FOREACH col = col_names %]
[% col_totals.$col = 0 %]
[% NEXT IF col == "" %]
[% col_idx = 1 - col_idx %]
<th class="[% classes.$row_idx.$col_idx %]">
[% PROCESS value_display value = col field = col_field %]
</th>
[% END %]
<th class="ttotal">
Total
</th>
</tr>
</thead>
[% END %]
<tbody>
[% FOREACH row = row_names %]
[% row_total = 0 %]
[% row_idx = 1 - row_idx %]
<tr>
<td class="[% classes.$row_idx.$col_idx %]" align="right">
[% PROCESS value_display value = row field = row_field %]
</td>
[% FOREACH col = col_names %]
[% row_total = row_total + data.$tbl.$col.$row %]
[% NEXT IF col == "" %]
[% col_totals.$col = (col_totals.$col || 0) + data.$tbl.$col.$row %]
[% col_idx = 1 - col_idx %]
<td class="[% classes.$row_idx.$col_idx %]" align="center">
[% IF data.$tbl.$col.$row AND data.$tbl.$col.$row > 0 %]
<a href="[% urlbase %]&
[% row_field FILTER uri %]=[% row FILTER uri %]&
[% col_field FILTER uri %]=[% col FILTER uri %]">
[% data.$tbl.$col.$row %]</a>
[% ELSE %]
.
[% END %]
</td>
[% END %]
<td class="ttotal" align="right">
<a href="[% urlbase %]&
[% row_field FILTER uri %]=[% row FILTER uri %]
[% "&$col_vals" IF col_vals %]">
[% row_total %]</a>
[% grand_total = grand_total + row_total %]
</td>
</tr>
[% END %]
<tr>
[% row_idx = 1 - row_idx %]
<td class="ttotal">
Total
</td>
[% FOREACH col = col_names %]
[% NEXT IF col == "" %]
<td class="ttotal" align="center">
<a href="[% urlbase %]&
[% col_field FILTER uri %]=[% col FILTER uri %]
[% "&$row_vals" IF row_vals %]">
[% col_totals.$col %]</a>
</td>
[% END %]
<td class="ttotal" align="right">
<strong>
<a href="[% urlbase %]
[% "&$row_vals" IF row_vals %]
[% "&$col_vals" IF col_vals %]">[% grand_total %]</a>
</strong>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</table>
[% BLOCK value_display %]
[% SET disp_value = display_value(field, value) %]
[% IF field == 'assigned_to' OR field == 'reporter'
OR field == 'qa_contact'
%]
[% disp_value = value FILTER email %]
[% END %]
[% disp_value FILTER html FILTER replace('^ $',' ') %]
[% END %]
|