From e991ddaacedd4d248e17f55a8e2cc30eb9dd27ea Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 23 Dec 2016 04:46:47 -0500 Subject: [PATCH] LP#1117808: teach Z39.50 import about merge profiles This patch adds a widget to the Z39.50 overlay dialog to allow the user to select a MARC merge profile to use during the merge. For the purpose of applying the merge profile, the incoming record from the Z39.50 server is treated as the target of the merge, as the user is assumed to be picking a Z39.50 record that is "better" overall but may need to be supplement with fields from the incumbent record. As before, the user can choose to edit the incoming record, but note that the version that is edited is the /original/ version of the Z39.50 record, with any changes due to the merge profile being applied after the edit. Merge profiles that have a 'preserve' specification are excluded from selection, as such profiles have the effect of swapping what is considered the lead record for the purpose of the MARC merge This patch also tweaks the dialog to use the egRecordBreaker directive to display the incumbent record, as that permits easier copy-and-pasting if the user chooses to edit the Z39.50 record. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../templates/staff/cat/z3950/t_overlay.tt2 | 19 ++++++--- .../web/js/ui/default/staff/cat/z3950/app.js | 39 ++++++++++++++++++- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/z3950/t_overlay.tt2 b/Open-ILS/src/templates/staff/cat/z3950/t_overlay.tt2 index bb51345da9..e471e20ac8 100644 --- a/Open-ILS/src/templates/staff/cat/z3950/t_overlay.tt2 +++ b/Open-ILS/src/templates/staff/cat/z3950/t_overlay.tt2 @@ -5,18 +5,25 @@ 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 b0bd16160b..dac7c3707c 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 @@ -306,8 +306,42 @@ function($scope , $q , $location , $timeout , $window, egCore , egGridDataProvi controller: ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { $scope.focusMe = true; - $scope.overlay_target = overlay_target; + $scope.merge_profile = null; + $scope.overlay_target = { + id : overlay_target, + merged : false + }; + + egCore.pcrud.retrieve('bre', $scope.overlay_target.id) + .then(function(rec) { + $scope.overlay_target.orig_marc_xml = rec.marc(); + $scope.overlay_target.marc_xml = rec.marc(); + $scope.merge_marc(); // in case a sticky value was already set + }); + + $scope.merge_marc = function() { + if (!$scope.merge_profile) return; + egCore.net.request( + 'open-ils.cat', + 'open-ils.cat.merge.marc.per_profile', + egCore.auth.token(), + $scope.merge_profile, + [ args.marc_xml, $scope.overlay_target.orig_marc_xml ] + ).then(function(merged) { + if (merged) { + $scope.overlay_target.marc_xml = merged; + $scope.overlay_target.merged = true; + } + }); + } + $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() { @@ -324,6 +358,7 @@ function($scope , $q , $location , $timeout , $window, egCore , egGridDataProvi $scope.cancel = function () { $uibModalInstance.dismiss() } }] }).result.then(function (args) { + $scope.merge_marc(); if (!args || !args.name) return; }); }; @@ -334,7 +369,7 @@ function($scope , $q , $location , $timeout , $window, egCore , egGridDataProvi 'open-ils.cat.biblio.record.marc.replace', egCore.auth.token(), overlay_target, - args.marc_xml, + (args.overlay_target.merged ? args.overlay_target.marc_xml : args.marc_xml), null, // FIXME bib source null, $scope.selectFieldStripGroups() -- 2.43.2