Add a patron.util.format_name() function and have every XUL interface which shows...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Oct 2009 05:06:16 +0000 (05:06 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Oct 2009 05:06:16 +0000 (05:06 +0000)
Add .alias to the name thus rendered in parenthesis.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14411 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/circ/circ_brief.xul
Open-ILS/xul/staff_client/server/patron/bill_details.js
Open-ILS/xul/staff_client/server/patron/bill_wizard.js
Open-ILS/xul/staff_client/server/patron/display.js
Open-ILS/xul/staff_client/server/patron/hold_details.js
Open-ILS/xul/staff_client/server/patron/info_notes.xul
Open-ILS/xul/staff_client/server/patron/summary.js
Open-ILS/xul/staff_client/server/patron/util.js

index 8a1b977..2797678 100644 (file)
@@ -321,12 +321,7 @@ cat.util.mark_item_damaged = function(copy_ids) {
                                     auto_checkin = true; 
                                     JSAN.use('patron.util');
                                     var patron_obj = patron.util.retrieve_fleshed_au_via_id( ses(), my_circ.usr() );
-                                    var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') +
-                                        patron_obj.family_name() + ', ' +
-                                        patron_obj.first_given_name() + ' ' +
-                                        ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
-                                        ( patron_obj.suffix() ? patron_obj.suffix() : '')
-                                        + ' : ' + patron_obj.card().barcode()
+                                    var patron_name = patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode();
                                     var msg = $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.item_circulating_to_patron', [ 
                                         copies[i].barcode(),
                                         patron_name,
@@ -360,12 +355,8 @@ cat.util.mark_item_damaged = function(copy_ids) {
                                     JSAN.use('util.money');
                                     var circ_obj = robj.payload.circ;
                                     var patron_obj = circ_obj.usr();
-                                    var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') +
-                                        patron_obj.family_name() + ', ' +
-                                        patron_obj.first_given_name() + ' ' +
-                                        ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
-                                        ( patron_obj.suffix() ? patron_obj.suffix() : '')
-                                        + ' : ' + patron_obj.card().barcode()
+                                    JSAN.use('patron.util');
+                                    var patron_name = patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode();
 
                                     var r1 = error.yns_alert(
                                         $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.charge_patron_prompt.message', [ 
index 7589b02..c95ecb4 100644 (file)
@@ -72,8 +72,9 @@
                                                g.patron_id = r_circ.usr(); $('add_billing').disabled = false;
                                                g.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), r_circ.usr() ], function(preq) {
                                                        var r_au = preq.getResultObject();
-                                                       $('patron_name').value = r_au.family_name() + ', ' + r_au.first_given_name() + ' ' + (r_au.second_given_name() ? r_au.second_given_name() + ' : ' + r_au.card().barcode() : '');
-                                                       JSAN.use('patron.util'); patron.util.set_penalty_css(r_au);
+                                                       JSAN.use('patron.util'); 
+                                                       $('patron_name').value = patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode();
+                            patron.util.set_penalty_css(r_au);
                                                });
 
                                        } catch(E) {
index 92ed9ca..f479c4d 100644 (file)
@@ -8,12 +8,7 @@ function retrieve_patron() {
         g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id );
         
         $('patron_name').setAttribute('value', 
-            ( g.au_obj.prefix() ? g.au_obj.prefix() + ' ' : '') + 
-            g.au_obj.family_name() + ', ' + 
-            g.au_obj.first_given_name() + ' ' +
-            ( g.au_obj.second_given_name() ? g.au_obj.second_given_name() + ' ': '' ) +
-            ( g.au_obj.suffix() ? g.au_obj.suffix() : '')
-            + ' : ' + g.au_obj.card().barcode() 
+            patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode() 
         );
     }
 
index 21a28e5..9d15e55 100644 (file)
@@ -72,12 +72,7 @@ function retrieve_patron() {
         g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id );
         
         $('patron_name').setAttribute('value', 
-            ( g.au_obj.prefix() ? g.au_obj.prefix() + ' ' : '') + 
-            g.au_obj.family_name() + ', ' + 
-            g.au_obj.first_given_name() + ' ' +
-            ( g.au_obj.second_given_name() ? g.au_obj.second_given_name() + ' ' : '' ) +
-            ( g.au_obj.suffix() ? g.au_obj.suffix() : '')
-            + ' : ' + g.au_obj.card().barcode() 
+            patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode() 
         );
     }
 
index 975d5b7..884cbe3 100644 (file)
@@ -428,14 +428,11 @@ patron.display.prototype = {
                                                ['render'],
                                                function(e) {
                                                        return function() { 
+                                                               JSAN.use('patron.util'); 
                                                                e.setAttribute('value',
-                                                                       ( obj.patron.prefix() ? obj.patron.prefix() + ' ' : '') + 
-                                                                       obj.patron.family_name() + ', ' + 
-                                                                       obj.patron.first_given_name() + ' ' +
-                                                                       ( obj.patron.second_given_name() ? obj.patron.second_given_name() + ' ' : '' ) +
-                                                                       ( obj.patron.suffix() ? obj.patron.suffix() : '')
+                                    patron.util.format_name( obj.patron )
                                                                );
-                                                               JSAN.use('patron.util'); patron.util.set_penalty_css(obj.patron);
+                                patron.util.set_penalty_css(obj.patron);
                                                        };
                                                }
                                        ],
index 96f3ea3..7f321d2 100644 (file)
@@ -83,12 +83,7 @@ function render_patron() {
         var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.ahr.usr() );
         
         $('patron_name').setAttribute('value', 
-            ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') + 
-            au_obj.family_name() + ', ' + 
-            au_obj.first_given_name() + ' ' +
-            ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) +
-            ( au_obj.suffix() ? au_obj.suffix() : '')
-            + ' : ' + au_obj.card().barcode() 
+            patron.util.format_name( au_obj ) + ' : ' + au_obj.card().barcode() 
         );
     }
 }
index f62f0dc..cc0ddf4 100644 (file)
                                                                p.simple(
                                                                        '<hr/>'
                                                                        + '<p>'+ $("patronStrings").getString('staff.patron.info_notes.render_notes.pertaining_to') + ' ' + 
-                                                                               ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') + 
-                                                                               patron_obj.family_name() + ', ' + 
-                                                                               patron_obj.first_given_name() + ' ' +
-                                                                               ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
-                                                                               ( patron_obj.suffix() ? patron_obj.suffix() : '')
-                                                                               + ' : ' 
+                                                                               patron.util.format_name( patron_obj ) + ' : ' 
                                                                        + patron_obj.card().barcode() + '</p>'
                                                                        + '<p><b>"' + g.notes[id].title() + '"</b>'
                                                                        + $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.created_on', [g.notes[id].create_date().toString().substr(0,10), staff_obj[0], g.data.hash.aou[ staff_obj[3] ].shortname()]) 
index 0181e09..2e4e351 100644 (file)
@@ -638,11 +638,7 @@ patron.summary.prototype = {
                                                                obj.patron = robj;
                                                                JSAN.use('patron.util');
                                                                util.widgets.set_text('patron_name',
-                                                                       ( obj.patron.prefix() ? obj.patron.prefix() + ' ' : '') + 
-                                                                       obj.patron.family_name() + ', ' + 
-                                                                       obj.patron.first_given_name() + ' ' +
-                                                                       ( obj.patron.second_given_name() ? obj.patron.second_given_name() + ' ' : '' ) +
-                                                                       ( obj.patron.suffix() ? obj.patron.suffix() : '')
+                                    patron.util.format_name( obj.patron )
                                                                );
                                                                patron.util.set_penalty_css(obj.patron);
                                                                JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
index 1cca1d9..e690cb6 100644 (file)
@@ -6,7 +6,7 @@ patron.util = {};
 patron.util.EXPORT_OK  = [ 
        'columns', 'mbts_columns', 'mb_columns', 'mp_columns', /*'std_map_row_to_column',*/ 'std_map_row_to_columns',
        'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id',
-    'merge', 'ausp_columns'
+    'merge', 'ausp_columns', 'format_name'
 ];
 patron.util.EXPORT_TAGS        = { ':all' : patron.util.EXPORT_OK };
 
@@ -808,4 +808,14 @@ patron.util.merge = function(record_ids) {
     }
 }
 
+patron.util.format_name = function(patron_obj) {
+    var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') +
+        patron_obj.family_name() + ', ' +
+        patron_obj.first_given_name() + ' ' +
+        ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
+        ( patron_obj.suffix() ? patron_obj.suffix() : '') +
+        ( patron_obj.alias() ? ' (' + patron_obj.alias() + ')' : '');
+    return patron_name;
+}
+
 dump('exiting patron/util.js\n');