From 4ab840ad26a3b65e035097e828a02742e2e41e2e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 18 Nov 2016 16:01:47 -0500 Subject: [PATCH] LP#1642761 Hatch print config UI WIP Signed-off-by: Bill Erickson --- .../staff/admin/workstation/t_print_config.tt2 | 18 ++++++ .../js/ui/default/staff/admin/workstation/app.js | 65 ++++++---------------- Open-ILS/web/js/ui/default/staff/services/hatch.js | 6 +- 3 files changed, 39 insertions(+), 50 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 a771b45e51..f986bf344e 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 @@ -315,6 +315,24 @@ + +
+
+
+ +
+
+ +
+
+ +
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 79095b1527..f276c1b452 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 @@ -220,15 +220,11 @@ function($scope , $window , $location , egCore , egConfirmDialog) { .controller('PrintConfigCtrl', ['$scope','egCore', function($scope , egCore) { - console.log('PrintConfigCtrl'); - - $scope.actionPending = false; - $scope.isTestView = false; + $scope.printConfig = {}; $scope.setContext = function(ctx) { $scope.context = ctx; $scope.isTestView = false; - $scope.actionPending = false; } $scope.setContext('default'); @@ -240,14 +236,6 @@ function($scope , egCore) { return printer; } - $scope.currentPrinter = function() { - if ($scope.printConfig && $scope.printConfig[$scope.context]) { - return $scope.getPrinterByAttr( - 'name', $scope.printConfig[$scope.context].printer - ); - } - } - // fetch info on all remote printers egCore.hatch.getPrinters() .then(function(printers) { @@ -260,35 +248,34 @@ function($scope , egCore) { $scope.defaultPrinter = def; loadPrinterOptions(def.name); } - }) - .then(function() { - $scope.printConfig = {}; - - // apply the default printer to every context which has - // no printer configured. + }).then(function() { angular.forEach( ['default','receipt','label','mail','offline'], function(ctx) { egCore.hatch.getPrintConfig(ctx).then(function(conf) { - if (!conf) { - conf = { - context : ctx, - printer : $scope.defaultPrinter.name, - autoMargins : true, - allPages : true, - pageRanges : [] - }; + if (conf) { + $scope.printConfig[ctx] = conf; + } else { + $scope.resetPrinterSettings(ctx); } - $scope.printConfig[ctx] = conf; }); } ); }); + $scope.resetPrinterSettings = function(context) { + $scope.printConfig[context] = { + context : context, + printer : $scope.defaultPrinter ? $scope.defaultPrinter.name : null, + autoMargins : true, + allPages : true, + pageRanges : [] + }; + } - $scope.usingManualMargins = function(ctx) { - var conf = $scope.printConfig[ctx]; - return conf && conf.marginType; + $scope.savePrinterSettings = function(context) { + return egCore.hatch.setPrintConfig( + context, $scope.printConfig[context]); } $scope.printerConfString = function() { @@ -299,22 +286,6 @@ function($scope , egCore) { $scope.printConfig[$scope.context], undefined, 2); } - $scope.resetConfig = function() { - $scope.actionPending = true; - $scope.printConfigError = null; - $scope.printConfig[$scope.context] = { - context : $scope.context - } - - if ($scope.defaultPrinter) { - $scope.printConfig[$scope.context].printer = - $scope.defaultPrinter.name; - } - - egCore.hatch.setPrintConfig($scope.printConfig) - .finally(function() {$scope.actionPending = false}); - } - function loadPrinterOptions(name) { egCore.hatch.getPrinterOptions(name).then( function(options) {$scope.printerOptions = options}); diff --git a/Open-ILS/web/js/ui/default/staff/services/hatch.js b/Open-ILS/web/js/ui/default/staff/services/hatch.js index e552d7e714..c235294473 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -192,12 +192,12 @@ angular.module('egCoreMod') service.remotePrint = function( context, contentType, content, withDialog) { - return service.getPrintConfig().then( - function(conf) { + return service.getPrintConfig(context).then( + function(config) { // print configuration retrieved; print return service.attemptHatchDelivery({ action : 'print', - config : conf[context], + settings : config, content : content, contentType : contentType, showDialog : withDialog, -- 2.11.0