Improve COPY_DELETE_WARNING event handling
authorJason Etheridge <jason@esilibrary.com>
Thu, 5 Jan 2012 22:26:06 +0000 (17:26 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 31 Jan 2012 19:50:01 +0000 (14:50 -0500)
Make it overridable in copy buckets, and let Cancel on perm denied dialog fail gracefully.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/server/cat/copy_browser.js
Open-ILS/xul/staff_client/server/cat/copy_buckets.js
Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/circ/copy_status.js

index c71183f..0fbce27 100644 (file)
@@ -558,7 +558,14 @@ cat.copy_browser.prototype = {
                                         );
                                         if (robj == null) throw(robj);
                                         if (typeof robj.ilsevent != 'undefined') {
-                                            if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
+                                            if (
+                                                (robj.ilsevent != 0)
+                                                && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
+                                                && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
+                                                && (robj.ilsevent != 5000 /* PERM_DENIED */)
+                                            ) {
+                                                throw(robj);
+                                            }
                                         }
                                         obj.refresh_list();
                                     }
@@ -750,6 +757,8 @@ cat.copy_browser.prototype = {
                                                 {
                                                     'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
                                                     'overridable_events' : [
+                                                        1208 /* TITLE_LAST_COPY */,
+                                                        1227 /* COPY_DELETE_WARNING */
                                                     ]
                                                 }
                                             );
@@ -769,7 +778,16 @@ cat.copy_browser.prototype = {
                                                         continue loop;
                                                     }
                                                 } else {
-                                                    if (robj.ilsevent != 0) throw(robj);
+                                                    if (typeof robj.ilsevent != 'undefined') {
+                                                        if (
+                                                            (robj.ilsevent != 0)
+                                                            && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
+                                                            && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
+                                                            && (robj.ilsevent != 5000 /* PERM_DENIED */)
+                                                        ) {
+                                                            throw(robj);
+                                                        }
+                                                    }
                                                 }
                                             }
                                             break loop;
index a9e3137..74fd2bf 100644 (file)
@@ -493,26 +493,18 @@ cat.copy_buckets.prototype = {
                                     {
                                         'title' : document.getElementById('catStrings').getString('staff.cat.copy_buckets.batch.error'),
                                         'overridable_events' : [
-                                            1208 /* TITLE_LAST_COPY */
+                                            1208 /* TITLE_LAST_COPY */,
+                                            1227 /* COPY_DELETE_WARNING */
                                         ]
                                     }
                                 );
                                 if (typeof robj.ilsevent != 'undefined') {
                                     switch(Number(robj.ilsevent)) {
                                         case 1208 /* TITLE_LAST_COPY */ :
+                                        case 1227 /* COPY_DELETE_WARNING */ :
+                                        case 5000 /* PERM_DENIED */ :
                                             // ignore this
                                         break;
-                                        case 1227 /* COPY_DELETE_WARNING */ : 
-                                            var copy;
-                                            for (var i = 0; i < copies.length; i++) { if (copies[i].id()==robj.payload) copy = function(a){return a;}(copies[i]); }
-                                            /* The copy in question is not in an ideal status for deleting */
-                                            var err = '*** ' + robj.desc + ' ***\n';
-                                            /* The barcode for the item is {1} */
-                                            err += $('catStrings').getFormattedString('cat.barcode_for_item',[ copy.barcode() ]) + '\n';
-                                            /* The whole batch operation failed */
-                                            err += $('catStrings').getString('cat.batch_operation_failed') + '\n';
-                                            alert(err);
-                                        break;
                                         default:
                                             obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.batch.error'), robj);
                                     }
index 046c20f..75a3704 100644 (file)
@@ -209,7 +209,14 @@ cat.util.transfer_copies = function(params) {
         );
         
         if (typeof robj.ilsevent != 'undefined') {
-            throw(robj);
+            if (
+                (robj.ilsevent != 0)
+                && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
+                && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
+                && (robj.ilsevent != 5000 /* PERM_DENIED */)
+            ) {
+                throw(robj);
+            }
         } else {
             alert($("catStrings").getString('staff.cat.util.transfer_copies.successful_transfer'));
         }
index 89e6287..29a64d1 100644 (file)
@@ -627,6 +627,7 @@ circ.copy_status.prototype = {
                                     switch(Number(robj.ilsevent)) {
                                         case 1208 /* TITLE_LAST_COPY */:
                                         case 1227 /* COPY_DELETE_WARNING */:
+                                        case 5000 /* PERM_DENIED */:
                                         break;
                                         default:
                                             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.success.error'), robj);
@@ -882,6 +883,8 @@ circ.copy_status.prototype = {
                                             {
                                                 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
                                                 'overridable_events' : [
+                                                    1208 /* TITLE_LAST_COPY */,
+                                                    1227 /* COPY_DELETE_WARNING */
                                                 ]
                                             }
                                         );
@@ -901,7 +904,16 @@ circ.copy_status.prototype = {
                                                     continue loop;
                                                 }
                                             } else {
-                                                if (robj.ilsevent != 0) { throw(robj); }
+                                                if (typeof robj.ilsevent != 'undefined') {
+                                                    if (
+                                                        (robj.ilsevent != 0)
+                                                        && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
+                                                        && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
+                                                        && (robj.ilsevent != 5000 /* PERM_DENIED */)
+                                                    ) {
+                                                        throw(robj);
+                                                    }
+                                                }
                                             }
                                         }
                                         break loop;