LP#1710401: Z39.50 should notice overlay target change
authorMike Rylander <mrylander@gmail.com>
Thu, 12 Jul 2018 15:03:44 +0000 (11:03 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 16 Jul 2018 13:01:18 +0000 (09:01 -0400)
Currently, we record the overlay target at UI startup and use that going
forward until the interface is reloaded.  This commit inspects the local
storage version of the target for changes and offers the user the chance to
proceed with the new target or cancel the action.  If the target has been
unset, the user is given the option of proceeding with the load-time target.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>

Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/z3950/app.js

index bfecba8..a043b31 100644 (file)
@@ -10,5 +10,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     s.GO_BACK                           = "[% l('Go back') %]";
     s.IMPORT_BUTTON_LABEL               = "[% l('Import') %]";
     s.SAVE_BUTTON_LABEL                 = "[% l('Save') %]";
+    s.OVERLAY_CHANGED_TITLE             = "[% l('Overlay target changed') %]";
+    s.OVERLAY_CHANGED                   = "[% l('The overlay target has changed from [_1] to [_2].  Continue with overlay of record [_2]?', '{{id}}', '{{live_id}}') %]";
+    s.OVERLAY_REMOVED_TITLE             = "[% l('Overlay target removed') %]";
+    s.OVERLAY_REMOVED                   = "[% l('The overlay target has been removed.  The previous target was record [_1].  Continue with overlay of record [_1]?', '{{id}}') %]";
 }]);
 </script>
index 5e54ee5..b48c4df 100644 (file)
@@ -332,6 +332,7 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
     $scope.overlay_record = function() {
         var items = $scope.gridControls.selectedItems();
         var overlay_target = $scope.local_overlay_target;
+        var live_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record') || 0;
         var args = {
             'marc_xml' : items[0]['marcxml']
         };
@@ -341,19 +342,15 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
             size: 'lg',
             controller:
                 ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
-                $scope.focusMe = true;
-                $scope.merge_profile = null;
-                $scope.overlay_target = {
-                    id : overlay_target,
-                    merged : false
-                };
 
-                $scope.overlay_target.marc_xml = args.marc_xml;
-                egCore.pcrud.retrieve('bre', $scope.overlay_target.id)
-                .then(function(rec) {
-                    $scope.overlay_target.orig_marc_xml = rec.marc();
-                    $scope.merge_marc(); // in case a sticky value was already set
-                });
+                $scope.immediate_merge = function () {
+                    $scope.overlay_target.marc_xml = args.marc_xml;
+                    egCore.pcrud.retrieve('bre', $scope.overlay_target.id)
+                    .then(function(rec) {
+                        $scope.overlay_target.orig_marc_xml = rec.marc();
+                        $scope.merge_marc(); // in case a sticky value was already set
+                    });
+                }
 
                 $scope.merge_marc = function() {
                     if (!$scope.merge_profile) return;
@@ -370,18 +367,8 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                         }
                     });
                 }
-                $scope.$watch('merge_profile', function(newVal, oldVal) {
-                    if (newVal && newVal !== oldVal) {
-                        $scope.merge_marc();
-                    }
-                });
 
-                $scope.args = args;
-                args.overlay_target = $scope.overlay_target;
-                $scope.ok = function(args) { $uibModalInstance.close(args) };
-                $scope.cancel = function () { $uibModalInstance.dismiss() };
-                
-               $scope.editOverlayRecord = function() {
+                $scope.editOverlayRecord = function() {
                     $uibModal.open({
                         templateUrl: './cat/z3950/t_edit_overlay_record',
                         backdrop: 'static',
@@ -400,6 +387,55 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                         if (!args || !args.name) return;
                     });
                 };
+
+                $scope.focusMe = true;
+                $scope.merge_profile = null;
+                $scope.overlay_target = {
+                    id : overlay_target,
+                    live_id : live_overlay_target,
+                    merged : false
+                };
+
+                $scope.$watch('merge_profile', function(newVal, oldVal) {
+                    if (newVal && newVal !== oldVal) {
+                        $scope.merge_marc();
+                    }
+                });
+
+                $scope.args = args;
+                args.overlay_target = $scope.overlay_target;
+                $scope.ok = function(args) { $uibModalInstance.close(args) };
+                $scope.cancel = function () { $uibModalInstance.dismiss() };
+                
+                if (overlay_target != live_overlay_target) {
+                    var confirm_title = egCore.strings.OVERLAY_CHANGED_TITLE;
+                    var confirm_msg = egCore.strings.OVERLAY_CHANGED;
+
+                    if (live_overlay_target == 0) { // someone unset the target...
+                        confirm_title = egCore.strings.OVERLAY_REMOVED_TITLE;
+                        confirm_msg = egCore.strings.OVERLAY_REMOVED;
+                    }
+
+                    egConfirmDialog.open(
+                        confirm_title,
+                        confirm_msg,
+                        { id : overlay_target, live_id : live_overlay_target }
+                    ).result.then(
+                        function () { // proceed -- but check live overlay for unset-ness
+                            if (live_overlay_target != 0) {
+                                $scope.overlay_target.id = $scope.overlay_target.live_id;
+                                overlay_target = live_overlay_target;
+                            }
+                            $scope.immediate_merge();
+                        },
+                        function () {
+                            $scope.cancel();
+                        }
+                    );
+                } else {
+                    $scope.immediate_merge();
+                }
+
             }]
         }).result.then(function (args) {
             egCore.net.request(