LP1845241: Use the correct API call to Undelete a bib record
authorJane Sandberg <sandbej@linnbenton.edu>
Sun, 8 Mar 2020 14:58:09 +0000 (07:58 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 22 Jul 2020 14:34:00 +0000 (10:34 -0400)
To test:

1) Open up a delete-ready bibliographic record in the Web client
(no attached holdings, no located URI, no open orders attached, etc.)
2) Delete it.
3) Undelete it.  Note that the "Undelete" button briefly turns into a
"Delete" button before changing back to an "Undelete" button.  Note that
the bib record does not show up in search results within the Web client.
4) Apply this commit.
5) Now try undeleting the record again.  Notice that the "Delete" button
does not revert to an "Undelete" button.  Note also that the record is
once again showing up in search results (although you may have to be a
bit creative using search terms, due to search results caching).

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: blake <blake@mobiusconsortium.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/cat/share/marcedit_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index 295078c..38d2792 100644 (file)
@@ -12,10 +12,12 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     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}}') %]";
+    s.ALERT_UNDELETE_FAILED     = "[% l('Could not undelete record [_1]: [_2]', '{{id}}', '{{desc}}') %]";
     s.DIRTY_MARC_WARNING        = "[% l('There is unsaved data in this record.') %]"
     s.MARC_ALERT_CREATE_SUCCESS = "[% l('Successfully created new record') %]";
     s.MARC_ALERT_CREATE_FAILED  = "[% l('Failed to create new record: [_1]', '{{error}}') %]";
     s.MARC_ALERT_UPDATE_SUCCESS = "[% l('Successfully updated record') %]";
     s.MARC_ALERT_UPDATE_FAILED  = "[% l('Failed to update record: [_1]', '{{error}}') %]";
+    s.SUCCESS_UNDELETE_RECORD   = "[% l('Record is no longer deleted') %]";
 }]);
 </script>
index 3967267..0a6a0dd 100644 (file)
@@ -1331,8 +1331,24 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                 };
 
                 $scope.undeleteRecord = function () {
-                    $scope.Record().deleted(false);
-                    return $scope.saveRecord();
+                    if ($scope.record_type == 'bre') {
+                        egCore.net.request(
+                            'open-ils.cat',
+                            'open-ils.cat.biblio.record_entry.undelete',
+                            egCore.auth.token(), $scope.recordId
+                        ).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);
+                            }
+                        });
+                    }
                 };
 
                 $scope.validateHeadings = function () {