From f5d27df4111b54367d7f270f7b63d4f8e9db2b92 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Wed, 19 Dec 2012 11:41:28 -0500 Subject: [PATCH] LP #1092179 FlattenerGrid Filter dialog lead to clobbering grid's base query 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 Signed-off-by: Ben Shum --- Open-ILS/src/templates/actor/user/event_log.tt2 | 7 +++---- Open-ILS/src/templates/circ/hold_pull_list.tt2 | 8 +++++++- .../web/js/dojo/openils/widget/FlattenerGrid.js | 13 ++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/templates/actor/user/event_log.tt2 b/Open-ILS/src/templates/actor/user/event_log.tt2 index 9bbc7223f5..de1afa12d3 100644 --- a/Open-ILS/src/templates/actor/user/event_log.tt2 +++ b/Open-ILS/src/templates/actor/user/event_log.tt2 @@ -196,13 +196,12 @@ /* 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(); diff --git a/Open-ILS/src/templates/circ/hold_pull_list.tt2 b/Open-ILS/src/templates/circ/hold_pull_list.tt2 index 485d717fe0..67056a811a 100644 --- a/Open-ILS/src/templates/circ/hold_pull_list.tt2 +++ b/Open-ILS/src/templates/circ/hold_pull_list.tt2 @@ -21,9 +21,15 @@ }; 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(); } diff --git a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js index 03166da3eb..54e67c2524 100644 --- a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js @@ -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 */ ); } -- 2.43.2