webstaff: embed serials prediction wizard into modal
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 19:36:43 +0000 (15:36 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:41 +0000 (12:06 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_manage.tt2
Open-ILS/src/templates/staff/serials/t_pattern_editor_dialog.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2
Open-ILS/src/templates/staff/serials/t_prediction_wizard.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_wizard.js

index 8791b1f..38758d0 100644 (file)
@@ -15,7 +15,6 @@
         <eg-prediction-manager ng-if="active_tab == 'prediction'"
             bib-id="bib_id" ssub-id="ssub.id">
         </eg-prediction-manager>
-<eg-prediction-wizard></eg-prediction-wizard>
       </uib-tab>
       <uib-tab index="'view-issues'" heading="[% l('View Issues') %]">
         <p>View Issues TODO</p>
diff --git a/Open-ILS/src/templates/staff/serials/t_pattern_editor_dialog.tt2 b/Open-ILS/src/templates/staff/serials/t_pattern_editor_dialog.tt2
new file mode 100644 (file)
index 0000000..a42db74
--- /dev/null
@@ -0,0 +1,13 @@
+<!-- use <form> so we get submit-on-enter for free -->
+<div>
+  <div class="modal-header">
+    <button type="button" class="close" 
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Edit Prediction Pattern') %]</h4>
+  </div>
+  <div class="modal-body">
+    <div class="container-fluid">
+      <eg-prediction-wizard pattern-code="patternCode" on-save="ok"></eg-prediction-wizard pattern-code>
+   </div>
+ </div>
+</div> <!-- modal-content -->
index ea0c9af..a68e181 100644 (file)
@@ -22,7 +22,7 @@
             <option value="supplement">[% l('Supplement') %]</option>
             <option value="index">[% l('Index') %]</option>
         </select>
-        <button class="btn btn-default">[% l('Edit Pattern') %]</button>
+        <button class="btn btn-default" ng-click="openPatternEditorDialog(pred)">[% l('Edit Pattern') %]</button>
     </div>
     <div>
         <button class="btn btn-primary" ng-disabled="!predform.$dirty">[% l('Save') %]</button>
index 6a30a11..976dd0a 100644 (file)
         <button class="btn btn-warning pull-left" ng-click="tab.active = tab.active - 1">
             [% l('Back') %]
         </button>
-        <button class="btn btn-primary pull-right">
+        <button class="btn btn-primary pull-right" ng-click="handle_save()">
             [% l('Save') %]
         </button>
       </div>
index fe5d5ba..e64ebb1 100644 (file)
@@ -28,6 +28,26 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
         if (newVal && newVal != oldVal) reload(newVal);
     });
 
+    $scope.openPatternEditorDialog = function(pred) {
+        $uibModal.open({
+            templateUrl: './serials/t_pattern_editor_dialog',
+            size: 'lg',
+            windowClass: 'eg-wide-modal',
+            controller:
+                ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
+                $scope.focusMe = true;
+                $scope.patternCode = pred.pattern_code;
+                $scope.ok = function(patternCode) { $uibModalInstance.close(patternCode) }
+                $scope.cancel = function () { $uibModalInstance.dismiss() }
+            }]
+        }).result.then(function (patternCode) {
+            if (pred.patternCode !== patternCode) {
+                pred.patternCode = patternCode;
+                
+            }
+        });
+    }
+
 }]
     }
 })
index ff370fc..5ac7909 100644 (file)
@@ -5,7 +5,8 @@ angular.module('egSerialsAppDep')
         transclude: true,
         restrict:   'E',
         scope: {
-            patternCode : '='
+            patternCode : '=',
+            onSave      : '='
         },
         templateUrl: './serials/t_prediction_wizard',
         controller:
@@ -474,9 +475,14 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider) {
     }
     // 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","m","(day)","w","m","x","06,12","y","pw02we","y","ow0402th,0501"]);
-    console.debug($scope.pattern);
+    $scope.pattern = new PredictionPattern(JSON.parse($scope.patternCode));
+    $scope.handle_save = function() {
+        $scope.patternCode = JSON.stringify($scope.pattern.compile());
+        if (angular.isFunction($scope.onSave)) {
+            $scope.onSave($scope.patternCode);
+        }
+    }
+
 }]
     }
 })