LP1735566: Ask before deleting items in non-ideal statuses in AngularJS
authorJane Sandberg <sandbej@linnbenton.edu>
Thu, 17 Oct 2019 18:11:34 +0000 (11:11 -0700)
committerBill Erickson <berickxx@gmail.com>
Tue, 21 Jan 2020 16:57:16 +0000 (11:57 -0500)
To test:

1) Apply this commit.
2) Log in as a user with COPY_DELETE_WARNING.override permission.
3) Go to item status and scan an item in a non-ideal status (like #1:
checked out)
4) Delete the item.  Note that you are alerted of the item's non-ideal
status, and you can confirm that you actually want to delete it.
5) Repeat steps 3-4 with an item in an ideal status (like #0:
Available). Note that no such alert appears.
6) Open the holdings view and repeat steps 4-5.
7) Log in as a user without the COPY_DELETE_WARNING.override
permission. Note that you are still informed about the non-ideal status,
but you aren't able to continue with the deletion without an admin
using their credentials.

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Garry Collum <gcollum@gmail.com>
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/cat/catalog/index.tt2
Open-ILS/src/templates/staff/circ/share/circ_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/circ/services/item.js

index 6db7cee..be572de 100644 (file)
       "[% l('Permanently delete selected items and/or call numbers from catalog?') %]";
     s.CONFIRM_DELETE_COPIES_VOLUMES_MESSAGE =
       "[% l('Will delete {{copies}} items and {{volumes}} call numbers') %]";
+    s.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_TITLE =
+      "[% l('One or more items could not be deleted. Override?') %]";
+    s.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_BODY =
+      "[% l('Reason(s) include: [_1]', '{{evt_desc}}') %]";
     s.CONFIRM_DELETE_PEERS =
       "[% l('Unlink selected conjoined items?') %]";
     s.CONFIRM_DELETE_PEERS_MESSAGE =
index 5e40fb5..9849afe 100644 (file)
@@ -66,6 +66,10 @@ s.ON_DEMAND_COPY_ALERT = {
         'CLAIMSNEVERCHECKEDOUT' : '[% l("Item was marked claims never checked out") %]'
     }
 };
+s.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_TITLE =
+  "[% l('One or more items could not be deleted. Override?') %]";
+s.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_BODY =
+  "[% l('Reason(s) include: [_1]', '{{evt_desc}}') %]";
 }]);
 </script>
 
index 0793e01..f05c363 100644 (file)
@@ -1301,12 +1301,32 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         ).result.then(function() {
             egCore.net.request(
                 'open-ils.cat',
-                'open-ils.cat.asset.volume.fleshed.batch.update.override',
+                'open-ils.cat.asset.volume.fleshed.batch.update',
                 egCore.auth.token(), cnList, 1, flags
-            ).then(function(update_count) {
-                holdingsSvcInst.fetchAgain().then(function() {
-                    $scope.holdingsGridDataProvider.refresh();
-                });
+            ).then(function(resp) {
+                var evt = egCore.evt.parse(resp);
+                if (evt) {
+                    egConfirmDialog.open(
+                        egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_TITLE,
+                        egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_BODY,
+                        {'evt_desc': evt.desc}
+                    ).result.then(function() {
+                        egCore.net.request(
+                            'open-ils.cat',
+                            'open-ils.cat.asset.volume.fleshed.batch.update.override',
+                            egCore.auth.token(), cnList, 1,
+                            { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
+                        ).then(function() {
+                            holdingsSvcInst.fetchAgain().then(function() {
+                                $scope.holdingsGridDataProvider.refresh();
+                            });
+                        });
+                    });
+                } else {
+                    holdingsSvcInst.fetchAgain().then(function() {
+                        $scope.holdingsGridDataProvider.refresh();
+                    });
+                }
             });
         });
     }
index 8e21428..d07c598 100644 (file)
@@ -580,10 +580,28 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
             ).result.then(function() {
                 egCore.net.request(
                     'open-ils.cat',
-                    'open-ils.cat.asset.volume.fleshed.batch.update.override',
+                    'open-ils.cat.asset.volume.fleshed.batch.update',
                     egCore.auth.token(), cnList, 1, flags
-                ).then(function(){
-                    angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
+                ).then(function(resp){
+                    var evt = egCore.evt.parse(resp);
+                    if (evt) {
+                        egConfirmDialog.open(
+                            egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_TITLE,
+                            egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_BODY,
+                            {'evt_desc': evt.desc}
+                        ).result.then(function() {
+                            egCore.net.request(
+                                'open-ils.cat',
+                                'open-ils.cat.asset.volume.fleshed.batch.update.override',
+                                egCore.auth.token(), cnList, 1,
+                                { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
+                            ).then(function() {
+                                angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
+                            });
+                        });
+                    } else {
+                        angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
+                    }
                 });
             });
         },
@@ -980,3 +998,4 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
     return service;
 }])
 .filter('string_pick', function() { return function(i){ return arguments[i] || ''; }; })
+