From db4c1c8684f0b9c24aef6c9dd1fefc1226c6bd75 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 15 Jul 2009 19:17:50 +0000 Subject: [PATCH] Not tested, but let the keys 'search_limit' and 'search_sort' be useable in the JSON-encoded 'query' object that pre-populates the search fields in search_form.xul when spawned by say, the patron editor git-svn-id: svn://svn.open-ils.org/ILS/trunk@13607 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/patron/display.js | 4 +++- .../xul/staff_client/server/patron/search_form.js | 10 ++++++++-- .../xul/staff_client/server/patron/search_result.js | 13 ++++++++++--- .../staff_client/server/patron/search_result.xul | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index 35aadb9343..e4350f51af 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -698,7 +698,7 @@ patron.display.prototype = { obj.render_search_form(params); }, 0); }, - 'on_submit' : function(query) { + 'on_submit' : function(query,search_limit,search_sort) { obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true'); obj.controller.view.cmd_patron_merge.setAttribute('disabled','true'); var list_frame = obj.right_deck.reset_iframe( @@ -706,6 +706,8 @@ patron.display.prototype = { {}, { 'query' : query, + 'search_limit' : search_limit, + 'search_sort' : search_sort, 'on_select' : function(list) { if (!list) return; if (list.length < 1) return; diff --git a/Open-ILS/xul/staff_client/server/patron/search_form.js b/Open-ILS/xul/staff_client/server/patron/search_form.js index 76759047c5..b0b101ef48 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_form.js +++ b/Open-ILS/xul/staff_client/server/patron/search_form.js @@ -14,6 +14,12 @@ patron.search_form.prototype = { var obj = this; + // The bulk of params.query is getting parsed/rendered by obj.controller.init below, and will be reconstituted from possibly modified XUL elements upon Submit. + // But we're going to let search_limit and search_sort be configurable now by those spawning this interface, and let's assume there are no corresponding widgets for now. + // I'm going to place them into the "obj" scope for this instance. + obj.search_limit = params.param2; + obj.search_sort = JSON2js( params.param3 ); // Let's assume this is encoded as JSON + JSAN.use('OpenILS.data'); this.OpenILS = {}; obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'}); @@ -329,12 +335,12 @@ patron.search_form.prototype = { } } if (typeof obj.on_submit == 'function') { - obj.on_submit(query); + obj.on_submit(query,obj.search_limit,obj.search_sort); } if (typeof window.xulG == 'object' && typeof window.xulG.on_submit == 'function') { obj.error.sdump('D_PATRON','patron.search_form: Calling external .on_submit()\n'); - window.xulG.on_submit(query); + window.xulG.on_submit(query,obj.search_limit,obj.search_sort); } else { obj.error.sdump('D_PATRON','patron.search_form: No external .on_query()\n'); } diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.js b/Open-ILS/xul/staff_client/server/patron/search_result.js index 44ba0a0ae0..9f304d67ca 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.js +++ b/Open-ILS/xul/staff_client/server/patron/search_result.js @@ -19,6 +19,8 @@ patron.search_result.prototype = { var obj = this; obj.query = params['query']; + obj.search_limit = params['search_limit']; + obj.search_sort = params['search_sort']; JSAN.use('OpenILS.data'); this.OpenILS = {}; obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'}); @@ -183,7 +185,12 @@ patron.search_result.prototype = { try { var results = []; - var params = [ ses(), search_hash, obj.result_cap + 1, [ 'family_name ASC', 'first_given_name ASC', 'second_given_name ASC', 'dob DESC' ] ]; + var params = [ + ses(), + search_hash, + typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap + 1, + typeof obj.search_sort != 'undefined' ? obj.search_sort : [ 'family_name ASC', 'first_given_name ASC', 'second_given_name ASC', 'dob DESC' ] + ]; if (inactive) { params.push(1); if (document.getElementById('active')) { @@ -203,9 +210,9 @@ patron.search_result.prototype = { alert($("patronStrings").getString('staff.patron.search_result.search.no_patrons_found')); return; } - if (results.length == obj.result_cap+1) { + if (results.length == typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap+1) { results.pop(); - alert($("patronStrings").getFormattedString('staff.patron.search_result.search.capped_results', [obj.result_cap])); + alert($("patronStrings").getFormattedString('staff.patron.search_result.search.capped_results', [typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap])); } } else { alert($("patronStrings").getString('staff.patron.search_result.search.enter_search_terms')); diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.xul b/Open-ILS/xul/staff_client/server/patron/search_result.xul index 53b7781180..a037dce310 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.xul +++ b/Open-ILS/xul/staff_client/server/patron/search_result.xul @@ -56,7 +56,7 @@ } JSAN.use('patron.search_result'); g.search_result = new patron.search_result(); - g.search_result.init( { 'query' : query } ); + g.search_result.init( { 'query' : query, 'search_limit' : xulG.search_limit, 'search_sort' : xulG.search_sort } ); } catch(E) { var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/search_result.xul', E]); -- 2.43.2