From: Galen Charlton Date: Fri, 12 May 2017 21:59:02 +0000 (-0400) Subject: webstaff: implement creating scap from a pattern template X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a66ec31a254970e53d91c11c21fb83773279ee93;p=working%2FEvergreen.git webstaff: implement creating scap from a pattern template 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 5a95ff121e..68e47d9981 100644 --- a/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 @@ -6,6 +6,9 @@
+ +
@@ -26,7 +29,10 @@ - + +
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 a8567a27c9..d0ed636652 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 @@ -22,6 +22,13 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , function reload(ssubId) { var ssub = egSerialsCoreSvc.get_ssub(ssubId); $scope.predictions = egCore.idl.toTypedHash(ssub.scaps()); + egSerialsCoreSvc.fetch_spt().then(function() { + $scope.pattern_templates = egCore.idl.toTypedHash(egSerialsCoreSvc.sptList); + $scope.active_pattern_template = { id : null }; + if ($scope.pattern_templates.length > 0) { + $scope.active_pattern_template.id = $scope.pattern_templates[0].id; + } + }); } $scope.$watch('ssubId', function(newVal, oldVal) { @@ -74,10 +81,25 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $scope.new_prediction.active = true; $scope.new_prediction.create_date = new Date(); $scope.new_prediction.subscription = $scope.ssubId; + $scope.new_prediction.pattern_code = null; } $scope.importScapFromBibRecord = function() { } + + $scope.importScapFromSpt = function() { + $scope.new_prediction = egCore.idl.toTypedHash(new egCore.idl.scap()); + $scope.new_prediction.type = 'basic'; + $scope.new_prediction.active = true; + $scope.new_prediction.create_date = new Date(); + $scope.new_prediction.subscription = $scope.ssubId; + for (var i = 0; i < $scope.pattern_templates.length; i++) { + if ($scope.pattern_templates[i].id == $scope.active_pattern_template.id) { + $scope.new_prediction.pattern_code = $scope.pattern_templates[i].pattern_code; + break; + } + } + } $scope.openPatternEditorDialog = function(pred) { $uibModal.open({ 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 35a164323f..3394585f61 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 @@ -6,7 +6,8 @@ function(egCore , orderByFilter , $q) { bibId : null, subId : null, subTree : [], - subList : [] + subList : [], + sptList : [] }; // fetch subscription, distributions, streams, captions, @@ -162,5 +163,17 @@ function(egCore , orderByFilter , $q) { } } + service.fetch_spt = function() { + return egCore.net.request( + 'open-ils.serial', + 'open-ils.serial.pattern_template.retrieve.at.atomic', + egCore.auth.token(), + egCore.auth.user().ws_ou() + ).then(function(list) { + service.sptList.length = 0; + angular.extend(service.sptList, list); + }); + } + return service; }]);