From: Galen Charlton Date: Thu, 25 May 2017 22:45:01 +0000 (-0400) Subject: webstaff: implement import patterns from bibliographic/mfhd records X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a79e292e231eceb0f73ce76d433e83eb40c7620e;p=working%2FEvergreen.git webstaff: implement import patterns from bibliographic/mfhd records Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 b/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 index 343f6368bf..24c9c416b3 100644 --- a/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 @@ -5,7 +5,7 @@
- + diff --git a/Open-ILS/src/templates/staff/serials/t_select_pattern_dialog.tt2 b/Open-ILS/src/templates/staff/serials/t_select_pattern_dialog.tt2 new file mode 100644 index 0000000000..1f900d71a2 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_select_pattern_dialog.tt2 @@ -0,0 +1,32 @@ +
+ + + + + +
diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js b/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js index 7cace142c7..eb588536b5 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js @@ -15,8 +15,14 @@ angular.module('egSerialsAppDep') function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $uibModal , $timeout , $location) { + $scope.has_pattern_to_import = false; egSerialsCoreSvc.fetch($scope.bibId).then(function() { reload($scope.ssubId); + egSerialsCoreSvc.fetch_patterns_from_bibs_mfhds($scope.bibId).then(function() { + if (egSerialsCoreSvc.potentialPatternList.length > 0) { + $scope.has_pattern_to_import = true; + } + }); }); function reload(ssubId) { @@ -85,6 +91,37 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , } $scope.importScapFromBibRecord = function() { + $uibModal.open({ + templateUrl: './serials/t_select_pattern_dialog', + size: 'md', + backdrop: 'static', + controller: + ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { + $scope.focusMe = true; + $scope.potentials = egSerialsCoreSvc.potentialPatternList.slice(); + $scope.ok = function(patternCode) { $uibModalInstance.close($scope.potentials) } + $scope.cancel = function () { $uibModalInstance.dismiss() } + }] + }).result.then(function (potentials) { + var marc = []; + angular.forEach(potentials, function(pot) { + if (pot.selected) { + marc.push(pot.marc); + } + }); + if (marc.length == 0) return; + egCore.net.request( + 'open-ils.serial', + 'open-ils.serial.caption_and_pattern.create_from_records', + egCore.auth.token(), + $scope.ssubId, + marc + ).then(function() { + egSerialsCoreSvc.fetch($scope.bibId).then(function() { + reload($scope.ssubId); + }); + }); + }); } $scope.importScapFromSpt = function() { diff --git a/Open-ILS/web/js/ui/default/staff/serials/services/core.js b/Open-ILS/web/js/ui/default/staff/serials/services/core.js index be44b93796..7ec21ba0a2 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/serials/services/core.js @@ -10,6 +10,7 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm subList : [], sptList : [], mfhdList : [], + potentialPatternList : [], flatMfhdList : [], itemMap : {}, itemTree : [], @@ -121,6 +122,32 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm }); } + service.fetch_patterns_from_bibs_mfhds = function(bibId) { + return egCore.net.request( + 'open-ils.serial', + 'open-ils.serial.caption_and_pattern.find_legacy_by_bib_record.atomic', + egCore.auth.token(), + bibId + ).then(function(list) { + service.potentialPatternList = egCore.idl.toTypedHash(list); + angular.forEach(service.potentialPatternList, function(pot) { + var rec = new MARC21.Record({ marcxml : pot.marc }); + var pattern_fields = rec.fields.filter(function(f) { + return (f.tag == '853' || f.tag == '854' || f.tag == '855'); + }); + pot.desc = ''; + if (pattern_fields.length > 0) { + // just take the first one + var fld = pattern_fields[0]; + pot.desc = fld.tag + ' ' + fld.ind1 + fld.ind2 + + fld.subfields.map(function(sf) { + return '$' + sf[0] + sf[1] + }).join(''); + } + }); + }) + } + // fetch subscription, distributions, streams, captions, // and notes associated with the indicated bib service.fetch = function(bibId, contextOrg) {