From f6e3a636877b74e2dd77904d89e6e3ccff9e24f2 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 6 Jul 2005 05:52:48 +0000 Subject: [PATCH] patron search results git-svn-id: svn://svn.open-ils.org/ILS/trunk@1058 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../content/evergreen/patron/patron_search.js | 70 +++++++++++++++++- .../evergreen/patron/patron_search_results.js | 85 ++++++++++++++++++++++ .../evergreen/patron/patron_search_results.xul | 32 ++++++++ .../patron/patron_search_results_overlay.xul | 22 ++++++ 4 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.js create mode 100644 Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.xul create mode 100644 Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results_overlay.xul diff --git a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js index 93e91c5658..d70174919f 100644 --- a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js +++ b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search.js @@ -10,12 +10,32 @@ function patron_search_init(p) { 'onload' : patron_search_init_after_clamshell(p) } ); + + p.w.crazy_search = function (crazy_search_hash) { + return patron_search( p.w, crazy_search_hash ); + }; +} + +function patron_search(search_win, crazy_search_hash) { + sdump('D_PATRON_SEARCH',arg_dump(arguments)); + var result = []; + try { + result = user_request( + 'open-ils.actor', + 'open-ils.actor.patron.search.advanced', + [ G.auth_ses[0], crazy_search_hash ] + )[0]; + sdump('D_PATRON_SEARCH','result.length = ' + result.length + '\n'); + } catch(E) { + handle_error(E); + } + return result; } function patron_search_init_after_clamshell(p) { sdump('D_PATRON_SEARCH',arg_dump(arguments)); return function (clamshell_w) { - var form = spawn_patron_search_form( + p.w.search_form = spawn_patron_search_form( clamshell_w.document, 'new_iframe', clamshell_w.first_deck, { @@ -23,8 +43,14 @@ function patron_search_init_after_clamshell(p) { } ); - clamshell_w.new_card_in_second_deck( - 'chrome://evergreen/content/main/about.xul', {}); + p.w.result_tree = spawn_patron_search_results( + clamshell_w.document, + 'new_iframe', + clamshell_w.second_deck, { + 'onload' : patron_init_after_patron_search_results(p) + } + ); + }; } @@ -33,8 +59,44 @@ function patron_init_after_patron_search_form(p) { return function(form_w) { form_w.register_search_callback( function (ev) { - alert('Submitted: ' + + sdump('D_PATRON_SEARCH','Submitted: ' + js2JSON(form_w.crazy_search_hash) + '\n'); + if (p.w.crazy_search) { + p.w.result_tree.add_patrons( + p.w.crazy_search( form_w.crazy_search_hash ) + ); + } + } + ); + }; +} + +function patron_init_after_patron_search_results(p) { + sdump('D_PATRON_SEARCH',arg_dump(arguments)); + return function(results_w) { + results_w.register_patron_select_callback( + function (ev) { + alert('Selected: ' + + js2JSON(results_w.selection_id) + '\n'); + } + ); + results_w.register_flesh_patron_function( + function (treeitem) { + sdump('D_PATRON_SEARCH',arg_dump(arguments)); + user_async_request( + 'open-ils.actor', + 'open-ils.actor.user.fleshed.retrieve', + [ G.auth_ses[0], treeitem.getAttribute('record_id') ], + function (request) { + sdump('D_PATRON_SEARCH',arg_dump(arguments)); + try { + var patron = request.getResultObject(); + results_w.map_patron_to_cols( patron, treeitem ); + } catch(E) { + sdump('D_ERROR',js2JSON(E) + '\n'); + } + } + ); } ); }; diff --git a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.js b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.js new file mode 100644 index 0000000000..9b35bb09cc --- /dev/null +++ b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.js @@ -0,0 +1,85 @@ +sdump('D_TRACE','Loading patron_search_results.js\n'); + +function patron_search_results_init(p) { + sdump('D_PATRON_SEARCH_RESULTS',"TESTING: patron_search_results.js: " + mw.G['main_test_variable'] + '\n'); + + p.w.patron_cols = [ + { + 'id' : 'id_col', 'label' : getString('au_label_id'), 'flex' : 1, + 'primary' : true, 'hidden' : false, 'fm_field_render' : '.id()' + }, + { + 'id' : 'prefix_col', 'label' : getString('au_label_prefix'), 'flex' : 1, + 'primary' : false, 'hidden' : false, 'fm_field_render' : '.prefix()' + }, + { + 'id' : 'family_name_col', 'label' : getString('au_label_family_name'), 'flex' : 1, + 'primary' : false, 'hidden' : false, 'fm_field_render' : '.family_name()' + }, + { + 'id' : 'first_given_name_col', 'label' : getString('au_label_first_given_name'), 'flex' : 1, + 'primary' : false, 'hidden' : false, 'fm_field_render' : '.first_given_name()' + }, + { + 'id' : 'second_given_name_col', 'label' : getString('au_label_second_given_name'), 'flex' : 1, + 'primary' : false, 'hidden' : false, 'fm_field_render' : '.second_given_name()' + }, + { + 'id' : 'suffix_col', 'label' : getString('au_label_suffix'), 'flex' : 1, + 'primary' : false, 'hidden' : false, 'fm_field_render' : '.suffix()' + } + ]; + + p.w.tree_win = spawn_paged_tree( + p.w.document, 'new_iframe', p.paged_tree, { + 'cols' : p.w.patron_cols, + 'onload' : patron_search_results_init_after_paged_tree(p) + } + ); + + p.w.register_patron_select_callback = function (f) { + p.w._patron_select_callback = f; + } + + p.w.register_flesh_patron_function = function (f) { + p.w._flesh_patron_function = f; + } + + p.w.map_patron_to_cols = function (patron, treeitem) { + patron_search_results_map_patron_to_cols(p, patron, treeitem); + } + + if (p.onload) { + try { + sdump('D_TRACE','trying psuedo-onload...\n'); + p.onload(p.w); + } catch(E) { + sdump('D_ERROR', js2JSON(E) + '\n' ); + } + } + +} + +function patron_search_results_init_after_paged_tree(p) { + return function (tree_win) { + tree_win.register_select_callback( p.w._patron_select_callback ); + tree_win.register_flesh_row_function( p.w._flesh_patron_function ); + p.w.add_patrons = tree_win.add_rows; + }; +} + +function patron_search_results_map_patron_to_cols(p, patron, treeitem) { + var cols = new Array(); + for (var i = 0; i < p.w.patron_cols.length; i++) { + var hash = p.w.patron_cols[i]; + var cmd = 'patron'+hash.fm_field_render; + var col = ''; + try { + col = eval( cmd ); + } catch(E) { + sdump('D_ERROR',js2JSON(E) + '\n'); + } + cols.push( col ); + } + p.w.tree_win.map_cols_to_treeitem( cols, treeitem ); +} diff --git a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.xul b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.xul new file mode 100644 index 0000000000..af4f7ec872 --- /dev/null +++ b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results.xul @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results_overlay.xul b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results_overlay.xul new file mode 100644 index 0000000000..a8c1c10ffa --- /dev/null +++ b/Evergreen/staff_client/chrome/content/evergreen/patron/patron_search_results_overlay.xul @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + -- 2.11.0