From c7c418a87d2284423f58a0d3e1a418c32a8b4ab6 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 29 Mar 2012 15:15:24 -0400 Subject: [PATCH] AutoGrid retains external search filters AutoGrid now caches the search passed to the most recent loadAll call separately from any filters passed via PCrudFilterDialog. This allows AutoGrid to retain externally-supplied (persistent) filters (e.g. context org unit selector) while being able to easily remove filters passed via the filter dialog. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../web/js/dojo/openils/widget/AutoGrid.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index 4ea8178f3e..12c2ef2734 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -103,11 +103,20 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { href : 'javascript:void(0);', onclick : function() { if (!self.filterDialog) { + self.filterDialog = new openils.widget.PCrudFilterDialog( {fmClass:self.fmClass, suppressFilterFields:self.suppressFilterFields}) + self.filterDialog.onApply = function(filter) { - self.refresh(self.cachedQueryOpts, filter); + self.cachedQuerySearch = dojo.mixin( filter, self.preFilterSearch ); + self.resetStore(); + self.loadAll( + dojo.mixin( { offset : 0 }, self.cachedQueryOpts ), + self.cachedQuerySearch, + true + ); }; + self.filterDialog.startup(); } self.filterDialog.show(); @@ -511,7 +520,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { } }, - loadAll : function(opts, search) { + loadAll : function(opts, search, filter_triggered) { var _this = this; // first we have to load the column picker to determine the sort fields. @@ -535,10 +544,10 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { } // column picker not wanted or already loaded - this._loadAll(opts, search); + this._loadAll(opts, search, filter_triggered); }, - _loadAll : function(opts, search) { + _loadAll : function(opts, search, filter_triggered) { var self = this; dojo.require('openils.PermaCrud'); @@ -565,6 +574,11 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { this.cachedQuerySearch = search; this.cachedQueryOpts = opts; + + // retain the most recent external loadAll + if (!filter_triggered || !this.preFilterSearch) + this.preFilterSearch = dojo.clone( this.cachedQuerySearch ); + if(search) new openils.PermaCrud().search(this.fmClass, search, opts); else -- 2.43.2