From fefd158f424939fc473f54a2ffe4ee0e39ffba08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 6 Dec 2010 18:00:21 +0000 Subject: [PATCH] Ergonomy improvement in smart rule management Added a jQuery table filter, usefull when you have a lot of rows. This filter works on the entire row and allows you for exemple to type "Adul Perio 5". Indentation cleaning. Added tabs to filter colums on 4 axes: All, Issues, Fines and Reserves. Moved the table filter to the right of the tabs. Signed-off-by: Colin Campbell Signed-off-by: Chris Cormack --- .../jquery/plugins/jquery.uitablefilter.js | 90 +++++++++++ .../prog/en/modules/admin/smart-rules.tmpl | 141 +++++++++++++----- 2 files changed, 190 insertions(+), 41 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.uitablefilter.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.uitablefilter.js b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.uitablefilter.js new file mode 100644 index 0000000000..d80c8ddce8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.uitablefilter.js @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2008 Greg Weber greg at gregweber.info + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * documentation at http://gregweber.info/projects/uitablefilter + * + * allows table rows to be filtered (made invisible) + * + * t = $('table') + * $.uiTableFilter( t, phrase ) + * + * arguments: + * jQuery object containing table rows + * phrase to search for + * optional arguments: + * column to limit search too (the column title in the table header) + * ifHidden - callback to execute if one or more elements was hidden + */ +jQuery.uiTableFilter = function(jq, phrase, column, ifHidden){ + var new_hidden = false; + if( this.last_phrase === phrase ) return false; + + var phrase_length = phrase.length; + var words = phrase.toLowerCase().split(" "); + + // these function pointers may change + var matches = function(elem) { elem.show() } + var noMatch = function(elem) { elem.hide(); new_hidden = true } + var getText = function(elem) { return elem.text() } + + if( column ) { + var index = null; + jq.find("thead > tr:last > th").each( function(i){ + if( $.trim($(this).text()) == column ){ + index = i; return false; + } + }); + if( index == null ) throw("given column: " + column + " not found") + + getText = function(elem){ return jQuery(elem.find( + ("td:eq(" + index + ")") )).text() + } + } + + // if added one letter to last time, + // just check newest word and only need to hide + if( (words.size > 1) && (phrase.substr(0, phrase_length - 1) === + this.last_phrase) ) { + + if( phrase[-1] === " " ) + { this.last_phrase = phrase; return false; } + + var words = words[-1]; // just search for the newest word + + // only hide visible rows + matches = function(elem) {;} + var elems = jq.find("tbody > tr:visible") + } + else { + new_hidden = true; + var elems = jq.find("tbody > tr") + } + + elems.each(function(){ + var elem = jQuery(this); + jQuery.uiTableFilter.has_words( getText(elem), words, false ) ? + matches(elem) : noMatch(elem); + }); + + last_phrase = phrase; + if( ifHidden && new_hidden ) ifHidden(); + return jq; +}; + +// caching for speedup +jQuery.uiTableFilter.last_phrase = "" + +// not jQuery dependent +// "" [""] -> Boolean +// "" [""] Boolean -> Boolean +jQuery.uiTableFilter.has_words = function( str, words, caseSensitive ) +{ + var text = caseSensitive ? str : str.toLowerCase(); + for (var i=0; i < words.length; i++) { + if (text.indexOf(words[i]) === -1) return false; + } + return true; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl index 4e65c5907f..6cba8f3743 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl @@ -2,6 +2,9 @@ Koha › Administration › Issuing Rules + + + @@ -46,36 +88,48 @@ $(document).ready(function() {

To modify a rule, create a new one with the same patron type and item type.

-
+
Select a library :
" />
-
+
+ +
+ - - - - - - - - - - - - - - - +
Patron CategoryItem TypeCurrent Checkouts AllowedLoan Period (day)Fine AmountFine Charging IntervalFine Grace period (day)Suspension in Days (day)Renewals Allowed (count)Holds Allowed (count)Rental Discount (%) 
+ + + + + + + + + + + + + + + + + @@ -94,25 +148,27 @@ $(document).ready(function() { - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + +
Patron CategoryItem TypeCurrent Checkouts AllowedLoan Period (day)Fine AmountFine Charging IntervalFine Grace period (day)Suspension in Days (day)Renewals Allowed (count)Holds Allowed (count)Rental Discount (%) 
- Unlimited - - - - + Unlimited + + + + &categorycode=&branch=">Delete
"/>
+
+

Defaults for this library

-- 2.39.5