From 89172664c2d548c220fcd87dc0a6ec4adcddfe56 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 2 May 2017 17:56:08 -0400 Subject: [PATCH] webstaff: UI for setting pattern regularity Signed-off-by: Galen Charlton --- .../staff/serials/t_day_of_week_selector.tt2 | 9 ++ .../staff/serials/t_prediction_wizard.tt2 | 104 +++++++++++++++++++++ .../staff/serials/t_week_in_month_selector.tt2 | 11 +++ .../staff/serials/directives/prediction_wizard.js | 84 ++++++++++++++++- 4 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/templates/staff/serials/t_day_of_week_selector.tt2 create mode 100644 Open-ILS/src/templates/staff/serials/t_week_in_month_selector.tt2 diff --git a/Open-ILS/src/templates/staff/serials/t_day_of_week_selector.tt2 b/Open-ILS/src/templates/staff/serials/t_day_of_week_selector.tt2 new file mode 100644 index 0000000000..19418611f0 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_day_of_week_selector.tt2 @@ -0,0 +1,9 @@ + 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 2ab95cc364..fa9b884eb4 100644 --- a/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2 @@ -302,6 +302,110 @@
+
+ + [% l('(combined issues, skipped issues, etc.)') %] +
+
+
+
+ + +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+ + [% l('week in') %] + +
+
+ + [% l('week on') %] + +
+
+ + [% l('week on') %] + + [% l('in') %] + +
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
diff --git a/Open-ILS/src/templates/staff/serials/t_week_in_month_selector.tt2 b/Open-ILS/src/templates/staff/serials/t_week_in_month_selector.tt2 new file mode 100644 index 0000000000..56b1f550da --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_week_in_month_selector.tt2 @@ -0,0 +1,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 8437f186ce..beb2b15e3d 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 @@ -33,9 +33,11 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { this.chron_levels = []; this.alt_chron_levels = []; this.frequency_type = 'preset'; + this.use_regularity = false; + this.regularity = []; var nr_sf_map = { - '0' : 'link', + '8' : 'link', 'n' : 'note', 'p' : 'pieces_per_issuance', 'w' : 'frequency', @@ -186,7 +188,55 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) { }); } if (sf == 'y') { - // TODO regularity + this.use_regularity = true; + var regularity_type = value.substring(0, 1); + var parts = []; + var chron_type = value.substring(1, 2); + value.substring(2).split(/,/).forEach(function(value) { + var piece = {}; + if (chron_type == 'd') { + if (value.match(/^\d\d$/)) { + piece.sub_type = 'day_of_month'; + piece.day_of_month = value; + } else if (value.match(/^\d\d\d\d$/)) { + piece.sub_type = 'specific_date'; + piece.specific_date = value; + } else { + piece.sub_type = 'day_of_week'; + piece.day_of_week = value; + } + } else if (chron_type == 'm') { + piece.sub_type = 'month'; + piece.month = value; + } else if (chron_type == 's') { + piece.sub_type = 'season'; + piece.season = value; + } else if (chron_type == 'w') { + if (value.match(/^\d\d\d\d$/)) { + piece.sub_type = 'week_in_month'; + piece.week = value.substring(0, 2); + piece.month = value.substring(2, 4); + } else if (value.match(/^\d\d[a-z][a-z]$/)) { + piece.sub_type = 'week_day'; + piece.week = value.substring(0, 2); + piece.day = value.substring(2, 4); + } else if (value.length == 6) { + piece.sub_type = 'week_day_in_month'; + piece.month = value.substring(0, 2); + piece.week = value.substring(2, 4); + piece.day = value.substring(4, 6); + } + } else if (chron_type == 'y') { + piece.sub_type = 'year'; + piece.year = value; + } + parts.push(piece); + }); + self.regularity.push({ + regularity_type : regularity_type, + chron_type : chron_type, + parts : parts + }); } } } @@ -296,6 +346,36 @@ function($scope , $q) { } }) +.directive('egWeekInMonthSelector', function() { + return { + transclude: true, + restrict: 'E', + scope: { + ngModel : '=' + }, + templateUrl: './serials/t_week_in_month_selector', + controller: + ['$scope','$q', +function($scope , $q) { +}] + } +}) + +.directive('egDayOfWeekSelector', function() { + return { + transclude: true, + restrict: 'E', + scope: { + ngModel : '=' + }, + templateUrl: './serials/t_day_of_week_selector', + controller: + ['$scope','$q', +function($scope , $q) { +}] + } +}) + .directive('egMonthDaySelector', function() { return { transclude: true, -- 2.11.0