From d5fb03768e5475437f2b2ae2b541ea59b7e3d32c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 8 Oct 2015 21:28:53 +0000 Subject: [PATCH] webstaff: improve MARC record deletion 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 Signed-off-by: Kathy Lussier --- .../templates/staff/cat/share/marcedit_strings.tt2 | 4 +++ .../js/ui/default/staff/cat/services/marcedit.js | 34 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2 b/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2 index 81b3190395..0f6fa3366d 100644 --- a/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2 @@ -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}}') %]"; }]); diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js index 5fb520238f..026767fc73 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js @@ -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 () { -- 2.11.0