the other part of patron search. Still need to update util.list to have an optional...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Dec 2005 15:23:22 +0000 (15:23 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Dec 2005 15:23:22 +0000 (15:23 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2370 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/evergreen/main/constants.js
Open-ILS/xul/staff_client/chrome/content/evergreen/util/list.js
Open-ILS/xul/staff_client/server/patron/display.js
Open-ILS/xul/staff_client/server/patron/search_form.js
Open-ILS/xul/staff_client/server/patron/search_result.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/patron/search_result.xul [new file with mode: 0644]
Open-ILS/xul/staff_client/server/patron/search_result_overlay.xul [new file with mode: 0644]

index cd7d886..30e34fd 100644 (file)
@@ -11,8 +11,10 @@ var api = {
        'fm_aou_retrieve' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_tree.retrieve' },
        'fm_aou_retrieve_related_via_session' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.full_path.retrieve' },
        'fm_aout_retrieve' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_types.retrieve' },
+       'fm_au_ids_retrieve_via_hash' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.search.advanced' },
        'fm_au_retrieve_via_session' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.actor.user.session' },
        'fm_au_retrieve_via_barcode' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve_by_barcode' },
+       'fm_au_retrieve_via_id' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve' },
        'fm_ccs_retrieve' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all' },
        'fm_cit_retrieve' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.ident_types.retrieve' },
        'fm_cst_retrieve' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.standings.retrieve' },
index ae42f0a..3c0fb82 100644 (file)
@@ -24,6 +24,7 @@ util.list.prototype = {
        'init' : function (params) {
 
                if (typeof params.map_row_to_column == 'function') this.map_row_to_column = params.map_row_to_column;
+               if (typeof params.retrieve_row == 'function') this.retrieve_row = params.retrieve_row;
 
                this.prebuilt = false;
                if (typeof params.prebuilt != 'undefined') this.prebuilt = params.prebuilt;
@@ -77,6 +78,34 @@ util.list.prototype = {
                dump('tree = ' + this.node + '  treechildren = ' + this.treechildren + '\n');
                dump('treeitem = ' + treeitem + '  treerow = ' + treerow + '\n');
 
+               if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+
+                       treerow.setAttribute('retrieve_id',params.retrieve_id);
+                       //FIXME//Make async and fire when row is visible in list
+                       var row;
+                       if (typeof params.retrieve_row == 'function') {
+
+                               row = params.retrieve_row( params );
+
+                       } else {
+
+                               if (typeof this.retrieve_row == 'function') {
+
+                                       row = this.retrieve_row( params );
+
+                               }
+                       }
+                       params.row = row;
+                       this._map_row_to_treecell(params,treerow);
+
+               } else {
+                       this._map_row_to_treecell(params,treerow);
+               }
+
+               return treeitem;
+       },
+
+       '_map_row_to_treecell' : function(params,treerow) {
                for (var i = 0; i < this.columns.length; i++) {
                        var treecell = document.createElement('treecell');
                        var label = '';
@@ -95,9 +124,7 @@ util.list.prototype = {
                        treerow.appendChild( treecell );
                        dump('treecell = ' + treecell + ' with label = ' + label + '\n');
                }
-
-               return treeitem;
-       }
+       },
 
 }
 dump('exiting util.list.js\n');
index b6ac5e4..35a23a1 100644 (file)
@@ -149,14 +149,24 @@ patron.display.prototype = {
                        obj.summary_window = frame.contentWindow;
                } else {
                        obj.controller.view.PatronNavBar.selectedIndex = 0;
-                       var frame = obj.left_deck.set_iframe(
+                       var form_frame = obj.left_deck.set_iframe(
                                urls.remote_patron_search_form
                                +'?session=' + window.escape(obj.session),
                                {},
                                {
+                                       'on_submit' : function(query) {
+                                               var list_frame = obj.right_deck.reset_iframe(
+                                                       urls.remote_patron_search_result
+                                                       +'?session=' + window.escape(obj.session) + '&' + query,
+                                                       {},
+                                                       {
+                                                       }
+                                               );
+                                               obj.search_result = list_frame.contentWindow;
+                                       }
                                }
                        );
-                       obj.search_window = frame.contentWindow;
+                       obj.search_window = form_frame.contentWindow;
                        obj._checkout_spawned = true;
                }
        },
index 5ba97d1..9c6920e 100644 (file)
@@ -36,7 +36,7 @@ patron.search_form.prototype = {
                                                                var node = document.getElementById(id);
                                                                if (node && node.value != '') {
                                                                        if (query == '') {
-                                                                               query += '?';
+                                                                               // Responsible for own ? or &
                                                                        } else {
                                                                                query += '&';
                                                                        }
diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.js b/Open-ILS/xul/staff_client/server/patron/search_result.js
new file mode 100644 (file)
index 0000000..8199453
--- /dev/null
@@ -0,0 +1,140 @@
+dump('entering patron/search_result.js\n');
+
+if (typeof patron == 'undefined') patron = {};
+patron.search_result = function (params) {
+
+       JSAN.use('util.error'); this.error = new util.error();
+       JSAN.use('util.network'); this.network = new util.network();
+       this.w = window;
+}
+
+patron.search_result.prototype = {
+
+       'init' : function( params ) {
+
+               var obj = this;
+
+               obj.session = params['session'];
+               obj.query = params['query'];
+
+               JSAN.use('OpenILS.data'); this.OpenILS = {}; 
+               obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+
+               JSAN.use('util.list'); obj.list = new util.list('patron_list');
+               function getString(s) { return obj.OpenILS.data.entities[s]; }
+               obj.list.init(
+                       {
+                               'columns' : [
+                                       {
+                                               'active' : 'barcode_col', 'label' : 'Barcode', 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.card().barcode()'
+                                       },
+                                       { 
+                                               'active' : 'id_col', 'label' : getString('staff.au_label_active'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.active() ? "Yes" : "No"'
+                                       },
+                                       { 
+                                               'id' : 'id_col', 'label' : getString('staff.au_label_id'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.id()'
+                                       },
+                                       { 
+                                               'id' : 'prefix_col', 'label' : getString('staff.au_label_prefix'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.prefix()'
+                                       },
+                                       { 
+                                               'id' : 'family_name_col', 'label' : getString('staff.au_label_family_name'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.family_name()'
+                                       },
+                                       { 
+                                               'id' : 'first_given_name_col', 'label' : getString('staff.au_label_first_given_name'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.first_given_name()'
+                                       },
+                                       { 
+                                               'id' : 'second_given_name_col', 'label' : getString('staff.au_label_second_given_name'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.second_given_name()'
+                                       },
+                                       { 
+                                               'id' : 'suffix_col', 'label' : getString('staff.au_label_suffix'), 'flex' : 1, 
+                                               'primary' : false, 'hidden' : false, 'render' : 'my.au.suffix()'
+                                       },
+                               ],
+                               'map_row_to_column' : function(row,col) {
+                                       // row contains { 'my' : { 'au' : {} } }
+                                       // col contains one of the objects listed above in columns
+                                       var my = row.my;
+                                       return eval( col.render );
+                               },
+                               'retrieve_row' : function(params) {
+                                       var id = params.retrieve_id;
+                                       var patron = obj.network.request(
+                                               api.fm_au_retrieve_via_id.app,
+                                               api.fm_au_retrieve_via_id.method,
+                                               [ obj.session, id ]
+                                       );
+
+                                       var row = params.row;
+                                       if (typeof row.my == 'undefined') row.my = {};
+                                       row.my.au = patron;
+
+                                       return row;
+                               }
+                       }
+               );
+               JSAN.use('util.controller'); obj.controller = new util.controller();
+               obj.controller.init(
+                       {
+                               control_map : {
+                                       'cmd_broken' : [
+                                               ['command'],
+                                               function() { alert('Not Yet Implemented'); }
+                                       ],
+                               }
+                       }
+               );
+
+               if (obj.query) obj.search(obj.query);
+       },
+
+       'search' : function(query) {
+               var search_hash = {};
+               for (var i in query) {
+                       switch( i ) {
+                               case 'phone': case 'ident': 
+                               
+                                       search_hash[ i ] = {};
+                                       search_hash[ i ].value = query[i];
+                                       search_hash[i].group = 2; 
+                               break;
+
+                               case 'street1': case 'street2': case 'city': case 'state': case 'post_code': 
+                               
+                                       search_hash[ i ] = {};
+                                       search_hash[ i ].value = query[i];
+                                       search_hash[i].group = 1; 
+                               break;
+
+                               case 'family_name': case 'first_given_name': case 'second_given_name': case 'email':
+
+                                       search_hash[ i ] = {};
+                                       search_hash[ i ].value = query[i];
+                                       search_hash[i].group = 0; 
+                               break;
+                       }
+               }
+               try {
+                       var results = this.network.request(
+                               api.fm_au_ids_retrieve_via_hash.app,
+                               api.fm_au_ids_retrieve_via_hash.method,
+                               [ this.session, search_hash ]
+                       );
+                       for (var i = 0; i < results.length; i++) {
+                               this.list.append( { 'retrieve_id' : results[i], 'row' : {} } );
+                       }
+               } catch(E) {
+                       this.error.sdump('D_ERROR','patron.search_result.search: ' + js2JSON(E));
+               }
+       }
+
+}
+
+dump('exiting patron/search_result.js\n');
diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.xul b/Open-ILS/xul/staff_client/server/patron/search_result.xul
new file mode 100644 (file)
index 0000000..1ac9fc8
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/evergreen.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://evergreen/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+<?xul-overlay href="/xul/server/patron/search_result_overlay.xul"?>
+
+<window id="patron_search_result_win" 
+       onload="my_init()"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">var myPackageDir = 'evergreen'; var IAMXUL = true; var g = {};</script>
+        <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for patron_search_result.xul');
+
+                               g.cgi = new CGI();
+                               var session = g.cgi.param('session');
+                               var keys = g.cgi.keys();
+                               var query = {};
+                               for (var i = 0; i < keys.length; i++) {
+                                       query[keys[i]] = g.cgi.param(keys[i]);
+                               }
+
+                               JSAN.use('patron.search_result'); g.search_result = new patron.search_result();
+                               g.search_result.init( { 'session' : session, 'query' : query } );
+       
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\n" + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="patron_search_result_cmds">
+               <command id="cmd_patron_refresh" />
+               <command id="cmd_patron_checkout" />
+               <command id="cmd_patron_items" />
+               <command id="cmd_patron_holds" />
+               <command id="cmd_patron_bills" />
+               <command id="cmd_patron_edit" />
+               <command id="cmd_patron_info" />
+       </commandset>
+
+       <box id="patron_search_result_main" />
+
+</window>
+
diff --git a/Open-ILS/xul/staff_client/server/patron/search_result_overlay.xul b/Open-ILS/xul/staff_client/server/patron/search_result_overlay.xul
new file mode 100644 (file)
index 0000000..1693edf
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://evergreen/locale/lang.dtd">
+<overlay id="patron_search_result_overlay" 
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>dump('loading patron/search_result_overlay.xul\n');</script>
+
+<commandset id="patron_search_result_cmds" />
+
+       <box id="patron_search_result_main" flex="1">
+               <tree id="patron_list" flex="1" enableColumnDrag="true"/>
+       </box>
+
+</overlay>