webstaff: update review pane to display pattern summary
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 17:14:50 +0000 (13:14 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 17:14:50 +0000 (13:14 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_pattern_summary.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js

diff --git a/Open-ILS/src/templates/staff/serials/t_pattern_summary.tt2 b/Open-ILS/src/templates/staff/serials/t_pattern_summary.tt2
new file mode 100644 (file)
index 0000000..ce98556
--- /dev/null
@@ -0,0 +1,48 @@
+<div class="container prediction_pattern_summary">
+  <div class="row" ng-if="pattern.use_enum">
+    [% l('Enumeration captions:') %]
+    {{pattern.display_enum_captions()}}
+  </div>
+  <div class="row" ng-if="pattern.use_alt_enum">
+    [% l('Alternative enumeration captions:') %]
+    {{pattern.display_alt_enum_captions()}}
+  </div>
+  <div class="row" ng-if="pattern.use_chron">
+    [% l('Chronology captions:') %]
+    {{pattern.display_chron_captions()}}
+  </div>
+  <div class="row" ng-if="pattern.use_alt_chron">
+    [% l('Alternative chronology captions:') %]
+    {{pattern.display_alt_chron_captions()}}
+  </div>
+  <div class="row">
+    [% l('Frequency:') %]
+    <span ng-if="pattern.frequency_type == 'preset'">
+      <span ng-switch="pattern.frequency_preset">
+        <span ng-switch-when="d">[% l('Daily') %]</span>
+        <span ng-switch-when="w">[% l('Weekly (Weekly)') %]</span>
+        <span ng-switch-when="c">[% l('2 x per week (Semiweekly)') %]</span>
+        <span ng-switch-when="i">[% l('3 x per week (Three times a week)') %]</span>
+        <span ng-switch-when="e">[% l('Every two weeks (Biweekly)') %]</span>
+        <span ng-switch-when="m">[% l('Monthly') %]</span>
+        <span ng-switch-when="s">[% l('2 x per month (Semimonthly)') %]</span>
+        <span ng-switch-when="j">[% l('3 x per month (Three times a month)') %]</span>
+        <span ng-switch-when="b">[% l('Every other month (Bimonthly)') %]</span>
+        <span ng-switch-when="q">[% l('Quarterly') %]</span>
+        <span ng-switch-when="f">[% l('2 x per year (Semiannual)') %]</span>
+        <span ng-switch-when="t">[% l('3 x per year (Three times a year)') %]</span>
+        <span ng-switch-when="a">[% l('Yearly (Annual)') %]</span>
+        <span ng-switch-when="g">[% l('Every other year (Biennial)') %]</span>
+        <span ng-switch-when="h">[% l('Every three years (Triennial)') %]</span>
+        <span ng-switch-when="x">[% l('Completely irregular') %]</span>
+        <span ng-switch-when="k">[% l('Continuously updated') %]</span>
+      </span>
+    </span>
+    <span ng-if="pattern.frequency_type == 'numeric'">
+      [% l('[_1] issues per year', '{{pattern.frequency_numeric}}') %]
+    </span>
+  </div>
+  <div class="row" ng-if="pattern.use_regularity">
+    [% l('Specifies regularity adjustments') %]
+  </div>
+</div>
index 0a4e33e..6a30a11 100644 (file)
     </uib-tab>
     <uib-tab index="4" disable="tab.active != 4" heading="[% l('Review') %]">
       <div class="row">
-        Pattern code: {{pattern.compile()}}
+        <div class="col-md-2">
+          <span class="strong-text-2">[% l('Raw Pattern Code') %]</span>
+          <a class="pull-right" href ng-click="show_pattern_code = false"
+              title="[% l('Hide Raw Pattern Code') %]"
+              ng-show="show_pattern_code">
+              <span class="glyphicon glyphicon-resize-small"></span>
+          </a>
+          <a class="pull-right" href ng-click="show_pattern_code = true"
+              title="[% l('Show Raw Pattern Code') %]"
+              ng-hide="show_pattern_code">
+              <span class="glyphicon glyphicon-resize-full"></span>
+          </a>
+        </div>
+        <div class="col-md-6" ng-show="show_pattern_code">
+          <pre>{{pattern.compile_stringify()}}</pre>
+        </div>
+      </div>
+      <div class="row">
+        <div class="col-md-2">
+          <span class="strong-text-2">[% l('Pattern Summary') %]</span>
+        </div>
+        <div class="col-md-6">
+          <eg-prediction-pattern-summary pattern="pattern"></eg-prediction-pattern-summary>
+        </div>
       </div>
       <div class="row">
         <div class="col-md-2">
index 01e8e3b..ff370fc 100644 (file)
@@ -357,7 +357,11 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) {
                     patternCode.push(val);
                 });
             }
-            return JSON.stringify(patternCode);
+            return patternCode;
+        }
+
+        this.compile_stringify = function() {
+            return JSON.stringify(this.compile(), null, 2);
         }
 
         this.add_enum_level = function() {
@@ -447,6 +451,26 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) {
             }
         }
 
+        this.display_enum_captions = function() {
+            return self.enum_levels.map(function(lvl) {
+                return lvl.caption;
+            }).join(', ');
+        }
+        this.display_alt_enum_captions = function() {
+            return self.alt_enum_levels.map(function(lvl) {
+                return lvl.caption;
+            }).join(', ');
+        }
+        this.display_chron_captions = function() {
+            return self.chron_levels.map(function(lvl) {
+                return lvl.caption;
+            }).join(', ');
+        }
+        this.display_alt_chron_captions = function() {
+            return self.alt_chron_levels.map(function(lvl) {
+                return lvl.caption;
+            }).join(', ');
+        }
     }
     // TODO chron only
 
@@ -557,3 +581,19 @@ function($scope , $q) {
 }]
     }
 })
+
+.directive('egPredictionPatternSummary', function() {
+    return {
+        transclude: true,
+        restrict:   'E',
+        scope: {
+            pattern : '<'
+        },
+        templateUrl: './serials/t_pattern_summary',
+        controller:
+       ['$scope','$q',
+function($scope , $q) {
+}]
+    }
+})
+