From 6455db11ae7db888e00cad9b02a81197b878ffe5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 18 Jan 2017 16:22:30 -0500 Subject: [PATCH] LP#1646166 Hatch availability display improvements 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 Signed-off-by: Kathy Lussier --- .../admin/workstation/t_print_config.tt2 | 20 +++--- .../ui/default/staff/admin/workstation/app.js | 70 ++++++++++--------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 index 4c88af276d..8cd6bf9747 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 @@ -15,19 +15,15 @@
-

[% l('Remote Printer Settings') %]

- -
-[% l('Remote printing is not available on this browser. The settings below will have no effect.') %] -
+

[% l('Hatch Printer Settings') %]

-[% 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.") %] - [% l('Enable Remote Printing.') %] + [% l('Enable Hatch Printing.') %]

@@ -59,8 +55,12 @@
+
+[% l('Hatch is not installed in this browser. Printing must be configured via the native browser print configuration.') %] +
+ -
+
@@ -100,7 +100,7 @@
-
+
@@ -351,7 +351,7 @@
-
+

[% l('Compiled Printer Settings') %]

{{printerConfString()}}
diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 7de3694222..75804a6d29 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -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(); -- 2.43.2