webstaff: UI for setting pattern regularity
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 2 May 2017 21:56:08 +0000 (17:56 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:40 +0000 (12:06 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_day_of_week_selector.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2
Open-ILS/src/templates/staff/serials/t_week_in_month_selector.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js

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 (file)
index 0000000..1941861
--- /dev/null
@@ -0,0 +1,9 @@
+<select ng-model="ngModel">
+  <option value="mo">[% l('Monday') %]</option>
+  <option value="tu">[% l('Tuesday') %]</option>
+  <option value="we">[% l('Wednesday') %]</option>
+  <option value="th">[% l('Thursday') %]</option>
+  <option value="fr">[% l('Friday') %]</option>
+  <option value="sa">[% l('Saturday') %]</option>
+  <option value="su">[% l('Sunday') %]</option>
+</select>
index 2ab95cc..fa9b884 100644 (file)
         </div>
       </div>
       <div class="row">
+        <div class="checkbox">
+          <label>
+            <input type="checkbox" ng-model="pattern.use_regularity">
+            [% l('Use specific regularity information?') %]
+          </label>
+            <em>[% l('(combined issues, skipped issues, etc.)') %]</em>
+         </div>
+         <div class="row" ng-if="pattern.use_regularity">
+            <div class="row pad-vert" ng-repeat="reg in pattern.regularity">
+               <div class="col-md-2">
+                 <button ng-click="pattern.remove_regularity($index)"
+                         class="btn btn-sm btn-warning">
+                   [% l('Remove Regularity') %]
+                 </button>
+                 <button ng-if="$last" ng-click="pattern.add_regularity()"
+                         class="btn btn-sm btn-warning">
+                   [% l('Add Regularity') %]
+                 </button>
+               </div>
+               <div class="col-md-1">
+                 <select ng-model="reg.regularity_type">
+                   <option value="p">[% l('Published') %]</option>
+                   <option value="o">[% l('Omitted') %]</option>
+                   <option value="c">[% l('Combined') %]</option>
+                 </select>
+               </div>
+               <div class="col-md-1">
+                 <select ng-model="reg.chron_type">
+                   <option value="d">[% l('Day') %]</option>
+                   <option value="w">[% l('Week') %]</option>
+                   <option value="m">[% l('Month') %]</option>
+                   <option value="s">[% l('Season') %]</option>
+                   <option value="y">[% l('Year') %]</option>
+                 </select>
+               </div>
+               <div class="col-md-6">
+                 <div class="row" ng-repeat="part in reg.parts">
+                   <div class="col-md-8">
+                     <div ng-if="reg.chron_type == 's'">
+                       <label>[% l('Every') %] <eg-season-selector ng-model="part.season"></eg-season-selector></label>
+                     </div>
+                     <div ng-if="reg.chron_type == 'm'">
+                       <label>[% l('Every') %] <eg-month-selector ng-model="part.month"></eg-month-selector></label>
+                     </div>
+                     <div ng-if="reg.chron_type == 'd'">
+                       <select ng-model="part.sub_type">
+                         <option value="day_of_month">[% l('On day of month') %]</option>
+                         <option value="specific_date">[% l('On specific date') %]</option>
+                         <option value="day_of_week">[% l('On day of week') %]</option>
+                       </select>
+                       <div ng-if="part.sub_type == 'day_of_month'">
+                         <input type="number" step="1" min="1" max="31" ng-model="part.day_of_month">
+                       </div>
+                       <div ng-if="part.sub_type == 'specific_date'">
+                          <eg-month-day-selector day="part.day" month="part.month"></eg-month-day-selector>
+                       </div>
+                       <div ng-if="part.sub_type == 'day_of_week'">
+                          <eg-day-of-week-selector ng-model="part.day_of_week"></eg-day-of-week-selector>
+                       </div>
+                     </div>
+                     <div ng-if="reg.chron_type == 'w'">
+                       <select ng-model="part.sub_type">
+                         <option value="week_in_month">[% l('Week and month') %]</option>
+                         <option value="week_day">[% l('Week and day') %]</option>
+                         <option value="week_day_in_month">[% l('Week, month, and day') %]</option>
+                       </select>
+                       <div ng-if="part.sub_type == 'week_in_month'">
+                         <eg-week-in-month-selector ng-model="part.week"></eg-week-in-month-selector>
+                         [% l('week in') %]
+                         <eg-month-selector ng-model="part.month"></eg-month-selector>
+                       </div>
+                       <div ng-if="part.sub_type == 'week_day'">
+                         <eg-week-in-month-selector ng-model="part.week"></eg-week-in-month-selector>
+                         [% l('week on') %]
+                         <eg-day-of-week-selector ng-model="part.day"></eg-day-of-week-selector>
+                       </div>
+                       <div ng-if="part.sub_type == 'week_day_in_month'">
+                         <eg-week-in-month-selector ng-model="part.week"></eg-week-in-month-selector>
+                         [% l('week on') %]
+                         <eg-day-of-week-selector ng-model="part.day"></eg-day-of-week-selector>
+                         [% l('in') %]
+                         <eg-month-selector ng-model="part.month"></eg-month-selector>
+                       </div>
+                     </div>
+                     <div ng-if="reg.chron_type == 'y'">
+                       <input type="number" min="1" max="9999" ng-model="part.year">
+                     </div>
+                   </div>
+                   <div class="col-md-4">
+                     <button  ng-click="pattern.remove__regularity_part(reg, $index)"
+                             class="btn btn-xs btn-warning">
+                       [% l('Remove Part') %]
+                     </button>
+                     <button ng-if="$last" ng-click="pattern.add_regularity_part(reg)"
+                             class="btn btn-xs btn-warning">
+                       [% l('Add Part') %]
+                     </button>
+                   </div>
+                 </div>
+               </div>
+            </div>
+         </div>
+      </div>
+      <div class="row">
         <button class="btn btn-warning pull-left" ng-click="tab.active = tab.active - 1">
             [% l('Back') %]
         </button>
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 (file)
index 0000000..56b1f55
--- /dev/null
@@ -0,0 +1,11 @@
+<select ng-model="ngModel">
+  <option value="99">[% l('Last') %]</option>
+  <option value="98">[% l('Next to Last') %]</option>
+  <option value="97">[% l('Third to Last') %]</option>
+  <option value="00">[% l('Every') %]</option>
+  <option value="01">[% l('First') %]</option>
+  <option value="02">[% l('Second') %]</option>
+  <option value="03">[% l('Third') %]</option>
+  <option value="04">[% l('Fourth') %]</option>
+  <option value="05">[% l('Fifth') %]</option>
+</select>
index 8437f18..beb2b15 100644 (file)
@@ -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,