[open-ils-commits] r19138 - branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jan 7 18:06:16 EST 2011


Author: senator
Date: 2011-01-07 18:06:10 -0500 (Fri, 07 Jan 2011)
New Revision: 19138

Modified:
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud/Store.js
Log:
Backport r19137 from trunk

Make openils.PermaCrud.Store use a default order_by clause in common situations

This avoids an issue where, using a FilteringSelect dijit, sometimes you type a
couple letters, let's says "ABC", and you get a set of matches like this:

"ABCDE"
"ABCD"
"ABC"

just because there happens to be no specific ordering.  If you click the ABC
match and tab away too quickly, the dijit will reset itself to the first match,
"ABCDE".  This is probably a Dojo/Dijit bug, as I've been able to duplicate the
problem with other stores, but that's all murky.

This avoids the issue by making sure the shortest match is at the top of the
list.



Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud/Store.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud/Store.js	2011-01-07 23:05:29 UTC (rev 19137)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud/Store.js	2011-01-07 23:06:10 UTC (rev 19138)
@@ -236,6 +236,7 @@
             if (qkeys.length < 1)
                 throw new PCSError("Not enough meat on that query");
 
+            var first_term;
             for (var qkey in req.query) {
                 var value = req.query[qkey];
                 var type = typeof value;
@@ -282,6 +283,7 @@
                     if (req.queryOptions && req.queryOptions.ignoreCase)
                         op = "ilike";
 
+                    if (!first_term) first_term = key;
                     if (op) {
                         pcrud_query[key] = {};
                         pcrud_query[key][op] = term;
@@ -315,6 +317,9 @@
                 /* XXX not sure whether multiple columns will work as such. */
                 hashkey = "order_by:" + opts.order_by[this.fmclass] + ":" +
                     hashkey;
+            } else if (first_term) {
+                opts.order_by = {};
+                opts.order_by[this.fmclass] = first_term + " ASC";
             }
 
             opts.id_list = this.stubby;



More information about the open-ils-commits mailing list