handle no-default printer scenario in print config
authorBill Erickson <berick@esilibrary.com>
Mon, 12 May 2014 13:54:50 +0000 (09:54 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 12 May 2014 13:54:50 +0000 (09:54 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js

index c074176..b0ec9aa 100644 (file)
@@ -188,7 +188,15 @@ function($scope , egCore) {
     .then(function(config) {
         $scope.printConfig = config;
 
-        if (!$scope.defaultPrinter) return;
+        var pname = '';
+        if ($scope.defaultPrinter) {
+            pname = $scope.defaultPrinter.name;
+
+        } else if ($scope.printers.length == 1) {
+            // if the OS does not report a default printer, but only
+            // one printer is available, treat it as the default.
+            pname = $scope.printers[0].name;
+        }
 
         // apply the default printer to every context which has
         // no printer configured.
@@ -198,7 +206,7 @@ function($scope , egCore) {
                 if (!$scope.printConfig[ctx]) {
                     $scope.printConfig[ctx] = {
                         context : ctx,
-                        printer : $scope.defaultPrinter.name
+                        printer : pname
                     }
                 }
             }