From: phasefx Date: Wed, 14 Oct 2009 05:06:16 +0000 (+0000) Subject: Add a patron.util.format_name() function and have every XUL interface which shows... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=be65ae6c627274aca4c61d24c9f2ab948f3e0d2e;p=evergreen%2Fbjwebb.git Add a patron.util.format_name() function and have every XUL interface which shows the patron's name make use of it. 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 --- diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 8a1b977b9..2797678b0 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -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', [ diff --git a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul index 7589b026a..c95ecb4b4 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul @@ -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) { diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index 92ed9ca5f..f479c4d7d 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -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() ); } diff --git a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js index 21a28e55e..9d15e55bc 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js @@ -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() ); } diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index 975d5b7ba..884cbe3d9 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -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); }; } ], diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.js b/Open-ILS/xul/staff_client/server/patron/hold_details.js index 96f3ea36b..7f321d2c0 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.js @@ -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() ); } } diff --git a/Open-ILS/xul/staff_client/server/patron/info_notes.xul b/Open-ILS/xul/staff_client/server/patron/info_notes.xul index f62f0dc32..cc0ddf4ef 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_notes.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_notes.xul @@ -166,12 +166,7 @@ p.simple( '
' + '

'+ $("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() + '

' + '

"' + g.notes[id].title() + '"' + $("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()]) diff --git a/Open-ILS/xul/staff_client/server/patron/summary.js b/Open-ILS/xul/staff_client/server/patron/summary.js index 0181e096f..2e4e35189 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.js +++ b/Open-ILS/xul/staff_client/server/patron/summary.js @@ -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'}); diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index 1cca1d9d3..e690cb674 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -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');