From: Bill Erickson Date: Thu, 17 Apr 2014 16:01:06 +0000 (-0400) Subject: browser staff : print config UI cont. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1c83dadf6201474ca5145790bb9c3d6ae9578be0;p=working%2FEvergreen.git browser staff : print config UI cont. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 index 38de2931a9..86fd3faaee 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 @@ -1,47 +1,68 @@
-

[% l('Printer Context') %]

+

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

-
- - - - - + +
+
+
+
+
+
+ + +
+ +
+
+
+
+

+

[% l('Printer Test') %]

@@ -64,7 +85,8 @@
+ class="btn btn-default btn-lg pull-right btn-success"> + [% l('Print') %]
@@ -103,6 +125,7 @@ ng-init="htmlPrintContent='

[% l('Welcome, Stranger!') %]

{{value1}}

{{value2}}

+

{{date_value | date}}

'"> diff --git a/Open-ILS/src/templates/staff/css/print.css.tt2 b/Open-ILS/src/templates/staff/css/print.css.tt2 index c7feb78f72..5410ba990b 100644 --- a/Open-ILS/src/templates/staff/css/print.css.tt2 +++ b/Open-ILS/src/templates/staff/css/print.css.tt2 @@ -6,6 +6,7 @@ body div:not([id="print-div"]) { display:none } div { display: none } #print-div { display: block } #print-div div { display: block } +#print-div pre { border: none } [%# vim: ft=css diff --git a/Open-ILS/src/templates/staff/t_navbar.tt2 b/Open-ILS/src/templates/staff/t_navbar.tt2 index b2c80a0a40..9eb14d9c91 100644 --- a/Open-ILS/src/templates/staff/t_navbar.tt2 +++ b/Open-ILS/src/templates/staff/t_navbar.tt2 @@ -83,7 +83,7 @@
  • - [% l('Workstation Administration') %] + [% l('Workstation') %]
  • 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 2c773118f5..e47fc381e3 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 @@ -32,6 +32,9 @@ angular.module('egWorkstationAdmin', ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'e function($scope , egPrintStore) { console.log('PrintingCtrl'); + egPrintStore.printers() + .then(function(printers) { $scope.printers = printers }); + $scope.setContext = function(ctx) { $scope.context = ctx } $scope.setContentType = function(type) { $scope.contentType = type } $scope.testPrint = function() { @@ -41,7 +44,11 @@ function($scope , egPrintStore) { egPrintStore.print( $scope.contentType, $scope.htmlPrintContent, - {'value1' : 'Value One', 'value2' : 'Value Two'} + { + value1 : 'Value One', + value2 : 'Value Two', + date_value : '2015-02-04T14:04:34-0400' + } ); } } diff --git a/Open-ILS/web/js/ui/default/staff/services/printstore.js b/Open-ILS/web/js/ui/default/staff/services/printstore.js index b9596383c5..2dbf595308 100644 --- a/Open-ILS/web/js/ui/default/staff/services/printstore.js +++ b/Open-ILS/web/js/ui/default/staff/services/printstore.js @@ -20,8 +20,8 @@ angular.module('egCoreMod') .factory('egPrintStore', - ['$q','$window','$timeout','$compile','$rootScope', - function($q , $window , $timeout , $compile , $rootScope) { + ['$q','$window','$timeout','$interpolate','$rootScope', + function($q , $window , $timeout , $interpolate , $rootScope) { var service = {}; service.msgId = 0; @@ -38,7 +38,7 @@ angular.module('egCoreMod') var msg2 = {}; // shallow copy and scrub msg before sending angular.forEach(msg, function(val, key) { - if (key.match(/deferred|printScope/)) return; + if (key.match(/deferred/)) return; msg2[key] = val; }); service.socket.send(JSON.stringify(msg2)); @@ -129,6 +129,8 @@ angular.module('egCoreMod') return; } + console.debug("connecting to Hatch..."); + try { service.socket = new WebSocket(service.hatchURL); } catch(e) { @@ -180,13 +182,7 @@ angular.module('egCoreMod') // print locally via the browser service.browserPrint = function(msg) { - // let our local print container handle printing - var content = msg.content; - if (msg.contentType == 'text/html') { - content = - service.processHtmlTemplate(msg.content, msg.printScope) - } - service.onBrowserPrint(msg.contentType, content); + service.onBrowserPrint(msg.contentType, msg.content); msg.success = true; // assume browser print succeeded } @@ -194,38 +190,41 @@ angular.module('egCoreMod') * TODO: local and hatch templates need to go through generation.. * */ - service.processHtmlTemplate = function(template, printScope) { + service.interpolateHtmlTemplate = function(template, printScope) { // TODO: for print template security, we must scrub // the scope object and remove any references to // functions or objects. Otherwise, print templates // would have the power to modify data via the scope var subScope = $rootScope.$new(); angular.forEach(printScope, function(val, key) {subScope[key] = val}); - var element = angular.element(template); - element = $compile(element)(subScope); - console.log('element zero ' + element[0]); - return element[0]; + var html = $interpolate(template)(subScope); + subScope.$destroy(); + return html; } // print the provided content // supported values for contentType are 'text/html' and 'text/plain' service.print = function(contentType, content, printScope) { - if (service.hatchAvailable === false) { - service.browserPrint(contentType, content); - return $q.when(); - } + + if (contentType == 'text/html') { + content = service.interpolateHtmlTemplate(content, printScope); + console.debug('generated HTML ' + content); + } return service.dispatchRequest({ key : 'no-op', action : 'print', content : content, - contentType : contentType, - printScope : printScope + contentType : contentType //printer : printer // TODO: prefs, etc. }); } + service.printers = function() { + return service.dispatchRequest({key : 'no-op', action : 'printers'}); + } + // get the value for a stored item service.getItem = function(key) { return service.dispatchRequest({key : key, action : 'get'}); @@ -307,37 +306,30 @@ angular.module('egCoreMod') .directive('egPrintContainer', function() { return { restrict : 'AE', - template : '
    ' + - '
    ' + - '
    ' + - '' + - '
    {{printContent}}
    ' + - '
    ', - + template : '
    ', controller : ['$scope','$window','$timeout','egPrintStore', function($scope , $window , $timeout, egPrintStore) { - // if contentType == 'text/html', content is a DOM node egPrintStore.onBrowserPrint = function(contentType, content) { - console.log('print content ' + content); - $scope.contentType = contentType; switch(contentType) { case 'text/csv': case 'text/plain': - $scope.printContent = content; - break; + // preserve newlines, spaces, etc. + content = '
    ' + content + '
    '; case 'text/html': // TODO: make this angular-y var div = document.getElementById('eg-print-container-for-html'); while (div.childNodes[0]) div.removeChild(div.childNodes[0]); - div.appendChild(content); + div.innerHTML = content; } // force the template to absorb the data before printing // if an apply/digest loop is not already in progress //if (!$scope.$$phase) $scope.$apply(); + // + // TODO: apply() may no longer be necessary $timeout( function() {