browser staff : print config UI cont.
authorBill Erickson <berick@esilibrary.com>
Wed, 23 Apr 2014 14:14:53 +0000 (10:14 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 23 Apr 2014 14:14:53 +0000 (10:14 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/services/printstore.js

index c4eb1dc..9ae2a3c 100644 (file)
@@ -38,6 +38,7 @@ function($scope , egPrintStore) {
     $scope.setContext = function(ctx) { 
         $scope.context = ctx; 
         $scope.isTestView = false;
+        $scope.actionPending = false;
     }
     $scope.setContext('default');
 
@@ -86,6 +87,7 @@ function($scope , egPrintStore) {
     });
 
     $scope.printerConfString = function() {
+        if ($scope.printConfigError) return $scope.printConfigError;
         if (!$scope.printConfig) return;
         if (!$scope.printConfig[$scope.context]) return;
         return JSON.stringify(
@@ -93,6 +95,8 @@ function($scope , egPrintStore) {
     }
 
     $scope.resetConfig = function() {
+        $scope.actionPending = true;
+        $scope.printConfigError = null;
         $scope.printConfig[$scope.context] = {
             context : $scope.context
         }
@@ -101,15 +105,22 @@ function($scope , egPrintStore) {
             $scope.printConfig[$scope.context].printer = 
                 $scope.defaultPrinter.name;
         }
+
+        egPrintStore.setPrintConfig($scope.printConfig)
+        .finally(function() {$scope.actionPending = false});
     }
 
     $scope.configurePrinter = function() {
+        $scope.printConfigError = null;
         $scope.actionPending = true;
         egPrintStore.configurePrinter(
             $scope.context,
             $scope.printConfig[$scope.context].printer
         )
-        .then(function(config) {$scope.printConfig = config})
+        .then(
+            function(config) {$scope.printConfig = config},
+            function(error) {$scope.printConfigError = error}
+        )
         .finally(function() {$scope.actionPending = false});
     }
 
index cd8dfcc..8992db2 100644 (file)
@@ -246,7 +246,7 @@ angular.module('egCoreMod')
         });
     }
 
-    service.setPrintConfig = function() {
+    service.setPrintConfig = function(conf) {
         service.printConfig = conf;
         return service.setItem('eg.printing.config', conf);
     }
@@ -271,8 +271,12 @@ angular.module('egCoreMod')
 
         // set the returned settings to the requested context
         .then(function(newconf) {
-            newconf.printer = printer;
-            return service.printConfig[context] = newconf;
+            if (angular.isObject(newconf)) {
+                newconf.printer = printer;
+                return service.printConfig[context] = newconf;
+            } else {
+                console.warn("configurePrinter() returned " + newconf);
+            }
         })
 
         // store the newly linked settings