From 500b7273183d62a1de67bbac6f0eafa8582bcb59 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 16 Feb 2017 12:17:55 -0500 Subject: [PATCH] LP#1646166 Hatch printing multi root-node templates Print templates with no root element or root elements that contained necessary attributes (id, style, etc.) failed to print correctly in some casese with Hatch HTML printing because the root node was dropped after compilation. This commit changes how we extract the compiled HTML from the page, using the more reliable method of pulling it directly from the print element div instead of inspecting the compiled nodes. Commit also wraps all content in for good measure. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- Open-ILS/web/js/ui/default/staff/services/print.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 02424a9da0..67a26b3078 100644 --- a/Open-ILS/web/js/ui/default/staff/services/print.js +++ b/Open-ILS/web/js/ui/default/staff/services/print.js @@ -79,6 +79,8 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg } return promise.then(function(html) { + // For good measure, wrap the compiled HTML in container tags. + html = "" + html + ""; return egHatch.remotePrint( args.context || 'default', args.content_type, @@ -214,15 +216,12 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg var resp = $compile($scope.elm.contents())(sub_scope); + var deferred = $q.defer(); $timeout(function(){ - // give the $digest a chance to complete then - // resolve with the compiled HTML from our - // print container - - deferred.resolve( - resp.contents()[0].parentNode.innerHTML - ); + // give the $digest a chance to complete then resolve + // with the compiled HTML from our print container + deferred.resolve($scope.elm.html()); }); return deferred.promise; -- 2.43.2