LP#1716479: (follow-up) fix handling of onSave callbacks for AngularJS MARC edit
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 4 Apr 2023 15:10:21 +0000 (11:10 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 4 Apr 2023 15:15:55 +0000 (11:15 -0400)
This patch fixes an issue that has been present for a while but
clarified by Beth Wills in the course of testing the base patch
for this bug.

Specifically, the routine to process onSave callbacks was
not bound to the scope properly, meaning that the wrong onSave
callbacks could be run when dealing with mutiple active
egMarcEditRecords.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index f132cc6..8f5f5f2 100644 (file)
@@ -1320,7 +1320,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                                         { id : $scope.recordId, desc : evt.desc }
                                     );
                                 } else {
-                                    loadRecord().then(processOnSaveCallbacks);
+                                    loadRecord().then($scope.processOnSaveCallbacks);
                                 }
                             });
                         } else {
@@ -1345,7 +1345,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                                 );
                             } else {
                                 ngToast.create(egCore.strings.SUCCESS_UNDELETE_RECORD);
-                                loadRecord().then(processOnSaveCallbacks);
+                                loadRecord().then($scope.processOnSaveCallbacks);
                             }
                         });
                     }
@@ -1390,7 +1390,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                     });
                 }
 
-                processOnSaveCallbacks = function() {
+                $scope.processOnSaveCallbacks = function() {
                     var deferred = $q.defer();
                     if (typeof $scope.onSaveCallback !== 'undefined') {
                         var promise = deferred.promise;
@@ -1475,7 +1475,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                             $scope.bibSource = $scope.bib_source.id;
                         }
 
-                        return $timeout(processOnSaveCallbacks);
+                        return $timeout($scope.processOnSaveCallbacks);
                     }
 
                     $scope.mangle_005();
@@ -1514,7 +1514,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                                 alert('Could not create anonymous cache key!');
                             }
                         });
-                    }).then(loadRecord).then(processOnSaveCallbacks);
+                    }).then(loadRecord).then($scope.processOnSaveCallbacks);
                 };
 
                 $scope.seeBreaker = function () {