Allow true deletion of existing addresses in patron editor. Let summary sidebar...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Aug 2010 18:36:26 +0000 (18:36 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Aug 2010 18:36:26 +0000 (18:36 +0000)
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
Open-ILS/xul/staff_client/server/patron/summary.js

index 1287ef4..0c1015f 100644 (file)
@@ -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]);
index 571a97f..821cfee 100644 (file)
@@ -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,'');
+                                }
                             };
                         }
                     ]