From: Bill Erickson Date: Thu, 29 May 2014 17:00:42 +0000 (-0400) Subject: initial print templates config UI X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9b36657d63bcea27d84c8fb6729f89b0dba12691;p=working%2FEvergreen.git initial print templates config UI Signed-off-by: Bill Erickson --- 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 new file mode 100644 index 0000000000..f90fc01a3c --- /dev/null +++ b/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 @@ -0,0 +1,176 @@ +
+ + + +
+
+

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

+
+
+ +
+
+ +
+
+ + +
+
+
+
+ + +
+ + + +
+
+
+
+
+ + +
+
+
+
+
+
+

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

+
{{printerConfString()}}
+
+
+ + +
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 new file mode 100644 index 0000000000..cda10b2fd9 --- /dev/null +++ b/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 @@ -0,0 +1,43 @@ + + +

[% l('Print Templates') %]

+ +
+
[% l('Template Name') %]
+
+ +
+
+
+ + +
+
+ +
+ +
+ +
+
+

[% l('Preview') %]

+
+
+
+

[% l('Template') %]

+
+ +
+
+
+ diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 deleted file mode 100644 index f90fc01a3c..0000000000 --- a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 +++ /dev/null @@ -1,176 +0,0 @@ -
- - - -
-
-

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

-
-
- -
-
- -
-
- - -
-
-
-
- - -
- - - -
-
-
-
-
- - -
-
-
-
-
-
-

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

-
{{printerConfString()}}
-
-
- - -
-
-
- - -
-
-
-
-
- - -
-
-
-
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
-
- diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 index 40287c56c1..3a14bbeb73 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 @@ -93,7 +93,7 @@
@@ -101,6 +101,15 @@
+
+ +
+
[% l('Stored Preferences') %] diff --git a/Open-ILS/src/templates/staff/share/print_templates/index.tt2 b/Open-ILS/src/templates/staff/share/print_templates/index.tt2 new file mode 100644 index 0000000000..0bcedf0290 --- /dev/null +++ b/Open-ILS/src/templates/staff/share/print_templates/index.tt2 @@ -0,0 +1,2 @@ +[% USE CGI %] +[% l('Print Template Not Found: [_1]', CGI.url("-path",1,"-relative",1)) %] diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2 new file mode 100644 index 0000000000..71e6bf23f9 --- /dev/null +++ b/Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2 @@ -0,0 +1,52 @@ +Welcome to {{current_location.name}}!
+You have the following bills: +
+ +{{xact.id}} +
+ +
+
Bill #{{xact.id}}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% l('Date:') %]{{xact.xact_start | date:'short'}}
[% l('Type') %]:{{xact.summary.xact_type}}
[% l('Last Billing') %]:{{xact.summary.last_billing_type}}
+ {{xact.summary.last_billing_note}} +
[% l('Total Billed') %]:{{xact.summary.total_owed | currency}}
[% l('Last Payment') %]:{{xact.summary.last_payment_type}}
+ {{xact.summary.last_payment_note}} +
[% l('Total Paid') %]:{{xact.summary.total_paid | currency}}
[% l('Balance') %]:{{xact.summary.balance_owed | currency}}
+
+
+
+
+
+{{current_location.shortname}} {{today | date:'short'}} +

+ 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 b0ec9aa574..9e3a104eb0 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 @@ -14,9 +14,15 @@ angular.module('egWorkstationAdmin', $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); var resolver = {delay : function(egStartup) {return egStartup.go()}}; - $routeProvider.when('/admin/workstation/printing', { - templateUrl: './admin/workstation/t_printing', - controller: 'PrintingCtrl', + $routeProvider.when('/admin/workstation/print/config', { + templateUrl: './admin/workstation/t_print_config', + controller: 'PrintConfigCtrl', + resolve : resolver + }); + + $routeProvider.when('/admin/workstation/print/templates', { + templateUrl: './admin/workstation/t_print_templates', + controller: 'PrintTemplatesCtrl', resolve : resolver }); @@ -146,10 +152,10 @@ function($scope , $window , $location , egCore) { } }]) -.controller('PrintingCtrl', +.controller('PrintConfigCtrl', ['$scope','egCore', function($scope , egCore) { - console.log('PrintingCtrl'); + console.log('PrintConfigCtrl'); $scope.actionPending = false; $scope.isTestView = false; @@ -286,6 +292,90 @@ function($scope , egCore) { }]) +.controller('PrintTemplatesCtrl', + ['$scope','$q','egCore', +function($scope , $q , egCore) { + + $scope.print = { + template_name : 'bills_current', + template_output : '' + }; + + // print preview scope data + // TODO: consider moving the template-specific bits directly + // into the templates or storing template- specific script files + // alongside the templates + $scope.preview_scope = { + current_location : egCore.idl.toHash( + egCore.org.get(egCore.auth.user().ws_ou())), + today : new Date(), + + //bills + transactions : [ + { + id : 1, + xact_start : new Date().toISOString(), + summary : { + xact_type : 'circulation', + last_billing_type : 'Overdue materials', + total_owed : 1.50, + last_payment_note : 'Test Note 1', + total_paid : 0.50, + balance_owed : 1.00 + } + }, { + id : 2, + xact_start : new Date().toISOString(), + summary : { + xact_type : 'circulation', + last_billing_type : 'Overdue materials', + total_owed : 2.50, + last_payment_note : 'Test Note 2', + total_paid : 0.50, + balance_owed : 2.00 + } + } + ] + } + + $scope.template_changed = function() { + egCore.hatch.getPrintTemplate($scope.print.template_name) + .then(function(html) { + $scope.print.template_content = html; + }); + } + + $scope.save_locally = function() { + egCore.hatch.storePrintTemplate( + $scope.print.template_name, + $scope.print.template_content + ); + } + + $scope.template_changed(); // load the default +}]) + +// TODO: move compilation into egHatch! +.directive('egPrintTemplateOutput', ['$compile',function($compile) { + return function(scope, element, attrs) { + scope.$watch( + function(scope) { + return scope.$eval(attrs.content); + }, + function(value) { + var result = element.html(value); + var print_scope = scope.$new(true); + // copy only the print preview scope data + // into the isolate scope for compilation + angular.forEach(scope.preview_scope, function(val, key) { + print_scope[key] = val; + }) + $compile(element.contents())(print_scope); + } + ); + }; +}]) + .controller('StoredPrefsCtrl', ['$scope','$q','egCore','egConfirmDialog', function($scope , $q , egCore , egConfirmDialog) { 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 547cdf99c3..edd6907d7e 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -28,8 +28,8 @@ angular.module('egCoreMod') .factory('egHatch', - ['$q','$window','$timeout','$interpolate','$rootScope', - function($q , $window , $timeout , $interpolate , $rootScope) { + ['$q','$window','$timeout','$interpolate','$rootScope','$http', + function($q , $window , $timeout , $interpolate , $rootScope , $http) { var service = {}; service.msgId = 0; @@ -40,6 +40,8 @@ angular.module('egCoreMod') service.defaultHatchURL = 'wss://localhost:8443/hatch'; service.hatchRequired = false; + service.printTemplateBase = 'share/print_templates/t_'; + // write a message to the Hatch websocket service.sendToHatch = function(msg) { var msg2 = {}; @@ -259,14 +261,14 @@ angular.module('egCoreMod') if (service.printConfig) return $q.when(service.printConfig); - return service.getRemoteItem('eg.printing.config') + return service.getRemoteItem('eg.print.config') .then(function(conf) { return (service.printConfig = conf || {}) }); } service.setPrintConfig = function(conf) { service.printConfig = conf; - return service.setRemoteItem('eg.printing.config', conf); + return service.setRemoteItem('eg.print.config', conf); } // ----------- @@ -302,7 +304,7 @@ angular.module('egCoreMod') // store the newly linked settings .then(function() { - service.setItem('eg.printing.config', service.printConfig); + service.setItem('eg.print.config', service.printConfig); }) // return the final settings to the caller @@ -457,6 +459,39 @@ angular.module('egCoreMod') return keys; } + // loads an HTML print template by name from the server + // If no template is available in local/hatch storage, + // fetch the template as an HTML file from the server. + service.getPrintTemplate = function(name) { + var deferred = $q.defer(); + + service.getItem('eg.print.template.' + name) + .then(function(html) { + + if (html) { + // we have a locally stored template + deferred.resolve(html); + return; + } + + var path = service.printTemplateBase + name; + console.debug('fetching template ' + path); + + $http.get(path) + .success(function(data) { deferred.resolve(data) }) + .error(function() { + console.error('unable to locate print template: ' + name); + deferred.reject(); + }); + }); + + return deferred.promise; + } + + service.storePrintTemplate = function(name, html) { + return service.setItem('eg.print.template.' + name, html); + } + return service; }]) diff --git a/Open-ILS/web/js/ui/default/staff/services/print_templates.js b/Open-ILS/web/js/ui/default/staff/services/print_templates.js new file mode 100644 index 0000000000..e69de29bb2