From: Bill Erickson Date: Fri, 13 Jul 2012 20:31:41 +0000 (-0400) Subject: ACQ : Support lineitem fucus in ACQ unified search X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2353b9392fd60d37be326e8548bdd01faf8fd756;p=evergreen%2Fmasslnc.git ACQ : Support lineitem fucus in ACQ unified search Adds support for a "focus_li" URL parameter to ACQ unified search results pages. When present, the page of results containing the requested lineitem are loaded (instead of the default page 1) and the lineitem is made visible in the viewable screen using the lineitem table focusLi mechanism. Signed-off-by: Bill Erickson Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js b/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js index 20d8a17c16..de24dcba68 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table_pager.js @@ -60,6 +60,40 @@ function LiTablePager() { } }; + this.focusLi = function() { + var liId = this.liTable.focusLineitem; + if (liId && this.liTable.liCache[liId] && dojo.byId('li-title-ref-' + liId)) + this.liTable.focusLi(); + }; + + /* given a lineitem to focus, this will determine what page in + * the results set the lineitem sits, then fetch that page + * of results. Returns false if no focus requested. + */ + this.loadFocusLi = function() { + var liId = this.liTable.focusLineitem; + if (!liId) return false; + + var _this = this; + this.getAllLineitemIDs( + function(r) { + var allIds = openils.Util.readResponse(r); + var idx = dojo.indexOf(allIds, liId); + // if li not found, result is loading page 1 + + var page = 1; + while ( idx >= (page * _this.displayLimit) ) { + page++; + } + + _this.displayOffset = (_this.displayLimit * (page - 1)); + _this.dataLoader(); + } + ); + + return true; + }; + this.getAllLineitemIDs = function(callback) { this.dataLoader({ "id_list": true, diff --git a/Open-ILS/web/js/ui/default/acq/search/unified.js b/Open-ILS/web/js/ui/default/acq/search/unified.js index 68fb3bb25a..b7f0137836 100644 --- a/Open-ILS/web/js/ui/default/acq/search/unified.js +++ b/Open-ILS/web/js/ui/default/acq/search/unified.js @@ -775,6 +775,13 @@ function ResultManager(liPager, poGrid, plGrid, invGrid) { }; this.resultsComplete = function() { + + // now that the records are loaded, we need to do the actual focusing + if (this.result_type == 'lineitem') { + if (this.liPager) + this.liPager.focusLi(); + } + if (!this.count_results) this.show("no_results"); else this.finish(this.result_type); @@ -838,6 +845,15 @@ function ResultManager(liPager, poGrid, plGrid, invGrid) { ); } + // if the caller has requested we focus on a specific + // lineitem, allow the pager to find the lineitem + // and load the results directly. + if (this.result_type == 'lineitem') { + if (this.liPager && this.liPager.loadFocusLi()) { + return; + } + } + interface.dataLoader(); }; }