[open-ils-commits] [GIT] Evergreen ILS branch master updated. f8cbc52c5a40eddfe30cac0955fd2c23e09a59d9
Evergreen Git
git at git.evergreen-ils.org
Sun Feb 7 16:02:18 EST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via f8cbc52c5a40eddfe30cac0955fd2c23e09a59d9 (commit)
via 75150d47c01e4daab5df5a9b8aeae8ed8234b56f (commit)
from e32a1d4feeb9fe2fa2bf133bce4e6cd4b4414e77 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f8cbc52c5a40eddfe30cac0955fd2c23e09a59d9
Author: Galen Charlton <gmc at esilibrary.com>
Date: Fri Nov 20 21:26:05 2015 +0000
LP#1516867: set limit on when HTML report output sorting
To avoid taking an excessive amount of time to render an
HTML report or sort its values, dynamic sorting is enabled
only when there are at most 10,000 rows of output.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Ben Shum <ben at evergreener.net>
diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl
index 758cb2c..fabd2db 100755
--- a/Open-ILS/src/reporter/clark-kent.pl
+++ b/Open-ILS/src/reporter/clark-kent.pl
@@ -113,6 +113,12 @@ my $resultset_limit = $opt_resultset_limit //
0;
$resultset_limit = 0 unless $resultset_limit =~ /^\d+$/; # 0 means no limit
+# What follows is an emperically-derived magic number; if
+# the row count is larger than this, the table-sorting JavaScript
+# won't be loaded to excessive churn when viewing HTML reports
+# in the staff client or web browser.
+my $sortable_limit = 10000;
+
my ($dbh,$running,$sth, at reports,$run, $current_time);
if ($daemon) {
@@ -555,7 +561,6 @@ sub build_html {
td,th { border: solid black 1px; }
* { font-family: sans-serif; }
</style>
- <script src="/js/sortable/sortable.min.js"></script>
<link rel="stylesheet" href="/js/sortable/sortable-theme-minimal.css" />
CSS
@@ -566,7 +571,11 @@ sub build_html {
print $raw "<tr><td>".join('</td><td>', @$_)."</td></tr>\n" for (@{$r->{data}});
}
- print $raw '</tbody></table></body></html>';
+ print $raw '</tbody></table>';
+ if (@{ $r->{data} } <= $sortable_limit) {
+ print $raw '<script src="/js/sortable/sortable.min.js"></script>';
+ }
+ print $raw '</body></html>';
$raw->close;
}
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
index 373418e..539a576 100644
--- a/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
+++ b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
@@ -2,4 +2,5 @@ Sortable HTML reports
^^^^^^^^^^^^^^^^^^^^^
HTML reports can now be sorted by clicking on the header for a given column.
Clicking on the header toggles between sorting the column in ascending and
-descending order.
+descending order. Note that sorting is available only when there are
+at most 10,000 rows of output.
commit 75150d47c01e4daab5df5a9b8aeae8ed8234b56f
Author: Dan Scott <dscott at laurentian.ca>
Date: Mon Nov 16 22:20:28 2015 -0500
LP#1516867 Make HTML report tables sortable
Using the sortable JavaScript library from https://github.com/hubspot/sortable
(MIT license), we can make HTML reports much more usable by making them
sortable by clicking on the column headers. This should save some downloading
of CSV or Excel versions of the reports.
To test:
[1] Create or use a report template and generate an HTML report; ensure
that the report has at most 10,000 rows of output.
[2] View the report output and click on one of the column headings;
verify that the table sorts itself by that column's values.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Ben Shum <ben at evergreener.net>
diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl
index 0e8a99b..758cb2c 100755
--- a/Open-ILS/src/reporter/clark-kent.pl
+++ b/Open-ILS/src/reporter/clark-kent.pl
@@ -553,18 +553,20 @@ sub build_html {
table { border-collapse: collapse; }
th { background-color: lightgray; }
td,th { border: solid black 1px; }
- * { font-family: sans-serif; font-size: 10px; }
+ * { font-family: sans-serif; }
</style>
+ <script src="/js/sortable/sortable.min.js"></script>
+ <link rel="stylesheet" href="/js/sortable/sortable-theme-minimal.css" />
CSS
- print $raw "</head><body><table>";
+ print $raw "</head><body><table class='sortable-theme-minimal' data-sortable>";
{ no warnings;
- print $raw "<tr><th>".join('</th><th>',@{$r->{column_labels}}).'</th></tr>';
- print $raw "<tr><td>".join('</td><td>',@$_ ).'</td></tr>' for (@{$r->{data}});
+ print $raw "<thead><tr><th>".join('</th><th>', @{$r->{column_labels}})."</th></tr></thead>\n<tbody>";
+ print $raw "<tr><td>".join('</td><td>', @$_)."</td></tr>\n" for (@{$r->{data}});
}
- print $raw '</table></body></html>';
+ print $raw '</tbody></table></body></html>';
$raw->close;
}
diff --git a/Open-ILS/web/js/sortable/LICENSE b/Open-ILS/web/js/sortable/LICENSE
new file mode 100644
index 0000000..e19dfc9
--- /dev/null
+++ b/Open-ILS/web/js/sortable/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2013 Adam Schwartz, http://adamschwartz.co
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/Open-ILS/web/js/sortable/sortable-theme-minimal.css b/Open-ILS/web/js/sortable/sortable-theme-minimal.css
new file mode 100644
index 0000000..96db314
--- /dev/null
+++ b/Open-ILS/web/js/sortable/sortable-theme-minimal.css
@@ -0,0 +1,55 @@
+/* line 2, ../sass/_sortable.sass */
+table[data-sortable] {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+/* line 6, ../sass/_sortable.sass */
+table[data-sortable] th {
+ vertical-align: bottom;
+ font-weight: bold;
+}
+/* line 10, ../sass/_sortable.sass */
+table[data-sortable] th, table[data-sortable] td {
+ text-align: left;
+ padding: 10px;
+}
+/* line 14, ../sass/_sortable.sass */
+table[data-sortable] th:not([data-sortable="false"]) {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ -o-user-select: none;
+ user-select: none;
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+ -webkit-touch-callout: none;
+ cursor: pointer;
+}
+/* line 26, ../sass/_sortable.sass */
+table[data-sortable] th:after {
+ content: "";
+ visibility: hidden;
+ display: inline-block;
+ vertical-align: inherit;
+ height: 0;
+ width: 0;
+ border-width: 5px;
+ border-style: solid;
+ border-color: transparent;
+ margin-right: 1px;
+ margin-left: 10px;
+ float: right;
+}
+/* line 40, ../sass/_sortable.sass */
+table[data-sortable] th[data-sorted="true"]:after {
+ visibility: visible;
+}
+/* line 43, ../sass/_sortable.sass */
+table[data-sortable] th[data-sorted-direction="descending"]:after {
+ border-top-color: inherit;
+ margin-top: 8px;
+}
+/* line 47, ../sass/_sortable.sass */
+table[data-sortable] th[data-sorted-direction="ascending"]:after {
+ border-bottom-color: inherit;
+ margin-top: 3px;
+}
diff --git a/Open-ILS/web/js/sortable/sortable.min.js b/Open-ILS/web/js/sortable/sortable.min.js
new file mode 100644
index 0000000..8278f50
--- /dev/null
+++ b/Open-ILS/web/js/sortable/sortable.min.js
@@ -0,0 +1,2 @@
+/*! sortable.js 0.8.0 */
+(function(){var a,b,c,d,e,f,g;a="table[data-sortable]",d=/^-?[£$¤]?[\d,.]+%?$/,g=/^\s+|\s+$/g,c=["click"],f="ontouchstart"in document.documentElement,f&&c.push("touchstart"),b=function(a,b,c){return null!=a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},e={init:function(b){var c,d,f,g,h;for(null==b&&(b={}),null==b.selector&&(b.selector=a),d=document.querySelectorAll(b.selector),h=[],f=0,g=d.length;g>f;f++)c=d[f],h.push(e.initTable(c));return h},initTable:function(a){var b,c,d,f,g,h;if(1===(null!=(h=a.tHead)?h.rows.length:void 0)&&"true"!==a.getAttribute("data-sortable-initialized")){for(a.setAttribute("data-sortable-initialized","true"),d=a.querySelectorAll("th"),b=f=0,g=d.length;g>f;b=++f)c=d[b],"false"!==c.getAttribute("data-sortable")&&e.setupClickableTH(a,c,b);return a}},setupClickableTH:function(a,d,f){var g,h,i,j,k,l;for(i=e.getColumnType(a,f),h=function(b){var c,g,h,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D;if(b.handled===!0)return!1;for(b.hand
led=!0,m="true"===this.getAttribute("data-sorted"),n=this.getAttribute("data-sorted-direction"),h=m?"ascending"===n?"descending":"ascending":i.defaultSortDirection,p=this.parentNode.querySelectorAll("th"),s=0,w=p.length;w>s;s++)d=p[s],d.setAttribute("data-sorted","false"),d.removeAttribute("data-sorted-direction");if(this.setAttribute("data-sorted","true"),this.setAttribute("data-sorted-direction",h),o=a.tBodies[0],l=[],m){for(D=o.rows,v=0,z=D.length;z>v;v++)g=D[v],l.push(g);for(l.reverse(),B=0,A=l.length;A>B;B++)k=l[B],o.appendChild(k)}else{for(r=null!=i.compare?i.compare:function(a,b){return b-a},c=function(a,b){return a[0]===b[0]?a[2]-b[2]:i.reverse?r(b[0],a[0]):r(a[0],b[0])},C=o.rows,j=t=0,x=C.length;x>t;j=++t)k=C[j],q=e.getNodeValue(k.cells[f]),null!=i.comparator&&(q=i.comparator(q)),l.push([q,k,j]);for(l.sort(c),u=0,y=l.length;y>u;u++)k=l[u],o.appendChild(k[1])}return"function"==typeof window.CustomEvent&&"function"==typeof a.dispatchEvent?a.dispatchEvent(new CustomEve
nt("Sortable.sorted",{bubbles:!0})):void 0},l=[],j=0,k=c.length;k>j;j++)g=c[j],l.push(b(d,g,h));return l},getColumnType:function(a,b){var c,d,f,g,h,i,j,k,l,m,n;if(d=null!=(l=a.querySelectorAll("th")[b])?l.getAttribute("data-sortable-type"):void 0,null!=d)return e.typesObject[d];for(m=a.tBodies[0].rows,h=0,j=m.length;j>h;h++)for(c=m[h],f=e.getNodeValue(c.cells[b]),n=e.types,i=0,k=n.length;k>i;i++)if(g=n[i],g.match(f))return g;return e.typesObject.alpha},getNodeValue:function(a){var b;return a?(b=a.getAttribute("data-value"),null!==b?b:"undefined"!=typeof a.innerText?a.innerText.replace(g,""):a.textContent.replace(g,"")):""},setupTypes:function(a){var b,c,d,f;for(e.types=a,e.typesObject={},f=[],c=0,d=a.length;d>c;c++)b=a[c],f.push(e.typesObject[b.name]=b);return f}},e.setupTypes([{name:"numeric",defaultSortDirection:"descending",match:function(a){return a.match(d)},comparator:function(a){return parseFloat(a.replace(/[^0-9.-]/g,""),10)||0}},{name:"date",defaultSortDirection:"as
cending",reverse:!0,match:function(a){return!isNaN(Date.parse(a))},comparator:function(a){return Date.parse(a)||0}},{name:"alpha",defaultSortDirection:"ascending",match:function(){return!0},compare:function(a,b){return a.localeCompare(b)}}]),setTimeout(e.init,0),"function"==typeof define&&define.amd?define(function(){return e}):"undefined"!=typeof exports?module.exports=e:window.Sortable=e}).call(this);
\ No newline at end of file
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
new file mode 100644
index 0000000..373418e
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
@@ -0,0 +1,5 @@
+Sortable HTML reports
+^^^^^^^^^^^^^^^^^^^^^
+HTML reports can now be sorted by clicking on the header for a given column.
+Clicking on the header toggles between sorting the column in ascending and
+descending order.
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/reporter/clark-kent.pl | 21 ++++++--
.../angular-location-update => sortable}/LICENSE | 13 ++---
.../web/js/sortable/sortable-theme-minimal.css | 55 ++++++++++++++++++++
Open-ILS/web/js/sortable/sortable.min.js | 2 +
.../Administration/sortable_html_reports.adoc | 6 ++
5 files changed, 84 insertions(+), 13 deletions(-)
copy Open-ILS/web/js/{ui/default/staff/extern/angular-location-update => sortable}/LICENSE (86%)
create mode 100644 Open-ILS/web/js/sortable/sortable-theme-minimal.css
create mode 100644 Open-ILS/web/js/sortable/sortable.min.js
create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list