From 39760f9054bf5baaf9d6cf040e6dc05194223f87 Mon Sep 17 00:00:00 2001 From: Vaibhav Varshney Date: Wed, 11 Jun 2025 11:46:07 +0530 Subject: [PATCH] FORMS-17789 Add DownloadDor as OOTB button in rule editor --- ui.frontend/package-lock.json | 14 +++++++------- ui.frontend/package.json | 2 +- ui.frontend/src/customFunctions.js | 22 +++++++++++++--------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ui.frontend/package-lock.json b/ui.frontend/package-lock.json index 57ef97e9be..a20359e29e 100644 --- a/ui.frontend/package-lock.json +++ b/ui.frontend/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aemforms/af-core": "^0.22.129", "@aemforms/af-core-xfa": "^0.1.6", - "@aemforms/af-custom-functions": "1.0.14", + "@aemforms/af-custom-functions": "1.0.15", "@aemforms/af-formatters": "^0.22.129" }, "devDependencies": { @@ -127,9 +127,9 @@ } }, "node_modules/@aemforms/af-custom-functions": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@aemforms/af-custom-functions/-/af-custom-functions-1.0.14.tgz", - "integrity": "sha512-rxFTfGKj9lMeFx0WsOempSavgXKFQZNinr8BLjREVagkuZesQjzlSn/mjoWrLf1YC3VPUnFOj408SX+SX0rChQ==" + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/@aemforms/af-custom-functions/-/af-custom-functions-1.0.15.tgz", + "integrity": "sha512-8mzNBGJ48B6GVL9N9FKuT+ufJgnRYWlY4Ni7U067cwN+sr9K4HWzBzQtShOlstZNXLuDNYt2pO03CMi1j6SQwg==" }, "node_modules/@aemforms/af-formatters": { "version": "0.22.129", @@ -11151,9 +11151,9 @@ } }, "@aemforms/af-custom-functions": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@aemforms/af-custom-functions/-/af-custom-functions-1.0.14.tgz", - "integrity": "sha512-rxFTfGKj9lMeFx0WsOempSavgXKFQZNinr8BLjREVagkuZesQjzlSn/mjoWrLf1YC3VPUnFOj408SX+SX0rChQ==" + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/@aemforms/af-custom-functions/-/af-custom-functions-1.0.15.tgz", + "integrity": "sha512-8mzNBGJ48B6GVL9N9FKuT+ufJgnRYWlY4Ni7U067cwN+sr9K4HWzBzQtShOlstZNXLuDNYt2pO03CMi1j6SQwg==" }, "@aemforms/af-formatters": { "version": "0.22.129", diff --git a/ui.frontend/package.json b/ui.frontend/package.json index dcef508c0a..22c2bcb1dc 100644 --- a/ui.frontend/package.json +++ b/ui.frontend/package.json @@ -28,6 +28,6 @@ "@aemforms/af-core": "^0.22.129", "@aemforms/af-core-xfa": "^0.1.6", "@aemforms/af-formatters": "^0.22.129", - "@aemforms/af-custom-functions": "1.0.14" + "@aemforms/af-custom-functions": "1.0.15" } } diff --git a/ui.frontend/src/customFunctions.js b/ui.frontend/src/customFunctions.js index 8633feeb0a..7a96f7b95f 100644 --- a/ui.frontend/src/customFunctions.js +++ b/ui.frontend/src/customFunctions.js @@ -39,14 +39,7 @@ export const customFunctions = { * @param {string} url - The URL to externalize. * @returns {string} - The externalized URL. */ - externalize: (url) => { - // Check if Granite.HTTP.externalize is available, otherwise return the original URL - if (window?.Granite?.HTTP && typeof window.Granite.HTTP.externalize === "function") { - return window.Granite.HTTP.externalize(url); - } else { - return url; - } - }, + externalize: cf.externalize, /** * Validates if the given URL is correct. @@ -114,5 +107,16 @@ export const customFunctions = { * * @returns {number} - The number of days since the Unix epoch */ - dateToDaysSinceEpoch: cf.dateToDaysSinceEpoch + dateToDaysSinceEpoch: cf.dateToDaysSinceEpoch, + + /** + * Downloads the Document of Record (DoR) for the form. + * + * @param {string=} fileName - The name of the file to be downloaded. Defaults to "Downloaded_DoR.pdf" if + * not specified. + * @param {scope} globals - An object containing read-only form instance, read-only target field instance, + * and methods for form modifications. + * @returns {void} + */ + downloadDoR: cf.downloadDoR, };