Prevent throwing a raw exception due to the manipulation of a non-existent node when...
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Mar 2010 21:35:34 +0000 (21:35 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Mar 2010 21:35:34 +0000 (21:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@15723 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/standing_penalties.js

index 437a370..7552a1b 100644 (file)
@@ -136,8 +136,20 @@ function penalty_init() {
                                     var parentNode = node.parentNode;
                                     parentNode.removeChild( node );
                                     delete(rows[ id ]);
-                                    var csp_id = typeof penalty.standing_penalty() == 'object' ? penalty.standing_penalty().id() : penalty.standing_penalty();
-                                    document.getElementById('csp_'+csp_id).setAttribute('disabled','false');
+
+                                    var csp_id;
+                                    if (typeof penalty.standing_penalty() == 'object') {
+                                        csp_id = penalty.standing_penalty().id();
+                                    } else {
+                                        csp_id = penalty.standing_penalty();
+                                    }
+
+                                    // Protect against manipulating a node that doesn't exist - which will
+                                    // be the case for system penalties with an ID of < 100 -- see csp_list above
+                                    var csp_node = document.getElementById('csp_'+csp_id);
+                                    if (csp_node) {
+                                        csp_node.setAttribute('disabled','false');
+                                    }
                                 }
                             } catch(E) {
                                 alert(E);