webstaff: finish implementing updating patterns
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 20:38:17 +0000 (16:38 -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_prediction_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js

index f406013..2872034 100644 (file)
@@ -25,7 +25,7 @@
         <button class="btn btn-default" ng-click="openPatternEditorDialog(pred)">[% l('Edit Pattern') %]</button>
     </div>
     <div>
-        <button class="btn btn-primary" ng-disabled="!pred.predform.$dirty">[% l('Save') %]</button>
+        <button type="submit" class="btn btn-primary" ng-disabled="!pred.predform.$dirty" ng-click="updateScap(pred)">[% l('Save') %]</button>
     </div>
     </form>
   </div>
index 2a45a95..7be34ea 100644 (file)
@@ -28,6 +28,18 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
         if (newVal && newVal != oldVal) reload(newVal);
     });
 
+    $scope.updateScap = function(pred) {
+        var scap = egCore.idl.fromTypedHash(pred);
+        egCore.pcrud.update(scap).then(function() {
+            // completely reset the model in order to reset the
+            // forms; causes a blink, alas
+            $scope.predictions = [];
+            egSerialsCoreSvc.fetch($scope.bibId).then(function() {
+                reload($scope.ssubId);
+            });
+        });
+    }
+
     $scope.openPatternEditorDialog = function(pred) {
         $uibModal.open({
             templateUrl: './serials/t_pattern_editor_dialog',
@@ -41,8 +53,8 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                 $scope.cancel = function () { $uibModalInstance.dismiss() }
             }]
         }).result.then(function (patternCode) {
-            if (pred.patternCode !== patternCode) {
-                pred.patternCode = patternCode;
+            if (pred.pattern_code !== patternCode) {
+                pred.pattern_code = patternCode;
                 pred.predform.$setDirty();        
             }
         });