LP#1724321 - add TCN duplicate checking to Edit then Import Function collab/csharp/lp1724321_fix_z3950_edit_then_import
authorChris Sharp <csharp@georgialibraries.org>
Wed, 8 Nov 2017 15:59:06 +0000 (10:59 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Wed, 8 Nov 2017 15:59:06 +0000 (10:59 -0500)
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
Open-ILS/web/js/ui/default/staff/cat/z3950/app.js

index d525a90..98aaddc 100644 (file)
@@ -630,6 +630,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
             embedded : '@',
             recordType : '@',
             maxUndo : '@',
+            importIsTrue : '@',
             saveLabel : '@'
         },
         link: function (scope, element, attrs) {
@@ -1335,40 +1336,76 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         }, function() { // failure
                             alert('Could not save the record!');
                         }).then(loadRecord).then(processOnSaveCallbacks);
-                    } else {
-                        $scope.Record().creator(egCore.auth.user().id());
-                        $scope.Record().create_date('now');
-                        return egCore.pcrud.create(
-                            $scope.Record()
-                        ).then(function(bre) {
-                            $scope.recordId = bre.id(); 
-                            $scope.caretRecId = $scope.recordId;
-                            if ($scope.enable_fast_add) {
+                    } else { // csharp - this is where we add the checks
+                        // Am I a z39.50 import?  If so, make sure I don't
+                        // match any existing TCNs
+                        if ($scope.import_is_true) {
+                            $scope.import = function() {
+                                var deferred = $q.defer();
+                                var items = $scope.gridControls.selectedItems();
                                 egCore.net.request(
-                                    'open-ils.actor',
-                                    'open-ils.actor.anon_cache.set_value',
-                                    null, 'edit-these-copies', {
-                                        record_id: $scope.recordId,
-                                        raw: [{
-                                            label : $scope.fast_item_callnumber,
-                                            barcode : $scope.fast_item_barcode,
-                                        }],
-                                        hide_vols : false,
-                                        hide_copies : false
-                                    }
-                                ).then(function(key) {
-                                    if (key) {
-                                        var url = egCore.env.basePath + 'cat/volcopy/' + key;
-                                        $timeout(function() { $window.open(url, '_blank') });
-                                    } else {
-                                        alert('Could not create anonymous cache key!');
+                                    'open-ils.cat',
+                                    'open-ils.cat.biblio.record.xml.import',
+                                    egCore.auth.token(),
+                                    items[0]['marcxml'],
+                                    null, // FIXME bib source
+                                    null,
+                                    null,
+                                    $scope.selectFieldStripGroups()
+                                ).then(
+                                    function() { deferred.resolve() },
+                                    null, // onerror
+                                    function(result) {
+                                        egConfirmDialog.open(
+                                            egCore.strings.IMPORTED_RECORD_FROM_Z3950,
+                                            egCore.strings.IMPORTED_RECORD_FROM_Z3950_AS_ID,
+                                            { id : result.id() },
+                                            egCore.strings.GO_TO_RECORD,
+                                            egCore.strings.GO_BACK
+                                        ).result.then(function() {
+                                            // NOTE: $location.path('/cat/catalog/record/' + result.id()) did not work
+                                            // for some reason
+                                            $window.location.href = egCore.env.basePath + 'cat/catalog/record/' + result.id();
+                                        });
                                     }
-                                });
-                            }
-                        }).then(loadRecord).then(processOnSaveCallbacks);
+                                );
+                        
+                                return deferred.promise;
+                            };
+                        } else {
+                            $scope.Record().creator(egCore.auth.user().id());
+                            $scope.Record().create_date('now');
+                            return egCore.pcrud.create(
+                                $scope.Record()
+                            ).then(function(bre) {
+                                $scope.recordId = bre.id(); 
+                                $scope.caretRecId = $scope.recordId;
+                                if ($scope.enable_fast_add) {
+                                    egCore.net.request(
+                                        'open-ils.actor',
+                                        'open-ils.actor.anon_cache.set_value',
+                                        null, 'edit-these-copies', {
+                                            record_id: $scope.recordId,
+                                            raw: [{
+                                                label : $scope.fast_item_callnumber,
+                                                barcode : $scope.fast_item_barcode,
+                                            }],
+                                            hide_vols : false,
+                                            hide_copies : false
+                                        }
+                                    ).then(function(key) {
+                                        if (key) {
+                                            var url = egCore.env.basePath + 'cat/volcopy/' + key;
+                                            $timeout(function() { $window.open(url, '_blank') });
+                                        } else {
+                                            alert('Could not create anonymous cache key!');
+                                        }
+                                    });
+                                }
+                            }).then(loadRecord).then(processOnSaveCallbacks);
+                        }
                     }
 
-
                 };
 
                 $scope.seeBreaker = function () {
index 45ad9d5..a8bae68 100644 (file)
@@ -266,6 +266,7 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                 $scope.ok = function(args) { $uibModalInstance.close(args) }
                 $scope.cancel = function () { $uibModalInstance.dismiss() }
                 $scope.save_label = egCore.strings.IMPORT_BUTTON_LABEL;
+                $scope.import_is_true = true;
                 $scope.import_record_callback = function (record_id) {
                     recId = record_id;
                     $scope.save_label = egCore.strings.SAVE_BUTTON_LABEL;