From 000623bb63fbec902f3863f3233a33aad0f24474 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 12 Jul 2018 11:03:44 -0400 Subject: [PATCH 1/1] LP#1710401: Z39.50 should notice overlay target change 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 Signed-off-by: Chris Sharp --- .../staff/cat/share/z3950_strings.tt2 | 4 + .../web/js/ui/default/staff/cat/z3950/app.js | 82 +++++++++++++------ 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2 b/Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2 index bfecba8cc3..a043b3137f 100644 --- a/Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/z3950_strings.tt2 @@ -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}}') %]"; }]); 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 5e54ee5ef5..b48c4df17e 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 @@ -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( -- 2.43.2