From 1a74c41638d4cebb6894d18232d876e542137fde Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 23 Aug 2010 18:36:26 +0000 Subject: [PATCH] Allow true deletion of existing addresses in patron editor. Let summary sidebar anticipate dissappearing addresses on refresh. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17314 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/actor/user/register.js | 9 ++ Open-ILS/xul/staff_client/server/patron/summary.js | 128 ++++++++++++++------- 2 files changed, 93 insertions(+), 44 deletions(-) diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index 1287ef4911..0c1015f2d4 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -1295,6 +1295,15 @@ function uEditDeleteAddr(id, noAlert) { if(!noAlert) { if(!confirm('Delete address ' + id)) return; /* XXX i18n */ } + var addr = patron.addresses().filter(function(i){return (i.id() == id)})[0]; + if (addr) { addr.isdeleted(1); } + var m_a = patron.mailing_address(); + if (typeof m_a == 'object' && m_a != null) { m_a = m_a.id(); } + if (m_a == id) { patron.mailing_address(null); } + var b_a = patron.billing_address(); + if (typeof b_a == 'object' && b_a != null) { b_a = b_a.id(); } + if (b_a == id) { patron.billing_address(null); } + var rows = dojo.query('tr[addr='+id+']', tbody); for(var i = 0; i < rows.length; i++) rows[i].parentNode.removeChild(rows[i]); diff --git a/Open-ILS/xul/staff_client/server/patron/summary.js b/Open-ILS/xul/staff_client/server/patron/summary.js index 571a97ff5e..821cfee3aa 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.js +++ b/Open-ILS/xul/staff_client/server/patron/summary.js @@ -672,10 +672,14 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.mailing_address().street1() - ); - if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.mailing_address()) { + util.widgets.set_text(e, + obj.patron.mailing_address().street1() + ); + if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], @@ -683,10 +687,14 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.mailing_address().street2() - ); - if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.mailing_address()) { + util.widgets.set_text(e, + obj.patron.mailing_address().street2() + ); + if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], @@ -694,10 +702,14 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.mailing_address().city() - ); - if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.mailing_address()) { + util.widgets.set_text(e, + obj.patron.mailing_address().city() + ); + if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], @@ -705,10 +717,14 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.mailing_address().state() - ); - if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.mailing_address()) { + util.widgets.set_text(e, + obj.patron.mailing_address().state() + ); + if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], @@ -716,10 +732,14 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.mailing_address().post_code() - ); - if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.mailing_address()) { + util.widgets.set_text(e, + obj.patron.mailing_address().post_code() + ); + if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], @@ -727,54 +747,74 @@ patron.summary.prototype = { ['render'], function(e) { return function() { - util.widgets.set_text(e, - obj.patron.billing_address().street1() - ); - if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + if (obj.patron.billing_address()) { + util.widgets.set_text(e, + obj.patron.billing_address().street1() + ); + if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], 'patron_physical_address_street2' : [ ['render'], function(e) { - return function() { - util.widgets.set_text(e, - obj.patron.billing_address().street2() - ); - if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + return function() { + if (obj.patron.billing_address()) { + util.widgets.set_text(e, + obj.patron.billing_address().street2() + ); + if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], 'patron_physical_address_city' : [ ['render'], function(e) { - return function() { - util.widgets.set_text(e, - obj.patron.billing_address().city() - ); - if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + return function() { + if (obj.patron.billing_address()) { + util.widgets.set_text(e, + obj.patron.billing_address().city() + ); + if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], 'patron_physical_address_state' : [ ['render'], function(e) { - return function() { - util.widgets.set_text(e, - obj.patron.billing_address().state() - ); - if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + return function() { + if (obj.patron.billing_address()) { + util.widgets.set_text(e, + obj.patron.billing_address().state() + ); + if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ], 'patron_physical_address_post_code' : [ ['render'], function(e) { - return function() { - util.widgets.set_text(e, - obj.patron.billing_address().post_code() - ); - if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + return function() { + if (obj.patron.billing_address()) { + util.widgets.set_text(e, + obj.patron.billing_address().post_code() + ); + if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');} + } else { + util.widgets.set_text(e,''); + } }; } ] -- 2.11.0