From: Bill Erickson Date: Fri, 12 Jul 2019 14:23:54 +0000 (-0400) Subject: LP1825851 more angjs revert X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bec79c64485c31bd9e3129bfc3eee7b4e2ee7cfc;p=working%2FEvergreen.git LP1825851 more angjs revert Signed-off-by: Bill Erickson --- 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 0364d2b0e6..d863844e3d 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 @@ -616,7 +616,7 @@ function($scope , $q , egCore , ngToast) { $scope.template_changed = function() { $scope.print.load_failed = false; - egCore.print.getPrintTemplate({template: $scope.print.template_name}) + egCore.print.getPrintTemplate($scope.print.template_name) .then( function(html) { $scope.print.template_content = html; diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index a2f22b7a06..a886195050 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -331,7 +331,7 @@ function($scope, $q , $location , $filter , egCore , egNet , egUser , egAlertDi $scope.print_address = function(addr) { egCore.print.print({ context : 'default', - template: 'patron_address', + template : 'patron_address', scope : { patron : egCore.idl.toHash(patronSvc.current), address : egCore.idl.toHash(addr) diff --git a/Open-ILS/web/js/ui/default/staff/services/print.js b/Open-ILS/web/js/ui/default/staff/services/print.js index 8c2ddcab55..d12a6cd84f 100644 --- a/Open-ILS/web/js/ui/default/staff/services/print.js +++ b/Open-ILS/web/js/ui/default/staff/services/print.js @@ -20,7 +20,6 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg service.template_base_path = 'share/print_templates/t_'; - service.server_template_path = '/print_template'; /* * context : 'default', 'receipt','label', etc. @@ -32,7 +31,6 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg * show_dialog : boolean, if true, print dialog is shown. This setting * only affects remote printers, since browser printers * do not allow such control - * server_hosted: if true, have the server compile the template for us. */ service.print = function(args) { if (!args) return $q.when(); @@ -40,7 +38,7 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg if (args.template) { // fetch the template, then proceed to printing - return service.getPrintTemplate(args) + return service.getPrintTemplate(args.template) .then(function(content) { args.content = content; if (!args.content_type) args.content_type = 'text/html'; @@ -50,43 +48,12 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg return service.print_content(args); }); }); + } return service.print_content(args); } - service.compileRemoteTemplate = function(templateName, templateData) { - - var formData = new FormData(); - - formData.append('ses', egAuth.token()); - formData.append('template_name', templateName); - formData.append('template_data', js2JSON(templateData)); - if (OpenSRF.locale) { - // .append() coerces arguments to strings, so if locale - // is null, the server will get the string "null" - formData.append('template_locale', OpenSRF.locale); - } - - return new Promise((resolve, reject) => { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState === 4) { - if (this.status === 200) { - resolve({ - content: xhttp.responseText, - contentType: this.getResponseHeader('content-type') - }); - } else { - reject('Error compiling print template'); - } - } - }; - xhttp.open('POST', service.server_template_path, true); - xhttp.send(formData); - }); - } - // add commonly used attributes to the print scope service.fleshPrintScope = function(scope) { if (!scope) scope = {}; @@ -191,12 +158,7 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg }).then(function(content) { // Ingest the content into the page DOM. - if (args.server_hosted) { - // Server hosted print templates arrive fully formed. - return service.ingest_print_content(type, null, null, content); - } else { - return service.ingest_print_content(type, content, printScope); - } + return service.ingest_print_content(type, content, printScope); }).then(function(html) { @@ -238,20 +200,17 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg }); } - // 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. if no HTML file is available, - // try loading the content from a server-hosted template. - service.getPrintTemplate = function(args) { + // 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(); - var name = args.template; egHatch.getItem('eg.print.template.' + name) .then(function(html) { if (html) { // we have a locally stored template - console.debug('Found saved template for ' + name); deferred.resolve(html); return; } @@ -260,31 +219,7 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg console.debug('fetching template ' + path); $http.get(path).then( - function(data) { - - if (data.data.match(/Print Template Not Found/)) { - - // AngJS templates return a dummy template w/ the - // above text if the template is not found instead - // of a 404. - return service.compileRemoteTemplate(name, args.scope) - .then( - function(response) { - console.debug('Found server-hosted template for ' + name); - args.content_type = response.contentType; - args.content = response.content; - deferred.resolve(args.content); - }, - function() { - console.error('unable to locate print template: ' + name); - deferred.reject(); - } - ); - } - - console.debug('Found server template file for ' + name); - deferred.resolve(data.data) - }, + function(data) { deferred.resolve(data.data) }, function() { console.error('unable to locate print template: ' + name); deferred.reject();