From 59f6433b6e406801301ab62edb2c6620aea470cd Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Wed, 8 Nov 2017 10:59:06 -0500 Subject: [PATCH] LP#1724321 - add TCN duplicate checking to Edit then Import Function Signed-off-by: Chris Sharp --- .../js/ui/default/staff/cat/services/marcedit.js | 97 +++++++++++++++------- Open-ILS/web/js/ui/default/staff/cat/z3950/app.js | 1 + 2 files changed, 68 insertions(+), 30 deletions(-) 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 d525a90933..98aaddca8b 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 @@ -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 () { diff --git a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js index 45ad9d55e2..a8bae68c0a 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js @@ -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; -- 2.11.0