LP#1646166 Hatch availability display improvements
authorBill Erickson <berickxx@gmail.com>
Wed, 18 Jan 2017 21:22:30 +0000 (16:22 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 26 Jan 2017 15:26:18 +0000 (10:26 -0500)
Hide printer settings in the print config UI when Hatch is not available
and provide better inline alerts.  Avoid attempts by the printer config
UI from talking to Hatch when Hatch is known not to be available.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js

index 4c88af2..8cd6bf9 100644 (file)
 
   <div class="row"> 
     <div class="col-md-12">
-      <h2>[% l('Remote Printer Settings') %]</h2>
-
-      <div class="alert alert-warning" ng-if="!hatchIsOpen()">
-[% l('Remote printing is not available on this browser.  The settings below will have no effect.') %]
-      </div>
+      <h2>[% l('Hatch Printer Settings') %]</h2>
 
       <div class="alert alert-warning" 
         ng-if="hatchIsOpen() && !useHatchPrinting()">
         <p>
-[% l("Remote printing is not enabled on this browser.  The settings below will have no effect until remote printing is enabled.") %]
+[% l("Hatch printing is not enabled on this browser.  The settings below will have no effect until Hatch printing is enabled.") %]
           <a href="./admin/workstation/hatch" target="_self" 
             title="[% l('Hatch Administration') %]">
-            [% l('Enable Remote Printing.') %]
+            [% l('Enable Hatch Printing.') %]
           </a>
         </p>
       </div>
       <div class="tab-content">
         <div class="tab-pane active">
 
+          <div class="alert alert-warning" ng-if="!isTestView && !hatchIsOpen()">
+[% l('Hatch is not installed in this browser.  Printing must be configured via the native browser print configuration.') %]
+          </div>
+
           <!-- printer config UI -->
-          <div class="row" ng-hide="isTestView">
+          <div class="row" ng-hide="isTestView || !hatchIsOpen()">
             <div class="col-md-6">
               <div class="input-group">
                 <div class="input-group-btn" uib-dropdown>
             </div>
           </div><!-- row -->
 
-          <div class="row" ng-hide="isTestView"> 
+          <div class="row" ng-hide="isTestView || !hatchIsOpen()"> 
             <div class="col-md-10">
               <div class="row">
                 <div class="col-md-1"></div>
             </div><!-- col -->
           </div><!-- row -->
 
-          <div class="row" ng-hide="isTestView">
+          <div class="row" ng-hide="isTestView || !hatchIsOpen()">
             <div class="col-md-12">
               <h3>[% l('Compiled Printer Settings') %]</h3>
               <pre>{{printerConfString()}}</pre>
index c5a4c76..ced569d 100644 (file)
@@ -223,6 +223,9 @@ function($scope , egCore) {
     }
     $scope.setContext('default');
 
+    $scope.setContentType = function(type) { $scope.contentType = type }
+    $scope.setContentType('text/plain');
+
     $scope.useHatchPrinting = function() {
         return egCore.hatch.usePrinting();
     }
@@ -239,33 +242,6 @@ function($scope , egCore) {
         return printer;
     }
 
-    // fetch info on all remote printers
-    egCore.hatch.getPrinters()
-    .then(function(printers) { 
-        $scope.printers = printers;
-
-        var def = $scope.getPrinterByAttr('is-default', true);
-        if (!def && printers.length) def = printers[0];
-
-        if (def) {
-            $scope.defaultPrinter = def;
-            loadPrinterOptions(def.name);
-        }
-    }).then(function() {
-        angular.forEach(
-            ['default','receipt','label','mail','offline'],
-            function(ctx) {
-                egCore.hatch.getPrintConfig(ctx).then(function(conf) {
-                    if (conf) {
-                        $scope.printConfig[ctx] = conf;
-                    } else {
-                        $scope.resetPrinterSettings(ctx);
-                    }
-                });
-            }
-        );
-    });
-
     $scope.resetPrinterSettings = function(context) {
         $scope.printConfig[context] = {
             context : context,
@@ -299,9 +275,6 @@ function($scope , egCore) {
         loadPrinterOptions(name);
     }
 
-    // for testing
-    $scope.setContentType = function(type) { $scope.contentType = type }
-
     $scope.testPrint = function(withDialog) {
         if ($scope.contentType == 'text/plain') {
             egCore.print.print({
@@ -325,7 +298,36 @@ function($scope , egCore) {
         }
     }
 
-    $scope.setContentType('text/plain');
+    // Load startup data....
+    // Don't bother talking to Hatch if it's not there.
+    if (!egCore.hatch.hatchAvailable) return;
+
+    // fetch info on all remote printers
+    egCore.hatch.getPrinters()
+    .then(function(printers) { 
+        $scope.printers = printers;
+
+        var def = $scope.getPrinterByAttr('is-default', true);
+        if (!def && printers.length) def = printers[0];
+
+        if (def) {
+            $scope.defaultPrinter = def;
+            loadPrinterOptions(def.name);
+        }
+    }).then(function() {
+        angular.forEach(
+            ['default','receipt','label','mail','offline'],
+            function(ctx) {
+                egCore.hatch.getPrintConfig(ctx).then(function(conf) {
+                    if (conf) {
+                        $scope.printConfig[ctx] = conf;
+                    } else {
+                        $scope.resetPrinterSettings(ctx);
+                    }
+                });
+            }
+        );
+    });
 
 }])
 
@@ -661,8 +663,10 @@ function($scope , $q , egCore , egConfirmDialog) {
     function refreshKeys() {
         $scope.keys = {local : [], remote : []};
 
-        egCore.hatch.getRemoteKeys().then(
-            function(keys) { $scope.keys.remote = keys.sort() })
+        if (egCore.hatch.hatchAvailable) {
+            egCore.hatch.getRemoteKeys().then(
+                function(keys) { $scope.keys.remote = keys.sort() })
+        }
     
         // local calls are non-async
         $scope.keys.local = egCore.hatch.getLocalKeys();