From: Galen Charlton Date: Fri, 5 May 2017 21:33:35 +0000 (-0400) Subject: webstaff: fix creating PredictionPattern from null pattern code X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=71d563d21aaa09c23de1438694b0d07df888c569;p=working%2FEvergreen.git webstaff: fix creating PredictionPattern from null pattern code Signed-off-by: Galen Charlton --- 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 5ac79090f3..9d267c14d8 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 @@ -27,12 +27,13 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { this.use_chron = false; this.use_alt_chron = false; this.use_calendar_changes = false; + this.calendar_change = []; this.compress_expand = '3'; this.caption_evaluation = '0'; this.enum_levels = []; this.alt_enum_levels = []; this.chron_levels = []; - this.alt_chron_levels = []; + this.alt_chron_levels = [{ caption : null, display_caption: false }]; this.frequency_type = 'preset'; this.use_regularity = false; this.regularity = []; @@ -164,7 +165,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { } if (sf == 'x') { this.use_calendar_change = true; - this.calendar_change = []; value.split(',').forEach(function(chg) { var calendar_change = { type : null, @@ -241,6 +241,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { } } } + if (self.frequency) { if (self.frequency.match(/^\d+$/)) { self.frequency_type = 'numeric'; @@ -472,10 +473,27 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { return lvl.caption; }).join(', '); } + + if (!patternCode) { + // starting from scratch, ensure there's + // enough so that the input wizard can be used + this.use_enum = true; + this.use_chron = true; + this.link = 0; + self.add_enum_level(); + self.add_alt_enum_level(); + self.add_chron_level(); + self.add_calendar_change(); + self.add_regularity(); + } } // TODO chron only - $scope.pattern = new PredictionPattern(JSON.parse($scope.patternCode)); + if ($scope.patternCode) { + $scope.pattern = new PredictionPattern(JSON.parse($scope.patternCode)); + } else { + $scope.pattern = new PredictionPattern(); + } $scope.handle_save = function() { $scope.patternCode = JSON.stringify($scope.pattern.compile()); if (angular.isFunction($scope.onSave)) {