LP#1724885 - Alert when TCN value already exists on bib import.
authorChris Sharp <csharp@georgialibraries.org>
Tue, 7 Nov 2017 20:41:26 +0000 (15:41 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 8 Nov 2017 16:06:45 +0000 (11:06 -0500)
To test
-------
[1] Ensure that the global flag 'cat.bib.use_id_for_tcn' is off.
[2] Import a record via Z39.50 in the web staff client.
[3] Repeat the Z39.50 search and attempt to import the record again.
    Note that the import will fail silently (with error messages
    in the browser console).
[4] Apply the patch and repeat step 3. This time, an alert modal
    will appear pointing out that the TCN is already in use.

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/z3950/app.js

index 7be4638..bfecba8 100644 (file)
@@ -2,6 +2,8 @@
 
 <script>
 angular.module('egCoreMod').run(['egStrings', function(s) {
+    s.TCN_EXISTS                        = "[% l('A record already exists with the requested TCN value') %]";
+    s.TCN_EXISTS_ERR                    = "[% l('An unexpected error occurred') %]";
     s.IMPORTED_RECORD_FROM_Z3950        = "[% l('Imported record') %]";
     s.IMPORTED_RECORD_FROM_Z3950_AS_ID  = "[% l('Record imported as ID [_1]', '{{id}}') %]";
     s.GO_TO_RECORD                      = "[% l('Go to record') %]";
index 45ad9d5..9ba6927 100644 (file)
@@ -27,9 +27,9 @@ angular.module('egCatZ3950Search',
  */
 .controller('Z3950SearchCtrl',
        ['$scope','$q','$location','$timeout','$window','egCore','egGridDataProvider','egZ3950TargetSvc','$uibModal',
-        'egConfirmDialog',
+        'egConfirmDialog','egAlertDialog',
 function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvider,  egZ3950TargetSvc,  $uibModal,
-         egConfirmDialog) {
+         egConfirmDialog, egAlertDialog) {
 
     // get list of targets
     egZ3950TargetSvc.loadTargets();
@@ -228,6 +228,17 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
             function() { deferred.resolve() },
             null, // onerror
             function(result) {
+                var evt = egCore.evt.parse(result);
+                if (evt) {
+                     if (evt.textcode == 'TCN_EXISTS') {
+                       egAlertDialog.open(
+                            egCore.strings.TCN_EXISTS
+                      );
+                     } else {
+                       // we shouldn't get here
+                       egAlertDialog.open(egCore.strings.TCN_EXISTS_ERR);
+                     }
+                } else {
                 egConfirmDialog.open(
                     egCore.strings.IMPORTED_RECORD_FROM_Z3950,
                     egCore.strings.IMPORTED_RECORD_FROM_Z3950_AS_ID,
@@ -239,6 +250,7 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                     // for some reason
                     $window.location.href = egCore.env.basePath + 'cat/catalog/record/' + result.id();
                 });
+              }   
             }
         );