ACQ general search sort funds; display year
authorBill Erickson <berick@esilibrary.com>
Wed, 18 Sep 2013 19:38:08 +0000 (15:38 -0400)
committerDan Wells <dbw2@calvin.edu>
Fri, 11 Oct 2013 15:30:32 +0000 (11:30 -0400)
* Display fiscal year next to fund code in the search fund selector.
* Sort by newest fiscal year first, followed by code

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/web/js/ui/default/acq/search/unified.js

index 39831da..1eaad19 100644 (file)
@@ -18,6 +18,8 @@ var resultManager;
 var uriManager;
 var pcrud = new openils.PermaCrud();
 var cgi = new openils.CGI();
+var fundSearchFormat = ['${0} (${1})', 'code', 'year'];
+var fundSort = {order_by : {"acqf":"year DESC, code"}};
 
 /* typing save: add {get,set}Value() to all HTML <select> elements */
 HTMLSelectElement.prototype.getValue = function() {
@@ -184,8 +186,11 @@ function TermSelectorFactory(terms) {
                 new openils.widget.AutoFieldWidget({
                     "fmClass": term.hint,
                     "fmField": term.field,
+                    "labelFormat": (term.field == 'fund') ? fundSearchFormat : null,
+                    "searchFormat": (term.field == 'fund') ? fundSearchFormat : null,
                     "noDisablePkey": true,
-                    "parentNode": dojo.create("span", null, parentNode, "only")
+                    "parentNode": dojo.create("span", null, parentNode, "only"),
+                    "searchOptions" : (term.field == 'fund') ? fundSort : null
                 }).build(
                     function(w) {
                         wStore[widgetKey] = w;