From b3d2fdd0ad5e0210ee9aae42b552ddf2572be2a3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 9 May 2017 16:34:48 -0400 Subject: [PATCH] webstaff: implement saving pattern as a template Signed-off-by: Galen Charlton --- .../staff/serials/t_prediction_wizard.tt2 | 8 +++++--- .../staff/serials/directives/prediction_wizard.js | 24 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 b/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 index 976dd0a3ad..4d369cc1ab 100644 --- a/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 @@ -442,9 +442,11 @@
-
- - +
+ + + +
diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js b/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js index 5cefee2d65..1ec9c0519b 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js @@ -501,10 +501,30 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { } else { $scope.pattern = new PredictionPattern(); } + + // possible sharing + $scope.share = { + pattern_name : null, + depth : 0 + }; + $scope.handle_save = function() { $scope.patternCode = JSON.stringify($scope.pattern.compile()); - if (angular.isFunction($scope.onSave)) { - $scope.onSave($scope.patternCode); + if ($scope.share.pattern_name !== null) { + var spt = new egCore.idl.spt(); + spt.name($scope.share.pattern_name); + spt.pattern_code($scope.patternCode); + spt.share_depth($scope.share.depth); + spt.owning_lib(egCore.auth.user().ws_ou()); + egCore.pcrud.create(spt).then(function() { + if (angular.isFunction($scope.onSave)) { + $scope.onSave($scope.patternCode); + } + }); + } else { + if (angular.isFunction($scope.onSave)) { + $scope.onSave($scope.patternCode); + } } } -- 2.11.0