LP #1092179 FlattenerGrid Filter dialog lead to clobbering grid's base query
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 19 Dec 2012 16:41:28 +0000 (11:41 -0500)
committerBen Shum <bshum@biblio.org>
Wed, 19 Dec 2012 22:26:38 +0000 (17:26 -0500)
You could see this in the Simplified Hold Pull List interface.  Using
the filter dialog would refresh the grid and populate it with rows
corresponding to your filters, but it would throw away your setting from
the context org dropdown (labeled "Show the pull list for..." there).

FlattenerGrid had a broken mechanism for trying to nicely mix a user's
input from things like context org dropdowns with whatever they put into
the filter dialog, and now that mechanism has been fixed.

This also means a tiny change to the User Event Log interface to react
to the slight change in FlattenerGrid's API.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/actor/user/event_log.tt2
Open-ILS/src/templates/circ/hold_pull_list.tt2
Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js

index 9bbc722..de1afa1 100644 (file)
 
     /* The callback fired when the OrgUnitFilteringSelect is changed */
     function set_grid_query_from_org_selector() {
-        /* Naughty: shouldn't use _baseQuery like this, but need to rethink
-           multiple competing filtering mechanisms. */
-        grid._baseQuery.perm_lib = aou.descendantNodeList(
+        grid.baseQuery.perm_lib = aou.descendantNodeList(
             org_selector.attr("value"), /* as id */ true
         );
 
-        /* But for the persistent filter UI, this would be grid.refresh() */
+        /* But for the persistent filter UI, this would be grid.filter()
+           and grid.refresh() */
         if (filter_semaphore())   /* avoid race between ou selector and other
                                      filter thing */
             filter_semaphore_callback();
index 485d717..67056a8 100644 (file)
     };
 
     function set_grid_query_from_org_selector() {
-        grid.query = {
+        grid.baseQuery = {  /* Don't optimize away this assignment.  It's
+                               important to store this data so that the filter
+                               dialog doesn't clobber it later. */
             "copy_circ_lib": org_selector.attr("value")
         };
+        grid.filter(
+            dojo.mixin(grid.query, grid.baseQuery),
+            true    /* re-fetch */
+        );
         grid.refresh();
     }
 
index 03166da..54e67c2 100644 (file)
@@ -26,6 +26,10 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             "filterWidgetBuilders": null,
             "filterSemaphore": null,
             "filterSemaphoreCallback": null,
+            "baseQuery": null,  /* Good place to mix in data from, say, context
+                                   OU selectors so that it should get mixed
+                                   correctly with the generated query from the
+                                   filter dialog. */
 
             /* These potential constructor arguments may be useful to
              * FlattenerGrid in their own right, and are passed to
@@ -392,8 +396,11 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             },
 
             "startup": function() {
-                /* Save original query for further filtering later */
-                this._baseQuery = dojo.clone(this.query);
+                /* Save original query for further filtering later, unless
+                 * we've already defined baseQuery from the outside, in
+                 * which case it persists. */
+                if (!this.baseQuery)
+                    this.baseQuery = dojo.clone(this.query);
 
                 this._addAutoFields();
 
@@ -503,7 +510,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                     this.filterUi.onApply = dojo.hitch(
                         this, function(filter) {
                             this.filter(
-                                dojo.mixin(filter, this._baseQuery),
+                                dojo.mixin(filter, this.baseQuery),
                                 true    /* re-render */
                             );
                         }