Fix can_have_copies checks
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 14 Dec 2011 19:30:52 +0000 (14:30 -0500)
committerDan Scott <dscott@laurentian.ca>
Wed, 14 Dec 2011 21:07:31 +0000 (16:07 -0500)
Bibs aren't required to have sources. Thus, adjust all appropriate locations
to support a default state of "no source bibs can have copies", without
erroring out.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/xul/staff_client/chrome/content/cat/opac.js
Open-ILS/xul/staff_client/server/cat/bib_brief.js
Open-ILS/xul/staff_client/server/cat/copy_browser.js

index da5f86c..dfc4c7d 100644 (file)
@@ -197,7 +197,7 @@ function rdetailDraw() {
                                var sourceReq = new Request(FETCH_BIB_SOURCE, G.user.session, bib.source());
                                sourceReq.send(true);
                                var source = sourceReq.result();
-                               if (source.can_have_copies() == 'f') {
+                               if (source && source.can_have_copies() == 'f') {
                                        alert(dojo.string.substitute(opac_strings.SOURCE_CANNOT_HAVE_COPIES, [source.source()]));
                                } else {
                                        var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid());
index a07b9a4..659d652 100644 (file)
@@ -573,7 +573,7 @@ function create_mfhd() {
             [ ses(), bibObj.source() ]
         );
 
-        if (cbsObj.can_have_copies() != get_db_true()) {
+        if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
             alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
             return;
         }
@@ -948,7 +948,7 @@ function add_volumes() {
                 [ ses(), bibObj.source() ]
             );
 
-            if (cbsObj.can_have_copies() != get_db_true()) {
+            if (cbdObj && cbsObj.can_have_copies() != get_db_true()) {
                 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
                 return;
             }
index df04c3d..face076 100644 (file)
@@ -173,7 +173,7 @@ function add_volumes() {
         try {
             JSAN.use('cat.util');
             var cbsObj = cat.util.get_cbs_for_bre_id(docid);
-            if (cbsObj.can_have_copies() != get_db_true()) {
+            if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
                 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
                 return;
             }
index 046c88e..c71183f 100644 (file)
@@ -1857,8 +1857,12 @@ cat.copy_browser.prototype = {
         try {
             JSAN.use('cat.util');
             var cbsObj = cat.util.get_cbs_for_bre_id(obj.docid);
-            obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true());
-            obj.source = cbsObj.source();
+            if(cbsObj) {
+                obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true());
+                obj.source = cbsObj.source();
+            } else {
+                obj.can_have_copies = true;
+            }
         } catch(E) {
             obj.error.sdump('D_ERROR','can have copies check: ' + E);
             alert(E);