From d63239012334e07c38a49a6d9d05870a2297cda2 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 3 Aug 2009 20:55:42 +0000 Subject: [PATCH] Backport changeset 13791 from trunk: restore raw z39.50 PQN search feature git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4_0@13795 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 + Open-ILS/xul/staff_client/server/cat/z3950.js | 83 ++++++++++++++++++++-- Open-ILS/xul/staff_client/server/cat/z3950.xul | 3 +- .../server/locale/en-US/cat.properties | 5 ++ 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index fe27bc5aea..e265f0375e 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2117,6 +2117,8 @@ + + diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.js b/Open-ILS/xul/staff_client/server/cat/z3950.js index f85745f2d8..c9802418bd 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.js +++ b/Open-ILS/xul/staff_client/server/cat/z3950.js @@ -184,6 +184,17 @@ cat.z3950.prototype = { obj.initial_search(); }, ], + 'raw_search' : [ + ['command'], + function() { + var raw = window.prompt( + $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.msg'), + $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.default_value'), + $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.title') + ); + if (raw) obj.initial_raw_search(raw); + } + ], 'page_next' : [ ['command'], function() { @@ -223,6 +234,7 @@ cat.z3950.prototype = { function handle_switch(node) { try { + $('search').setAttribute('disabled','true'); $('raw_search').setAttribute('disabled','true'); obj.active_services = []; var snl = document.getElementsByAttribute('mytype','service_class'); for (var i = 0; i < snl.length; i++) { @@ -231,6 +243,14 @@ cat.z3950.prototype = { if (n.checked) obj.active_services.push( n.getAttribute('service') ); } } + if (obj.active_services.length > 0) { + $('search').setAttribute('disabled','false'); + } + if (obj.active_services.length == 1) { + if (obj.active_services[0] != 'native-evergreen-catalog') { + $('raw_search').setAttribute('disabled','false'); + } + } var nl = document.getElementsByAttribute('mytype','search_class'); for (var i = 0; i < nl.length; i++) { nl[i].disabled = true; } var attrs = {}; @@ -434,13 +454,13 @@ cat.z3950.prototype = { obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true'); obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true'); - obj.search_params.service = []; - obj.search_params.username = []; - obj.search_params.password = []; + obj.search_params.service_array = []; + obj.search_params.username_array = []; + obj.search_params.password_array = []; for (var i = 0; i < obj.active_services.length; i++) { - obj.search_params.service.push( obj.active_services[i] ); - obj.search_params.username.push( document.getElementById( obj.active_services[i]+'_username' ).value ); - obj.search_params.password.push( document.getElementById( obj.active_services[i]+'_password' ).value ); + obj.search_params.service_array.push( obj.active_services[i] ); + obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value ); + obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value ); } obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length ); obj.search_params.offset = 0; @@ -464,6 +484,51 @@ cat.z3950.prototype = { } }, + 'initial_raw_search' : function(raw) { + try { + var obj = this; + obj.result_set = []; obj.number_of_result_sets = 0; + JSAN.use('util.widgets'); + util.widgets.remove_children( obj.controller.view.result_message ); + var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); + if (obj.active_services.length < 1) { + x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection'))); + return; + } + if (obj.active_services.length > 1) { + x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.too_many_selections'))); + return; + } + if (obj.active_services[0] == 'native-evergreen-catalog') { + x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.raw_search_unsupported_for_native_catalog'))); + return; + } + x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching'))); + obj.search_params = {}; obj.list.clear(); + obj.controller.view.page_next.disabled = true; + obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true'); + obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true'); + obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true'); + + obj.search_params.service_array = []; + obj.search_params.username_array = []; + obj.search_params.password_array = []; + for (var i = 0; i < obj.active_services.length; i++) { + obj.search_params.service_array.push( obj.active_services[i] ); + obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value ); + obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value ); + } + obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length ); + obj.search_params.offset = 0; + + obj.search_params.query = raw; + + obj.search(); + } catch(E) { + this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E); + } + }, + 'page_next' : function() { try { var obj = this; @@ -484,8 +549,14 @@ cat.z3950.prototype = { var method; if (typeof obj.search_params.query == 'undefined') { method = 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH'; + obj.search_params.service = obj.search_params.service_array; + obj.search_params.username = obj.search_params.username_array; + obj.search_params.password = obj.search_params.password_array; } else { method = 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH'; + obj.search_params.service = obj.search_params.service_array[0]; + obj.search_params.username = obj.search_params.username_array[0]; + obj.search_params.password = obj.search_params.password_array[0]; } obj.network.simple_request( method, diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.xul b/Open-ILS/xul/staff_client/server/cat/z3950.xul index 59683f2f43..e698bf123f 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.xul +++ b/Open-ILS/xul/staff_client/server/cat/z3950.xul @@ -127,9 +127,10 @@ +