webstaff: improve MARC record deletion
authorGalen Charlton <gmc@esilibrary.com>
Thu, 8 Oct 2015 21:28:53 +0000 (21:28 +0000)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:50 +0000 (14:58 -0500)
The MARC editor now asks the user to confirm
whether to delete the record, and in the case of
deleting bibs, now uses open-ils.cat.biblio.record_entry.delete
so as to catch things like volumes still attached
to the bib and cancelling holds in the bib record.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index 81b3190..0f6fa33 100644 (file)
@@ -8,5 +8,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     s.ADD_007                   = "[% l('Add 007') %]";
     s.ADD_REPLACE_008           = "[% l('Add/Replace 008') %]";
     s.DELETE_FIELD              = "[% l('Delete field') %]";
+    s.CONFIRM_DELETE_RECORD     = "[% l('Delete Record') %]";
+    s.CONFIRM_DELETE_BRE_MSG    = "[% l('Are you sure you want to delete title record [_1] from the catalog?', '{{id}}') %]";
+    s.CONFIRM_DELETE_ARE_MSG    = "[% l('Are you sure you want to delete authority record [_1] from the catalog?', '{{id}}') %]";
+    s.ALERT_DELETE_FAILED       = "[% l('Could not delete record [_1]: [_2]', '{{id}}', '{{desc}}') %]";
 }]);
 </script>
index 5fb5202..026767f 100644 (file)
@@ -645,8 +645,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
             });
 
         },
-        controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable',
-            function ( $timeout , $scope , $q,  $window , egCore ,  egTagTable ) {
+        controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable','egConfirmDialog','egAlertDialog',
+            function ( $timeout , $scope , $q,  $window , egCore ,  egTagTable , egConfirmDialog , egAlertDialog ) {
 
 
                 $scope.onSaveCallback = $scope.onSave;
@@ -1176,8 +1176,34 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                 };
 
                 $scope.deleteRecord = function () {
-                    $scope.Record().deleted(true);
-                    return $scope.saveRecord();
+                    egConfirmDialog.open(
+                        egCore.strings.CONFIRM_DELETE_RECORD,
+                        (($scope.record_type == 'bre') ?
+                            egCore.strings.CONFIRM_DELETE_BRE_MSG :
+                            egCore.strings.CONFIRM_DELETE_ARE_MSG),
+                        { id : $scope.recordId }
+                    ).result.then(function() {
+                        if ($scope.record_type == 'bre') {
+                            egCore.net.request(
+                                'open-ils.cat',
+                                'open-ils.cat.biblio.record_entry.delete',
+                                egCore.auth.token(), $scope.recordId
+                            ).then(function(resp) {
+                                var evt = egCore.evt.parse(resp);
+                                if (evt) {
+                                    return egAlertDialog.open(
+                                        egCore.strings.ALERT_DELETE_FAILED,
+                                        { id : $scope.recordId, desc : evt.desc }
+                                    );
+                                } else {
+                                    loadRecord().then(processOnSaveCallbacks);
+                                }
+                            });
+                        } else {
+                            $scope.Record().deleted(true);
+                            return $scope.saveRecord();
+                        }
+                    });
                 };
 
                 $scope.undeleteRecord = function () {