From: Galen Charlton Date: Fri, 28 Apr 2017 19:23:19 +0000 (-0400) Subject: webstaff: start of prediction wizard X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=77eff6be5aee7e54de9405c047fabf4c8af3c3ed;p=working%2FEvergreen.git webstaff: start of prediction wizard Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/serials/index.tt2 b/Open-ILS/src/templates/staff/serials/index.tt2 index 692e57d5b8..e37504dff5 100644 --- a/Open-ILS/src/templates/staff/serials/index.tt2 +++ b/Open-ILS/src/templates/staff/serials/index.tt2 @@ -11,6 +11,7 @@ + [% END %] diff --git a/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 b/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 new file mode 100644 index 0000000000..34533db476 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 @@ -0,0 +1,200 @@ +
+ + +
+
+ +
+
+ +
+
+
+
+
[% l('Level [_1]', '{{$index + 1}}') %]
+
+
+
+ + +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
[% l('Level [_1]', '{{$index + 1}}') %]
+
+
+
+ + +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+CHRON +
+
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
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 new file mode 100644 index 0000000000..63f3385073 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js @@ -0,0 +1,211 @@ +angular.module('egSerialsAppDep') + +.directive('egPredictionWizard', function() { + return { + transclude: true, + restrict: 'E', + scope: { + patternCode : '=' + }, + templateUrl: './serials/t_prediction_wizard', + controller: + ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider', +function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { + + $scope.tab = { active : 0 }; + // for use by ng-value + $scope.True = true; + $scope.False = false; + + // class for MARC21 serial predication pattern + // TODO move elsewhere + function PredictionPattern(patternCode) { + var self = this; + this.use_enum = false; + this.use_alt_enum = false; + this.use_chron = false; + this.compress_expand = '3'; + this.caption_evaluation = '0'; + this.enum_levels = []; + this.alt_enum_levels = []; + this.chron_levels = []; + this.alt_chron_levels = []; + + var nr_sf_map = { + '0' : 'link', + 'n' : 'note', + 'p' : 'pieces_per_issuance', + 'w' : 'frequency', + 't' : 'copy_caption' + } + var enum_level_map = { + 'a' : 0, + 'b' : 1, + 'c' : 2, + 'd' : 3, + 'e' : 4, + 'f' : 5 + } + var alt_enum_level_map = { + 'g' : 0, + 'h' : 1 + } + var chron_level_map = { + 'i' : 0, + 'j' : 1, + 'k' : 2, + 'l' : 3 + } + var alt_chron_level_map = { + 'm' : 0 + } + + var curr_enum_level = -1; + var curr_alt_enum_level = -1; + var curr_chron_level = -1; + var curr_alt_chron_level = -1; + if (patternCode && patternCode.length > 2 && (patternCode.length % 2 == 0)) { + // set indicator values + this.compress_expand = patternCode[0]; + this.caption_evaluation = patternCode[1]; + for (var i = 2; i < patternCode.length; i += 2) { + var sf = patternCode[i]; + var value = patternCode[i + 1]; + if (sf in nr_sf_map) { + this[nr_sf_map[sf]] = value; + continue; + } + if (sf in enum_level_map) { + this.use_enum = true; + curr_enum_level = enum_level_map[sf]; + this.enum_levels[curr_enum_level] = { + caption : value, + restart : false + } + continue; + } + if (sf in alt_enum_level_map) { + this.use_enum = true; + this.use_alt_enum = true; + curr_enum_level = -1; + curr_alt_enum_level = alt_enum_level_map[sf]; + this.alt_enum_levels[curr_alt_enum_level] = { + caption : value, + restart : false + } + continue; + } + if (sf in chron_level_map) { + this.use_chron = true; + curr_chron_level = chron_level_map[sf]; + this.chron_levels[curr_chron_level] = { + caption : value + } + continue; + } + if (sf in alt_chron_level_map) { + this.use_chron = true; + curr_chron_level = -1; + curr_alt_chron_level = alt_enum_level_map[sf]; + this.alt_chron_levels[curr_alt_chron_level] = { + caption : value + } + continue; + } + + if (sf == 'u') { + var units = { + type : 'number' + }; + if (value == 'und' || value == 'var') { + units.type = value; + } else if (!isNaN(parseInt(value))) { + units.value = parseInt(value); + } else { + continue; // escape garbage + } + if (curr_enum_level > 0) { + this.enum_levels[curr_enum_level].units_per_next_higher = units; + } else if (curr_alt_enum_level > 0) { + this.alt_enum_levels[curr_alt_enum_level].units_per_next_higher = units; + } + } + if (sf == 'v' && value == 'r') { + if (curr_enum_level > 0) { + this.enum_levels[curr_enum_level].restart = true; + } else if (curr_alt_enum_level > 0) { + this.alt_enum_levels[curr_alt_enum_level].restart = true; + } + } + if (sf == 'z') { + if (curr_enum_level > -1) { + this.enum_levels[curr_enum_level].numbering_scheme = value; + } else if (curr_alt_enum_level > -1) { + this.alt_enum_levels[curr_alt_enum_level].numbering_scheme = value; + } + } + if (sf == 'x') { + this.calendar_change = []; + value.split(',').forEach(function(chg) { + var calendar_change = { + season : null, + month : null, + day : null + } + if (chg.length == 2) { + if (chg >= '21') { + calendar_change.season = chg; + } else { + calendar_change.month = chg; + } + } else if (chg.length == 4) { + calendar_change.month = chg.substring(0, 2); + calendar_change.day = chg.substring(2, 4); + } + self.calendar_change.push(calendar_change); + }); + } + if (sf == 'y') { + // TODO regularity + } + } + } + + this.add_enum_level = function() { + if (self.enum_levels.length < 6) { + self.enum_levels.push({ + caption : null, + units_per_next_higher : { type : 'und' }, + restart : false + }); + } + } + this.drop_enum_level = function() { + if (self.enum_levels.length > 1) { + self.enum_levels.pop(); + } + } + + this.add_alt_enum_level = function() { + if (self.alt_enum_levels.length < 2) { + self.alt_enum_levels.push({ + caption : null, + units_per_next_higher : { type : 'und' }, + restart : false + }); + } + } + this.drop_alt_enum_level = function() { + if (self.alt_enum_levels.length > 1) { + self.alt_enum_levels.pop(); + } + } + } + // TODO chron only + + // dummy pattern + $scope.pattern = new PredictionPattern(["3","0","8","1","a","v.","b","no.","u","6","v","r","g","sequence","i","(year)","j","(month)","w","m","x","06,12"]); + console.debug($scope.pattern); +}] + } +})