[open-ils-commits] r17581 - in branches/rel_2_0/Open-ILS/xul/staff_client: chrome/content/util server/locale/en-US server/patron (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Sep 10 12:38:27 EDT 2010


Author: phasefx
Date: 2010-09-10 12:38:23 -0400 (Fri, 10 Sep 2010)
New Revision: 17581

Modified:
   branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/util/list.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill2.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill_history.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bills.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/info_group.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/search_result.js
   branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/util.js
Log:
merge r17576-r17580 from trunk for improved columns in Patron Search results list.  Also fleshes some patron data sent to misc receipt templates

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -1690,9 +1690,10 @@
     },
 
     // Takes fieldmapper class name and attempts to spit out column definitions suitable for .init
-    'fm_columns' : function(hint,column_extras) {
+    'fm_columns' : function(hint,column_extras,prefix) {
         var obj = this;
         var columns = [];
+        if (!prefix) { prefix = ''; }
         try {
             // requires the dojo library fieldmapper.autoIDL
             if (typeof fieldmapper == 'undefined') { throw 'fieldmapper undefined'; }
@@ -1703,7 +1704,24 @@
             var data = obj.data; data.stash_retrieve();
 
             function col_def(my_field) {
-                var col_id = hint + '_' + my_field.name;
+                var col_id = prefix + hint + '_' + my_field.name;
+                var dataobj = hint;
+                var datafield = my_field.name;
+                if (column_extras) {
+                    if (column_extras['*']) {
+                        if (column_extras['*']['dataobj']) {
+                            dataobj = column_extras['*']['dataobj'];
+                        }
+                    }
+                    if (column_extras[col_id]) {
+                        if (column_extras[col_id]['dataobj']) {
+                            dataobj = column_extras[col_id]['dataobj'];
+                        }
+                        if (column_extras[col_id]['datafield']) {
+                            datafield = column_extras[col_id]['datafield'];
+                        }
+                    }
+                }
                 var def = {
                     'id' : col_id,
                     'label' : my_field.label || my_field.name,
@@ -1716,26 +1734,26 @@
                 // my_field.datatype => bool float id int interval link money number org_unit text timestamp
                 if (my_field.datatype == 'link') {
                     def.render = function(my) { 
-                        return typeof my[hint][my_field.name]() == 'object' ? my[hint][my_field.name]()[my_field.key]() : my[hint][my_field.name](); 
+                        return typeof my[dataobj][datafield]() == 'object' ? my[dataobj][datafield]()[my_field.key]() : my[dataobj][datafield](); 
                     }
                 } else {
-                    def.render = function(my) { return my[hint][my_field.name](); }
+                    def.render = function(my) { return my[dataobj][datafield](); }
                 }
                 if (my_field.datatype == 'timestamp') {
                     JSAN.use('util.date');
                     def.render = function(my) {
-                        return util.date.formatted_date( my[hint][my_field.name](), '%{localized}' );
+                        return util.date.formatted_date( my[dataobj][datafield](), '%{localized}' );
                     }
                 }
                 if (my_field.datatype == 'org_unit') {
                     def.render = function(my) {
-                        return typeof my[hint][my_field.name]() == 'object' ? my[hint][my_field.name]().shortname() : data.hash.aou[ my[hint][my_field.name]() ].shortname();
+                        return typeof my[dataobj][datafield]() == 'object' ? my[dataobj][datafield]().shortname() : data.hash.aou[ my[dataobj][datafield]() ].shortname();
                     }
                 }
                 if (my_field.datatype == 'money') {
                     JSAN.use('util.money');
                     def.render = function(my) {
-                        return util.money.sanitize( my[hint][my_field.name]() );
+                        return util.money.sanitize( my[dataobj][datafield]() );
                     }
                 }
                 if (column_extras) {
@@ -1746,19 +1764,42 @@
                         if (column_extras['*']['expanded_label']) {
                             def.label = my_class.label + ': ' + def.label;
                         }
+                        if (column_extras['*']['label_prefix']) {
+                            def.label = column_extras['*']['label_prefix'] + def.label;
+                        }
+                        if (column_extras['*']['remove_virtual']) {
+                            if (my_field.virtual) {
+                                def.remove_me = true;
+                            }
+                        }
                     }
                     if (column_extras[col_id]) {
                         for (var attr in column_extras[col_id]) {
                             def[attr] = column_extras[col_id][attr];
                         }
+                        if (column_extras[col_id]['keep_me']) {
+                            def.remove_me = false;
+                        }
+                        if (column_extras[col_id]['label_prefix']) {
+                            def.label = column_extras[col_id]['label_prefix'] + def.label;
+                        }
                     }
                 }
-                return def;
+                if (def.remove_me) {
+                    dump('Skipping ' + def.label + '\n');
+                    return null;
+                } else {
+                    dump('Defining ' + def.label + '\n');
+                    return def;
+                }
             }
  
             for (var i = 0; i < my_class.fields.length; i++) {
                 var my_field = my_class.fields[i];
-                columns.push( col_def(my_field) );
+                var def = col_def(my_field);
+                if (def) {
+                    columns.push( def );
+                }
             }
 
         } catch(E) {

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2010-09-10 16:38:23 UTC (rev 17581)
@@ -335,6 +335,8 @@
 staff.patron.search_result.init.search_print=patron search print
 staff.patron.search_result.init.search_clipboard=patron search clipboard
 staff.patron.search_result.init.search_saving_columns=patron search saving columns
+staff.patron.search_result.mailing_address_column_label_prefix=Mailing Addr: 
+staff.patron.search_result.billing_address_column_label_prefix=Billing Addr: 
 staff.patron.summary.patron_bill.money=$ %1$s
 staff.patron.summary.retrieve.no_barcode=summary: No barcode or ID
 staff.patron.summary.patron_net_access=Internet

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill2.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill2.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill2.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -648,7 +648,7 @@
         var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current';
         JSAN.use('patron.util');
         var params = { 
-            'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), 
+            'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),g.patron_id,null), 
             'printer_context' : 'receipt',
             'template' : template
         };

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill_history.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill_history.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bill_history.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -376,7 +376,7 @@
         var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current';
         JSAN.use('patron.util');
         var params = { 
-            'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), 
+            'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),g.patron_id,null), 
             'template' : template
         };
         g.bill_list.print(params);

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bills.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bills.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/bills.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -516,7 +516,7 @@
                         var template = 'bill_payment';
                         JSAN.use('patron.util'); JSAN.use('util.functional');
                         var params = { 
-                            'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), 
+                            'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id,null), 
                             'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
                             'staff' : obj.data.list.au[0],
                             'header' : obj.data.print_list_templates[template].header,
@@ -684,7 +684,7 @@
             var columns = patron.util.mbts_columns({});
             var template = 'bills_main_view';
             var params = { 
-                'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), 
+                'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id,null), 
                 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
                 'staff' : obj.data.list.au[0],
                 'header' : obj.data.print_list_templates[template].header,

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/info_group.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/info_group.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/info_group.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -116,7 +116,7 @@
                         return row;
                     }
 
-                    patron.util.retrieve_fleshed_au_via_id( ses(), id, function(req) {
+                    patron.util.retrieve_fleshed_au_via_id( ses(), id, null, function(req) {
                         row.my.au = req.getResultObject();
                         process_and_return();
                     });
@@ -428,7 +428,7 @@
         if (g.sel_list.length == 0) g.sel_list[0] = g.patron_id;
         for (var i = 0; i < g.sel_list.length; i++) {    
 
-            var patron_a = patron.util.retrieve_fleshed_au_via_id(ses(),g.sel_list[i]);
+            var patron_a = patron.util.retrieve_fleshed_au_via_id(ses(),g.sel_list[i],null);
             if (typeof patron_a.ilsevent != 'undefined') throw(patron_a);
             switch(direction) {
                 case true:

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/search_result.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/search_result.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/search_result.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -29,33 +29,57 @@
         JSAN.use('util.list'); obj.list = new util.list('patron_list');
 
         JSAN.use('patron.util');
-        var columns = patron.util.columns(
-            {
-                /* 'active' : { 'hidden' : 'false' }, */
-                'barred' : { 'hidden' : 'false' },
-                'family_name' : { 'hidden' : 'false' },
-                'first_given_name' : { 'hidden' : 'false' },
-                'second_given_name' : { 'hidden' : 'false' },
-                'dob' : { 'hidden' : obscure_dob }
-            },
-            {
-                'except_these' : [
-                    'au_barcode',
-                ]
-            }
+        var columns = obj.list.fm_columns('au',{
+            '*' : { 'remove_virtual' : true, 'expanded_label' : false, 'hidden' : true },
+            'au_barcode' : { 'hidden' : false },
+            'au_barred' : { 'hidden' : false },
+            'au_family_name' : { 'hidden' : false },
+            'au_first_given_name' : { 'hidden' : false },
+            'au_second_given_name' : { 'hidden' : false },
+            'au_dob' : { 'hidden' : false }
+        }).concat(
+            obj.list.fm_columns('ac',{
+                '*' : { 'remove_virtual' : true, 'expanded_label' : true, 'hidden' : true },
+                'ac_barcode' : { 'hidden' : false }
+            })
+        ).concat(
+            obj.list.fm_columns('aua',{
+                '*' : {
+                    'dataobj' : 'billing_aua',
+                    'remove_virtual' : true,
+                    'label_prefix' : $('patronStrings').getString('staff.patron.search_result.billing_address_column_label_prefix'),
+                    'hidden' : true
+                }
+            },'billing_')
+        ).concat(
+            obj.list.fm_columns('aua',{
+                '*' : {
+                    'dataobj' : 'mailing_aua',
+                    'remove_virtual' : true,
+                    'label_prefix' : $('patronStrings').getString('staff.patron.search_result.mailing_address_column_label_prefix'),
+                    'hidden' : true
+                }
+            },'mailing_')
         );
+
         obj.list.init(
             {
                 'columns' : columns,
                 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
                 'retrieve_row' : function(params) {
                     var id = params.retrieve_id;
-                    var au_obj = patron.util.retrieve_au_via_id( ses(), id,
+                    var au_obj = patron.util.retrieve_fleshed_au_via_id(
+                        ses(),
+                        id,
+                        ["card","billing_address","mailing_address"],
                         function(req) {
                             try {
                                 var row = params.row;
                                 if (typeof row.my == 'undefined') row.my = {};
                                 row.my.au = req.getResultObject();
+                                row.my.ac = row.my.au.card();
+                                row.my.billing_aua = row.my.au.billing_address();
+                                row.my.mailing_aua = row.my.au.mailing_address();
                                 if (typeof params.on_retrieve == 'function') {
                                     params.on_retrieve(row);
                                 } else {

Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/util.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/util.js	2010-09-10 16:35:51 UTC (rev 17580)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/patron/util.js	2010-09-10 16:38:23 UTC (rev 17581)
@@ -227,7 +227,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'mp_staff', 'label' : commonStrings.getString('staff.mp_accepting_usr_label'), 'flex' : 1,
-            'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); return s.family_name() + " (" + s.card().barcode() + ") @ " + data.hash.aou[ s.home_ou() ].shortname(); }
+            'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s,["card"]); return s.family_name() + " (" + s.card().barcode() + ") @ " + data.hash.aou[ s.home_ou() ].shortname(); }
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'mp_xact', 'label' : commonStrings.getString('staff.mp_xact_label'), 'flex' : 1,
@@ -590,15 +590,15 @@
     return parts;
 }
 
-patron.util.retrieve_fleshed_au_via_id = function(session, id, f) {
+patron.util.retrieve_fleshed_au_via_id = function(session, id, fields, func) {
     JSAN.use('util.network');
     var network = new util.network();
     var patron_obj = network.simple_request(
         'FM_AU_FLESHED_RETRIEVE_VIA_ID.authoritative',
-        [ session, id ],
-        typeof f == 'function' ? f : null
+        [ session, id, fields ],
+        typeof func == 'function' ? func : null
     );
-    if (typeof f != 'function') {
+    if (typeof func != 'function') {
         patron.util.set_penalty_css(patron_obj);
         return patron_obj;
     }



More information about the open-ils-commits mailing list