From 56abb3c0b017b272b64e6671464b1c314db7d476 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 22 Jul 2020 11:05:34 -0400 Subject: [PATCH] LP#1888518: fix authority delete/undelete in AngularJS editor This patch ensures that authority record deletion and undeletion works in the AngularJS editor. To test ------- [1] Go to Manage Authorities -> search -> edit a hit, then click the delete button in the editor window. [2] Note that the record is not deleted. [3] Apply the patch. [4] Repeat step 1; this time, the record should be deleted, as can be verified by rerunning the search in the authorities window. [5] Click the undelete button; verify that the record shows up again. Signed-off-by: Galen Charlton --- .../js/ui/default/staff/cat/services/marcedit.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 0a6a0dddef..d77b73747d 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 @@ -1323,7 +1323,20 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) loadRecord().then(processOnSaveCallbacks); } }); + } else if ($scope.record_type == 'are') { + egCore.pcrud.remove($scope.Record()).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 { + // fallback for sre? $scope.Record().deleted(true); return $scope.saveRecord(); } @@ -1348,6 +1361,26 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) loadRecord().then(processOnSaveCallbacks); } }); + } else if ($scope.record_type = 'are') { + $scope.Record().deleted(false); + $scope.mangle_005(); // force an update of the 005 upon + // undelete to ensure that the MARC record + // is different, thereby forcing a + // a full reingest of the authority record + $scope.record.pruneEmptyFieldsAndSubfields(); + $scope.Record().marc($scope.record.toXmlString()); + egCore.pcrud.update($scope.Record()).then(function(resp) { + var evt = egCore.evt.parse(resp); + if (evt) { + return egAlertDialog.open( + egCore.strings.ALERT_UNDELETE_FAILED, + { id : $scope.recordId, desc : evt.desc } + ); + } else { + ngToast.create(egCore.strings.SUCCESS_UNDELETE_RECORD); + loadRecord().then(processOnSaveCallbacks); + } + }); } }; -- 2.11.0