subsequent patch from Lebbeous Fogle-Weekley to prevent display of bare nulls in...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Nov 2009 21:10:22 +0000 (21:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Nov 2009 21:10:22 +0000 (21:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14848 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/summary.xul

index d77ac66..3e117f3 100644 (file)
 
         function copy_address(a) {
             var p = g.summary.patron;
+            var parts = [
+                p.first_given_name(), p.second_given_name(), p.family_name(),
+                a.street1(), a.street2(), a.city(), a.county(),
+                a.state(), a.post_code(), a.country()
+            ];
+            for (var i = 0; i < parts.length; i++)
+                if (parts[i] == null) parts[i] = "";
+
             var s = $("patronStrings").getFormattedString(
-                'staff.patron.mailable_address_format',
-                [p.first_given_name(), p.second_given_name(), p.family_name(),
-                    a.street1(), a.street2(), a.city(), a.county(),
-                    a.state(), a.post_code(), a.country()]
+                'staff.patron.mailable_address_format', parts
+            );
+            // Replace literal instances of '\n' and excessive whitespace.
+            copy_to_clipboard(
+                s.replace(/(\\n)+/g, "\n").replace(/ {2,}/g, " ")
             );
-            // Without the following call to replace(), you get
-            // literal instances of '\n' in the string.
-            copy_to_clipboard(s.replace(/(\\n)+/g, "\n"));
         }
 
         function copy_mailing_address() {