From 61a1d3e0cc5f74703bdcb906f46441e557d224a6 Mon Sep 17 00:00:00 2001 From: Dzmitry Yurtsevich Date: Wed, 23 Oct 2024 13:41:18 +0200 Subject: [PATCH] fix: Fix JS - null pointer errors and absent parameter with later decomposing (#273) Fixes #271 --- .../resources/webapp/pdf-exporter/js/pdf-exporter.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js b/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js index b3b2c4a..50edc13 100644 --- a/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js +++ b/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js @@ -45,7 +45,7 @@ const PdfExporter = { }, openPopup: function (params) { - this.exportContext = params?.exportContext ? params.exportContext : new ExportContext(); + this.exportContext = params?.exportContext ? params.exportContext : new ExportContext({}); this.hideAlerts(); this.loadFormData(); @@ -606,8 +606,12 @@ const PdfExporter = { document.querySelectorAll(".modal__container.pdf-exporter input.error").forEach(input => { input.classList.remove("error"); }); - document.getElementById('page-previews').innerHTML = ""; - document.getElementById("suspicious-wi").innerHTML = ""; + if (document.getElementById('page-previews')) { + document.getElementById('page-previews').innerHTML = ""; + } + if (document.getElementById("suspicious-wi")) { + document.getElementById("suspicious-wi").innerHTML = ""; + } }, callAsync: function ({method, url, contentType, responseType, body}) { @@ -629,4 +633,4 @@ const PdfExporter = { }, } -PdfExporter.init(); \ No newline at end of file +PdfExporter.init();