}
};
+ 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,
};
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);
);
}
+ // 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();
};
}