From 79b8ea4df1c9e6b227649d764cc85eaf349af12e Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 13 Jul 2017 16:43:01 -0400 Subject: [PATCH] webstaff: improve dirty detection and reloading on prediction manager Signed-off-by: Galen Charlton --- .../templates/staff/serials/t_prediction_manager.tt2 | 18 +++++++++--------- .../staff/serials/directives/prediction_manager.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) 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 0dda638680..f28b1b67a3 100644 --- a/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2 @@ -11,7 +11,7 @@
- +
- +

[% l('Existing Prediction Patterns') %]

- +
- + - +
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 14164f3ffc..d0cd44f568 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 @@ -16,6 +16,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $uibModal , $timeout , $location , egConfirmDialog , ngToast) { $scope.has_pattern_to_import = false; + $scope.forms = []; egSerialsCoreSvc.fetch($scope.bibId).then(function() { reload($scope.ssubId); egSerialsCoreSvc.fetch_patterns_from_bibs_mfhds($scope.bibId).then(function() { @@ -26,6 +27,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); function reload(ssubId) { + if (!ssubId) return; var ssub = egSerialsCoreSvc.get_ssub(ssubId); $scope.predictions = egCore.idl.toTypedHash(ssub.scaps()); angular.forEach($scope.predictions, function(pred) { @@ -48,10 +50,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); } - $scope.$watch('ssubId', function(newVal, oldVal) { - if (newVal && newVal != oldVal) reload(newVal); - }); - $scope.createScap = function(pred) { var scap = egCore.idl.fromTypedHash(pred); egCore.pcrud.create(scap).then(function() { @@ -162,12 +160,14 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , } // Mark form dirty because, when it's created from a template, // it can be immediately saved if the user so chooses. The - // $timeout() allows this to happen after the form is bound - // is bound to $scope.new_prediction. - $timeout(function() { $scope.new_prediction.predform.$setDirty() }); + // $watch() allows this to happen after the form is bound + // is bound to the scope. + $scope.$watch('forms.newpredform', function(form) { + if (form) form.$setDirty(); + }); } - $scope.openPatternEditorDialog = function(pred, viewOnly) { + $scope.openPatternEditorDialog = function(pred, form, viewOnly) { $uibModal.open({ templateUrl: './serials/t_pattern_editor_dialog', size: 'lg', @@ -184,7 +184,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }).result.then(function (patternCode) { if (pred.pattern_code !== patternCode) { pred.pattern_code = patternCode; - pred.predform.$setDirty(); + form.$setDirty(); } }); } -- 2.11.0