Fix sorting when printing from FlattenerGrid-based interfaces
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 13 Aug 2012 15:47:48 +0000 (11:47 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 24 Aug 2012 18:15:34 +0000 (14:15 -0400)
This particularly affects the Simplified Hold Pull List.  The printed
verison of your data is supposed to reflect the same sort order that has
been selected in the visual interface, and now it does.

Buggy handling of the different avenues of sorting the grid (clicking column
headers, using the column-picker/multicolumn-sort dialog, default sort order)
had broken the flow of the data needed to build the right sort clause for
some situations.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/dojo/openils/FlattenerStore.js

index 700d3f2..6f3f989 100644 (file)
@@ -16,7 +16,8 @@ if (!dojo._hasResource["openils.FlattenerStore"]) {
     dojo.declare(
         "openils.FlattenerStore", null, {
 
-        "_last_fetch": null,        /* used internally */
+        "_last_fetch": null,        /* timestamp. used internally */
+        "_last_fetch_sort": null,   /* dijit sort object. used internally */
         "_flattener_url": "/opac/extras/flattener",
 
         /* Everything between here and the constructor can be specified in
@@ -172,6 +173,12 @@ if (!dojo._hasResource["openils.FlattenerStore"]) {
             req.queryOptions = req.queryOptions || {};
             req.abort = function() { console.warn("[unimplemented] abort()"); };
 
+            /* If we were asked to fetch without any sort order specified (as
+             * will happen when coming from fetchToPrint(), try to use the
+             * last cached sort order, if any. */
+            req.sort = req.sort || this._last_fetch_sort;
+            this._last_fetch_sort = req.sort;
+
             if (!this.mapKey)
                 this._get_map_key();