Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
4199ac1f
Commit
4199ac1f
authored
Jul 08, 2010
by
Guy Pyrzak
Committed by
Frédéric Buclin
Jul 08, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 142394: Tabular reports should be sortable
r=pyrzak a=LpSolit
parent
905e7009
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
34 deletions
+123
-34
report-table.html.tmpl
template/en/default/reports/report-table.html.tmpl
+121
-33
report.html.tmpl
template/en/default/reports/report.html.tmpl
+2
-1
No files found.
template/en/default/reports/report-table.html.tmpl
View file @
4199ac1f
...
...
@@ -17,6 +17,8 @@
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
# <rdean@cambianetworks.com>
# Frédéric Buclin <LpSolit@gmail.com>
# Guy Pyrzak <guy.parzak@gmail.com>
#%]
[%# INTERFACE:
...
...
@@ -43,6 +45,90 @@
[% tbl_field FILTER url_quote %]=[% tbl FILTER url_quote %][% END %]
[% END %]
<script type="text/javascript">
YAHOO.util.Event.addListener(window, "load", function() {
this.Linkify = function(elLiner, oRecord, oColumn, oData) {
if (oData == 0)
elLiner.innerHTML = ".";
else
elLiner.innerHTML = "<a href='[% urlbase %]&[% row_field FILTER js %]="
+ oRecord.getData("row_title").replace(/\s+$/,"")
+ "&[% col_field FILTER js %]=" + oColumn.field
+ "'>" + oData + "</a>";
};
this.LinkifyTotal = function(elLiner, oRecord, oColumn, oData) {
if (oData == 0)
elLiner.innerHTML = ".";
else
elLiner.innerHTML = "<a href='[% urlbase %]&[% row_field FILTER js %]="
+ oRecord.getData("row_title").replace(/\s+$/,"")
+ "[% '&' _ 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:"[% col 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", myColumnDefs, this.myDataSource, {formatRow: totalRowFormatter});
});
</script>
[% IF tbl_field %]
<h2>[% tbl_disp FILTER email FILTER html %]</h2>
[% END %]
...
...
@@ -67,27 +153,29 @@
[% col_idx = 0 %]
[% row_idx = 0 %]
[% grand_total = 0 %]
<table border="1">
<div id="tabular_report_container">
<table
id="tabular_report"
border="1">
[% IF col_field %]
<thead>
<tr>
<t
d
class="[% classes.$row_idx.$col_idx %]">
</t
d
>
<t
h
class="[% classes.$row_idx.$col_idx %]">
</t
h
>
[% FOREACH col = col_names %]
[% col_totals.$col = 0 %]
[% NEXT IF col == "" %]
[% col_idx = 1 - col_idx %]
<t
d
class="[% classes.$row_idx.$col_idx %]">
<t
h
class="[% classes.$row_idx.$col_idx %]">
[% PROCESS value_display value = col field = col_field %]
</t
d
>
</t
h
>
[% END %]
<t
d
class="ttotal">
<t
h
class="ttotal">
Total
</t
d
>
</t
h
>
</tr>
</thead>
[% END %]
<tbody>
[% FOREACH row = row_names %]
[% row_total = 0 %]
...
...
@@ -122,32 +210,32 @@
</td>
</tr>
[% END %]
<tr>
[% row_idx = 1 - row_idx %]
<td class="ttotal">
Total
</td>
[% FOREACH col = col_names %]
[% NEXT IF col == "" %]
<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 url_quote %]=[% col FILTER url_quote %]
[% "&$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>
<td class="ttotal" align="center">
<a href="[% urlbase %]&
[% col_field FILTER url_quote %]=[% col FILTER url_quote %]
[% "&$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>
...
...
template/en/default/reports/report.html.tmpl
View file @
4199ac1f
...
...
@@ -74,9 +74,10 @@
.t2 { background-color: #dfefff } /* light blue */
.t3 { background-color: #dddddd } /* grey */
.t4 { background-color: #c3d3ed } /* darker blue */
.ttotal { background-color: #cfffdf } /* light green */
.ttotal
, .ttotal td
{ background-color: #cfffdf } /* light green */
"
header_addl_info = time
yui = ['datatable']
%]
[% IF debug %]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment